Обсуждение: BUG #3295: pg_get_serial_sequence returns wrong sequence name for a serial column
BUG #3295: pg_get_serial_sequence returns wrong sequence name for a serial column
От
"Philip Ives"
Дата:
The following bug has been logged online:
Bug reference: 3295
Logged by: Philip Ives
Email address: phil@ivesdigital.com
PostgreSQL version: 8.1.4
Operating system: Darwin and FreeBSD 4
Description: pg_get_serial_sequence returns wrong sequence name for a
serial column
Details:
pg_get_serial_sequence doesn't return the correct sequence name and returns
a null. This function either shouldn't exist or it should always return the
right name.
: Table "public.ccprocesses"
Column | Type |
Modifiers
---------------------+-----------------------------+------------------------
------------------------------------------
id | bigint | not null default
nextval(('seq_ccprocesses_id'::text)::regclass)
select * from pg_get_serial_sequence('ccprocesses','id');
pg_get_serial_sequence
------------------------
(1 row)
"Philip Ives" <phil@ivesdigital.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