Further improve the names generated for indexes on expressions.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 27 Jul 2026 20:19:24 +0000 (16:19 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 27 Jul 2026 20:19:24 +0000 (16:19 -0400)
commit5a3b22eb304806d5e492e6b62a34e77d6e060573
tree1e1d4fcd1bcf657e980e15722c97b6fb63b8835b
parent0fd30e2119ede879080cef426abf4f9b304e3f51
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@gmail.com>
Author: Chauhan Dhruv <chauhandhruv351@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CANWwWcp_DCJjq8pomeqp6W=fbygvzXXQO028VDJ9_6sLPjQnVA@mail.gmail.com
src/backend/commands/indexcmds.c
src/test/regress/expected/create_index.out
src/test/regress/sql/create_index.sql