Re: pg_dump: use ALTER TABLE for PKs

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>, pgsql-hackers(at)postgresql(dot)org
Cc: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
Subject: Re: pg_dump: use ALTER TABLE for PKs
Date: 2002-02-19 20:53:04
Message-ID: 3.0.5.32.20020220075304.039fd9b0@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 21:26 18/02/02 -0500, Neil Conway wrote:
>
>Bruce suggested that this should get some code review, since a bug in
>pg_dump would be bad news. Any comments would be welcome.
>

Part of the reason I did not implement this earlier was that ALTER
TABLE...PK did not handle child tables 'properly' (for some arbitrary
meaning of the word 'properly'). How have you covered:

CREATE TABLE PARENT(F1 INT PRIMARY KEY);
CREATE TABLE CHILD(...) INHERIT PARENT

this should create a PK on CHILD; what does pg-dump and the ALTER TABLE
implementation do? Not sure how it should work, but ultimately we need to
put the PK (and, necessarily, FK) creation at the end of the data load:

CREATE TABLE PARENT(F1 INT);
CREATE TABLE CHILD(...) INHERIT PARENT

Load PARENT
Load CHILD

ALTER TABLE PARENT...PK
ALTER TABLE CHILD...PK

This is a non-trivial issue since we also need to cater for:

CREATE TABLE PARENT(F1 INT);
CREATE TABLE CHILD1(...) INHERIT PARENT
ALTER TABLE PARENT...PK
CREATE TABLE CHILD2(...) INHERIT PARENT

Which, at least historically, resulted in CHILD1 *not* having a PK. I would
have built CVS and checked myself, but I'm relocating office (and servers)
at the moment.

----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Conway 2002-02-19 20:59:44 Re: questions on ALTER TABLE ... OWNER
Previous Message Philip Warner 2002-02-19 20:39:18 Re: questions on ALTER TABLE ... OWNER