Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wk4M5-000Rxf-2K for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Jul 2026 18:29:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wk4M4-008un0-24 for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Jul 2026 18:29:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wk4M4-008ums-1J for pgsql-bugs@lists.postgresql.org; Wed, 15 Jul 2026 18:29:12 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wk4Ly-00000000R9X-3z8V for pgsql-bugs@lists.postgresql.org; Wed, 15 Jul 2026 18:29:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 66FIT4o03574720; Wed, 15 Jul 2026 14:29:04 -0400 From: Tom Lane To: Maaz Syed Adeeb cc: pgsql-bugs@lists.postgresql.org, matthew.ripley28@gmail.com Subject: Re: CREATE INDEX with an expression in an INCLUDE column fails with XX000 "unrecognized node type" instead of 0A000 on master In-reply-to: References: Comments: In-reply-to Maaz Syed Adeeb message dated "Wed, 15 Jul 2026 06:05:06 -0700" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <3574683.1784140106.0@sss.pgh.pa.us> Date: Wed, 15 Jul 2026 14:29:04 -0400 Message-ID: <3574719.1784140144@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3574683.1784140106.1@sss.pgh.pa.us> Maaz Syed Adeeb writes: > 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. Thanks for the report! This is evidently happening because we have not applied parse transformation to the included columns. I think that the most appropriate way to fix it is to start doing so, even though the feature will be rejected later. More or less as attached (but we ought to add a test case too). regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="wip-fix-index-included-expressions.patch"; charset="us-ascii" Content-ID: <3574683.1784140106.2@sss.pgh.pa.us> Content-Description: wip-fix-index-included-expressions.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse= _utilcmd.c index 58ccc7b68f2..ccf6ee55310 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -3122,6 +3122,26 @@ transformIndexStmt(Oid relid, IndexStmt *stmt, cons= t char *queryString) } } = + /* + * Likewise take care of any expressions in INCLUDING. (At this writing= , + * those will be rejected later on, but probably someday we'll wish to + * support them.) + */ + foreach(l, stmt->indexIncludingParams) + { + IndexElem *ielem =3D (IndexElem *) lfirst(l); + + if (ielem->expr) + { + /* Do parse transformation of the expression */ + ielem->expr =3D transformExpr(pstate, ielem->expr, + EXPR_KIND_INDEX_EXPRESSION); + + /* We have to fix its collations too */ + assign_expr_collations(pstate, ielem->expr); + } + } + /* * Check that only the base rel is mentioned. (This should be dead code * now that add_missing_from is history.) ------- =_aaaaaaaaaa0--