Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Shane Ambler wrote:
>>> CREATE TABLE jefftest ( id serial, num int );
>>> INSERT INTO jefftest (num) values (generate_series(1,10));
>>> INSERT INTO jefftest (num) values (generate_series(11,20));
>>> INSERT INTO jefftest (num) values (generate_series(21,30));
> Don't use set-returning functions in "scalar context".
I think what is actually happening is that the expanded targetlist is
On the eleventh iteration, generate_series() returns ExprEndResult to
show that it's done ... but the 11th nextval() call already happened.
If you switched the columns around, you wouldn't get the extra call.
If you think that's bad, the behavior with multiple set-returning
functions in the same targetlist is even stranger. The whole thing
is a mess and certainly not something we would've invented if we
hadn't inherited it from Berkeley.
regards, tom lane
In response to
pgsql-hackers by date
|Next:||From: Alvaro Herrera||Date: 2007-10-04 15:33:06|
|Subject: Re: Not *quite* there on ecpg fixes|
|Previous:||From: Simon Riggs||Date: 2007-10-04 15:10:31|
|Subject: Re: First steps with 8.3 and autovacuum launcher|
pgsql-sql by date
|Next:||From: Tore Lukashaugen||Date: 2007-10-04 17:39:09|
|Subject: What SQL is running against my DB?|
|Previous:||From: Alvaro Herrera||Date: 2007-10-04 14:46:56|
|Subject: Re: [HACKERS] Why does the sequence skip a number withgenerate_series?|