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

Re: BUG #3295: pg_get_serial_sequence returns wrong sequence name for a serial column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Philip Ives" <phil(at)ivesdigital(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3295: pg_get_serial_sequence returns wrong sequence name for a serial column
Date: 2007-05-21 23:21:46
Message-ID: 129.1179789706@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Philip Ives" <phil(at)ivesdigital(dot)com> writes:
> pg_get_serial_sequence doesn't return the correct sequence name and returns
> a null.

Can you provide a reproducible test case for this?

The example you give looks suspiciously like the column was not created
using the SERIAL notation, but through some hand approximation to that.
pg_get_serial_sequence() only works for actual SERIAL columns, because
it looks for a pg_depend entry that's made by SERIAL but not by just
creating a column that happens to involve a nextval() default.

As of 8.2 there's an ALTER SEQUENCE OWNED BY command that you can use
to reproduce this side-effect of SERIAL, but in prior releases there's
no way, unless you're brave enough to insert the pg_depend entry by
hand.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Klint GoreDate: 2007-05-22 02:40:37
Subject: Re: BUG #3277: error occurs between different versions
Previous:From: Philip IvesDate: 2007-05-21 19:10:34
Subject: BUG #3295: pg_get_serial_sequence returns wrong sequence name for a serial column

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