Обсуждение: pgsql: Improve makeArrayTypeName's algorithm for choosing array type na

Поиск
Список
Период
Сортировка

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

От
Tom Lane
Дата:
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(-)