BUG #17259: RETURN QUERY no longer accepts an UPDATE RETURNING

Started by PG Bug reporting formover 4 years ago2 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 17259
Logged by: Jorge Gualtieri
Email address: jorge@jrg.com.br
PostgreSQL version: 14.0
Operating system: Ubuntu 20.04.3 LTS
Description:

In version 14.0 RETURN QUERY with UPDATE RETURNING in a function is
reporting an error and it works in version 13.4.
Test code:
--
create table test (i int primary key, j int);
insert into test values (1,1);

create or replace function f_test() returns setof int
language plpgsql
as $fn$
begin
return query
update test
set j = j+1
where i = 1
returning j;

end;
$fn$;

select * from f_test();
--
ERROR: 42601: query is not a SELECT
CONTEXT: query: update test
set j = j+1
where i = 1
returning j
PL/pgSQL function f_test() line 3 at RETURN QUERY
LOCATION: exec_stmt_return_query, pl_exec.c:3571

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PG Bug reporting form (#1)
Re: BUG #17259: RETURN QUERY no longer accepts an UPDATE RETURNING

PG Bug reporting form <noreply@postgresql.org> writes:

In version 14.0 RETURN QUERY with UPDATE RETURNING in a function is
reporting an error and it works in version 13.4.

Thanks for the report! This was already reported and repaired [1]/messages/by-id/1F2F75F0-27DF-406F-848D-8B50C7EEF06A@gmail.com,
so it should be okay in 14.1.

regards, tom lane

[1]: /messages/by-id/1F2F75F0-27DF-406F-848D-8B50C7EEF06A@gmail.com