Thread: bad error message

bad error message

From
"Martin A. Marques"
Date:
When I try this commands, some error messages aren't right:

[postgres@math pgsql]$ createdb test
CREATE DATABASE
[postgres@math pgsql]$ psql test
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

 test=# CREATE TABLE dedicacion (
test(#        id_dedi          SERIAL UNIQUE,
test(#        nombre_dedi      CHAR(10) UNIQUE
test(# );
NOTICE:  CREATE TABLE will create implicit sequence 'dedicacion_id_dedi_seq'
for SERIAL column 'dedicacion.id_dedi'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index
'dedicacion_id_dedi_key' for table 'dedicacion'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index
'dedicacion_id_dedi_key' for table 'dedicacion'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index
'dedicacion_nombre_dedi_key' for table 'dedicacion'
ERROR:  Cannot create index: 'dedicacion_id_dedi_key' already exists
test=# \dt
       List of relations
    Name     | Type  |  Owner
-------------+-------+----------
 pga_forms   | table | postgres
 pga_queries | table | postgres
 pga_reports | table | postgres
 pga_schema  | table | postgres
 pga_scripts | table | postgres
(5 rows)

test=#


Now, as you can see, the error says it couldn't create the index. It says
nothing about the table not been created, but it doesn't apeare anywhere.
This happens when I put the redundant UNIQUE to the serial data type.

If someone is asking why I do this, it's because I program also for informix,
and the serial data type in informix doesn't have unique values.

Hope someone can change these error messages, because it took me some time to
find out what was wrong.

Saludos... :-)

--
System Administration: It's a dirty job,
but someone told I had to do it.
-----------------------------------------------------------------
Martín Marqués            email:     martin@math.unl.edu.ar
Santa Fe - Argentina        http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------

Redundant UNIQUE specs (was Re: [GENERAL] bad error message)

From
Tom Lane
Date:
"Martin A. Marques" <martin@math.unl.edu.ar> writes:
> test=# CREATE TABLE dedicacion (
> test(#        id_dedi          SERIAL UNIQUE,
> test(#        nombre_dedi      CHAR(10) UNIQUE
> test(# );
> NOTICE:  CREATE TABLE will create implicit sequence 'dedicacion_id_dedi_seq' 
> for SERIAL column 'dedicacion.id_dedi'
> NOTICE:  CREATE TABLE/UNIQUE will create implicit index 
> 'dedicacion_id_dedi_key' for table 'dedicacion'
> NOTICE:  CREATE TABLE/UNIQUE will create implicit index 
> 'dedicacion_id_dedi_key' for table 'dedicacion'
> NOTICE:  CREATE TABLE/UNIQUE will create implicit index 
> 'dedicacion_nombre_dedi_key' for table 'dedicacion'
> ERROR:  Cannot create index: 'dedicacion_id_dedi_key' already exists

Hm.  There is code in the parser to discard duplicate UNIQUE
specifications when a PRIMARY KEY is present.  Shouldn't it just
do so in all cases, PRIMARY KEY or no?
        regards, tom lane