Re: bug error message constraint "con_item_id_costelement" for table "costs" does not exist SQL state: 42704

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: bug error message constraint "con_item_id_costelement" for table "costs" does not exist SQL state: 42704
Дата
Msg-id 19144.1469721911@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: bug error message constraint "con_item_id_costelement" for table "costs" does not exist SQL state: 42704  (Vitaly Burovoy <vitaly.burovoy@gmail.com>)
Ответы Re: bug error message constraint "con_item_id_costelement" for table "costs" does not exist SQL state: 42704  (joel.traf@magwerks.com)
Список pgsql-bugs
Vitaly Burovoy <vitaly.burovoy@gmail.com> writes:
> On 7/28/16, joel.traf@magwerks.com <joel.traf@magwerks.com> wrote:
>> The documentation states "create temp table mytable (including all) "
>> is suppose to create all the constraints

> CREATE TABLE ... (LIKE ...)
> creates indexes and constraints with names as if they weren't given
> (i.e. by default), so your
> constraint "con_item_id_costelement" becomes
> "costs_cost_item_id_cost_costelem_id_key"

There's a comment in generateClonedIndexStmt about that:

     * We don't try to preserve the name of the source index; instead, just
     * let DefineIndex() choose a reasonable name.

However, this isn't documented anywhere user-visible AFAICS, and it
probably should be.

It's rather annoying that LIKE doesn't duplicate names of constraints,
especially now that we've invented ON CONFLICT and thereby made constraint
names something that would be explicitly referenced in DML code.  However,
I'm afraid that doing so is harder than it looks because index names have
to be unique within a schema.  If we tried to copy constraint names we'd
get a failure anytime the new table is in the same schema as the LIKE
source table.

            regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Vitaly Burovoy
Дата:
Сообщение: Re: bug error message constraint "con_item_id_costelement" for table "costs" does not exist SQL state: 42704
Следующее
От: joel.traf@magwerks.com
Дата:
Сообщение: Re: bug error message constraint "con_item_id_costelement" for table "costs" does not exist SQL state: 42704