Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 9005C1EA2927 for ; Sat, 9 Jun 2012 04:06:52 -0300 (ADT) Received: from mahout.postgresql.org ([98.129.198.123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SdFl2-0005QG-Ja for pgsql-bugs@postgresql.org; Sat, 09 Jun 2012 07:06:51 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SdFkp-0005aI-MT for pgsql-bugs@postgresql.org; Sat, 09 Jun 2012 07:06:35 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1SdFkp-0006cC-Bn for pgsql-bugs@postgresql.org; Sat, 09 Jun 2012 07:06:35 +0000 Date: Sat, 09 Jun 2012 07:06:35 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6683: dropping a table with a serial column from an extension needs to explicitely drop the associated seq To: pgsql-bugs@postgresql.org From: phb.emaj@free.fr X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/79 X-Sequence-Number: 33306 The following bug has been logged on the website: Bug reference: 6683 Logged by: Philippe BEAUDOIN Email address: phb.emaj@free.fr PostgreSQL version: 9.1.4 Operating system: Linux Description: = When a table having a seial column has been created by a CREATE EXTENSION, and when this table is later dropped from the extension, the associated sequence must be also explicitely dropped from the extension. = Otherwise, after the table is detached from the extension, neither the table can be dropped, nor the extension (except using CASCADE clauses). This unattended behaviour could be considered as a design choice. In this case, this should be clearly documentated. Here is a test case to easily reproduce this issue. Just copy/paste and adjust initial parameters. #!/bin/sh export PGINST=3D/usr/local/pg913 export PGBIN=3D$PGINST/bin export PGEXT=3D$PGINST/share/postgresql/extension export PGHOST=3Dlocalhost export PGPORT=3D5913 export PGUSER=3Dpostgres export PGDATABASE=3Dphb echo "-----------------------------------------------------------------------" echo " Issue: dropping a table with a serial column from an extension needs " echo " to explicitely drop the associated sequence from the extension" echo "-----------------------------------------------------------------------" echo Connection parameters: $PGHOST - $PGPORT - $PGUSER - $PGDATABASE # Build the extension control file cat >$PGINST/share/postgresql/extension/phb.control <$PGEXT/phb--1.0.0.sql < Create the extension" $PGBIN/psql -ac "create extension phb;" $PGBIN/psql -ac "\dx+ phb" echo "--> Now remove tbl1 from the extension" $PGBIN/psql -ac "alter extension phb drop table phb.tbl1;" echo "--> The table pushed out of the extension cannot be dropped, neither the extension" $PGBIN/psql -ac "drop table phb.tbl1;" $PGBIN/psql -ac "drop extension phb;" echo "--> And what if we drop the generated sequence from the extension ?" $PGBIN/psql -ac "\dx+ phb" $PGBIN/psql -ac "alter extension phb drop sequence phb.tbl1_col1_seq;" $PGBIN/psql -ac "\dx+ phb" $PGBIN/psql -ac "drop extension phb;" $PGBIN/psql -ac "\d phb.tbl1;" # cleanup the environment $PGBIN/psql template1 -ac "drop database phb;" rm $PGINST/share/postgresql/extension/phb*