Re: Adding OLD/NEW support to RETURNING

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Robert Treat <rob(at)xzilla(dot)net>, Jeff Davis <pgsql(at)j-davis(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(at)vondra(dot)me>
Subject: Re: Adding OLD/NEW support to RETURNING
Date: 2025-01-08 06:16:38
Message-ID: CACJufxGY+9n5ZEveF9iXnQRmTjSE-TRbEO9pAzdjOuWp_ue59w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.
two minor issues.

if (qry->returningList == NIL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("RETURNING must have at least one column"),
parser_errposition(pstate,

exprLocation(linitial(returningClause->exprs)))));

we can reduce one level parenthesis by:
if (qry->returningList == NIL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("RETURNING must have at least one column"),
parser_errposition(pstate,

exprLocation(linitial(returningClause->exprs))));

seems no tests for this error case.
we can add one in case someone in future is wondering if this is ever reachable.
like:
create temp table s1();
insert into s1 default values returning new.*;
drop temp table s1;

transformReturningClause
case RETURNING_OPTION_NEW: not tested,
we can add one at src/test/regress/sql/returning.sql line 176:

INSERT INTO foo DEFAULT VALUES RETURNING WITH (new AS n, old AS o, new as n) *;

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-01-08 06:21:26 Re: per backend WAL statistics
Previous Message Xuneng Zhou 2025-01-08 05:34:48 Re: Unsafe access BufferDescriptors array in BufferGetLSNAtomic()