Skip site navigation (1) Skip section navigation (2)

Re: Why does the sequence skip a number with generate_series?

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Jeff Frost <jeff(at)frostconsultingllc(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Why does the sequence skip a number with generate_series?
Date: 2007-10-04 01:06:22
Message-ID: 20071003175808.P16566@megazone.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
On Tue, 2 Oct 2007, Jeff Frost wrote:

> I expected these numbers to be in sync, but was suprised to see that the
> sequence skips a values after every generate series.
>
> 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));

It seems to do what you'd expect if you do
 INSERT INTO jefftest(num) select a from generate_series(1,10) as foo(a);
 INSERT INTO jefftest(num) select a from generate_series(11,20) as foo(a);
 INSERT INTO jefftest(num) select a from generate_series(21,30) as foo(a);

I tried a function that raises a notice and called it as
 select f1(1), generate_series(1,10);
and got 11 notices so it looks like there's some kind of phantom involved.

In response to

Responses

pgsql-hackers by date

Next:From: Ron MayerDate: 2007-10-04 01:37:18
Subject: Re: Use of "postmaster"
Previous:From: Brendan JurdDate: 2007-10-03 23:54:12
Subject: Re: [HACKERS] Use of "postmaster"

pgsql-sql by date

Next:From: Tena SakaiDate: 2007-10-04 02:25:04
Subject: Re: field separator problem
Previous:From: Michael FuhrDate: 2007-10-04 00:54:10
Subject: Re: field separator problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group