Thread: pg_attribute.attisinherited ?

pg_attribute.attisinherited ?

From
Alvaro Herrera
Date:
This should not happen, I guess:

alvh=> CREATE TABLE test_inh (a int);
CREATE TABLE
alvh=> CREATE TABLE test_inh_child (b int) INHERITS (test_inh);
CREATE TABLE
alvh=> ALTER TABLE test_inh_child RENAME a TO c;
ALTER TABLE
alvh=> SELECT * FROM test_inh;
ERROR:  Relation "test_inh_child" has no column "a"

alvh=> ALTER TABLE test_inh_child RENAME c TO a;
ALTER TABLE
alvh=> ALTER TABLE test_inh_child DROP COLUMN a;
ALTER TABLE
alvh=> SELECT * FROM test_inh;
ERROR:  Relation "test_inh_child" has no column "a"


I remember Tom suggested adding something like attisinherited and
preventing this kind of operations on such attributes, because one can
do things such as

alvh=> ALTER TABLE test_inh_child ADD COLUMN a TEXT;
ALTER TABLE
alvh=> INSERT INTO test_inh_child VALUES (1, 'hello world');
INSERT 33449 1
alvh=> SELECT * FROM test_inh;
server closed the connection unexpectedly       This probably means the server terminated abnormally       before or
whileprocessing the request.
 
The connection to the server was lost.  Attempting reset: Failed.
!> 

-- 
Alvaro Herrera (<alvherre[a]atentus.com>)
"Entristecido, Wutra
echa a Freyr a rodar
y a nosotros al mar" (cancion de Las Barreras, Heliconia)



Re: pg_attribute.attisinherited ?

From
Alvaro Herrera
Date:
On Fri, 23 Aug 2002 18:14:28 -0400 (CLT)
I said:

> I remember Tom suggested adding something like attisinherited and
> preventing this kind of operations on such attributes, because one can
> do things such as [...]

Well, maybe nobody cares or are just too busy (maybe it's weekend)... 
anyway I made a patch that creates the attisinherited attribute and I
think I got it working (that is, inherited attributes have it set and
for non-inherited it is false).  I haven't yet written checks for
disallowing the unwanted operations, though.

I will test it some more and post a patch later.

-- 
Alvaro Herrera (<alvherre[a]atentus.com>)
"Como puedes confiar en algo que pagas y que no ves,
y no confiar en algo que te dan y te lo muestran?" (German Poo)