Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFuMm-0004iq-LB for pgsql-docs@arkaria.postgresql.org; Wed, 13 Mar 2013 22:41:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UFuMm-00021y-09 for pgsql-docs@arkaria.postgresql.org; Wed, 13 Mar 2013 22:41:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFuMl-00021s-88 for pgsql-docs@postgresql.org; Wed, 13 Mar 2013 22:41:47 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFuMh-0000WL-DX for pgsql-docs@postgresql.org; Wed, 13 Mar 2013 22:41:45 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1UFuMg-0002JL-J9; Wed, 13 Mar 2013 18:41:42 -0400 Date: Wed, 13 Mar 2013 18:41:42 -0400 From: Bruce Momjian To: robins Cc: pgsql-docs@postgresql.org Subject: Re: Clarify 'dependent objects' for DROP COLUMN Message-ID: <20130313224142.GE22282@momjian.us> References: <20130313211941.GB22282@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -4.3 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org On Thu, Mar 14, 2013 at 03:38:42AM +0530, robins wrote: > Thanks Bruce. > > I think by using the word 'constraint' I understand what the documentation > meant. > > Both my queries (samples given below) arose from the fact that although there > was a 'relation', this is probably not what the documentation was talking > about. > > Q1: > postgres=# CREATE TABLE serialTest3 (f1 bigint); > CREATE TABLE > postgres=# CREATE SEQUENCE seq4 OWNED BY serialTest3.f1; > CREATE SEQUENCE > postgres=# DROP SEQUENCE seq4; > DROP SEQUENCE > postgres=# > > > Q2: > postgres=# CREATE TABLE serialTest3 (f1 bigint); > CREATE TABLE > postgres=# CREATE SEQUENCE seq4 OWNED BY serialTest3.f1; > CREATE SEQUENCE > postgres=# ALTER TABLE serialTest3 DROP COLUMN f1 RESTRICT; > ALTER TABLE > postgres=# > > I was working on some regression tests and then just wanted to be sure that > this (Q2 in particular) was perfectly legal, before adding checks for them. It seems like the OWNED BY only handles auto-drop, rather than sequence removal restrictions: The OWNED BY option causes the sequence to be associated with a specific table column, such that if that column (or its whole table) is dropped, the sequence will be automatically dropped as well. The specified table must have the same owner and be in the same schema as the sequence. OWNED BY NONE, the default, specifies that there is no such association. Seems it is not the same as actually referencing the sequence in the table. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs