From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | possible bug with inheritance? |
Date: | 2010-02-12 12:40:34 |
Message-ID: | 20100212124034.GC25282@a-kretschmer.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
Hi,
Our documentation says:
"All check constraints and not-null constraints on a parent table are
automatically inherited by its children."
Okay, this works as expected:
test=# create table parent (name text primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "parent_pkey" for table "parent"
CREATE TABLE
test=*# create table child (age int) inherits (parent) ;
CREATE TABLE
test=*# \d child
Table "public.child"
Column | Type | Modifiers
--------+---------+-----------
name | text | not null
age | integer |
Inherits: parent
Nice, the 'not null' constraint is in the child-table.
test=*# rollback;
ROLLBACK
test=# create table parent (name text);
CREATE TABLE
test=*# create table child (age int) inherits (parent) ;
CREATE TABLE
test=*# alter table parent add primary key (name);
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "parent_pkey" for table "parent"
ALTER TABLE
test=*# \d child
Table "public.child"
Column | Type | Modifiers
--------+---------+-----------
name | text |
age | integer |
Inherits: parent
Doh, there isn't the 'not null' - modifier. The parent-table contains
this modifier as part of the primary key - definition.
Other test:
test=# create table parent (name text);
CREATE TABLE
test=*# create table child (age int) inherits (parent) ;
CREATE TABLE
test=*# alter table parent alter column name set not null;
ALTER TABLE
test=*# \d child
Table "public.child"
Column | Type | Modifiers
--------+---------+-----------
name | text | not null
age | integer |
Inherits: parent
Okay, we have again the 'not null'.
I think, that's not really clearly. In some case the 'not null' -
constraint are in the child-table, in other case they are not.
Version 8.4.2.
Bug, feature? What have i overlooked?
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2010-02-12 12:47:24 | Re: Weeding out unused user created database objects, could I use pg_catalog? |
Previous Message | Allan Kamau | 2010-02-12 12:32:03 | Weeding out unused user created database objects, could I use pg_catalog? |
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2010-02-12 12:51:20 | Re: Re: [COMMITTERS] pgsql: Make standby server continuously retry restoring the next WAL |
Previous Message | Tim Bunce | 2010-02-12 10:40:13 | Re: Add on_trusted_init and on_untrusted_init to plperl UPDATED [PATCH] |