pgsql: Further improve the names generated for indexes on expressions.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Further improve the names generated for indexes on expressions.
Date: 2026-07-27 20:19:38
Message-ID: E1woRnW-00000000YiR-3cnI@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Further improve the names generated for indexes on expressions.

Commit 181b6185c failed to do anything useful with a whole-row Var,
deeming it "fishy". But it is legal to put such a Var into an
expression index column, so let's expand it as the name of the table.

Another problem reachable via that one is that we could generate an
empty index column name, which isn't really legal although by chance
nothing complained about it. It's not clear whether any other such
cases remain, but as cheap insurance let's use "expr" if the tree walk
fails to generate any text.

Reported-by: Chauhan Dhruv <chauhandhruv351(at)gmail(dot)com>
Author: Chauhan Dhruv <chauhandhruv351(at)gmail(dot)com>
Co-authored-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CANWwWcp_DCJjq8pomeqp6W=fbygvzXXQO028VDJ9_6sLPjQnVA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5a3b22eb304806d5e492e6b62a34e77d6e060573

Modified Files
--------------
src/backend/commands/indexcmds.c | 25 +++++++++++++++++++------
src/test/regress/expected/create_index.out | 16 +++++++++++++---
src/test/regress/sql/create_index.sql | 10 +++++++---
3 files changed, 39 insertions(+), 12 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-07-27 23:54:08 pgsql: Fix propagation of indimmediate flag in index_create_copy()
Previous Message Masahiko Sawada 2026-07-27 16:12:35 pgsql: Fix race condition when enabling logical decoding concurrently.