mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-17 19:30:00 +08:00
Add the 'checkunique' argument to bt_index_check() and bt_index_parent_check(). When the flag is specified the procedures will check the unique constraint violation for unique indexes. Only one heap entry for all equal keys in the index should be visible (including posting list entries). Report an error otherwise. pg_amcheck called with the --checkunique option will do the same check for all the indexes it checks. Author: Anastasia Lubennikova <lubennikovaav@gmail.com> Author: Pavel Borisov <pashkin.elfe@gmail.com> Author: Maxim Orlov <orlovmg@gmail.com> Reviewed-by: Mark Dilger <mark.dilger@enterprisedb.com> Reviewed-by: Zhihong Yu <zyu@yugabyte.com> Reviewed-by: Peter Geoghegan <pg@bowt.ie> Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Discussion: https://postgr.es/m/CALT9ZEHRn5xAM5boga0qnrCmPV52bScEK2QnQ1HmUZDD301JEg%40mail.gmail.com
30 lines
1.1 KiB
SQL
30 lines
1.1 KiB
SQL
/* contrib/amcheck/amcheck--1.3--1.4.sql */
|
|
|
|
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
|
\echo Use "ALTER EXTENSION amcheck UPDATE TO '1.4'" to load this file. \quit
|
|
|
|
-- In order to avoid issues with dependencies when updating amcheck to 1.4,
|
|
-- create new, overloaded versions of the 1.2 bt_index_parent_check signature,
|
|
-- and 1.1 bt_index_check signature.
|
|
|
|
--
|
|
-- bt_index_parent_check()
|
|
--
|
|
CREATE FUNCTION bt_index_parent_check(index regclass,
|
|
heapallindexed boolean, rootdescend boolean, checkunique boolean)
|
|
RETURNS VOID
|
|
AS 'MODULE_PATHNAME', 'bt_index_parent_check'
|
|
LANGUAGE C STRICT PARALLEL RESTRICTED;
|
|
--
|
|
-- bt_index_check()
|
|
--
|
|
CREATE FUNCTION bt_index_check(index regclass,
|
|
heapallindexed boolean, checkunique boolean)
|
|
RETURNS VOID
|
|
AS 'MODULE_PATHNAME', 'bt_index_check'
|
|
LANGUAGE C STRICT PARALLEL RESTRICTED;
|
|
|
|
-- We don't want this to be available to public
|
|
REVOKE ALL ON FUNCTION bt_index_parent_check(regclass, boolean, boolean, boolean) FROM PUBLIC;
|
|
REVOKE ALL ON FUNCTION bt_index_check(regclass, boolean, boolean) FROM PUBLIC;
|