aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/opclasscmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/opclasscmds.c')
-rw-r--r--src/backend/commands/opclasscmds.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 1768140a830..e4b1369f193 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -1128,10 +1128,11 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
procform = (Form_pg_proc) GETSTRUCT(proctup);
/*
- * btree comparison procs must be 2-arg procs returning int4, while btree
- * sortsupport procs must take internal and return void. 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.
+ * 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. 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.
*/
if (amoid == BTREE_AM_OID)
{
@@ -1171,6 +1172,26 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
* Can't infer lefttype/righttype from proc, so use default rule
*/
}
+ else if (member->number == BTINRANGE_PROC)
+ {
+ if (procform->pronargs != 5)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("btree in_range procedures must have five arguments")));
+ if (procform->prorettype != BOOLOID)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("btree in_range procedures must return boolean")));
+
+ /*
+ * If lefttype/righttype isn't specified, use the proc's input
+ * types (we look at the test-value and offset arguments)
+ */
+ if (!OidIsValid(member->lefttype))
+ member->lefttype = procform->proargtypes.values[0];
+ if (!OidIsValid(member->righttype))
+ member->righttype = procform->proargtypes.values[2];
+ }
}
else if (amoid == HASH_AM_OID)
{