pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Regression in PL/PGSQL code using RETURN QUERY with Postgres 14
5+ messages / 3 participants
[nested] [flat]

* Regression in PL/PGSQL code using RETURN QUERY with Postgres 14
@ 2021-10-07 18:38 Gavin Roy <gavinr@aweber.com>
  2021-10-07 18:54 ` Re: Regression in PL/PGSQL code using RETURN QUERY with Postgres 14 Adrian Klaver <adrian.klaver@aklaver.com>
  2021-10-07 19:05 ` Re: Regression in PL/PGSQL code using RETURN QUERY with Postgres 14 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 5+ messages in thread

From: Gavin Roy @ 2021-10-07 18:38 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi All,

My team was testing against Postgres 14 to ensure we could cleanly upgrade
and we ran across a regression in our PL/PGSQL code related to the updates
to RETURN QUERY.

Our code which works in previous versions of Postgres uses UPDATE RETURNING
and INSERT RETURNING in combination with RETURN QUERY. It appears that in
the parallelism updates, RETURN QUERY now only accepts SELECT queries.

Was this an intentional change in behavior? We can easily refactor our
PL/PGSQL functions to deal with the change, but if it was intentional,
perhaps it should be documented.

Regards,

Gavin

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Regression in PL/PGSQL code using RETURN QUERY with Postgres 14
  2021-10-07 18:38 Regression in PL/PGSQL code using RETURN QUERY with Postgres 14 Gavin Roy <gavinr@aweber.com>
@ 2021-10-07 18:54 ` Adrian Klaver <adrian.klaver@aklaver.com>
  2021-10-07 19:05   ` Re: Regression in PL/PGSQL code using RETURN QUERY with Postgres 14 Gavin Roy <gavinr@aweber.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Adrian Klaver @ 2021-10-07 18:54 UTC (permalink / raw)
  To: Gavin Roy <gavinr@aweber.com>; pgsql-general@lists.postgresql.org

On 10/7/21 11:38 AM, Gavin Roy wrote:
> Hi All,
> 
> My team was testing against Postgres 14 to ensure we could cleanly 
> upgrade and we ran across a regression in our PL/PGSQL code related to 
> the updates to RETURN QUERY.
> 
> Our code which works in previous versions of Postgres uses UPDATE 
> RETURNING and INSERT RETURNING in combination with RETURN QUERY. It 
> appears that in the parallelism updates, RETURN QUERY now only accepts 
> SELECT queries.

I'm pretty sure folks are going to want to see an example of the code 
and the errors thrown in version 14.

> 
> Was this an intentional change in behavior? We can easily refactor our 
> PL/PGSQL functions to deal with the change, but if it was intentional, 
> perhaps it should be documented.
> 
> Regards,
> 
> Gavin


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Regression in PL/PGSQL code using RETURN QUERY with Postgres 14
  2021-10-07 18:38 Regression in PL/PGSQL code using RETURN QUERY with Postgres 14 Gavin Roy <gavinr@aweber.com>
  2021-10-07 18:54 ` Re: Regression in PL/PGSQL code using RETURN QUERY with Postgres 14 Adrian Klaver <adrian.klaver@aklaver.com>
@ 2021-10-07 19:05   ` Gavin Roy <gavinr@aweber.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Gavin Roy @ 2021-10-07 19:05 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general@lists.postgresql.org

On Thu, Oct 7, 2021 at 2:54 PM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

> On 10/7/21 11:38 AM, Gavin Roy wrote:
> > Hi All,
> >
> > My team was testing against Postgres 14 to ensure we could cleanly
> > upgrade and we ran across a regression in our PL/PGSQL code related to
> > the updates to RETURN QUERY.
> >
> > Our code which works in previous versions of Postgres uses UPDATE
> > RETURNING and INSERT RETURNING in combination with RETURN QUERY. It
> > appears that in the parallelism updates, RETURN QUERY now only accepts
> > SELECT queries.
>
> I'm pretty sure folks are going to want to see an example of the code
> and the errors thrown in version 14.
>

Sorry, I thought that was pretty clear. As an example, this worked prior to
14 and no longer works:

CREATE TABLE foo (
  bar  SERIAL  PRIMARY KEY,
  baz  TEXT
);

CREATE FUNCTION update_foo(in_bar INT4, in_baz TEXT) RETURNS SETOF foo AS $$
BEGIN
  RETURN QUERY UPDATE foo SET baz = in_baz WHERE bar = in_bar RETURNING
bar, baz;
END;
$$ LANGUAGE PLPGSQL;

postgres=# SELECT * FROM update_foo(1, 'baz?');
ERROR:  query is not a SELECT
CONTEXT:  query: UPDATE foo SET baz = in_baz WHERE bar = in_bar RETURNING
bar, baz
PL/pgSQL function update_foo(integer,text) line 3 at RETURN QUERY

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Regression in PL/PGSQL code using RETURN QUERY with Postgres 14
  2021-10-07 18:38 Regression in PL/PGSQL code using RETURN QUERY with Postgres 14 Gavin Roy <gavinr@aweber.com>
@ 2021-10-07 19:05 ` Tom Lane <tgl@sss.pgh.pa.us>
  2021-10-07 19:06   ` Re: Regression in PL/PGSQL code using RETURN QUERY with Postgres 14 Gavin Roy <gavinr@aweber.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Tom Lane @ 2021-10-07 19:05 UTC (permalink / raw)
  To: Gavin Roy <gavinr@aweber.com>; +Cc: pgsql-general@lists.postgresql.org

Gavin Roy <gavinr@aweber.com> writes:
> Our code which works in previous versions of Postgres uses UPDATE RETURNING
> and INSERT RETURNING in combination with RETURN QUERY. It appears that in
> the parallelism updates, RETURN QUERY now only accepts SELECT queries.

Yeah, that's a mistake, previously reported and fixed at

https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=e0eba586b

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Regression in PL/PGSQL code using RETURN QUERY with Postgres 14
  2021-10-07 18:38 Regression in PL/PGSQL code using RETURN QUERY with Postgres 14 Gavin Roy <gavinr@aweber.com>
  2021-10-07 19:05 ` Re: Regression in PL/PGSQL code using RETURN QUERY with Postgres 14 Tom Lane <tgl@sss.pgh.pa.us>
@ 2021-10-07 19:06   ` Gavin Roy <gavinr@aweber.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Gavin Roy @ 2021-10-07 19:06 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org

Thanks so much Tom!

Regards,

Gavin

On Thu, Oct 7, 2021 at 3:05 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Gavin Roy <gavinr@aweber.com> writes:
> > Our code which works in previous versions of Postgres uses UPDATE
> RETURNING
> > and INSERT RETURNING in combination with RETURN QUERY. It appears that in
> > the parallelism updates, RETURN QUERY now only accepts SELECT queries.
>
> Yeah, that's a mistake, previously reported and fixed at
>
>
> https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=e0eba586b
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2021-10-07 19:06 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-10-07 18:38 Regression in PL/PGSQL code using RETURN QUERY with Postgres 14 Gavin Roy <gavinr@aweber.com>
2021-10-07 18:54 ` Adrian Klaver <adrian.klaver@aklaver.com>
2021-10-07 19:05   ` Gavin Roy <gavinr@aweber.com>
2021-10-07 19:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-10-07 19:06   ` Gavin Roy <gavinr@aweber.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox