Re: create type error message

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jim(at)contactbda(dot)com
Cc: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: create type error message
Date: 2006-03-23 04:41:30
Message-ID: 2848.1143088890@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Jim Buttafuoco" <jim(at)contactbda(dot)com> writes:
> # create type a as (a text,b int);
> CREATE TYPE
> # create type a as (a text,b int);
> ERROR: relation "a" already exists

> seems like
> ERROR: type "a" already exists
> would be better.

It's not really all that easy, because tables and composite types both
have entries in both pg_class and pg_type. Consider

regression=# create table tt (a text,b int);
CREATE TABLE
regression=# create type tt as (a text,b int);
ERROR: relation "tt" already exists

regression=# create type zz as (a text,b int);
CREATE TYPE
regression=# create table zz (a text,b int);
ERROR: relation "zz" already exists

In all three cases the error is actually detected inside
heap_create_with_catalog, because we choose to make the pg_class entry
first. We could possibly alter the error report based on the relkind
of the entry we are about to make, but I'm unconvinced it'd be an
improvement...

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Enver ALTIN 2006-03-23 04:50:18 pgNixInstaller: Making PostgreSQL relocatable
Previous Message Andrew Dunstan 2006-03-23 04:30:48 Re: Static build of psql with readline support