agora inbox for pgsql-bugs@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Maaz Syed Adeeb <maaz.adeeb@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Cc: 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
Date: Wed, 15 Jul 2026 14:29:04 -0400
Message-ID: <3574719.1784140144@sss.pgh.pa.us> (raw)
In-Reply-To: <CAG+FJqOxYj=sVyHcys64h9DbvzP6EUPGHJ7oKj-PW=Qp5Ebk_g@mail.gmail.com>
References: <CAG+FJqOxYj=sVyHcys64h9DbvzP6EUPGHJ7oKj-PW=Qp5Ebk_g@mail.gmail.com>

Maaz Syed Adeeb <maaz.adeeb@gmail.com> 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

Attachments:

  [text/x-diff] wip-fix-index-included-expressions.patch (985B, ../3574719.1784140144@sss.pgh.pa.us/2-wip-fix-index-included-expressions.patch)
  download | inline diff:
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, const 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 = (IndexElem *) lfirst(l);
+
+		if (ielem->expr)
+		{
+			/* Do parse transformation of the expression */
+			ielem->expr = 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.)

view thread (8+ messages)  latest in thread

Message-ID: <3574719.1784140144@sss.pgh.pa.us>
Permalink:  ../3574719.1784140144@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3574719.1784140144@sss.pgh.pa.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, maaz.adeeb@gmail.com, 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: <3574719.1784140144@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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