From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Jeff Frost <jeff@frostconsultingllc.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Why does the sequence skip a number with generate_series?
Date: Wed, 3 Oct 2007 18:06:22 -0700 (PDT)
Message-ID: <20071003175808.P16566@megazone.bigpanda.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0710021716490.4701@discord.home.frostconsultingllc.com>
References: <Pine.LNX.4.64.0710021716490.4701@discord.home.frostconsultingllc.com>
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone.bigpanda.com, jeff@frostconsultingllc.com
Subject: Re: Why does the sequence skip a number with generate_series?
In-Reply-To: <20071003175808.P16566@megazone.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox