pgsql: Improve makeArrayTypeName's algorithm for choosing array type na

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve makeArrayTypeName's algorithm for choosing array type na
Date: 2022-07-26 19:38:28
Message-ID: E1oGQNv-001Nl5-MN@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve makeArrayTypeName's algorithm for choosing array type names.

As before, we start by prepending one underscore (truncating the
base name if necessary). But if there is a conflict, then instead of
prepending more and more underscores, append an underscore and some
digits, in much the same way that ChooseRelationName does. While
the previous logic could be driven to fail by creating a lot of
types with long names differing only near the end, this version seems
certain enough to eventually succeed that we can remove the failure
code path that was there before.

While at it, undo 6df7a9698's decision to split this code out of
makeArrayTypeName. That wasn't actually accomplishing anything,
because no other function was using it --- and it would have been
wrong to do so. The convention that a prefix "_" means an array,
not something else, is too ancient to mess with.

Andrey Lepikhov and Dmitry Koval, reviewed by Masahiko Sawada and myself

Discussion: https://postgr.es/m/b84cd82c-cc67-198a-8b1c-60f44e1259ad@postgrespro.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/70988b7b0a0bd03c59a2314d0b5bcf2135692349

Modified Files
--------------
src/backend/catalog/pg_type.c | 90 ++++++++++++-------------------
src/test/regress/expected/alter_table.out | 6 +--
2 files changed, 37 insertions(+), 59 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2022-07-26 20:03:54 Re: Unstable tests for recovery conflict handling
Previous Message Robert Haas 2022-07-26 19:14:36 pgsql: Fix brain fade in e530be2c5ce77475d56ccf8f4e0c4872b666ad5f.