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

creating a table with a serial column sets currval

From: Kris Jurka <books(at)ejurka(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: creating a table with a serial column sets currval
Date: 2007-10-18 20:10:46
Message-ID: Pine.BSO.4.64.0710181606530.12647@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-bugs
jurka=# create table t (c serial);
NOTICE:  CREATE TABLE will create implicit sequence "t_c_seq" for serial 
column "t.c"
CREATE TABLE
jurka=# select currval('t_c_seq');
  currval
---------
        1
(1 row)

I would expect it to say that currval wasn't set like so:

jurka=# create sequence myseq;
CREATE SEQUENCE
jurka=# select currval('myseq');
ERROR:  currval of sequence "myseq" is not yet defined in this session

Kris Jurka

Responses

pgsql-bugs by date

Next:From: Kris JurkaDate: 2007-10-18 20:23:59
Subject: Re: creating a table with a serial column sets currval
Previous:From: Julius StroffekDate: 2007-10-18 13:20:05
Subject: Re: 'on insert do instead' rule with a where clause responds 'INSERT 0 0'

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