git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: f862d57) | patch
Add UNIQUE null treatment option
Thu, 3 Feb 2022 10:29:54 +0000 (11:29 +0100)
Thu, 3 Feb 2022 10:48:21 +0000 (11:48 +0100)
commit 94aa7cc5f707712f592885995a28e018c7c80488
Add UNIQUE null treatment option

The SQL standard has been ambiguous about whether null values in
unique constraints should be considered equal or not. Different
implementations have different behaviors. In the SQL:202x draft, this
has been formalized by making this implementation-defined and adding
an option on unique constraint definitions UNIQUE [ NULLS [NOT]
DISTINCT ] to choose a behavior explicitly.

This patch adds this option to PostgreSQL. The default behavior
remains UNIQUE NULLS DISTINCT. Making this happen in the btree code
is pretty easy; most of the patch is just to carry the flag around to
all the places that need it.

The CREATE UNIQUE INDEX syntax extension is not from the standard,
it's my own invention.

I named all the internal flags, catalog columns, etc. in the negative
("nulls not distinct") so that the default PostgreSQL behavior is the
default if the flag is false.

Reviewed-by: Maxim Orlov <orlovmg@gmail.com>
Reviewed-by: Pavel Borisov <pashkin.elfe@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/84e5ee1b-387e-9a54-c326-9082674bde78@enterprisedb.com
36 files changed:
doc/src/sgml/catalogs.sgml diff | blob | blame | history
doc/src/sgml/ddl.sgml diff | blob | blame | history
doc/src/sgml/information_schema.sgml diff | blob | blame | history
doc/src/sgml/ref/alter_table.sgml diff | blob | blame | history
doc/src/sgml/ref/create_index.sgml diff | blob | blame | history
doc/src/sgml/ref/create_table.sgml diff | blob | blame | history
src/backend/access/nbtree/nbtinsert.c diff | blob | blame | history
src/backend/access/nbtree/nbtsort.c diff | blob | blame | history
src/backend/access/nbtree/nbtutils.c diff | blob | blame | history
src/backend/catalog/index.c diff | blob | blame | history
src/backend/catalog/information_schema.sql diff | blob | blame | history
src/backend/catalog/sql_features.txt diff | blob | blame | history
src/backend/catalog/toasting.c diff | blob | blame | history
src/backend/commands/indexcmds.c diff | blob | blame | history
src/backend/nodes/copyfuncs.c diff | blob | blame | history
src/backend/nodes/equalfuncs.c diff | blob | blame | history
src/backend/nodes/makefuncs.c diff | blob | blame | history
src/backend/nodes/outfuncs.c diff | blob | blame | history
src/backend/parser/gram.y diff | blob | blame | history
src/backend/parser/parse_utilcmd.c diff | blob | blame | history
src/backend/utils/adt/ruleutils.c diff | blob | blame | history
src/backend/utils/cache/relcache.c diff | blob | blame | history
src/backend/utils/sort/tuplesort.c diff | blob | blame | history
src/bin/pg_dump/pg_dump.c diff | blob | blame | history
src/bin/pg_dump/pg_dump.h diff | blob | blame | history
src/bin/psql/describe.c diff | blob | blame | history
src/include/catalog/catversion.h diff | blob | blame | history
src/include/catalog/pg_index.h diff | blob | blame | history
src/include/nodes/execnodes.h diff | blob | blame | history
src/include/nodes/makefuncs.h diff | blob | blame | history
src/include/nodes/parsenodes.h diff | blob | blame | history
src/include/utils/tuplesort.h diff | blob | blame | history
src/test/regress/expected/constraints.out diff | blob | blame | history
src/test/regress/expected/create_index.out diff | blob | blame | history
src/test/regress/sql/constraints.sql diff | blob | blame | history
src/test/regress/sql/create_index.sql diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /