Thread: Renaming a constraint

Renaming a constraint

From
Csaba Nagy
Date:
I found an old post regarding the subject, where modifying the
pg_constraint entry was recommended:

http://archives.postgresql.org/pgsql-admin/2003-04/msg00339.php

Is this still safe to do ? The pertinent docs don't say anything pro or
contra:
http://www.postgresql.org/docs/8.2/static/catalog-pg-constraint.html

I need to rename a few constraints to keep our schema logically
consistent. It would be of course nice to have an ALTER TABLE option to
do it, but if updating pg_constraint is safe it would do it for now.

Thanks,
Csaba.



Re: Renaming a constraint

From
Tom Lane
Date:
Csaba Nagy <nagy@ecircle-ag.com> writes:
> I found an old post regarding the subject, where modifying the
> pg_constraint entry was recommended:

> http://archives.postgresql.org/pgsql-admin/2003-04/msg00339.php

> Is this still safe to do ?

What kind of constraint?

            regards, tom lane

Re: Renaming a constraint

From
Csaba Nagy
Date:
On Tue, 2008-02-05 at 12:11 -0500, Tom Lane wrote:
> Csaba Nagy <nagy@ecircle-ag.com> writes:
> > I found an old post regarding the subject, where modifying the
> > pg_constraint entry was recommended:
>
> > http://archives.postgresql.org/pgsql-admin/2003-04/msg00339.php
>
> > Is this still safe to do ?
>
> What kind of constraint?

The only ones left are foreign key constraints. I had a few not nulls
too, but those are not actually there anyway (see my other post).

Thanks,
Csaba.



Re: Renaming a constraint

From
Tom Lane
Date:
Csaba Nagy <nagy@ecircle-ag.com> writes:
> On Tue, 2008-02-05 at 12:11 -0500, Tom Lane wrote:
>> Csaba Nagy <nagy@ecircle-ag.com> writes:
>>> Is this still safe to do ?
>>
>> What kind of constraint?

> The only ones left are foreign key constraints. I had a few not nulls
> too, but those are not actually there anyway (see my other post).

IIRC, the name of an FK constraint also appears in the arguments for its
triggers.  If you didn't update those too, the behavior might be a bit
inconsistent, depending on which PG version you're using.  In particular
I'm not sure which name pg_dump will believe.

            regards, tom lane

Re: Renaming a constraint

From
Csaba Nagy
Date:
On Wed, 2008-02-06 at 11:03 -0500, Tom Lane wrote:
> IIRC, the name of an FK constraint also appears in the arguments for its
> triggers.  If you didn't update those too, the behavior might be a bit
> inconsistent, depending on which PG version you're using.  In particular
> I'm not sure which name pg_dump will believe.

OK, I think I'll just give up on renaming them.

How hard would be to implement renaming constraints as an alter table
option ? It sounds to me like it should be a task requiring mostly
legwork than programming skills, would it be good task for a beginner in
C like me ? If it is at all regarded as a needed feature...

Thanks,
Csaba.