mirror of
https://github.com/postgres/postgres.git
synced 2025-07-20 05:03:10 +03:00
Rename amcancrosscompare
After more discussion about commit ce62f2f2a0
, 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
This commit is contained in:
@ -110,7 +110,8 @@ blhandler(PG_FUNCTION_ARGS)
|
|||||||
amroutine->amcanorder = false;
|
amroutine->amcanorder = false;
|
||||||
amroutine->amcanorderbyop = false;
|
amroutine->amcanorderbyop = false;
|
||||||
amroutine->amcanhash = false;
|
amroutine->amcanhash = false;
|
||||||
amroutine->amcancrosscompare = false;
|
amroutine->amconsistentequality = false;
|
||||||
|
amroutine->amconsistentordering = false;
|
||||||
amroutine->amcanbackward = false;
|
amroutine->amcanbackward = false;
|
||||||
amroutine->amcanunique = false;
|
amroutine->amcanunique = false;
|
||||||
amroutine->amcanmulticol = true;
|
amroutine->amcanmulticol = true;
|
||||||
|
@ -105,8 +105,10 @@ typedef struct IndexAmRoutine
|
|||||||
bool amcanorderbyop;
|
bool amcanorderbyop;
|
||||||
/* does AM support hashing using API consistent with the hash AM? */
|
/* does AM support hashing using API consistent with the hash AM? */
|
||||||
bool amcanhash;
|
bool amcanhash;
|
||||||
/* does AM support cross-type comparisons? */
|
/* do operators within an opfamily have consistent equality semantics? */
|
||||||
bool amcancrosscompare;
|
bool amconsistentequality;
|
||||||
|
/* do operators within an opfamily have consistent ordering semantics? */
|
||||||
|
bool amconsistentordering;
|
||||||
/* does AM support backward scanning? */
|
/* does AM support backward scanning? */
|
||||||
bool amcanbackward;
|
bool amcanbackward;
|
||||||
/* does AM support UNIQUE indexes? */
|
/* does AM support UNIQUE indexes? */
|
||||||
|
@ -257,7 +257,8 @@ brinhandler(PG_FUNCTION_ARGS)
|
|||||||
amroutine->amcanorder = false;
|
amroutine->amcanorder = false;
|
||||||
amroutine->amcanorderbyop = false;
|
amroutine->amcanorderbyop = false;
|
||||||
amroutine->amcanhash = false;
|
amroutine->amcanhash = false;
|
||||||
amroutine->amcancrosscompare = false;
|
amroutine->amconsistentequality = false;
|
||||||
|
amroutine->amconsistentordering = false;
|
||||||
amroutine->amcanbackward = false;
|
amroutine->amcanbackward = false;
|
||||||
amroutine->amcanunique = false;
|
amroutine->amcanunique = false;
|
||||||
amroutine->amcanmulticol = true;
|
amroutine->amcanmulticol = true;
|
||||||
|
@ -45,7 +45,8 @@ ginhandler(PG_FUNCTION_ARGS)
|
|||||||
amroutine->amcanorder = false;
|
amroutine->amcanorder = false;
|
||||||
amroutine->amcanorderbyop = false;
|
amroutine->amcanorderbyop = false;
|
||||||
amroutine->amcanhash = false;
|
amroutine->amcanhash = false;
|
||||||
amroutine->amcancrosscompare = false;
|
amroutine->amconsistentequality = false;
|
||||||
|
amroutine->amconsistentordering = false;
|
||||||
amroutine->amcanbackward = false;
|
amroutine->amcanbackward = false;
|
||||||
amroutine->amcanunique = false;
|
amroutine->amcanunique = false;
|
||||||
amroutine->amcanmulticol = true;
|
amroutine->amcanmulticol = true;
|
||||||
|
@ -66,7 +66,8 @@ gisthandler(PG_FUNCTION_ARGS)
|
|||||||
amroutine->amcanorder = false;
|
amroutine->amcanorder = false;
|
||||||
amroutine->amcanorderbyop = true;
|
amroutine->amcanorderbyop = true;
|
||||||
amroutine->amcanhash = false;
|
amroutine->amcanhash = false;
|
||||||
amroutine->amcancrosscompare = false;
|
amroutine->amconsistentequality = false;
|
||||||
|
amroutine->amconsistentordering = false;
|
||||||
amroutine->amcanbackward = false;
|
amroutine->amcanbackward = false;
|
||||||
amroutine->amcanunique = false;
|
amroutine->amcanunique = false;
|
||||||
amroutine->amcanmulticol = true;
|
amroutine->amcanmulticol = true;
|
||||||
|
@ -65,7 +65,8 @@ hashhandler(PG_FUNCTION_ARGS)
|
|||||||
amroutine->amcanorder = false;
|
amroutine->amcanorder = false;
|
||||||
amroutine->amcanorderbyop = false;
|
amroutine->amcanorderbyop = false;
|
||||||
amroutine->amcanhash = true;
|
amroutine->amcanhash = true;
|
||||||
amroutine->amcancrosscompare = true;
|
amroutine->amconsistentequality = true;
|
||||||
|
amroutine->amconsistentequality = false;
|
||||||
amroutine->amcanbackward = true;
|
amroutine->amcanbackward = true;
|
||||||
amroutine->amcanunique = false;
|
amroutine->amcanunique = false;
|
||||||
amroutine->amcanmulticol = false;
|
amroutine->amcanmulticol = false;
|
||||||
|
@ -108,7 +108,8 @@ bthandler(PG_FUNCTION_ARGS)
|
|||||||
amroutine->amcanorder = true;
|
amroutine->amcanorder = true;
|
||||||
amroutine->amcanorderbyop = false;
|
amroutine->amcanorderbyop = false;
|
||||||
amroutine->amcanhash = false;
|
amroutine->amcanhash = false;
|
||||||
amroutine->amcancrosscompare = true;
|
amroutine->amconsistentequality = true;
|
||||||
|
amroutine->amconsistentordering = true;
|
||||||
amroutine->amcanbackward = true;
|
amroutine->amcanbackward = true;
|
||||||
amroutine->amcanunique = true;
|
amroutine->amcanunique = true;
|
||||||
amroutine->amcanmulticol = true;
|
amroutine->amcanmulticol = true;
|
||||||
|
@ -51,7 +51,8 @@ spghandler(PG_FUNCTION_ARGS)
|
|||||||
amroutine->amcanorder = false;
|
amroutine->amcanorder = false;
|
||||||
amroutine->amcanorderbyop = true;
|
amroutine->amcanorderbyop = true;
|
||||||
amroutine->amcanhash = false;
|
amroutine->amcanhash = false;
|
||||||
amroutine->amcancrosscompare = false;
|
amroutine->amconsistentequality = false;
|
||||||
|
amroutine->amconsistentordering = false;
|
||||||
amroutine->amcanbackward = false;
|
amroutine->amcanbackward = false;
|
||||||
amroutine->amcanunique = false;
|
amroutine->amcanunique = false;
|
||||||
amroutine->amcanmulticol = false;
|
amroutine->amcanmulticol = false;
|
||||||
|
@ -1083,9 +1083,10 @@ query_supports_distinctness(Query *query)
|
|||||||
* the values are distinct. (Note: the opids entries could be cross-type
|
* the values are distinct. (Note: the opids entries could be cross-type
|
||||||
* operators, and thus not exactly the equality operators that the subquery
|
* operators, and thus not exactly the equality operators that the subquery
|
||||||
* would use itself. We use equality_ops_are_compatible() to check
|
* would use itself. We use equality_ops_are_compatible() to check
|
||||||
* compatibility. That looks at btree or hash opfamily membership, and so
|
* compatibility. That looks at opfamily membership for index AMs that have
|
||||||
* should give trustworthy answers for all operators that we might need
|
* declared that they support consistent equality semantics within an
|
||||||
* to deal with here.)
|
* opfamily, and so should give trustworthy answers for all operators that we
|
||||||
|
* might need to deal with here.)
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
query_is_distinct_for(Query *query, List *colnos, List *opids)
|
query_is_distinct_for(Query *query, List *colnos, List *opids)
|
||||||
|
24
src/backend/utils/cache/lsyscache.c
vendored
24
src/backend/utils/cache/lsyscache.c
vendored
@ -690,10 +690,11 @@ get_op_btree_interpretation(Oid opno)
|
|||||||
* semantics.
|
* semantics.
|
||||||
*
|
*
|
||||||
* This is trivially true if they are the same operator. Otherwise,
|
* This is trivially true if they are the same operator. Otherwise,
|
||||||
* we look to see if they can be found in the same btree or hash opfamily.
|
* Otherwise, we look to see if they both belong to an opfamily that
|
||||||
* Either finding allows us to assume that they have compatible notions
|
* guarantees compatible semantics for equality. Either finding allows us to
|
||||||
* of equality. (The reason we need to do these pushups is that one might
|
* assume that they have compatible notions of equality. (The reason we need
|
||||||
* be a cross-type operator; for instance int24eq vs int4eq.)
|
* to do these pushups is that one might be a cross-type operator; for
|
||||||
|
* instance int24eq vs int4eq.)
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
equality_ops_are_compatible(Oid opno1, Oid opno2)
|
equality_ops_are_compatible(Oid opno1, Oid opno2)
|
||||||
@ -718,7 +719,7 @@ equality_ops_are_compatible(Oid opno1, Oid opno2)
|
|||||||
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
|
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
|
||||||
IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
|
IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
|
||||||
|
|
||||||
if (amroutine->amcancrosscompare)
|
if (amroutine->amconsistentequality)
|
||||||
{
|
{
|
||||||
if (op_in_opfamily(opno2, op_form->amopfamily))
|
if (op_in_opfamily(opno2, op_form->amopfamily))
|
||||||
{
|
{
|
||||||
@ -738,12 +739,13 @@ equality_ops_are_compatible(Oid opno1, Oid opno2)
|
|||||||
* Return true if the two given comparison operators have compatible
|
* Return true if the two given comparison operators have compatible
|
||||||
* semantics.
|
* semantics.
|
||||||
*
|
*
|
||||||
* This is trivially true if they are the same operator. Otherwise,
|
* This is trivially true if they are the same operator. Otherwise, we look
|
||||||
* we look to see if they can be found in the same btree opfamily.
|
* to see if they both belong to an opfamily that guarantees compatible
|
||||||
* For example, '<' and '>=' ops match if they belong to the same family.
|
* semantics for ordering. (For example, for btree, '<' and '>=' ops match if
|
||||||
|
* they belong to the same family.)
|
||||||
*
|
*
|
||||||
* (This is identical to equality_ops_are_compatible(), except that we
|
* (This is identical to equality_ops_are_compatible(), except that we check
|
||||||
* don't bother to examine hash opclasses.)
|
* amcanorder plus amconsistentordering instead of amconsistentequality.)
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
comparison_ops_are_compatible(Oid opno1, Oid opno2)
|
comparison_ops_are_compatible(Oid opno1, Oid opno2)
|
||||||
@ -768,7 +770,7 @@ comparison_ops_are_compatible(Oid opno1, Oid opno2)
|
|||||||
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
|
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
|
||||||
IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
|
IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
|
||||||
|
|
||||||
if (amroutine->amcanorder && amroutine->amcancrosscompare)
|
if (amroutine->amcanorder && amroutine->amconsistentordering)
|
||||||
{
|
{
|
||||||
if (op_in_opfamily(opno2, op_form->amopfamily))
|
if (op_in_opfamily(opno2, op_form->amopfamily))
|
||||||
{
|
{
|
||||||
|
@ -245,8 +245,10 @@ typedef struct IndexAmRoutine
|
|||||||
bool amcanorderbyop;
|
bool amcanorderbyop;
|
||||||
/* does AM support hashing using API consistent with the hash AM? */
|
/* does AM support hashing using API consistent with the hash AM? */
|
||||||
bool amcanhash;
|
bool amcanhash;
|
||||||
/* does AM support cross-type comparisons? */
|
/* do operators within an opfamily have consistent equality semantics? */
|
||||||
bool amcancrosscompare;
|
bool amconsistentequality;
|
||||||
|
/* do operators within an opfamily have consistent ordering semantics? */
|
||||||
|
bool amconsistentordering;
|
||||||
/* does AM support backward scanning? */
|
/* does AM support backward scanning? */
|
||||||
bool amcanbackward;
|
bool amcanbackward;
|
||||||
/* does AM support UNIQUE indexes? */
|
/* does AM support UNIQUE indexes? */
|
||||||
|
@ -283,7 +283,8 @@ dihandler(PG_FUNCTION_ARGS)
|
|||||||
amroutine->amcanorder = false;
|
amroutine->amcanorder = false;
|
||||||
amroutine->amcanorderbyop = false;
|
amroutine->amcanorderbyop = false;
|
||||||
amroutine->amcanhash = false;
|
amroutine->amcanhash = false;
|
||||||
amroutine->amcancrosscompare = false;
|
amroutine->amconsistentequality = false;
|
||||||
|
amroutine->amconsistentordering = false;
|
||||||
amroutine->amcanbackward = false;
|
amroutine->amcanbackward = false;
|
||||||
amroutine->amcanunique = false;
|
amroutine->amcanunique = false;
|
||||||
amroutine->amcanmulticol = false;
|
amroutine->amcanmulticol = false;
|
||||||
|
Reference in New Issue
Block a user