Re: [HACKERS] Problem with foreign keys and inheritance - Mailing list pgsql-hackers

From Oliver Elphick
Subject Re: [HACKERS] Problem with foreign keys and inheritance
Date
Msg-id 200001161510.PAA09186@linda.lfix.co.uk
Whole thread Raw
In response to Problem with foreign keys and inheritance  ("Oliver Elphick" <olly@lfix.co.uk>)
Responses Re: [HACKERS] Problem with foreign keys and inheritance
List pgsql-hackers
"Oliver Elphick" wrote: >[Version: CVS as of yesterday] >When I create a table that inherits from another table that
usesforeign >keys, I get something like this: > >  ERROR:  cache lookup of attribute 10 in relation 124171 failed >
>Thisis happening in get_attribute_name() of backend/utils/adt/ruleutils.c
 

Here is an SQL script that makes this happen:

========================================================
create database newj with encoding = 'SQL_ASCII';
\connect newj
create table person
(       id              char(10)        primary key,       name            text            not null,       address
  int,       salutation      text            default 'Dear Sir',       envelope        text,       email
text,      www             text
 
);

create table individual
(       gender          char(1)         check (gender = 'M' or gender = 'F'
  or gender is null),       born            datetime        check ((born >= '1 Jan 1880'
         and born <= 'today') or born is null),       surname         text,       forenames       text,       title
     text,       old_surname     text,       mobile          text,       ni_no           text,       constraint
is_namedcheck (not (surname isnull and forenames isnull))
 
)       inherits (person);

create table organisation
(       contact         char(10)        references individual (id) match full,       structure       char(1)
check(structure='L' or structure='C'                                             or structure='U' or structure='O')
 
)       inherits (person);

create table customer
(       acs_code        char(8),       acs_addr        int,        class           char(1)         default '',
type           char(2),       area            char(2),       country         char(2),       vat_class       char(1),
  vat_number      char(12),       discount        numeric(6,3)      check (discount >= -50.0::numeric(6,3)
                           and discount <= 50.0)::numeric(6,3),       commission      bool            default 'f',
status          char(1)         default '',       deliver_to      int,       factor_code     text
 
)       inherits (organisation);
========================================================

Table customer does not get created; instead, I get:
 ERROR:  cache lookup of attribute 10 in relation <some_oid> failed

-- 




pgsql-hackers by date:

Previous
From: "Ansley, Michael"
Date:
Subject: RE: [HACKERS] pg_dump not in very good shape
Next
From: Kristofer Munn
Date:
Subject: Re: [HACKERS] SELECT...FOR UPDATE OF class_name