pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas G. Lockhart <lockhart@alumni.caltech.edu>
To: Michael J. Sheldon <msheldon@cbrcomm.com>
Cc: 'pgsql-interfaces@postgresql.org' <pgsql-interfaces@postgreSQL.org>
Subject: Re: [INTERFACES] ODBC CREATE TABLE failures
Date: Fri, 01 Jan 1999 05:40:56 +0000
Message-ID: <368C5FE8.5032023A@alumni.caltech.edu> (raw)
References: <816099F7DDEFD111B37F00A0C90FD97D089B0D@gyrfalcon.cbrcomm.com>

> The application will automatically create the database structure if it
> does not already exist
> However, only the first table is being created.
> Code follows:
<snip>

You can test this code by running it through psql, and it fails there
too. Each CREATE TABLE statement is trying to use the same label for the
primary key constraint, but since Postgres enforces the primary key by
generating an implicit index this fails. Try using unique names for
constraints!

If for some reason these constraint names *must* be identical, you could
consider modifying the code in the parser to generate a unique internal
name based on both the constraint name and the table name, for example.
There is already a routine there to help you do this.

Failure example follows...

                  - Tom

postgres=>         CREATE TABLE FMGroups
postgres->         (
postgres->         GroupID INTEGER NOT NULL,
postgres->         GroupName VARCHAR(64) NOT NULL,
postgres->         Description VARCHAR(100),
postgres->         CONSTRAINT ID_pk PRIMARY KEY (GroupID),
postgres->         CONSTRAINT check_directory UNIQUE (GroupName)
postgres->         );
NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index id_pk for
table fmgroups
NOTICE:  CREATE TABLE/UNIQUE will create implicit index check_directory
for table fmgroups
CREATE
postgres=>         CREATE TABLE FMDirectories
postgres->         (
postgres->         DirectoryID INTEGER NOT NULL,
postgres->         DirectoryName VARCHAR(64) NOT NULL,
postgres->         Description VARCHAR(100),
postgres->         ParentID INTEGER NOT NULL,
postgres->         CONSTRAINT ID_pk PRIMARY KEY (DirectoryID),
postgres->         CONSTRAINT check_directory UNIQUE (DirectoryName)
postgres->         );
NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index id_pk for
table fmdirectories
NOTICE:  CREATE TABLE/UNIQUE will create implicit index check_directory
for table fmdirectories
ERROR:  Cannot create index: 'id_pk' already exists



view thread (6+ messages)  latest in thread

Message-ID: <368C5FE8.5032023A@alumni.caltech.edu>
Permalink:  ../368C5FE8.5032023A@alumni.caltech.edu/
Also on:    postgresql.org/message-id/368C5FE8.5032023A@alumni.caltech.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: lockhart@alumni.caltech.edu, msheldon@cbrcomm.com
  Subject: Re: [INTERFACES] ODBC CREATE TABLE failures
  In-Reply-To: <368C5FE8.5032023A@alumni.caltech.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox