diff options
Diffstat (limited to 'src/backend/parser/analyze.c')
| -rw-r--r-- | src/backend/parser/analyze.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index a9d1fecff5c..60cce378453 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -2018,6 +2018,19 @@ transformReturningList(ParseState *pstate, List *returningList) /* transform RETURNING identically to a SELECT targetlist */ rlist = transformTargetList(pstate, returningList, EXPR_KIND_RETURNING); + /* + * Complain if the nonempty tlist expanded to nothing (which is possible + * if it contains only a star-expansion of a zero-column table). If we + * allow this, the parsed Query will look like it didn't have RETURNING, + * with results that would probably surprise the user. + */ + if (rlist == NIL) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("RETURNING must have at least one column"), + parser_errposition(pstate, + exprLocation(linitial(returningList))))); + /* mark column origins */ markTargetListOrigins(pstate, rlist); |
