Hi Kyotaro,

Thank-you for looking at the patch.

> On 18/07/2019, at 6:54 PM, Kyotaro Horiguchi <horikyota....@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



Reply via email to