diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2022-02-03 11:29:54 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2022-02-03 11:48:21 +0100 |
commit | 94aa7cc5f707712f592885995a28e018c7c80488 (patch) | |
tree | d80b1f0a82a43a60e29d9b4960bcff884cdf0183 /src/include/catalog/pg_index.h | |
parent | f862d57057fdc73e663fe09d8948ed06b1b71dd7 (diff) | |
download | postgresql-94aa7cc5f707712f592885995a28e018c7c80488.tar.gz |
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
Diffstat (limited to 'src/include/catalog/pg_index.h')
-rw-r--r-- | src/include/catalog/pg_index.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h index c31111495f..f853846ee1 100644 --- a/src/include/catalog/pg_index.h +++ b/src/include/catalog/pg_index.h @@ -34,6 +34,7 @@ CATALOG(pg_index,2610,IndexRelationId) BKI_SCHEMA_MACRO int16 indnatts; /* total number of columns in index */ int16 indnkeyatts; /* number of key columns in index */ bool indisunique; /* is this a unique index? */ + bool indnullsnotdistinct; /* null treatment in unique index */ bool indisprimary; /* is this index for primary key? */ bool indisexclusion; /* is this index for exclusion constraint? */ bool indimmediate; /* is uniqueness enforced immediately? */ |