Re: ADD/DROP INHERITS

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: ADD/DROP INHERITS
Date: 2006-06-08 21:13:10
Message-ID: 1488.1149801190@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> Based on the test case Tom shows, I think we need to enforce that ADD
> INHERITS will barf if the columns are not in exactly the order they
> would have been in if we add done a CREATE ... INHERITS followed by a
> DROP INHERITS.

This seems overly strong; if we enforced that policy consistently, then
it would for example be illegal to ADD COLUMN to a parent. Consider

create table p(f1 int);
create table c(f2 int) inherits (p);
alter table p add column f3 int;

The column order in c will now be f1,f2,f3. However, after a dump and
reload it'll be f1,f3,f2, because f3 will already be an inherited column
when c is created. This is pretty much unavoidable and we've taken care
of the various loose ends needed to make it work safely.

What I'm saying is just that we should avoid *unnecessary* changes of
column order, and in particular that means taking at least a little care
to try to select a reasonable inhseqno during ADD INHERITS.

If you think the "first unused" policy wouldn't take care of enough
cases, one idea is to try to look at the columns that will be inherited
from the new parent, and to see if we can deduce a suitable inhseqno
based on those columns' positions. I suspect this will be a pretty ugly
heuristic though ...

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Browne 2006-06-08 21:13:30 Re: Fabian Pascal and RDBMS deficiencies in fully implementing the relational model
Previous Message Larry Rosenman 2006-06-08 21:08:48 Re: That EXPLAIN ANALYZE patch still needs work