[PATCH] docs: Document the automatically generated names for indices
[PATCH] docs: Document the automatically generated names for indices
От:
jadel@mercury.com
Дата:
Previously, the automatically generated names were entirely undocumented. That is not a very good state of affairs: although it's possibly inconvenient to rigidly specify what it is since it's an implementation detail, these names are user-visible, and it would be good to have documentation at all.
[PATCH] docs: Document the automatically generated names for indices
От:
jadel@mercury.com
Дата:
From: Jade Lovelace
I have intentionally been careful to not guarantee that the
automatically generated name *is* what's documented, but instead give
the general idea.
Knowing the format is useful for people writing migrations/ORM tools
which need to name their unique indices and may wish to use the
automatic naming system.
Signed-off-by: Jade Lovelace
---
doc/src/sgml/ref/create_index.sgml | 9 +++++++--
doc/src/sgml/ref/create_table.sgml | 30 ++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/doc/src/sgml/ref/create_index.sgml b/doc/src/sgml/ref/create_index.sgml
index a5bac9f..7354267 100644
--- a/doc/src/sgml/ref/create_index.sgml
+++ b/doc/src/sgml/ref/create_index.sgml
@@ -206,9 +206,14 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ]
+
If the name is omitted, PostgreSQL chooses a
- suitable name based on the parent table's name and the indexed column
- name(s).
+ suitable name based on the parent table's name and the indexed
+ column name(s). Generally, teh generated name will be something of the
+ shape tablename_columnname_idx, but this may vary in
+ the event of long table names, where it is truncated, or if the index
+ already exists, where a number is appended.
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 6bbf15e..bdabd86 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -796,6 +796,36 @@ WITH ( MODULUS numeric_literal, REM
(Double-quotes are needed to specify constraint names that contain spaces.)
If a constraint name is not specified, the system generates a name.
+
+ Generally, the generated name will be something of the shape
+ tablename_columnname_constrainttype, but this may vary in the
+ event of long table names, where it is truncated, or if the index
+ already exists, where a number is appended.
+ constrainttype is one of the following:
+
+
+
+ pkey in the case of primary keys
+
+
+
+ excl in the case of
+
+ EXCLUDE
+ constraints.
+
+
+
+
+ key in the case of
+ constraint triggers.
+
+
+
+ idx in other cases.
+
+
+
--
2.37.1
Re: [PATCH] docs: Document the automatically generated names for indices
От:
Bruce Momjian <bruce@momjian.us>
Дата:
On Thu, Sep 1, 2022 at 05:47:11PM -0700, jadel@mercury.com wrote: > From: Jade Lovelace > > I have intentionally been careful to not guarantee that the > automatically generated name *is* what's documented, but instead give > the general idea. > > Knowing the format is useful for people writing migrations/ORM tools > which need to name their unique indices and may wish to use the > automatic naming system. Uh, I always that if people didn't want to specify an index name, that they didn't care. I think there are enough concurrency issues listed below that I don't see the value of documenting this. If they really care, they can look at the source code. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Indecision is a decision. Inaction is an action. Mark Batterson