Ensure all implicit constraints are named

Started by Rod Taylorabout 23 years ago5 messagespatches
Jump to latest
#1Rod Taylor
rbt@rbt.ca

If they're not, the below causes problems, as the foreign key is added
after the CHECK. Cluster depends on the index name, so I thought it
wise to ensure all names are available, rather than leaving off the
CONSTRAINT "$n" portion for internally named constraints.

CREATE TABLE jkey (col integer primary key);
CREATE TABLE j (col integer REFERENCES jkey);
ALTER TABLE j ADD CHECK(col > 5);

This is a problem in 7.3 series as well as -Tip.

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

Attachments:

pg_dump-conname.patchtext/x-patch; charset=ISO-8859-1; name=pg_dump-conname.patchDownload+3-3
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rod Taylor (#1)
Re: Ensure all implicit constraints are named

Rod Taylor <rbt@rbt.ca> writes:

[above]

Er, weren't you just arguing for the opposite?

regards, tom lane

#3Rod Taylor
rbt@rbt.ca
In reply to: Tom Lane (#2)
Re: Ensure all implicit constraints are named

On Thu, 2003-06-05 at 01:53, Tom Lane wrote:

Rod Taylor <rbt@rbt.ca> writes:

[above]

Er, weren't you just arguing for the opposite?

Yes, I was. Until I realized that some things in pg_dump depend on the
specific name of the constraint in cases where they are auto-generated.

To fix the problem, they need to be common.

Someday I'll probably propose that cluster should work on a list of
columns, and build the index by itself if one is not already available.
Once thats done, we can probably revisit pg_dump and make these items
unnamed in the dump file.

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

#4Bruce Momjian
bruce@momjian.us
In reply to: Rod Taylor (#1)
Re: Ensure all implicit constraints are named

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------

Rod Taylor wrote:
-- Start of PGP signed section.

If they're not, the below causes problems, as the foreign key is added
after the CHECK. Cluster depends on the index name, so I thought it
wise to ensure all names are available, rather than leaving off the
CONSTRAINT "$n" portion for internally named constraints.

CREATE TABLE jkey (col integer primary key);
CREATE TABLE j (col integer REFERENCES jkey);
ALTER TABLE j ADD CHECK(col > 5);

This is a problem in 7.3 series as well as -Tip.

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

[ Attachment, skipping... ]
-- End of PGP section, PGP failed!

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#5Bruce Momjian
bruce@momjian.us
In reply to: Rod Taylor (#1)
Re: Ensure all implicit constraints are named

Patch applied to HEAD and 7.3.X. Thanks.

---------------------------------------------------------------------------

Rod Taylor wrote:
-- Start of PGP signed section.

If they're not, the below causes problems, as the foreign key is added
after the CHECK. Cluster depends on the index name, so I thought it
wise to ensure all names are available, rather than leaving off the
CONSTRAINT "$n" portion for internally named constraints.

CREATE TABLE jkey (col integer primary key);
CREATE TABLE j (col integer REFERENCES jkey);
ALTER TABLE j ADD CHECK(col > 5);

This is a problem in 7.3 series as well as -Tip.

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

[ Attachment, skipping... ]
-- End of PGP section, PGP failed!

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073