Re: [HACKERS] SetQuerySnapshot, once again

2002-06-18 Thread Tom Lane

Hiroshi Inoue [EMAIL PROTECTED] writes:
 Tom Lane wrote:
 Sorry, I don't understand ...

 Let t be a table which is defined as
   create table t (id serial primary key, dt text);
 Then is the following function *stable* ?
   create function f1(int4) returns text as
   '
   declare
   txt text;
   begin
   select dt into txt from t where id = $1;
   return txt;
   end
   ' language plpgsql;

I'm not sure exactly what you mean by stable here.

And I'm even less sure whether you are arguing for or
against adding SetQuerySnapshot calls into plpgsql...

regards, tom lane

---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



Re: [HACKERS] SetQuerySnapshot, once again

2002-06-18 Thread Hiroshi Inoue
 -Original Message-
 From: Tom Lane [mailto:[EMAIL PROTECTED]]
 
 Hiroshi Inoue [EMAIL PROTECTED] writes:
  Tom Lane wrote:
  Sorry, I don't understand ...
 
  Let t be a table which is defined as
create table t (id serial primary key, dt text);
  Then is the following function *stable* ?
create function f1(int4) returns text as
'
declare
txt text;
begin
select dt into txt from t where id = $1;
return txt;
end
' language plpgsql;
 
 I'm not sure exactly what you mean by "stable" here.

Wasn't it you who defined *stable* as 
  Cachable within a single command: given fixed input values, the
  result will not change if the function were to be repeatedly evaluated
  within a single SQL command; but the result could change over time.
?

 And I'm even less sure whether you are arguing for or
 against adding SetQuerySnapshot calls into plpgsql...

I already mentioned an opinion in 2001/09/08.
  Both the command counters and the snapshots in a
  function should advance except the leading SELECT
  statements.

regards,
Hiroshi Inoue

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [HACKERS] SetQuerySnapshot, once again

2002-06-18 Thread Tom Lane

Hiroshi Inoue [EMAIL PROTECTED] writes:
 I'm not sure exactly what you mean by stable here.

 Wasn't it you who defined *stable* as 
   Cachable within a single command: given fixed input values, the
   result will not change if the function were to be repeatedly evaluated
   within a single SQL command; but the result could change over time.

Oh, *that* stable ;-)

Okay, I get your point now.  You are right --- a function that
references a table that others might be concurrently changing
would not be stable under read-committed rules.  (But you could
probably get away with marking it stable anyway.)

 I already mentioned an opinion in 2001/09/08.
   Both the command counters and the snapshots in a
   function should advance except the leading SELECT
   statements.

I do not like the idea of treating the first select in a function
differently from the rest.  And such a rule wouldn't let you build
guaranteed-stable functions anyway; what if the outer query was
calling both your function, and another one that did cause the
snapshot to advance?  The behavior of your function would then
vary depending on whether the other function was invoked or not.

regards, tom lane

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [HACKERS] SetQuerySnapshot, once again

2002-06-18 Thread Hiroshi Inoue
Tom Lane wrote:
 
 "Hiroshi Inoue" [EMAIL PROTECTED] writes:
 
  I already mentioned an opinion in 2001/09/08.
Both the command counters and the snapshots in a
function should advance except the leading SELECT
statements.
 
 I do not like the idea of treating the first select in a function
 differently from the rest.  And such a rule wouldn't let you build
 guaranteed-stable functions anyway;

AFAIK there has been no analysis where we can get *stable*
functions. As far as I see, we can expect SELECT-only functions
to be *stable* if and only if they are surrounded by SELECT-only
*stable* functions.

regards, 
Hiroshi Inoue
http://w2422.nsk.ne.jp/~inoue/

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])