From: | m(dot)sakrejda(at)gmail(dot)com |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #9048: Misleading error in transferring sequence between tables |
Date: | 2014-01-31 02:03:28 |
Message-ID: | 20140131020328.13610.47977@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 9048
Logged by: Maciek Sakrejda
Email address: m(dot)sakrejda(at)gmail(dot)com
PostgreSQL version: 9.3.2
Operating system: Ubuntu 13.04 64-bit
Description:
If I run the following SQL:
CREATE TABLE events (id serial);
ALTER TABLE events RENAME TO old_events;
CREATE TABLE events (LIKE old_events INCLUDING ALL);
ALTER TABLE old_events ALTER COLUMN id DROP DEFAULT;
DROP TABLE old_events;
The drop fails with:
ERROR: cannot drop table old_events because other objects depend on it
DETAIL: default for table events column id depends on sequence
events_id_seq
HINT: Use DROP ... CASCADE to drop the dependent objects too.
Following the HINT advice would technically resolve this particular issue,
but in this case, what I'd really like to do is transfer the sequence to the
new table (someone on IRC helpfully suggested "ALTER SEQUENCE events_id_seq
OWNED BY events.id", which is exactly what I was looking for).
It's especially confusing, since once I drop the default, there is no clear
relationship between the sequence and the old_events table:
maciek=# \d+ old_events
Table "public.old_events"
Column | Type | Modifiers | Storage | Stats target | Description
--------+---------+-----------+---------+--------------+-------------
id | integer | not null | plain | |
Has OIDs: no
A '\d+' on the sequence itself does show the owner, but while the DETAIL
points out the sequence is the issue, it does not tell me about the
relationship to the parent table.
Could the error message suggest changing the ownership when there is
ownership but no functional dependency and there *is* a functional
dependency from another object?
From | Date | Subject | |
---|---|---|---|
Next Message | bashtanov | 2014-01-31 08:18:24 | BUG #9050: pg_stat_statements() contains rows with the same dbid, userid and query |
Previous Message | Tom Lane | 2014-01-31 00:38:35 | Re: BUG #9046: vacuum analyze fails on a table that has domain that is a date rage |