Re: Improving the names generated for indexes on expressions

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Improving the names generated for indexes on expressions
Date: 2025-12-01 19:26:31
Message-ID: CA+TgmoYs5cPdWAN22F-ArN7w7_+F9T3wPAOdzaoNMuWX-hphCw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 1, 2025 at 6:28 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-12-01 19:50:44 Re: split tablecmds.c
Previous Message Álvaro Herrera 2025-12-01 19:16:01 Re: split tablecmds.c