Allow virtual columns in index expressions or predicate

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Allow virtual columns in index expressions or predicate
Date: 2025-09-30 09:13:43
Message-ID: CAMbWs4811nG3w_3sLxps+EAuUsffA_83ZQ-1acEH_jQeq117mg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm looking for a solution to support virtual generated columns in
index expressions or predicate. The comment in DefineIndex() seems to
suggest that virtual generated columns there can be expanded in
RelationGetIndexExpressions() and RelationGetIndexPredicate().

/*
* XXX Virtual generated columns in index expressions or predicates
* could be supported, but it needs support in
* RelationGetIndexExpressions() and RelationGetIndexPredicate().
*/

I'm not sure this is the appropriate approach, especially since we
don't have the heap relation available in these functions. I think
we're good as long as we expand the virtual columns before the index
build process; otherwise, evaluating these expressions during the
build will cause executor errors due to unexpanded virtual columns.

I wonder if we can do the expansion in DefineIndex(), before the call
to index_create(), like the attached.

- Richard

Attachment Content-Type Size
v1-0001-Allow-virtual-columns-in-index-expressions-or-pre.patch application/octet-stream 7.9 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Stefanie Janine Stölting 2025-09-30 09:17:07 Re: Problem with DEB packages
Previous Message David Rowley 2025-09-30 09:03:07 Re: Fixing MSVC's inability to detect elog(ERROR) does not return