Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFtr8-0001Zt-JI for pgsql-docs@arkaria.postgresql.org; Wed, 13 Mar 2013 22:09:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UFtr8-0007HZ-3n for pgsql-docs@arkaria.postgresql.org; Wed, 13 Mar 2013 22:09:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFtr7-0007HU-Ei for pgsql-docs@postgresql.org; Wed, 13 Mar 2013 22:09:05 +0000 Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UFtr5-0008Ql-9C for pgsql-docs@postgresql.org; Wed, 13 Mar 2013 22:09:05 +0000 Received: by mail-wg0-f42.google.com with SMTP id 12so442912wgh.5 for ; Wed, 13 Mar 2013 15:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=0f/+qEUr43dVAc9dD8uXrp8DAZp7WZrzxI0iiuQ/t+U=; b=UI2MXqoAkOOZ0OK45jVMSBipVNuvjE4G+HSDWfnbWlZ/jlcdEVg+W38U/gRbP4pzXn tEyIqsriEPJwkXYapTHXdTwo2NrJHaFYwe6zGp0wHuG6TcZ2ccbJZ8JivjsTTNhxjx8i /Av0p8QEA0EGq+AAJncrVQgteCks3grz4jYxNPdx8Kf5Q21rAFxUZwm3j133OB5b9CEi 6grWJWXfkGH1pk4KsWQMvIEsM+1XlKh5n57fb9TXa5VikCTodkzLeQdGhuB8gGSfNEH9 oOR4YG5IfFPJQxBF9DsRSqvxi1WC7XRSNlgePHMHjjIiejmW91pxGRhTdL4wCWAnYHe8 I8GQ== X-Received: by 10.194.62.170 with SMTP id z10mr37240377wjr.34.1363212542868; Wed, 13 Mar 2013 15:09:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.13.227 with HTTP; Wed, 13 Mar 2013 15:08:42 -0700 (PDT) In-Reply-To: <20130313211941.GB22282@momjian.us> References: <20130313211941.GB22282@momjian.us> From: robins Date: Thu, 14 Mar 2013 03:38:42 +0530 Message-ID: Subject: Re: Clarify 'dependent objects' for DROP COLUMN To: pgsql-docs@postgresql.org Content-Type: multipart/alternative; boundary=047d7ba983025f056a04d7d5a77b X-Pg-Spam-Score: -2.0 (--) 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 --047d7ba983025f056a04d7d5a77b Content-Type: text/plain; charset=ISO-8859-1 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. Thanks again. -- Robins Tharakan ---------- Forwarded message ---------- I had to dig a little bit on this. The "dependent" object would be the removal of the constraint depending on the sequence. Here is an example: test=> create table test (x serial); CREATE TABLE test=> \d test Table "public.test" Column | Type | Modifiers --------+---------+-------------------------------------------------- x | integer | not null default nextval('test_x_seq'::regclass) test=> \ds List of relations Schema | Name | Type | Owner --------+------------+----------+---------- public | test_x_seq | sequence | postgres (1 row) --> test=> drop sequence test_x_seq; ERROR: cannot drop sequence test_x_seq because other objects depend on it DETAIL: default for table test column x depends on sequence test_x_seq HINT: Use DROP ... CASCADE to drop the dependent objects too. --> test=> drop sequence test_x_seq cascade; NOTICE: drop cascades to default for table test column x DROP SEQUENCE test=> \d test Table "public.test" Column | Type | Modifiers --------+---------+----------- x | integer | not null If this does not answer your questions, please post queries showing the problem. Thanks. --047d7ba983025f056a04d7d5a77b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks Bruce.

I think by using the w= ord 'constraint' I understand what the documentation meant.=A0

Both my queries (sampl= es given below) arose from the fact that although there was a 'relation= ', this is probably not what the documentation was talking about.

Q1:
postgres=3D# CREATE TABLE= serialTest3 (f1 bigint);
CREATE TABLE
postgres=3D# CREATE SEQUENCE seq4 OWNED BY serialTest3.f1;
CREATE SEQUENCE
postgres=3D# DROP SEQUENCE seq4;
DROP S= EQUENCE
postgres=3D#=A0


Q2:
postgres=3D# CREATE TABLE seria= lTest3 (f1 bigint);
CREATE TABLE
postgres=3D# CREA= TE SEQUENCE seq4 OWNED BY serialTest3.f1;
CREATE SEQUENCE
postgres=3D# ALTER TABLE serialTest3 DROP COLUMN f1 RESTRICT;
ALTER TABLE
postgres=3D#=A0

I was working on some regression tests and the= n just wanted to be sure that this (Q2 in particular) was perfectly legal, = before adding checks for them.

Thanks again.
--
Robins
Thar= akan


---------- Forwarded message ----------<= div class=3D"">

I had to dig a little bit on this. =A0The "dependent"= object would be the
removal of the constraint depending on the sequence. =A0Here is an
example:

=A0 =A0 =A0 =A0 test=3D> create table test (x serial);
=A0 =A0 =A0 =A0 CREATE TABLE
=A0 =A0 =A0 =A0 test=3D> \d test
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Table &q= uot;public.test"
=A0 =A0 =A0 =A0 =A0Column | =A0Type =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0Modifiers
=A0 =A0 =A0 =A0 --------+---------+----------------------------------------= ----------
=A0 =A0 =A0 =A0 =A0x =A0 =A0 =A0| integer | not null default nextval('t= est_x_seq'::regclass)

=A0 =A0 =A0 =A0 test=3D> \ds
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0List of relations
=A0 =A0 =A0 =A0 =A0Schema | =A0 =A0Name =A0 =A0| =A0 Type =A0 | =A0Owner =A0 =A0 =A0 =A0 --------+------------+----------+----------
=A0 =A0 =A0 =A0 =A0public | test_x_seq | sequence | postgres
=A0 =A0 =A0 =A0 (1 row)

--> =A0 =A0 test=3D> drop sequence test_x_seq;
=A0 =A0 =A0 =A0 ERROR: =A0cannot drop sequence test_x_seq because other obj= ects depend on it
=A0 =A0 =A0 =A0 DETAIL: =A0default for table test column x depends on seque= nce test_x_seq
=A0 =A0 =A0 =A0 HINT: =A0Use DROP ... CASCADE to drop the dependent objects= too.
--> =A0 =A0 test=3D> drop sequence test_x_seq cascade;
=A0 =A0 =A0 =A0 NOTICE: =A0drop cascades to default for table test column x=
=A0 =A0 =A0 =A0 DROP SEQUENCE
=A0 =A0 =A0 =A0 test=3D> \d test
=A0 =A0 =A0 =A0 =A0 =A0 =A0Table "public.test"
=A0 =A0 =A0 =A0 =A0Column | =A0Type =A0 | Modifiers
=A0 =A0 =A0 =A0 --------+---------+-----------
=A0 =A0 =A0 =A0 =A0x =A0 =A0 =A0| integer | not null

If this does not answer your questions, please post queries showing the
problem. =A0 Thanks.
--047d7ba983025f056a04d7d5a77b--