| From: | Maaz Syed Adeeb <maaz(dot)adeeb(at)gmail(dot)com> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | matthew(dot)ripley28(at)gmail(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us |
| Subject: | CREATE INDEX with an expression in an INCLUDE column fails with XX000 "unrecognized node type" instead of 0A000 on master |
| Date: | 2026-07-15 13:05:06 |
| Message-ID: | CAG+FJqOxYj=sVyHcys64h9DbvzP6EUPGHJ7oKj-PW=Qp5Ebk_g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
PostgreSQL version: 20devel (git master)
On current master, creating an index with an expression in an INCLUDE
(non-key) column fails with an internal error ("unrecognized node
type", SQLSTATE XX000) instead of the user-facing
FEATURE_NOT_SUPPORTED (0A000) "expressions are not supported in
included columns". The statement is still correctly rejected, but with
the wrong error class and a message.
Minimal repro
CREATE TABLE foo (id int PRIMARY KEY, x int, y int);
CREATE INDEX idx_foo ON foo (x) INCLUDE ((x + y));
Actual result on master (20devel):
postgres=# select version();
version
------------------------------------------------------------------------
PostgreSQL 20devel on aarch64-unknown-linux-gnu, compiled by gcc
(GCC) 7.3.1 20180712 (Red Hat 7.3.1-18), 64-bit
(1 row)
postgres=# CREATE TABLE foo (id int PRIMARY KEY, x int, y int);
CREATE TABLE
postgres=# CREATE INDEX idx_foo ON foo (x) INCLUDE ((x + y));
ERROR: unrecognized node type: 74
postgres=# \errverbose
ERROR: XX000: unrecognized node type: 74
LOCATION: expression_tree_walker_impl, nodeFuncs.c:2733
(built from git master, HEAD at the time of testing:
572c3b2ddf8c90303d57bf33add4dcbf1b30b866)
Expected result (behavior on all released majors, e.g. 16.13):
postgres=# CREATE INDEX idx_foo ON foo (x) INCLUDE ((x + y));
ERROR: expressions are not supported in included columns
postgres=# \errverbose
ERROR: 0A000: expressions are not supported in included columns
LOCATION: ComputeIndexAttrs, indexcmds.c:1910
This appears to have been introduced by:
commit 181b6185c79e09e6ac94428189d9afac807244ac
"Improve the names generated for indexes on expressions"
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=181b6185c79e09e6ac94428189d9afac807244ac
which replaced the previous static "expr" fallback name with a walk of
the expression. Prior to that commit the INCLUDE expression was never
walked at this stage.
The trigger is any parenthesized expression in INCLUDE, not just
arithmetic; e.g. INCLUDE ((x)) fails the same way with "unrecognized
node type: 72"
(CC'ing Tom Lane, author of the patch that I've linked which is likely
causing the issue, and Matthew Ripley, author of a test that led me
down to this discovery when run against master)
Regards,
Maaz Syed Adeeb
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Konstantin Knizhnik | 2026-07-15 13:37:16 | Bug in heap_get_root_tuples |
| Previous Message | Kenny Chen | 2026-07-15 11:51:32 | Re: BUG #19547: libpqrcv_create_slot dereferences NULL on a malformed CREATE_REPLICATION_SLOT reply |