From 2aec7ee8f5bfd3735769c6b29f4ac83ed538584f Mon Sep 17 00:00:00 2001 From: Peter Geoghegan Date: Tue, 20 May 2025 15:52:42 -0400 Subject: [PATCH v1] Remove OPTIONS support proc from nbtree. --- src/include/access/nbtree.h | 12 ++----- src/include/catalog/pg_amproc.dat | 20 +++++------ src/backend/access/nbtree/nbtree.c | 2 +- src/backend/access/nbtree/nbtvalidate.c | 3 -- doc/src/sgml/btree.sgml | 37 ++------------------- doc/src/sgml/xindex.sgml | 15 +++------ src/test/regress/expected/alter_generic.out | 25 +++----------- src/test/regress/expected/psql.out | 2 +- src/test/regress/regress.c | 7 ---- src/test/regress/sql/alter_generic.sql | 20 ++--------- 10 files changed, 27 insertions(+), 116 deletions(-) diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h index ebca02588..8acc577f2 100644 --- a/src/include/access/nbtree.h +++ b/src/include/access/nbtree.h @@ -704,13 +704,8 @@ BTreeTupleGetMaxHeapTID(IndexTuple itup) * offer a forth amproc procedure (BTEQUALIMAGE_PROC). For full details, * see doc/src/sgml/btree.sgml. * - * An operator class may choose to offer a fifth amproc procedure - * (BTOPTIONS_PROC). These procedures define a set of user-visible - * parameters that can be used to control operator class behavior. None of - * the built-in B-Tree operator classes currently register an "options" proc. - * * To facilitate more efficient B-Tree skip scans, an operator class may - * choose to offer a sixth amproc procedure (BTSKIPSUPPORT_PROC). For full + * choose to offer a fifth amproc procedure (BTSKIPSUPPORT_PROC). For full * details, see src/include/utils/skipsupport.h. */ @@ -718,9 +713,8 @@ BTreeTupleGetMaxHeapTID(IndexTuple itup) #define BTSORTSUPPORT_PROC 2 #define BTINRANGE_PROC 3 #define BTEQUALIMAGE_PROC 4 -#define BTOPTIONS_PROC 5 -#define BTSKIPSUPPORT_PROC 6 -#define BTNProcs 6 +#define BTSKIPSUPPORT_PROC 5 +#define BTNProcs 5 /* * We need to be able to tell the difference between read and write diff --git a/src/include/catalog/pg_amproc.dat b/src/include/catalog/pg_amproc.dat index 925051489..fad086dc2 100644 --- a/src/include/catalog/pg_amproc.dat +++ b/src/include/catalog/pg_amproc.dat @@ -22,7 +22,7 @@ { amprocfamily => 'btree/bool_ops', amproclefttype => 'bool', amprocrighttype => 'bool', amprocnum => '1', amproc => 'btboolcmp' }, { amprocfamily => 'btree/bool_ops', amproclefttype => 'bool', - amprocrighttype => 'bool', amprocnum => '6', amproc => 'btboolskipsupport' }, + amprocrighttype => 'bool', amprocnum => '5', amproc => 'btboolskipsupport' }, { amprocfamily => 'btree/bool_ops', amproclefttype => 'bool', amprocrighttype => 'bool', amprocnum => '4', amproc => 'btequalimage' }, { amprocfamily => 'btree/bpchar_ops', amproclefttype => 'bpchar', @@ -44,7 +44,7 @@ { amprocfamily => 'btree/char_ops', amproclefttype => 'char', amprocrighttype => 'char', amprocnum => '4', amproc => 'btequalimage' }, { amprocfamily => 'btree/char_ops', amproclefttype => 'char', - amprocrighttype => 'char', amprocnum => '6', amproc => 'btcharskipsupport' }, + amprocrighttype => 'char', amprocnum => '5', amproc => 'btcharskipsupport' }, { amprocfamily => 'btree/datetime_ops', amproclefttype => 'date', amprocrighttype => 'date', amprocnum => '1', amproc => 'date_cmp' }, { amprocfamily => 'btree/datetime_ops', amproclefttype => 'date', @@ -52,7 +52,7 @@ { amprocfamily => 'btree/datetime_ops', amproclefttype => 'date', amprocrighttype => 'date', amprocnum => '4', amproc => 'btequalimage' }, { amprocfamily => 'btree/datetime_ops', amproclefttype => 'date', - amprocrighttype => 'date', amprocnum => '6', amproc => 'date_skipsupport' }, + amprocrighttype => 'date', amprocnum => '5', amproc => 'date_skipsupport' }, { amprocfamily => 'btree/datetime_ops', amproclefttype => 'date', amprocrighttype => 'timestamp', amprocnum => '1', amproc => 'date_cmp_timestamp' }, @@ -67,7 +67,7 @@ { amprocfamily => 'btree/datetime_ops', amproclefttype => 'timestamp', amprocrighttype => 'timestamp', amprocnum => '4', amproc => 'btequalimage' }, { amprocfamily => 'btree/datetime_ops', amproclefttype => 'timestamp', - amprocrighttype => 'timestamp', amprocnum => '6', + amprocrighttype => 'timestamp', amprocnum => '5', amproc => 'timestamp_skipsupport' }, { amprocfamily => 'btree/datetime_ops', amproclefttype => 'timestamp', amprocrighttype => 'date', amprocnum => '1', amproc => 'timestamp_cmp_date' }, @@ -84,7 +84,7 @@ amprocrighttype => 'timestamptz', amprocnum => '4', amproc => 'btequalimage' }, { amprocfamily => 'btree/datetime_ops', amproclefttype => 'timestamptz', - amprocrighttype => 'timestamptz', amprocnum => '6', + amprocrighttype => 'timestamptz', amprocnum => '5', amproc => 'timestamp_skipsupport' }, { amprocfamily => 'btree/datetime_ops', amproclefttype => 'timestamptz', amprocrighttype => 'date', amprocnum => '1', @@ -135,7 +135,7 @@ { amprocfamily => 'btree/integer_ops', amproclefttype => 'int2', amprocrighttype => 'int2', amprocnum => '4', amproc => 'btequalimage' }, { amprocfamily => 'btree/integer_ops', amproclefttype => 'int2', - amprocrighttype => 'int2', amprocnum => '6', amproc => 'btint2skipsupport' }, + amprocrighttype => 'int2', amprocnum => '5', amproc => 'btint2skipsupport' }, { amprocfamily => 'btree/integer_ops', amproclefttype => 'int2', amprocrighttype => 'int4', amprocnum => '1', amproc => 'btint24cmp' }, { amprocfamily => 'btree/integer_ops', amproclefttype => 'int2', @@ -156,7 +156,7 @@ { amprocfamily => 'btree/integer_ops', amproclefttype => 'int4', amprocrighttype => 'int4', amprocnum => '4', amproc => 'btequalimage' }, { amprocfamily => 'btree/integer_ops', amproclefttype => 'int4', - amprocrighttype => 'int4', amprocnum => '6', amproc => 'btint4skipsupport' }, + amprocrighttype => 'int4', amprocnum => '5', amproc => 'btint4skipsupport' }, { amprocfamily => 'btree/integer_ops', amproclefttype => 'int4', amprocrighttype => 'int8', amprocnum => '1', amproc => 'btint48cmp' }, { amprocfamily => 'btree/integer_ops', amproclefttype => 'int4', @@ -177,7 +177,7 @@ { amprocfamily => 'btree/integer_ops', amproclefttype => 'int8', amprocrighttype => 'int8', amprocnum => '4', amproc => 'btequalimage' }, { amprocfamily => 'btree/integer_ops', amproclefttype => 'int8', - amprocrighttype => 'int8', amprocnum => '6', amproc => 'btint8skipsupport' }, + amprocrighttype => 'int8', amprocnum => '5', amproc => 'btint8skipsupport' }, { amprocfamily => 'btree/integer_ops', amproclefttype => 'int8', amprocrighttype => 'int4', amprocnum => '1', amproc => 'btint84cmp' }, { amprocfamily => 'btree/integer_ops', amproclefttype => 'int8', @@ -212,7 +212,7 @@ { amprocfamily => 'btree/oid_ops', amproclefttype => 'oid', amprocrighttype => 'oid', amprocnum => '4', amproc => 'btequalimage' }, { amprocfamily => 'btree/oid_ops', amproclefttype => 'oid', - amprocrighttype => 'oid', amprocnum => '6', amproc => 'btoidskipsupport' }, + amprocrighttype => 'oid', amprocnum => '5', amproc => 'btoidskipsupport' }, { amprocfamily => 'btree/oidvector_ops', amproclefttype => 'oidvector', amprocrighttype => 'oidvector', amprocnum => '1', amproc => 'btoidvectorcmp' }, @@ -282,7 +282,7 @@ { amprocfamily => 'btree/uuid_ops', amproclefttype => 'uuid', amprocrighttype => 'uuid', amprocnum => '4', amproc => 'btequalimage' }, { amprocfamily => 'btree/uuid_ops', amproclefttype => 'uuid', - amprocrighttype => 'uuid', amprocnum => '6', amproc => 'uuid_skipsupport' }, + amprocrighttype => 'uuid', amprocnum => '5', amproc => 'uuid_skipsupport' }, { amprocfamily => 'btree/record_ops', amproclefttype => 'record', amprocrighttype => 'record', amprocnum => '1', amproc => 'btrecordcmp' }, { amprocfamily => 'btree/record_image_ops', amproclefttype => 'record', diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index 765659887..1642c42c6 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -118,7 +118,7 @@ bthandler(PG_FUNCTION_ARGS) amroutine->amstrategies = BTMaxStrategyNumber; amroutine->amsupport = BTNProcs; - amroutine->amoptsprocnum = BTOPTIONS_PROC; + amroutine->amoptsprocnum = 0; amroutine->amcanorder = true; amroutine->amcanorderbyop = false; amroutine->amcanhash = false; diff --git a/src/backend/access/nbtree/nbtvalidate.c b/src/backend/access/nbtree/nbtvalidate.c index 817ad358f..b673463fe 100644 --- a/src/backend/access/nbtree/nbtvalidate.c +++ b/src/backend/access/nbtree/nbtvalidate.c @@ -103,9 +103,6 @@ btvalidate(Oid opclassoid) ok = check_amproc_signature(procform->amproc, BOOLOID, true, 1, 1, OIDOID); break; - case BTOPTIONS_PROC: - ok = check_amoptsproc_signature(procform->amproc); - break; case BTSKIPSUPPORT_PROC: ok = check_amproc_signature(procform->amproc, VOIDOID, true, 1, 1, INTERNALOID); diff --git a/doc/src/sgml/btree.sgml b/doc/src/sgml/btree.sgml index 027361f20..2e66323bd 100644 --- a/doc/src/sgml/btree.sgml +++ b/doc/src/sgml/btree.sgml @@ -207,7 +207,7 @@ As shown in , btree defines - one required and five optional support functions. The six + one required and four optional support functions. The five user-defined methods are: @@ -550,45 +550,12 @@ equalimage(opcintype oid) returns bool - - options - - - Optionally, a B-tree operator family may provide - options (operator class specific - options) support functions, registered under support - function number 5. These functions define a set of user-visible - parameters that control operator class behavior. - - - An options support function must have the - signature - -options(relopts local_relopts *) returns void - - The function is passed a pointer to a local_relopts - struct, which needs to be filled with a set of operator class - specific options. The options can be accessed from other support - functions using the PG_HAS_OPCLASS_OPTIONS() and - PG_GET_OPCLASS_OPTIONS() macros. - - - Currently, no B-Tree operator class has an options - support function. B-tree doesn't allow flexible representation of keys - like GiST, SP-GiST, GIN and BRIN do. So, options - probably doesn't have much application in the current B-tree index - access method. Nevertheless, this support function was added to B-tree - for uniformity, and will probably find uses during further - evolution of B-tree in PostgreSQL. - - - skipsupport Optionally, a btree operator family may provide a skip - support function, registered under support function number 6. + support function, registered under support function number 5. These functions give the B-tree code a way to iterate through every possible value that can be represented by an operator class's underlying input type, in key space order. This is used by the core code when it diff --git a/doc/src/sgml/xindex.sgml b/doc/src/sgml/xindex.sgml index 7e23a7b6e..cda36ed70 100644 --- a/doc/src/sgml/xindex.sgml +++ b/doc/src/sgml/xindex.sgml @@ -454,19 +454,12 @@ 4 - - - Define options that are specific to this operator class - (optional) - - 5 - Return the addresses of C-callable skip support function(s) (optional) - 6 + 5 @@ -1070,7 +1063,7 @@ DEFAULT FOR TYPE int8 USING btree FAMILY integer_ops AS FUNCTION 2 btint8sortsupport(internal) , FUNCTION 3 in_range(int8, int8, int8, boolean, boolean) , FUNCTION 4 btequalimage(oid) , - FUNCTION 6 btint8skipsupport(internal) ; + FUNCTION 5 btint8skipsupport(internal) ; CREATE OPERATOR CLASS int4_ops DEFAULT FOR TYPE int4 USING btree FAMILY integer_ops AS @@ -1084,7 +1077,7 @@ DEFAULT FOR TYPE int4 USING btree FAMILY integer_ops AS FUNCTION 2 btint4sortsupport(internal) , FUNCTION 3 in_range(int4, int4, int4, boolean, boolean) , FUNCTION 4 btequalimage(oid) , - FUNCTION 6 btint4skipsupport(internal) ; + FUNCTION 5 btint4skipsupport(internal) ; CREATE OPERATOR CLASS int2_ops DEFAULT FOR TYPE int2 USING btree FAMILY integer_ops AS @@ -1098,7 +1091,7 @@ DEFAULT FOR TYPE int2 USING btree FAMILY integer_ops AS FUNCTION 2 btint2sortsupport(internal) , FUNCTION 3 in_range(int2, int2, int2, boolean, boolean) , FUNCTION 4 btequalimage(oid) , - FUNCTION 6 btint2skipsupport(internal) ; + FUNCTION 5 btint2skipsupport(internal) ; ALTER OPERATOR FAMILY integer_ops USING btree ADD -- cross-type comparisons int8 vs int2 diff --git a/src/test/regress/expected/alter_generic.out b/src/test/regress/expected/alter_generic.out index 23bf33f10..03fa37f64 100644 --- a/src/test/regress/expected/alter_generic.out +++ b/src/test/regress/expected/alter_generic.out @@ -4,11 +4,6 @@ -- directory paths and dlsuffix are passed to us in environment variables \getenv libdir PG_LIBDIR \getenv dlsuffix PG_DLSUFFIX -\set regresslib :libdir '/regress' :dlsuffix -CREATE FUNCTION test_opclass_options_func(internal) - RETURNS void - AS :'regresslib', 'test_opclass_options_func' - LANGUAGE C; -- Clean up in case a prior regression run failed SET client_min_messages TO 'warning'; DROP ROLE IF EXISTS regress_alter_generic_user1; @@ -362,9 +357,9 @@ ERROR: invalid operator number 0, must be between 1 and 5 ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 1 < ; -- operator without argument types ERROR: operator argument types must be specified in ALTER OPERATOR FAMILY ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 0 btint42cmp(int4, int2); -- invalid options parsing function -ERROR: invalid function number 0, must be between 1 and 6 -ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 7 btint42cmp(int4, int2); -- function number should be between 1 and 6 -ERROR: invalid function number 7, must be between 1 and 6 +ERROR: invalid function number 0, must be between 1 and 5 +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 6 btint42cmp(int4, int2); -- function number should be between 1 and 5 +ERROR: invalid function number 6, must be between 1 and 5 ALTER OPERATOR FAMILY alt_opf4 USING btree ADD STORAGE invalid_storage; -- Ensure STORAGE is not a part of ALTER OPERATOR FAMILY ERROR: STORAGE cannot be specified in ALTER OPERATOR FAMILY DROP OPERATOR FAMILY alt_opf4 USING btree; @@ -507,23 +502,11 @@ ALTER OPERATOR FAMILY alt_opf18 USING btree ERROR: ordering equal image functions must not be cross-type -- Should fail. Not allowed to have cross-type skip support function. ALTER OPERATOR FAMILY alt_opf18 USING btree - ADD FUNCTION 6 (int4, int2) btint4skipsupport(internal); + ADD FUNCTION 5 (int4, int2) btint4skipsupport(internal); ERROR: btree skip support functions must not be cross-type ALTER OPERATOR FAMILY alt_opf18 USING btree DROP FUNCTION 2 (int4, int4); ERROR: function 2(integer,integer) does not exist in operator family "alt_opf18" DROP OPERATOR FAMILY alt_opf18 USING btree; --- Should fail. Invalid opclass options function (#5) specifications. -CREATE OPERATOR FAMILY alt_opf19 USING btree; -ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 test_opclass_options_func(internal, text[], bool); -ERROR: function test_opclass_options_func(internal, text[], boolean) does not exist -ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4) btint42cmp(int4, int2); -ERROR: invalid operator class options parsing function -HINT: Valid signature of operator class options parsing function is (internal) RETURNS void. -ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4, int2) btint42cmp(int4, int2); -ERROR: left and right associated data types for operator class options parsing functions must match -ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4) test_opclass_options_func(internal); -- Ok -ALTER OPERATOR FAMILY alt_opf19 USING btree DROP FUNCTION 5 (int4, int4); -DROP OPERATOR FAMILY alt_opf19 USING btree; -- -- Statistics -- diff --git a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out index cf48ae6d0..390dad39f 100644 --- a/src/test/regress/expected/psql.out +++ b/src/test/regress/expected/psql.out @@ -5332,7 +5332,7 @@ Function | in_range(time without time zone,time without time zone,i btree | uuid_ops | uuid | uuid | 1 | uuid_cmp btree | uuid_ops | uuid | uuid | 2 | uuid_sortsupport btree | uuid_ops | uuid | uuid | 4 | btequalimage - btree | uuid_ops | uuid | uuid | 6 | uuid_skipsupport + btree | uuid_ops | uuid | uuid | 5 | uuid_skipsupport hash | uuid_ops | uuid | uuid | 1 | uuid_hash hash | uuid_ops | uuid | uuid | 2 | uuid_hash_extended (6 rows) diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index 3dbba0690..269c9d46e 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -803,13 +803,6 @@ test_support_func(PG_FUNCTION_ARGS) PG_RETURN_POINTER(ret); } -PG_FUNCTION_INFO_V1(test_opclass_options_func); -Datum -test_opclass_options_func(PG_FUNCTION_ARGS) -{ - PG_RETURN_NULL(); -} - /* one-time tests for encoding infrastructure */ PG_FUNCTION_INFO_V1(test_enc_setup); Datum diff --git a/src/test/regress/sql/alter_generic.sql b/src/test/regress/sql/alter_generic.sql index 5e20dc633..eed49253e 100644 --- a/src/test/regress/sql/alter_generic.sql +++ b/src/test/regress/sql/alter_generic.sql @@ -6,13 +6,6 @@ \getenv libdir PG_LIBDIR \getenv dlsuffix PG_DLSUFFIX -\set regresslib :libdir '/regress' :dlsuffix - -CREATE FUNCTION test_opclass_options_func(internal) - RETURNS void - AS :'regresslib', 'test_opclass_options_func' - LANGUAGE C; - -- Clean up in case a prior regression run failed SET client_min_messages TO 'warning'; @@ -310,7 +303,7 @@ ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 6 < (int4, int2); -- ope ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 0 < (int4, int2); -- operator number should be between 1 and 5 ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 1 < ; -- operator without argument types ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 0 btint42cmp(int4, int2); -- invalid options parsing function -ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 7 btint42cmp(int4, int2); -- function number should be between 1 and 6 +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 6 btint42cmp(int4, int2); -- function number should be between 1 and 5 ALTER OPERATOR FAMILY alt_opf4 USING btree ADD STORAGE invalid_storage; -- Ensure STORAGE is not a part of ALTER OPERATOR FAMILY DROP OPERATOR FAMILY alt_opf4 USING btree; @@ -446,19 +439,10 @@ ALTER OPERATOR FAMILY alt_opf18 USING btree ADD FUNCTION 4 (int4, int2) btequalimage(oid); -- Should fail. Not allowed to have cross-type skip support function. ALTER OPERATOR FAMILY alt_opf18 USING btree - ADD FUNCTION 6 (int4, int2) btint4skipsupport(internal); + ADD FUNCTION 5 (int4, int2) btint4skipsupport(internal); ALTER OPERATOR FAMILY alt_opf18 USING btree DROP FUNCTION 2 (int4, int4); DROP OPERATOR FAMILY alt_opf18 USING btree; --- Should fail. Invalid opclass options function (#5) specifications. -CREATE OPERATOR FAMILY alt_opf19 USING btree; -ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 test_opclass_options_func(internal, text[], bool); -ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4) btint42cmp(int4, int2); -ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4, int2) btint42cmp(int4, int2); -ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4) test_opclass_options_func(internal); -- Ok -ALTER OPERATOR FAMILY alt_opf19 USING btree DROP FUNCTION 5 (int4, int4); -DROP OPERATOR FAMILY alt_opf19 USING btree; - -- -- Statistics -- -- 2.49.0