support create index on virtual generated column.

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: support create index on virtual generated column.
Date: 2025-03-26 07:15:00
Message-ID: CACJufxGao-cypdNhifHAdt8jHfK6-HX=tRBovBkgRuxw063GaA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.
attached patch for implementing $subject feature.

* internally such index will be transformed into expression index.
for example, an index on (b int GENERATED ALWAYS AS (a * 2) VIRTUAL) will be
converted into an expression index on ((a * 2)).
* in pageinspect module, add some test to check the index content of
virtual generated column.
* primary key, unique index over virtual generated column are not supported.
not sure they make sense or not.
* expression index and predicate index over virtual generated columns are
currently not supported.
* virtual generated column can not be in "include column"
* all types of indexes are supported, and a hash index, gist test has
been added.
* To support ALTER TABLE SET EXPRESSION, in pg_index, we need to track
the original
virtual generated column attribute number, so ALTER TABLE SET EXPRESSION can
identify which index needs to be rebuilt.
* ALTER COLUMN SET DATA TYPE will also cause table rewrite, so we really
need to track the virtual generated column attribute number that
index was built on.

Attachment Content-Type Size
v1-0001-support-create-index-on-virtual-generated-column.patch text/x-patch 38.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Steven Niu 2025-03-26 07:17:15 [PATCH] avoid double scanning in function byteain
Previous Message Stepan Neretin 2025-03-26 07:14:40 Re: Accessing an invalid pointer in BufferManagerRelation structure