pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: m.sakrejda@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #9048: Misleading error in transferring sequence between tables
Date: Fri, 31 Jan 2014 02:03:28 +0000
Message-ID: <20140131020328.13610.47977@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      9048
Logged by:          Maciek Sakrejda
Email address:      m.sakrejda@gmail.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?


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



Message-ID: <20140131020328.13610.47977@wrigleys.postgresql.org>
Permalink:  ../20140131020328.13610.47977@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20140131020328.13610.47977@wrigleys.postgresql.org

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: m.sakrejda@gmail.com
  Subject: Re: BUG #9048: Misleading error in transferring sequence between tables
  In-Reply-To: <20140131020328.13610.47977@wrigleys.postgresql.org>
  References: <20140131020328.13610.47977@wrigleys.postgresql.org>

* 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