Re: wrong message when trying to create an already existing index - Mailing list pgsql-general

From Melvin Davidson
Subject Re: wrong message when trying to create an already existing index
Date
Msg-id CANu8FiyiWwKahzA=2dg87zJS8PoGcceMMG=mCGhQKmTO1oZTWA@mail.gmail.com
Whole thread Raw
In response to Re: wrong message when trying to create an already existing index  (legrand legrand <legrand_legrand@hotmail.com>)
Responses Re: wrong message when trying to create an already existing index
List pgsql-general


On Sat, Mar 10, 2018 at 10:54 AM, legrand legrand <legrand_legrand@hotmail.com> wrote:
I thougth that thoses messages where using relation's relkind:
  r = ordinary table,
  i = index,
  S = sequence,
  t = TOAST table,
  v = view,
  m = materialized view,
  c = composite type,
  f = foreign table,
  p = partitioned table

wouldn't it be easier to read for beginners ?

Regards
PAscal



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html


>message speaks about relation (and not index)
>Would it be possible that this message reports the correct object type ?
>I thougth that thoses messages where using relation's relkind:
>wouldn't it be easier to read for beginners ?

PostgreSQL is a "relational" database, and as such _all_ objects in the database are
considered _relations_, even indexes. Therefore, the error message is correct, because
_relation_ NEWINDEX already exists.

I believe that the code is generic as the clause "IF EXISTS" checks against pg_class
for other _relations_ as defined in relkind, and therefore reports a generic message as
"relation _relname_ already exists"

To report on a specific relation type would be redundant, because you already know
from your SQL statement what type/relkind of relation you are trying to CREATE.
IE: SQL> create  index if not exists NEWINDEX on SCHEMA.TABLE(COL);
                 ^^^^^


--
Melvin Davidson
Maj. Database & Exploration Specialist

Universe Exploration Command – UXC

Employment by invitation only!

pgsql-general by date:

Previous
From: legrand legrand
Date:
Subject: Re: wrong message when trying to create an already existing index
Next
From: legrand legrand
Date:
Subject: Re: wrong message when trying to create an already existing index