trouble with the automatic indexes on CREATE TABLE - Mailing list pgsql-general

From Bill McGonigle
Subject trouble with the automatic indexes on CREATE TABLE
Date
Msg-id 200105152220.f4FMKgA21992@postgresql.org
Whole thread Raw
Responses Re: trouble with the automatic indexes on CREATE TABLE  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
When doing CREATE TABLE (piped in from a file with my table definitions) I'
m getting errors that I think are related to the automatic index creation
on my UNIQUE columns:

ERROR:  Relation 'phone_number_types' does not exist
ERROR:  Cannot create index: 'phone_number__phone_number__key' already
exists
ERROR:  Relation 'delivery_methods' does not exist
ERROR:  Cannot create index: 'delivery_meth_delivery_meth_key' already
exists
ERROR:  Relation 'phone_number_locations' does not exist
ERROR:  Cannot create index: 'phone_number__phone_number__key' already
exists

I suspect that the name PostgreSQL (7.0.3) is picking for the
automatically created indexes may be colliding with other index names from
other colums.  This is what I can't seem to figure out how to avoid.

For instance:

CREATE TABLE Delivery_Methods (
         delivery_method_id INTEGER NOT NULL UNIQUE,
         delivery_method VARCHAR(50) NOT NULL UNIQUE
);

I think it's having trouble when it truncates the column name and winds up
with the same key name for both columns.  Is there a way to force it to
not truncate or to specify the index name for it to use?

Thanks,
-Bill

pgsql-general by date:

Previous
From: Alex Pilosov
Date:
Subject: index doesn't work for null?
Next
From: Tom Lane
Date:
Subject: Re: trouble with the automatic indexes on CREATE TABLE