Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit af4002b

Browse files
committed
Rename amcancrosscompare
After more discussion about commit ce62f2f, rename the index AM property amcancrosscompare to two separate properties amconsistentequality and amconsistentordering. Also improve the documentation and update some comments that were previously missed. Reported-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/E1tngY6-0000UL-2n%40gemulon.postgresql.org
1 parent 6da469b commit af4002b

File tree

12 files changed

+41
-26
lines changed

12 files changed

+41
-26
lines changed

contrib/bloom/blutils.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ blhandler(PG_FUNCTION_ARGS)
110110
amroutine->amcanorder = false;
111111
amroutine->amcanorderbyop = false;
112112
amroutine->amcanhash = false;
113-
amroutine->amcancrosscompare = false;
113+
amroutine->amconsistentequality = false;
114+
amroutine->amconsistentordering = false;
114115
amroutine->amcanbackward = false;
115116
amroutine->amcanunique = false;
116117
amroutine->amcanmulticol = true;

doc/src/sgml/indexam.sgml

+4-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ typedef struct IndexAmRoutine
105105
bool amcanorderbyop;
106106
/* does AM support hashing using API consistent with the hash AM? */
107107
bool amcanhash;
108-
/* does AM support cross-type comparisons? */
109-
bool amcancrosscompare;
108+
/* do operators within an opfamily have consistent equality semantics? */
109+
bool amconsistentequality;
110+
/* do operators within an opfamily have consistent ordering semantics? */
111+
bool amconsistentordering;
110112
/* does AM support backward scanning? */
111113
bool amcanbackward;
112114
/* does AM support UNIQUE indexes? */

src/backend/access/brin/brin.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ brinhandler(PG_FUNCTION_ARGS)
257257
amroutine->amcanorder = false;
258258
amroutine->amcanorderbyop = false;
259259
amroutine->amcanhash = false;
260-
amroutine->amcancrosscompare = false;
260+
amroutine->amconsistentequality = false;
261+
amroutine->amconsistentordering = false;
261262
amroutine->amcanbackward = false;
262263
amroutine->amcanunique = false;
263264
amroutine->amcanmulticol = true;

src/backend/access/gin/ginutil.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ ginhandler(PG_FUNCTION_ARGS)
4545
amroutine->amcanorder = false;
4646
amroutine->amcanorderbyop = false;
4747
amroutine->amcanhash = false;
48-
amroutine->amcancrosscompare = false;
48+
amroutine->amconsistentequality = false;
49+
amroutine->amconsistentordering = false;
4950
amroutine->amcanbackward = false;
5051
amroutine->amcanunique = false;
5152
amroutine->amcanmulticol = true;

src/backend/access/gist/gist.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ gisthandler(PG_FUNCTION_ARGS)
6666
amroutine->amcanorder = false;
6767
amroutine->amcanorderbyop = true;
6868
amroutine->amcanhash = false;
69-
amroutine->amcancrosscompare = false;
69+
amroutine->amconsistentequality = false;
70+
amroutine->amconsistentordering = false;
7071
amroutine->amcanbackward = false;
7172
amroutine->amcanunique = false;
7273
amroutine->amcanmulticol = true;

src/backend/access/hash/hash.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ hashhandler(PG_FUNCTION_ARGS)
6565
amroutine->amcanorder = false;
6666
amroutine->amcanorderbyop = false;
6767
amroutine->amcanhash = true;
68-
amroutine->amcancrosscompare = true;
68+
amroutine->amconsistentequality = true;
69+
amroutine->amconsistentequality = false;
6970
amroutine->amcanbackward = true;
7071
amroutine->amcanunique = false;
7172
amroutine->amcanmulticol = false;

src/backend/access/nbtree/nbtree.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ bthandler(PG_FUNCTION_ARGS)
108108
amroutine->amcanorder = true;
109109
amroutine->amcanorderbyop = false;
110110
amroutine->amcanhash = false;
111-
amroutine->amcancrosscompare = true;
111+
amroutine->amconsistentequality = true;
112+
amroutine->amconsistentordering = true;
112113
amroutine->amcanbackward = true;
113114
amroutine->amcanunique = true;
114115
amroutine->amcanmulticol = true;

src/backend/access/spgist/spgutils.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ spghandler(PG_FUNCTION_ARGS)
5151
amroutine->amcanorder = false;
5252
amroutine->amcanorderbyop = true;
5353
amroutine->amcanhash = false;
54-
amroutine->amcancrosscompare = false;
54+
amroutine->amconsistentequality = false;
55+
amroutine->amconsistentordering = false;
5556
amroutine->amcanbackward = false;
5657
amroutine->amcanunique = false;
5758
amroutine->amcanmulticol = false;

src/backend/optimizer/plan/analyzejoins.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -1083,9 +1083,10 @@ query_supports_distinctness(Query *query)
10831083
* the values are distinct. (Note: the opids entries could be cross-type
10841084
* operators, and thus not exactly the equality operators that the subquery
10851085
* would use itself. We use equality_ops_are_compatible() to check
1086-
* compatibility. That looks at btree or hash opfamily membership, and so
1087-
* should give trustworthy answers for all operators that we might need
1088-
* to deal with here.)
1086+
* compatibility. That looks at opfamily membership for index AMs that have
1087+
* declared that they support consistent equality semantics within an
1088+
* opfamily, and so should give trustworthy answers for all operators that we
1089+
* might need to deal with here.)
10891090
*/
10901091
bool
10911092
query_is_distinct_for(Query *query, List *colnos, List *opids)

src/backend/utils/cache/lsyscache.c

+13-11
Original file line numberDiff line numberDiff line change
@@ -690,10 +690,11 @@ get_op_btree_interpretation(Oid opno)
690690
* semantics.
691691
*
692692
* This is trivially true if they are the same operator. Otherwise,
693-
* we look to see if they can be found in the same btree or hash opfamily.
694-
* Either finding allows us to assume that they have compatible notions
695-
* of equality. (The reason we need to do these pushups is that one might
696-
* be a cross-type operator; for instance int24eq vs int4eq.)
693+
* Otherwise, we look to see if they both belong to an opfamily that
694+
* guarantees compatible semantics for equality. Either finding allows us to
695+
* assume that they have compatible notions of equality. (The reason we need
696+
* to do these pushups is that one might be a cross-type operator; for
697+
* instance int24eq vs int4eq.)
697698
*/
698699
bool
699700
equality_ops_are_compatible(Oid opno1, Oid opno2)
@@ -718,7 +719,7 @@ equality_ops_are_compatible(Oid opno1, Oid opno2)
718719
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
719720
IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
720721

721-
if (amroutine->amcancrosscompare)
722+
if (amroutine->amconsistentequality)
722723
{
723724
if (op_in_opfamily(opno2, op_form->amopfamily))
724725
{
@@ -738,12 +739,13 @@ equality_ops_are_compatible(Oid opno1, Oid opno2)
738739
* Return true if the two given comparison operators have compatible
739740
* semantics.
740741
*
741-
* This is trivially true if they are the same operator. Otherwise,
742-
* we look to see if they can be found in the same btree opfamily.
743-
* For example, '<' and '>=' ops match if they belong to the same family.
742+
* This is trivially true if they are the same operator. Otherwise, we look
743+
* to see if they both belong to an opfamily that guarantees compatible
744+
* semantics for ordering. (For example, for btree, '<' and '>=' ops match if
745+
* they belong to the same family.)
744746
*
745-
* (This is identical to equality_ops_are_compatible(), except that we
746-
* don't bother to examine hash opclasses.)
747+
* (This is identical to equality_ops_are_compatible(), except that we check
748+
* amcanorder plus amconsistentordering instead of amconsistentequality.)
747749
*/
748750
bool
749751
comparison_ops_are_compatible(Oid opno1, Oid opno2)
@@ -768,7 +770,7 @@ comparison_ops_are_compatible(Oid opno1, Oid opno2)
768770
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
769771
IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
770772

771-
if (amroutine->amcanorder && amroutine->amcancrosscompare)
773+
if (amroutine->amcanorder && amroutine->amconsistentordering)
772774
{
773775
if (op_in_opfamily(opno2, op_form->amopfamily))
774776
{

src/include/access/amapi.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,10 @@ typedef struct IndexAmRoutine
245245
bool amcanorderbyop;
246246
/* does AM support hashing using API consistent with the hash AM? */
247247
bool amcanhash;
248-
/* does AM support cross-type comparisons? */
249-
bool amcancrosscompare;
248+
/* do operators within an opfamily have consistent equality semantics? */
249+
bool amconsistentequality;
250+
/* do operators within an opfamily have consistent ordering semantics? */
251+
bool amconsistentordering;
250252
/* does AM support backward scanning? */
251253
bool amcanbackward;
252254
/* does AM support UNIQUE indexes? */

src/test/modules/dummy_index_am/dummy_index_am.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ dihandler(PG_FUNCTION_ARGS)
283283
amroutine->amcanorder = false;
284284
amroutine->amcanorderbyop = false;
285285
amroutine->amcanhash = false;
286-
amroutine->amcancrosscompare = false;
286+
amroutine->amconsistentequality = false;
287+
amroutine->amconsistentordering = false;
287288
amroutine->amcanbackward = false;
288289
amroutine->amcanunique = false;
289290
amroutine->amcanmulticol = false;

0 commit comments

Comments
 (0)