BUG #19924: unrecognized node type in create_plan_recurse: UNION, LIMIT, json_populate_recordset, inheritance

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: hackerzheng666(at)gmail(dot)com
Subject: BUG #19924: unrecognized node type in create_plan_recurse: UNION, LIMIT, json_populate_recordset, inheritance
Date: 2026-11-20 06:25:27
Message-ID: 19924-8aecd924385fafcc@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19924
Logged by: Zheng Hacker
Email address: hackerzheng666(at)gmail(dot)com
PostgreSQL version: 19.0
Operating system: Linux x86_64, Ubuntu 22.04.5, gcc 11.4.0, cassert
Description:

Tested on git master (20devel) d94964f14f39936d69c6b8d3fc5020f0fdae1617 of
2026-11-20 and on an older unreleased master build. The version selected in
this form is the closest option available; I did not test 19.0 or any
released branch.

A UNION (with duplicate elimination) of two identical queries, each with
json_populate_recordset() in the select list over a join that involves a
table with an inheritance child, together with a LIMIT, fails in the planner
with an internal error whose node tag is a garbage number.

Fresh cluster, default settings:

CREATE TABLE t1 (c0 int4, c1 int8);
CREATE TABLE t3 (c0 int4, c1 interval);
CREATE TABLE ch4 () INHERITS (t1);
(SELECT json_populate_recordset(CAST('2147483647' AS oid), CAST('[]' AS
json), FALSE) AS c0
FROM t3 AS a0 INNER JOIN t1 AS a1 USING (c0))
UNION
(SELECT json_populate_recordset(CAST('2147483647' AS oid), CAST('[]' AS
json), FALSE) AS c0
FROM t3 AS a0 INNER JOIN t1 AS a1 USING (c0))
LIMIT 2;

ERROR: unrecognized node type: 3301232

With \set VERBOSITY verbose on master d94964f:
ERROR: XX000: unrecognized node type: 3301232
LOCATION: create_plan_recurse, createplan.c:547

The number is the same on every run and for the variants below.

What I ran, all on the same statement list (no tables are populated, all
tables are empty):
- git master d94964f (built from source, cassert): 3 of 3 fresh clusters
give the error above.
- An older, unreleased master build (cassert): 3 of 3 fresh clusters give
the same error.
- On master, each of these removals makes the error disappear (one run each,
same cluster): replacing UNION with UNION ALL; removing LIMIT; using only
one branch with LIMIT; INTERSECT instead of UNION; dropping the inheritance
child ch4 before the query. Re-creating ch4 brings the error back.
- The function matters: with generate_series(1,2), unnest(ARRAY[1,2]) or a
plain column a0.c0 in place of json_populate_recordset(...) there is no
error (one run each on master). With json_populate_recordset(NULL::t1,
CAST('[]' AS json)) the same error with the same number 3301232 appears.

Found by a statement-sequence fuzzer and reduced to the statements above.

What I did not do: I did not trace where the Path node is freed or
overwritten, I did not test a build without --enable-cassert (the error
comes from elog, so I expect it there too, but I have not run it), and I did
not test released branches.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrey Rachitskiy 2026-11-20 06:35:40 Re: BUG #19594: to_char/jsonpath format cache serves a format tree parsed in the wrong strict-mode
Previous Message Fujii Masao 2026-11-20 06:23:19 Re: BUG #19594: to_char/jsonpath format cache serves a format tree parsed in the wrong strict-mode