Re: BUG #17227: segmentation fault with jsonb_to_recordset

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: bernddorn@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2021-10-13T20:54:52Z
Lists: pgsql-bugs
I wrote:
> This works OK in v12, so somebody broke it between v12 and v13.

Looks like the somebody was me.  git bisect pins the blame on

commit 7266d0997dd2a0632da38a594c78e25ff21df67e
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date:   Thu Aug 1 18:50:22 2019 -0400

    Allow functions-in-FROM to be pulled up if they reduce to constants.

A relevant-looking part of the commit message is

    To do this, we need to rearrange when eval_const_expressions()
    happens for expressions in function RTEs.  I moved it to
    inline_set_returning_functions(), which already has to iterate over
    every function RTE, and in consequence renamed that function to
    preprocess_function_rtes().

Apparently this idea failed to account for subexpressions pulled up
during later processing.  Back to the drawing board.

			regards, tom lane



Commits

  1. Fix planner error with pulling up subquery expressions into function RTEs.

  2. Allow functions-in-FROM to be pulled up if they reduce to constants.