Re: Improving the names generated for indexes on expressions

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: "David G. Johnston" <david.g.johnston@gmail.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-01T19:26:31Z
Lists: pgsql-hackers
On Sat, Nov 1, 2025 at 6:28 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> If people are dead set against double-quoting, I think the only way
> forward is to not include operator names in the generated index names.
> I do not think that's a better way personally, but I seem to be
> outvoted.  Here's a v2 that does it like that.

Is this better or worse than deparsing the whole expression to a
string and then smushing sequences of quote-requiring characters down
to a single underscore, as I suggested before?

I'm not saying what you've done is worse, but it does have the
disadvantage that you can only cover a few node types, whereas that
approach would cover every node type more or less automatically. Maybe
there are implementation difficulties, but I wouldn't think so... or
maybe you've got a scenario in mind where it would produce silly
results.

Nonwithstanding the above, I looked at the regression test cases and I
think all the changes are improvements. But, for example:

-ERROR:  cannot alter type "test_type1" because column
"test_tbl1_idx.row" uses it
+ERROR:  cannot alter type "test_type1" because column
"test_tbl1_idx.x_y" uses it

This would come out complaining about test_tbl1_idx_row_x_y_test_type1
with the above proposal. I like the inclusion of row. The inclusion of
test_type1 I like less well, but I'd accept it in the name of
uniformity. However, I don't feel strongly about it -- if you like
what you've done here, I'd say go for it.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



Commits

  1. Improve the names generated for indexes on expressions.