Re: [PATCH] Implement INSERT SET syntax

Поиск
Список
Период
Сортировка
От Gareth Palmer
Тема Re: [PATCH] Implement INSERT SET syntax
Дата
Msg-id 823D82DF-70B9-4662-BBEA-ECEB72EF725D@internetnz.net.nz
обсуждение исходный текст
Ответ на Re: [PATCH] Implement INSERT SET syntax  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Ответы Re: [PATCH] Implement INSERT SET syntax  (Ibrar Ahmed <ibrar.ahmad@gmail.com>)
Список pgsql-hackers
Hi Kyotaro,

Thank-you for looking at the patch.

> On 18/07/2019, at 6:54 PM, Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:
>
> Hello.
>
> If I'm not missing something, "SELECT <targetlist>" without
> having FROM clause doesn't need to be tweaked. Thus
> insert_set_clause is useless and all we need here would be
> something like the following. (and the same for OVERRIDING.)
>
> +       | SET set_clause_list from_clause
> +         {
> +           SelectStmt *n = makeNode(SelectStmt);
> +           n->targetList = $2;
> +           n->fromClause = $3;
> +           $$ = makeNode(InsertStmt);
> +           $$->selectStmt = (Node *)n;
> +           $$->cols = $2;
> +         }

While that would mostly work, it would prevent setting the column to its
default value using the DEFAULT keyword.

Only expressions specified in valuesLists allow DEFAULT to be used. Those
in targetList do not because transformInsertStmt() treats that as a general
SELECT statement and the grammar does not allow the use of DEFAULT there.

So this would generate a "DEFAULT is not allowed in this context" error
if only targetList was used:

INSERT INTO t set c1 = DEFAULT;


Regards,
Gareth

> regards.
>
> --
> Kyotaro Horiguchi
> NTT Open Source Software Center




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

Предыдущее
От: David Rowley
Дата:
Сообщение: Re: Tid scan improvements
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: Documentation fix for adding a column with a default value