OSDN Git Service

Adjust naming of indexes and their columns per recent discussion.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 23 Dec 2009 02:35:25 +0000 (02:35 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 23 Dec 2009 02:35:25 +0000 (02:35 +0000)
commitcfc5008a51f4f1e83e9209071882ace91abe1f3f
tree4ed533202faa4ce1c86d5f6908811c4d65d6ed0a
parentb7d67954456f15762c04e5269b64adc88dcd0860
Adjust naming of indexes and their columns per recent discussion.

Index expression columns are now named after the FigureColname result for
their expressions, rather than always being "pg_expression_N".  Digits are
appended to this name if needed to make the column name unique within the
index.  (That happens for regular columns too, thus fixing the old problem
that CREATE INDEX fooi ON foo (f1, f1) fails.  Before exclusion indexes
there was no real reason to do such a thing, but now maybe there is.)

Default names for indexes and associated constraints now include the column
names of all their columns, not only the first one as in previous practice.
(Of course, this will be truncated as needed to fit in NAMEDATALEN.  Also,
pkey indexes retain the historical behavior of not naming specific columns
at all.)

An example of the results:

regression=# create table foo (f1 int, f2 text,
regression(# exclude (f1 with =, lower(f2) with =));
NOTICE:  CREATE TABLE / EXCLUDE will create implicit index "foo_f1_lower_exclusion" for table "foo"
CREATE TABLE
regression=# \d foo_f1_lower_exclusion
Index "public.foo_f1_lower_exclusion"
 Column |  Type   | Definition
--------+---------+------------
 f1     | integer | f1
 lower  | text    | lower(f2)
btree, for table "public.foo"
18 files changed:
src/backend/bootstrap/bootparse.y
src/backend/catalog/index.c
src/backend/catalog/toasting.c
src/backend/commands/indexcmds.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/outfuncs.c
src/backend/parser/gram.y
src/backend/parser/parse_target.c
src/backend/parser/parse_utilcmd.c
src/include/catalog/index.h
src/include/commands/defrem.h
src/include/nodes/parsenodes.h
src/include/parser/parse_target.h
src/test/regress/expected/alter_table.out
src/test/regress/expected/foreign_key.out
src/test/regress/expected/inherit.out
src/test/regress/output/constraints.source