inheritance and partial index: how to override constraints or default_values
От | Nico |
---|---|
Тема | inheritance and partial index: how to override constraints or default_values |
Дата | |
Msg-id | 01022712153500.02035@localhost.localdomain обсуждение исходный текст |
Ответы |
Re: inheritance and partial index: how to override
constraints or default_values
|
Список | pgsql-general |
I want to partial index every table in a inherited tree. Please let me know how to override the fields along inheritance? ===8<============= CREATE SEQUENCE "a_id_seq" increment 1 minvalue 0100000000 maxvalue 0199999999 start 0100000001 cache 1; CREATE TABLE "a" ( "id" int4 DEFAULT nextval('a_id_seq'::text) UNIQUE NOT NULL, "info_a" text, "created" timestamp DEFAULT CURRENT_TIMESTAMP ); SELECT * from "a"; CREATE SEQUENCE "b_id_seq" increment 1 minvalue 0200000000 maxvalue 0299999999 start 0200000001 cache 1; CREATE TABLE "b" ( "id" int4 DEFAULT nextval('b_id_seq'::text) UNIQUE NOT NULL, "info_b" text ) inherits ("a"); SELECT * from "b"; ================ psql 7.1beta5 output: CREATE psql:test.sql:13: NOTICE: CREATE TABLE/UNIQUE will create implicit index 'a_id_key' for table 'a' CREATE id | info_a | created ----+--------+--------- (0 rows) CREATE psql:test.sql:20: NOTICE: CREATE TABLE/UNIQUE will create implicit index 'b_id_key' for table 'b' psql:test.sql:20: ERROR: CREATE TABLE: attribute "id" already exists in inherited schema psql:test.sql:21: ERROR: Relation 'b' does not exist ======8<============= A note for developers: along inheritance if there are two identical attribute names, IMHO, pg should use the last definition, rather than complaining. Or better, pg should check if they are of the same type, but however should always use the last constraint/default_value definition! (I am talking about father-son inheritance, and not multiple inheritance, where the attribute name conflict should be dealed separately) regards, nico
В списке pgsql-general по дате отправления: