references fail over rows inserted via inherited tables - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject references fail over rows inserted via inherited tables
Date
Msg-id 200105202338.f4KNcV716652@hub.org
Whole thread Raw
Responses Re: references fail over rows inserted via inherited tables
List pgsql-bugs
Diego Saravia (dsa@unsa.edu.ar) reports a bug with a severity of 4
The lower the number the more severe it is.

Short Description
references fail over rows inserted via inherited tables

Long Description
When you insert a row via an inherited table, with 7.1.1, you can see in the parent table.

But when you try to insert a reference to that value you can't.

Sample Code
/*I have a problem with inherited primary keys

When I referenced a primary key inserted via an inherited table
it gives you an error

Is this the right way?

Example
*************************************************
*/


select version();
/*                            version
---------------------------------------------------------------
 PostgreSQL 7.1.1 on i686-pc-linux-gnu, compiled by GCC 2.95.2
(1 row)
*/

create table persona(
 id serial primary key,
 nombre text
);

create table usuario(
 alias text
) inherits (persona) ;


insert into usuario (alias,nombre) values ('no','NO');

insert into persona (nombre) values ('SI');

select * from persona;

/*
 id | nombre
----+--------
  2 | SI
  1 | NO
(2 rows)
*/

select * from usuario;

/*
 id | nombre | alias
----+--------+-------
  1 | NO     | no
(1 row)
*/

create table trabajo(
 titulo text,
 propietario integer references persona                                       );


insert into trabajo (titulo,propietario) values ('capaz',1);


/*ERROR:  <unnamed> referential integrity violation - key referenced from trabajo not found in persona   */


insert into trabajo (titulo,propietario) values ('capaz',2);

select * from trabajo;

/*
 titulo | propietario
--------+-------------
 capaz  |           2
(1 row)
*/




create table trabajo2(
 titulo text,
 propietario integer references usuario                                       );

/*
ERROR:  PRIMARY KEY for referenced table "usuario" not found

I think that this is also not Ok

*/









No file was uploaded with this report

pgsql-bugs by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: Problems with avg on interval data type
Next
From: Stephan Szabo
Date:
Subject: Re: references fail over rows inserted via inherited tables