Thread: pg_get_constraintdef

pg_get_constraintdef

From
"Christopher Kings-Lynne"
Date:
Is there some reason why pg_get_constraintdef only supports Foreign Key
constraints?  Why not have it output ALTER TABLE commands for UNIQUE and
PRIMARY KEY constraints?  That would make my life so much easier for
phpPgAdmin and also pg_dump could be simplified quite considerably...?

Chris



Re: pg_get_constraintdef

From
Tom Lane
Date:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> Is there some reason why pg_get_constraintdef only supports Foreign Key
> constraints?

Lack of implementation effort --- the original definition/implementation
was FK-specific, but now, as the code says,
* XXX The present implementation only works for foreign-key constraints, but* it could and should handle anything
pg_constraintstores.
 

Feel free to contribute some code.

> Why not have it output ALTER TABLE commands for UNIQUE and
> PRIMARY KEY constraints?  That would make my life so much easier for
> phpPgAdmin and also pg_dump could be simplified quite considerably...?

I do not think pg_dump would gain anything much, since it has to be able
to deal with older servers.
        regards, tom lane


Re: pg_get_constraintdef

From
"Christopher Kings-Lynne"
Date:
> "Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> > Is there some reason why pg_get_constraintdef only supports Foreign Key
> > constraints?
>
> Lack of implementation effort --- the original definition/implementation
> was FK-specific, but now, as the code says,
>
>  * XXX The present implementation only works for foreign-key
> constraints, but
>  * it could and should handle anything pg_constraint stores.
>
> Feel free to contribute some code.

I will, but unfortunately the damage has already been done...since I have to
support 7.3 anyway, fixing the above problem will actually make my life
harder, not easier...

Chris



Re: pg_get_constraintdef

From
"Ross J. Reedstrom"
Date:
On Mon, Jan 13, 2003 at 11:59:33AM +0800, Christopher Kings-Lynne wrote:
>Tom Lane writes:
> >
> > Feel free to contribute some code.
> 
> I will, but unfortunately the damage has already been done...since I have to
> support 7.3 anyway, fixing the above problem will actually make my life
> harder, not easier...

Yeah, but never let that stop you from doing the right thing. Heck,
isn't that almost a diagnostic for 'the right thing', "Hmm, this is easy:
I must be doing something wrong." ;-)

Ross


Re: pg_get_constraintdef

From
Kris Jurka
Date:

> On Mon, Jan 13, 2003 at 11:59:33AM +0800, Christopher Kings-Lynne wrote:
> >
> > I will, but unfortunately the damage has already been done...since I
have to
> > support 7.3 anyway, fixing the above problem will actually make my life
> > harder, not easier...

Another issue to consider is that when a dump from 7.2 is loaded into 7.3
no foreign keys are listed in pg_constraint, so some backwards
compatibility will be required because even if the 7.3 server supports
this functionality it does not mean it is being used.

Kris Jurka