Thread: inheritance and partial index: how to override constraints or default_values

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

Re: inheritance and partial index: how to override constraints or default_values

From
"Oliver Elphick"
Date:
Nico wrote:
  >I want to partial index every table in a inherited tree.
  >Please let me know how to override the fields along inheritance?

There is currently no facility that I know of for doing this.

It would be nice to be able to attach a column to an existing index.


--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "If we confess our sins, he is faithful and just to
      forgive us our sins, and to cleanse us from all
      unrighteousness."       I John 1:9