amroutine->amoptsprocnum = BLOOM_OPTIONS_PROC;
amroutine->amcanorder = false;
amroutine->amcanorderbyop = false;
+ amroutine->amcanhash = false;
+ amroutine->amcancrosscompare = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = true;
bool amcanorder;
/* does AM support ORDER BY result of an operator on indexed column? */
bool amcanorderbyop;
+ /* does AM support hashing using API consistent with the hash AM? */
+ bool amcanhash;
+ /* does AM support cross-type comparisons? */
+ bool amcancrosscompare;
/* does AM support backward scanning? */
bool amcanbackward;
/* does AM support UNIQUE indexes? */
amroutine->amoptsprocnum = BRIN_PROCNUM_OPTIONS;
amroutine->amcanorder = false;
amroutine->amcanorderbyop = false;
+ amroutine->amcanhash = false;
+ amroutine->amcancrosscompare = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = true;
amroutine->amoptsprocnum = GIN_OPTIONS_PROC;
amroutine->amcanorder = false;
amroutine->amcanorderbyop = false;
+ amroutine->amcanhash = false;
+ amroutine->amcancrosscompare = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = true;
amroutine->amoptsprocnum = GIST_OPTIONS_PROC;
amroutine->amcanorder = false;
amroutine->amcanorderbyop = true;
+ amroutine->amcanhash = false;
+ amroutine->amcancrosscompare = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = true;
amroutine->amoptsprocnum = HASHOPTIONS_PROC;
amroutine->amcanorder = false;
amroutine->amcanorderbyop = false;
+ amroutine->amcanhash = true;
+ amroutine->amcancrosscompare = false;
amroutine->amcanbackward = true;
amroutine->amcanunique = false;
amroutine->amcanmulticol = false;
amroutine->amoptsprocnum = BTOPTIONS_PROC;
amroutine->amcanorder = true;
amroutine->amcanorderbyop = false;
+ amroutine->amcanhash = false;
+ amroutine->amcancrosscompare = true;
amroutine->amcanbackward = true;
amroutine->amcanunique = true;
amroutine->amcanmulticol = true;
amroutine->amoptsprocnum = SPGIST_OPTIONS_PROC;
amroutine->amcanorder = false;
amroutine->amcanorderbyop = true;
+ amroutine->amcanhash = false;
+ amroutine->amcancrosscompare = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = false;
}
/*
- * btree comparison procs must be 2-arg procs returning int4. btree
- * sortsupport procs must take internal and return void. btree in_range
- * procs must be 5-arg procs returning bool. btree equalimage procs must
- * take 1 arg and return bool. hash support proc 1 must be a 1-arg proc
- * returning int4, while proc 2 must be a 2-arg proc returning int8.
- * Otherwise we don't know.
+ * Ordering comparison procs must be 2-arg procs returning int4. Ordering
+ * sortsupport procs must take internal and return void. Ordering
+ * in_range procs must be 5-arg procs returning bool. Ordering equalimage
+ * procs must take 1 arg and return bool. Hashing support proc 1 must be
+ * a 1-arg proc returning int4, while proc 2 must be a 2-arg proc
+ * returning int8. Otherwise we don't know.
*/
- else if (amoid == BTREE_AM_OID)
+ else if (GetIndexAmRoutineByAmId(amoid, false)->amcanorder)
{
if (member->number == BTORDER_PROC)
{
if (procform->pronargs != 2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("btree comparison functions must have two arguments")));
+ errmsg("ordering comparison functions must have two arguments")));
if (procform->prorettype != INT4OID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("btree comparison functions must return integer")));
+ errmsg("ordering comparison functions must return integer")));
/*
* If lefttype/righttype isn't specified, use the proc's input
procform->proargtypes.values[0] != INTERNALOID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("btree sort support functions must accept type \"internal\"")));
+ errmsg("ordering sort support functions must accept type \"internal\"")));
if (procform->prorettype != VOIDOID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("btree sort support functions must return void")));
+ errmsg("ordering sort support functions must return void")));
/*
* Can't infer lefttype/righttype from proc, so use default rule
if (procform->pronargs != 5)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("btree in_range functions must have five arguments")));
+ errmsg("ordering in_range functions must have five arguments")));
if (procform->prorettype != BOOLOID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("btree in_range functions must return boolean")));
+ errmsg("ordering in_range functions must return boolean")));
/*
* If lefttype/righttype isn't specified, use the proc's input
if (procform->pronargs != 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("btree equal image functions must have one argument")));
+ errmsg("ordering equal image functions must have one argument")));
if (procform->prorettype != BOOLOID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("btree equal image functions must return boolean")));
+ errmsg("ordering equal image functions must return boolean")));
/*
* pg_amproc functions are indexed by (lefttype, righttype), but
if (member->lefttype != member->righttype)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("btree equal image functions must not be cross-type")));
+ errmsg("ordering equal image functions must not be cross-type")));
}
}
- else if (amoid == HASH_AM_OID)
+ else if (GetIndexAmRoutineByAmId(amoid, false)->amcanhash)
{
if (member->number == HASHSTANDARD_PROC)
{
varattno = ((Var *) leftop)->varattno;
/*
- * We have to look up the operator's associated btree support
+ * We have to look up the operator's associated support
* function
*/
- if (index->rd_rel->relam != BTREE_AM_OID ||
+ if (!index->rd_indam->amcanorder ||
varattno < 1 || varattno > indnkeyatts)
elog(ERROR, "bogus RowCompare index qualification");
opfamily = index->rd_opfamily[varattno - 1];
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
- /* must be btree or hash */
- if (op_form->amopmethod == BTREE_AM_OID ||
- op_form->amopmethod == HASH_AM_OID)
+ if (amroutine->amcancrosscompare)
{
if (op_in_opfamily(opno2, op_form->amopfamily))
{
{
HeapTuple op_tuple = &catlist->members[i]->tuple;
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
+ IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
- if (op_form->amopmethod == BTREE_AM_OID)
+ if (amroutine->amcanorder && amroutine->amcancrosscompare)
{
if (op_in_opfamily(opno2, op_form->amopfamily))
{
bool amcanorder;
/* does AM support ORDER BY result of an operator on indexed column? */
bool amcanorderbyop;
+ /* does AM support hashing using API consistent with the hash AM? */
+ bool amcanhash;
+ /* does AM support cross-type comparisons? */
+ bool amcancrosscompare;
/* does AM support backward scanning? */
bool amcanbackward;
/* does AM support UNIQUE indexes? */
amroutine->amsupport = 1;
amroutine->amcanorder = false;
amroutine->amcanorderbyop = false;
+ amroutine->amcanhash = false;
+ amroutine->amcancrosscompare = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = false;
CREATE OPERATOR FAMILY alt_opf12 USING btree;
CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2);
-ERROR: btree comparison functions must return integer
+ERROR: ordering comparison functions must return integer
DROP OPERATOR FAMILY alt_opf12 USING btree;
ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK;
CREATE OPERATOR FAMILY alt_opf14 USING btree;
CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4);
-ERROR: btree comparison functions must have two arguments
+ERROR: ordering comparison functions must have two arguments
DROP OPERATOR FAMILY alt_opf14 USING btree;
ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK;
-- Should fail. Not allowed to have cross-type equalimage function.
ALTER OPERATOR FAMILY alt_opf18 USING btree
ADD FUNCTION 4 (int4, int2) btequalimage(oid);
-ERROR: btree equal image functions must not be cross-type
+ERROR: ordering equal image 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;