From ab69ea5ee09c9ad08c14d30a6f7efdb4d0520533 Mon Sep 17 00:00:00 2001
From: Emre Hasegeli <emre@hasegeli.com>
Date: Sun, 5 Apr 2015 19:14:11 +0200
Subject: [PATCH 7/7] remove minmax amprocs

---
 src/backend/access/brin/brin_minmax.c | 152 +++++++++++++++++++------------
 src/include/catalog/pg_amproc.h       | 164 ----------------------------------
 src/include/catalog/pg_opclass.h      |  54 +++++------
 3 files changed, 120 insertions(+), 250 deletions(-)

diff --git a/src/backend/access/brin/brin_minmax.c b/src/backend/access/brin/brin_minmax.c
index 299d6f7..419f969 100644
--- a/src/backend/access/brin/brin_minmax.c
+++ b/src/backend/access/brin/brin_minmax.c
@@ -8,49 +8,36 @@
  * IDENTIFICATION
  *	  src/backend/access/brin/brin_minmax.c
  */
 #include "postgres.h"
 
 #include "access/genam.h"
 #include "access/brin_internal.h"
 #include "access/brin_tuple.h"
 #include "access/skey.h"
 #include "catalog/pg_type.h"
+#include "catalog/pg_amop.h"
 #include "utils/datum.h"
 #include "utils/lsyscache.h"
+#include "utils/rel.h"
 #include "utils/syscache.h"
 
 
-/*
- * Procedure numbers must not collide with BRIN_PROCNUM defines in
- * brin_internal.h.  Note we only need inequality functions.
- */
-#define		MINMAX_NUM_PROCNUMS		4	/* # support procs we need */
-#define		PROCNUM_LESS			11
-#define		PROCNUM_LESSEQUAL		12
-#define		PROCNUM_GREATEREQUAL	13
-#define		PROCNUM_GREATER			14
-
-/*
- * Subtract this from procnum to obtain index in MinmaxOpaque arrays
- * (Must be equal to minimum of private procnums)
- */
-#define		PROCNUM_BASE			11
-
 typedef struct MinmaxOpaque
 {
-	FmgrInfo	operators[MINMAX_NUM_PROCNUMS];
-	bool		inited[MINMAX_NUM_PROCNUMS];
+	Oid			last_subtype;
+	FmgrInfo	strategy_procinfos[BTMaxStrategyNumber];
+	bool		strategy_inited[BTMaxStrategyNumber];
 } MinmaxOpaque;
 
-static FmgrInfo *minmax_get_procinfo(BrinDesc *bdesc, uint16 attno,
-					uint16 procnum);
+static FmgrInfo *minmax_get_strategy_procinfo(BrinDesc *bdesc, uint16 attno,
+					Oid subtype, uint16 strategynum);
 
 
 Datum
 brin_minmax_opcinfo(PG_FUNCTION_ARGS)
 {
 	Oid			typoid = PG_GETARG_OID(0);
 	BrinOpcInfo *result;
 
 	/*
 	 * opaque->operators is initialized lazily, as indicated by 'inited' which
@@ -115,34 +102,36 @@ brin_minmax_add_value(PG_FUNCTION_ARGS)
 		column->bv_values[1] = datumCopy(newval, attr->attbyval, attr->attlen);
 		column->bv_allnulls = false;
 		PG_RETURN_BOOL(true);
 	}
 
 	/*
 	 * Otherwise, need to compare the new value with the existing boundaries
 	 * and update them accordingly.  First check if it's less than the
 	 * existing minimum.
 	 */
-	cmpFn = minmax_get_procinfo(bdesc, attno, PROCNUM_LESS);
+	cmpFn = minmax_get_strategy_procinfo(bdesc, attno, attr->atttypid,
+										 BTLessStrategyNumber);
 	compar = FunctionCall2Coll(cmpFn, colloid, newval, column->bv_values[0]);
 	if (DatumGetBool(compar))
 	{
 		if (!attr->attbyval)
 			pfree(DatumGetPointer(column->bv_values[0]));
 		column->bv_values[0] = datumCopy(newval, attr->attbyval, attr->attlen);
 		updated = true;
 	}
 
 	/*
 	 * And now compare it to the existing maximum.
 	 */
-	cmpFn = minmax_get_procinfo(bdesc, attno, PROCNUM_GREATER);
+	cmpFn = minmax_get_strategy_procinfo(bdesc, attno, attr->atttypid,
+										 BTGreaterStrategyNumber);
 	compar = FunctionCall2Coll(cmpFn, colloid, newval, column->bv_values[1]);
 	if (DatumGetBool(compar))
 	{
 		if (!attr->attbyval)
 			pfree(DatumGetPointer(column->bv_values[1]));
 		column->bv_values[1] = datumCopy(newval, attr->attbyval, attr->attlen);
 		updated = true;
 	}
 
 	PG_RETURN_BOOL(updated);
@@ -152,24 +141,26 @@ brin_minmax_add_value(PG_FUNCTION_ARGS)
  * Given an index tuple corresponding to a certain page range and a scan key,
  * return whether the scan key is consistent with the index tuple's min/max
  * values.  Return true if so, false otherwise.
  */
 Datum
 brin_minmax_consistent(PG_FUNCTION_ARGS)
 {
 	BrinDesc   *bdesc = (BrinDesc *) PG_GETARG_POINTER(0);
 	BrinValues *column = (BrinValues *) PG_GETARG_POINTER(1);
 	ScanKey		key = (ScanKey) PG_GETARG_POINTER(2);
-	Oid			colloid = PG_GET_COLLATION();
+	Oid			colloid = PG_GET_COLLATION(),
+				subtype;
 	AttrNumber	attno;
 	Datum		value;
 	Datum		matches;
+	FmgrInfo   *frmg;
 
 	Assert(key->sk_attno == column->bv_attno);
 
 	/* handle IS NULL/IS NOT NULL tests */
 	if (key->sk_flags & SK_ISNULL)
 	{
 		if (key->sk_flags & SK_SEARCHNULL)
 		{
 			if (column->bv_allnulls || column->bv_hasnulls)
 				PG_RETURN_BOOL(true);
@@ -182,59 +173,66 @@ brin_minmax_consistent(PG_FUNCTION_ARGS)
 		 */
 		Assert(key->sk_flags & SK_SEARCHNOTNULL);
 		PG_RETURN_BOOL(!column->bv_allnulls);
 	}
 
 	/* if the range is all empty, it cannot possibly be consistent */
 	if (column->bv_allnulls)
 		PG_RETURN_BOOL(false);
 
 	attno = key->sk_attno;
+	subtype = key->sk_subtype;
 	value = key->sk_argument;
 	switch (key->sk_strategy)
 	{
 		case BTLessStrategyNumber:
-			matches = FunctionCall2Coll(minmax_get_procinfo(bdesc, attno,
-															PROCNUM_LESS),
-										colloid, column->bv_values[0], value);
+			frmg = minmax_get_strategy_procinfo(bdesc, attno, subtype,
+												BTLessStrategyNumber);
+			matches = FunctionCall2Coll(frmg, colloid, column->bv_values[0],
+										value);
 			break;
 		case BTLessEqualStrategyNumber:
-			matches = FunctionCall2Coll(minmax_get_procinfo(bdesc, attno,
-														  PROCNUM_LESSEQUAL),
-										colloid, column->bv_values[0], value);
+			frmg = minmax_get_strategy_procinfo(bdesc, attno, subtype,
+												BTLessEqualStrategyNumber);
+			matches = FunctionCall2Coll(frmg, colloid, column->bv_values[0],
+										value);
 			break;
 		case BTEqualStrategyNumber:
 
 			/*
 			 * In the equality case (WHERE col = someval), we want to return
 			 * the current page range if the minimum value in the range <=
 			 * scan key, and the maximum value >= scan key.
 			 */
-			matches = FunctionCall2Coll(minmax_get_procinfo(bdesc, attno,
-														  PROCNUM_LESSEQUAL),
-										colloid, column->bv_values[0], value);
+			frmg = minmax_get_strategy_procinfo(bdesc, attno, subtype,
+												BTLessEqualStrategyNumber);
+			matches = FunctionCall2Coll(frmg, colloid, column->bv_values[0],
+										value);
 			if (!DatumGetBool(matches))
 				break;
 			/* max() >= scankey */
-			matches = FunctionCall2Coll(minmax_get_procinfo(bdesc, attno,
-													   PROCNUM_GREATEREQUAL),
-										colloid, column->bv_values[1], value);
+			frmg = minmax_get_strategy_procinfo(bdesc, attno, subtype,
+												BTGreaterEqualStrategyNumber);
+			matches = FunctionCall2Coll(frmg, colloid, column->bv_values[1],
+										value);
 			break;
 		case BTGreaterEqualStrategyNumber:
-			matches = FunctionCall2Coll(minmax_get_procinfo(bdesc, attno,
-													   PROCNUM_GREATEREQUAL),
-										colloid, column->bv_values[1], value);
+			frmg = minmax_get_strategy_procinfo(bdesc, attno, subtype,
+												BTGreaterEqualStrategyNumber);
+			matches = FunctionCall2Coll(frmg, colloid, column->bv_values[1],
+										value);
 			break;
 		case BTGreaterStrategyNumber:
-			matches = FunctionCall2Coll(minmax_get_procinfo(bdesc, attno,
-															PROCNUM_GREATER),
-										colloid, column->bv_values[1], value);
+			frmg = minmax_get_strategy_procinfo(bdesc, attno, subtype,
+												BTGreaterStrategyNumber);
+			matches = FunctionCall2Coll(frmg, colloid, column->bv_values[1],
+										value);
 			break;
 		default:
 			/* shouldn't happen */
 			elog(ERROR, "invalid strategy number %d", key->sk_strategy);
 			matches = 0;
 			break;
 	}
 
 	PG_RETURN_DATUM(matches);
 }
@@ -245,20 +243,21 @@ brin_minmax_consistent(PG_FUNCTION_ARGS)
  */
 Datum
 brin_minmax_union(PG_FUNCTION_ARGS)
 {
 	BrinDesc   *bdesc = (BrinDesc *) PG_GETARG_POINTER(0);
 	BrinValues *col_a = (BrinValues *) PG_GETARG_POINTER(1);
 	BrinValues *col_b = (BrinValues *) PG_GETARG_POINTER(2);
 	Oid			colloid = PG_GET_COLLATION();
 	AttrNumber	attno;
 	Form_pg_attribute attr;
+	FmgrInfo   *frmg;
 	bool		needsadj;
 
 	Assert(col_a->bv_attno == col_b->bv_attno);
 
 	/* Adjust "hasnulls" */
 	if (!col_a->bv_hasnulls && col_b->bv_hasnulls)
 		col_a->bv_hasnulls = true;
 
 	/* If there are no values in B, there's nothing left to do */
 	if (col_b->bv_allnulls)
@@ -277,61 +276,96 @@ brin_minmax_union(PG_FUNCTION_ARGS)
 	{
 		col_a->bv_allnulls = false;
 		col_a->bv_values[0] = datumCopy(col_b->bv_values[0],
 										attr->attbyval, attr->attlen);
 		col_a->bv_values[1] = datumCopy(col_b->bv_values[1],
 										attr->attbyval, attr->attlen);
 		PG_RETURN_VOID();
 	}
 
 	/* Adjust minimum, if B's min is less than A's min */
-	needsadj = FunctionCall2Coll(minmax_get_procinfo(bdesc, attno,
-													 PROCNUM_LESS),
-						  colloid, col_b->bv_values[0], col_a->bv_values[0]);
+	frmg = minmax_get_strategy_procinfo(bdesc, attno, attr->atttypid,
+										BTLessStrategyNumber);
+	needsadj = FunctionCall2Coll(frmg, colloid, col_b->bv_values[0],
+								 col_a->bv_values[0]);
 	if (needsadj)
 	{
 		if (!attr->attbyval)
 			pfree(DatumGetPointer(col_a->bv_values[0]));
 		col_a->bv_values[0] = datumCopy(col_b->bv_values[0],
 										attr->attbyval, attr->attlen);
 	}
 
 	/* Adjust maximum, if B's max is greater than A's max */
-	needsadj = FunctionCall2Coll(minmax_get_procinfo(bdesc, attno,
-													 PROCNUM_GREATER),
-						  colloid, col_b->bv_values[1], col_a->bv_values[1]);
+	frmg = minmax_get_strategy_procinfo(bdesc, attno, attr->atttypid,
+										BTGreaterStrategyNumber);
+	needsadj = FunctionCall2Coll(frmg, colloid, col_b->bv_values[0],
+								 col_a->bv_values[0]);
 	if (needsadj)
 	{
 		if (!attr->attbyval)
 			pfree(DatumGetPointer(col_a->bv_values[1]));
 		col_a->bv_values[1] = datumCopy(col_b->bv_values[1],
 										attr->attbyval, attr->attlen);
 	}
 
 	PG_RETURN_VOID();
 }
 
 /*
- * Return the procedure corresponding to the given function support number.
+ * Get the procedure of the given strategy
+ *
+ * This function is a copy of inclusion_get_strategy_procinfo() on
+ * brin_inclusion.c.
  */
-static FmgrInfo *
-minmax_get_procinfo(BrinDesc *bdesc, uint16 attno, uint16 procnum)
+FmgrInfo *
+minmax_get_strategy_procinfo(BrinDesc *bdesc, uint16 attno, Oid subtype,
+							 uint16 strategynum)
 {
 	MinmaxOpaque *opaque;
-	uint16		basenum = procnum - PROCNUM_BASE;
+	uint16		basenum = strategynum - 1,
+				i;
 
 	opaque = (MinmaxOpaque *) bdesc->bd_info[attno - 1]->oi_opaque;
 
 	/*
-	 * We cache these in the opaque struct, to avoid repetitive syscache
-	 * lookups.
+	 * We cache the procedures for the last sub-type in the opaque struct,
+	 * to avoid repetitive syscache lookups.  If the sub-type is changed,
+	 * we cannot use any of them anymore.
 	 */
-	if (!opaque->inited[basenum])
+	if (opaque->last_subtype != subtype && opaque->strategy_inited)
+		for (i = 0; i < BTMaxStrategyNumber; i++)
+			opaque->strategy_inited[i] = false;
+
+	if (!opaque->strategy_inited[basenum])
 	{
-		fmgr_info_copy(&opaque->operators[basenum],
-					   index_getprocinfo(bdesc->bd_index, attno, procnum),
-					   bdesc->bd_context);
-		opaque->inited[basenum] = true;
+		HeapTuple	tuple;
+		Datum		oprDatum;
+		Oid			opfamily;
+		Form_pg_attribute attr;
+		bool		isNull;
+
+		opfamily = bdesc->bd_index->rd_opfamily[attno - 1];
+		attr = bdesc->bd_tupdesc->attrs[attno - 1];
+		tuple = SearchSysCache4(AMOPSTRATEGY, ObjectIdGetDatum(opfamily),
+								ObjectIdGetDatum(attr->atttypid),
+								ObjectIdGetDatum(subtype),
+								Int16GetDatum(strategynum));
+
+		if (!HeapTupleIsValid(tuple))
+			elog(ERROR, "missing strategy %d for attribute %d of index \"%s\"",
+				 strategynum, attno, RelationGetRelationName(bdesc->bd_index));
+
+		oprDatum = SysCacheGetAttr(AMOPSTRATEGY, tuple,
+								   Anum_pg_amop_amopopr, &isNull);
+		ReleaseSysCache(tuple);
+
+		Assert(!isNull && RegProcedureIsValid(DatumGetObjectId(oprDatum)));
+
+		fmgr_info_cxt(get_opcode(DatumGetObjectId(oprDatum)),
+					  &opaque->strategy_procinfos[basenum],
+					  bdesc->bd_context);
+		opaque->strategy_inited[basenum] = true;
 	}
 
-	return &opaque->operators[basenum];
+	return &opaque->strategy_procinfos[basenum];
 }
diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h
index 0e044f3..ca2509b 100644
--- a/src/include/catalog/pg_amproc.h
+++ b/src/include/catalog/pg_amproc.h
@@ -436,391 +436,227 @@ DATA(insert (	4017   25 25 2 4028 ));
 DATA(insert (	4017   25 25 3 4029 ));
 DATA(insert (	4017   25 25 4 4030 ));
 DATA(insert (	4017   25 25 5 4031 ));
 
 /* BRIN opclasses */
 /* minmax bytea */
 DATA(insert (   4064    17    17  1  3383 ));
 DATA(insert (   4064    17    17  2  3384 ));
 DATA(insert (   4064    17    17  3  3385 ));
 DATA(insert (   4064    17    17  4  3386 ));
-DATA(insert (   4064    17    17  11 1949 ));
-DATA(insert (   4064    17    17  12 1950 ));
-DATA(insert (   4064    17    17  13 1952 ));
-DATA(insert (   4064    17    17  14 1951 ));
 /* minmax "char" */
 DATA(insert (   4062    18    18  1  3383 ));
 DATA(insert (   4062    18    18  2  3384 ));
 DATA(insert (   4062    18    18  3  3385 ));
 DATA(insert (   4062    18    18  4  3386 ));
-DATA(insert (   4062    18    18  11 1246 ));
-DATA(insert (   4062    18    18  12   72 ));
-DATA(insert (   4062    18    18  13   74 ));
-DATA(insert (   4062    18    18  14   73 ));
 /* minmax name */
 DATA(insert (   4065    19    19  1  3383 ));
 DATA(insert (   4065    19    19  2  3384 ));
 DATA(insert (   4065    19    19  3  3385 ));
 DATA(insert (   4065    19    19  4  3386 ));
-DATA(insert (   4065    19    19  11  655 ));
-DATA(insert (   4065    19    19  12  656 ));
-DATA(insert (   4065    19    19  13  658 ));
-DATA(insert (   4065    19    19  14  657 ));
 /* minmax integer: int2, int4, int8 */
 DATA(insert (   4054    20    20  1  3383 ));
 DATA(insert (   4054    20    20  2  3384 ));
 DATA(insert (   4054    20    20  3  3385 ));
 DATA(insert (   4054    20    20  4  3386 ));
-DATA(insert (   4054    20    20  11  469 ));
-DATA(insert (   4054    20    20  12  471 ));
-DATA(insert (   4054    20    20  13  472 ));
-DATA(insert (   4054    20    20  14  470 ));
 DATA(insert (   4054    20    21  1  3383 ));
 DATA(insert (   4054    20    21  2  3384 ));
 DATA(insert (   4054    20    21  3  3385 ));
 DATA(insert (   4054    20    21  4  3386 ));
-DATA(insert (   4054    20    21  11 1858 ));
-DATA(insert (   4054    20    21  12 1860 ));
-DATA(insert (   4054    20    21  13 1861 ));
-DATA(insert (   4054    20    21  14 1859 ));
 DATA(insert (   4054    20    23  1  3383 ));
 DATA(insert (   4054    20    23  2  3384 ));
 DATA(insert (   4054    20    23  3  3385 ));
 DATA(insert (   4054    20    23  4  3386 ));
-DATA(insert (   4054    20    23  11  476 ));
-DATA(insert (   4054    20    23  12  478 ));
-DATA(insert (   4054    20    23  13  479 ));
-DATA(insert (   4054    20    23  14  477 ));
 
 DATA(insert (   4054    21    21  1  3383 ));
 DATA(insert (   4054    21    21  2  3384 ));
 DATA(insert (   4054    21    21  3  3385 ));
 DATA(insert (   4054    21    21  4  3386 ));
-DATA(insert (   4054    21    21  11   64 ));
-DATA(insert (   4054    21    21  12  148 ));
-DATA(insert (   4054    21    21  13  151 ));
-DATA(insert (   4054    21    21  14  146 ));
 DATA(insert (   4054    21    20  1  3383 ));
 DATA(insert (   4054    21    20  2  3384 ));
 DATA(insert (   4054    21    20  3  3385 ));
 DATA(insert (   4054    21    20  4  3386 ));
-DATA(insert (   4054    21    20  11 1852 ));
-DATA(insert (   4054    21    20  12 1854 ));
-DATA(insert (   4054    21    20  13 1855 ));
-DATA(insert (   4054    21    20  14 1853 ));
 DATA(insert (   4054    21    23  1  3383 ));
 DATA(insert (   4054    21    23  2  3384 ));
 DATA(insert (   4054    21    23  3  3385 ));
 DATA(insert (   4054    21    23  4  3386 ));
-DATA(insert (   4054    21    23  11  160 ));
-DATA(insert (   4054    21    23  12  166 ));
-DATA(insert (   4054    21    23  13  168 ));
-DATA(insert (   4054    21    23  14  162 ));
 
 DATA(insert (   4054    23    23  1  3383 ));
 DATA(insert (   4054    23    23  2  3384 ));
 DATA(insert (   4054    23    23  3  3385 ));
 DATA(insert (   4054    23    23  4  3386 ));
-DATA(insert (   4054    23    23  11   66 ));
-DATA(insert (   4054    23    23  12  149 ));
-DATA(insert (   4054    23    23  13  150 ));
-DATA(insert (   4054    23    23  14  147 ));
 DATA(insert (   4054    23    20  1  3383 ));
 DATA(insert (   4054    23    20  2  3384 ));
 DATA(insert (   4054    23    20  3  3385 ));
 DATA(insert (   4054    23    20  4  3386 ));
-DATA(insert (   4054    23    20  11  854 ));
-DATA(insert (   4054    23    20  12  856 ));
-DATA(insert (   4054    23    20  13  857 ));
-DATA(insert (   4054    23    20  14  855 ));
 DATA(insert (   4054    23    21  1  3383 ));
 DATA(insert (   4054    23    21  2  3384 ));
 DATA(insert (   4054    23    21  3  3385 ));
 DATA(insert (   4054    23    21  4  3386 ));
-DATA(insert (   4054    23    21  11  161 ));
-DATA(insert (   4054    23    21  12  167 ));
-DATA(insert (   4054    23    21  13  169 ));
-DATA(insert (   4054    23    21  14  163 ));
 
 /* minmax text */
 DATA(insert (   4056    25    25  1  3383 ));
 DATA(insert (   4056    25    25  2  3384 ));
 DATA(insert (   4056    25    25  3  3385 ));
 DATA(insert (   4056    25    25  4  3386 ));
-DATA(insert (   4056    25    25  11  740 ));
-DATA(insert (   4056    25    25  12  741 ));
-DATA(insert (   4056    25    25  13  743 ));
-DATA(insert (   4056    25    25  14  742 ));
 /* minmax oid */
 DATA(insert (   4068    26    26  1  3383 ));
 DATA(insert (   4068    26    26  2  3384 ));
 DATA(insert (   4068    26    26  3  3385 ));
 DATA(insert (   4068    26    26  4  3386 ));
-DATA(insert (   4068    26    26  11  716 ));
-DATA(insert (   4068    26    26  12  717 ));
-DATA(insert (   4068    26    26  13 1639 ));
-DATA(insert (   4068    26    26  14 1638 ));
 /* minmax tid */
 DATA(insert (   4069    27    27  1  3383 ));
 DATA(insert (   4069    27    27  2  3384 ));
 DATA(insert (   4069    27    27  3  3385 ));
 DATA(insert (   4069    27    27  4  3386 ));
-DATA(insert (   4069    27    27  11 2791 ));
-DATA(insert (   4069    27    27  12 2793 ));
-DATA(insert (   4069    27    27  13 2792 ));
-DATA(insert (   4069    27    27  14 2790 ));
 /* minmax float */
 DATA(insert (   4070   700   700  1  3383 ));
 DATA(insert (   4070   700   700  2  3384 ));
 DATA(insert (   4070   700   700  3  3385 ));
 DATA(insert (   4070   700   700  4  3386 ));
-DATA(insert (   4070   700   700  11  289 ));
-DATA(insert (   4070   700   700  12  290 ));
-DATA(insert (   4070   700   700  13  292 ));
-DATA(insert (   4070   700   700  14  291 ));
 
 DATA(insert (   4070   700   701  1  3383 ));
 DATA(insert (   4070   700   701  2  3384 ));
 DATA(insert (   4070   700   701  3  3385 ));
 DATA(insert (   4070   700   701  4  3386 ));
-DATA(insert (   4070   700   701  11  301 ));
-DATA(insert (   4070   700   701  12  303 ));
-DATA(insert (   4070   700   701  13  304 ));
-DATA(insert (   4070   700   701  14  303 ));
 
 DATA(insert (   4070   701   701  1  3383 ));
 DATA(insert (   4070   701   701  2  3384 ));
 DATA(insert (   4070   701   701  3  3385 ));
 DATA(insert (   4070   701   701  4  3386 ));
-DATA(insert (   4070   701   701  11  295 ));
-DATA(insert (   4070   701   701  12  296 ));
-DATA(insert (   4070   701   701  13  298 ));
-DATA(insert (   4070   701   701  14  297 ));
 
 DATA(insert (   4070   701   700  1  3383 ));
 DATA(insert (   4070   701   700  2  3384 ));
 DATA(insert (   4070   701   700  3  3385 ));
 DATA(insert (   4070   701   700  4  3386 ));
-DATA(insert (   4070   701   700  11  307 ));
-DATA(insert (   4070   701   700  12  308 ));
-DATA(insert (   4070   701   700  13  310 ));
-DATA(insert (   4070   701   700  14  309 ));
 
 /* minmax abstime */
 DATA(insert (   4072   702   702  1  3383 ));
 DATA(insert (   4072   702   702  2  3384 ));
 DATA(insert (   4072   702   702  3  3385 ));
 DATA(insert (   4072   702   702  4  3386 ));
-DATA(insert (   4072   702   702  11  253 ));
-DATA(insert (   4072   702   702  12  255 ));
-DATA(insert (   4072   702   702  13  256 ));
-DATA(insert (   4072   702   702  14  254 ));
 /* minmax reltime */
 DATA(insert (   4073   703   703  1  3383 ));
 DATA(insert (   4073   703   703  2  3384 ));
 DATA(insert (   4073   703   703  3  3385 ));
 DATA(insert (   4073   703   703  4  3386 ));
-DATA(insert (   4073   703   703  11  259 ));
-DATA(insert (   4073   703   703  12  261 ));
-DATA(insert (   4073   703   703  13  262 ));
-DATA(insert (   4073   703   703  14  260 ));
 /* minmax macaddr */
 DATA(insert (   4074   829   829  1  3383 ));
 DATA(insert (   4074   829   829  2  3384 ));
 DATA(insert (   4074   829   829  3  3385 ));
 DATA(insert (   4074   829   829  4  3386 ));
-DATA(insert (   4074   829   829  11  831 ));
-DATA(insert (   4074   829   829  12  832 ));
-DATA(insert (   4074   829   829  13  834 ));
-DATA(insert (   4074   829   829  14  833 ));
 /* minmax inet */
 DATA(insert (   4075   869   869  1  3383 ));
 DATA(insert (   4075   869   869  2  3384 ));
 DATA(insert (   4075   869   869  3  3385 ));
 DATA(insert (   4075   869   869  4  3386 ));
-DATA(insert (   4075   869   869  11  921 ));
-DATA(insert (   4075   869   869  12  922 ));
-DATA(insert (   4075   869   869  13  924 ));
-DATA(insert (   4075   869   869  14  923 ));
 /* inclusion inet */
 DATA(insert (   4102   869   869  1  4105 ));
 DATA(insert (   4102   869   869  2  4106 ));
 DATA(insert (   4102   869   869  3  4107 ));
 DATA(insert (   4102   869   869  4  4108 ));
 DATA(insert (   4102   869   869 11  4063 ));
 DATA(insert (   4102   869   869 12  4071 ));
 DATA(insert (   4102   869   869 14   930 ));
 /* minmax character */
 DATA(insert (   4076  1042  1042  1  3383 ));
 DATA(insert (   4076  1042  1042  2  3384 ));
 DATA(insert (   4076  1042  1042  3  3385 ));
 DATA(insert (   4076  1042  1042  4  3386 ));
-DATA(insert (   4076  1042  1042  11 1049 ));
-DATA(insert (   4076  1042  1042  12 1050 ));
-DATA(insert (   4076  1042  1042  13 1052 ));
-DATA(insert (   4076  1042  1042  14 1051 ));
 /* minmax time without time zone */
 DATA(insert (   4077  1083  1083  1  3383 ));
 DATA(insert (   4077  1083  1083  2  3384 ));
 DATA(insert (   4077  1083  1083  3  3385 ));
 DATA(insert (   4077  1083  1083  4  3386 ));
-DATA(insert (   4077  1083  1083  11 1102 ));
-DATA(insert (   4077  1083  1083  12 1103 ));
-DATA(insert (   4077  1083  1083  13 1105 ));
-DATA(insert (   4077  1083  1083  14 1104 ));
 /* minmax datetime (date, timestamp, timestamptz) */
 DATA(insert (   4059  1114  1114  1  3383 ));
 DATA(insert (   4059  1114  1114  2  3384 ));
 DATA(insert (   4059  1114  1114  3  3385 ));
 DATA(insert (   4059  1114  1114  4  3386 ));
-DATA(insert (   4059  1114  1114  11 2054 ));
-DATA(insert (   4059  1114  1114  12 2055 ));
-DATA(insert (   4059  1114  1114  13 2056 ));
-DATA(insert (   4059  1114  1114  14 2057 ));
 DATA(insert (   4059  1114  1184  1  3383 ));
 DATA(insert (   4059  1114  1184  2  3384 ));
 DATA(insert (   4059  1114  1184  3  3385 ));
 DATA(insert (   4059  1114  1184  4  3386 ));
-DATA(insert (   4059  1114  1184  11 2520 ));
-DATA(insert (   4059  1114  1184  12 2521 ));
-DATA(insert (   4059  1114  1184  13 2524 ));
-DATA(insert (   4059  1114  1184  14 2523 ));
 DATA(insert (   4059  1114  1082  1  3383 ));
 DATA(insert (   4059  1114  1082  2  3384 ));
 DATA(insert (   4059  1114  1082  3  3385 ));
 DATA(insert (   4059  1114  1082  4  3386 ));
-DATA(insert (   4059  1114  1082  11 2364 ));
-DATA(insert (   4059  1114  1082  12 2365 ));
-DATA(insert (   4059  1114  1082  13 2368 ));
-DATA(insert (   4059  1114  1082  14 2367 ));
 
 DATA(insert (   4059  1184  1184  1  3383 ));
 DATA(insert (   4059  1184  1184  2  3384 ));
 DATA(insert (   4059  1184  1184  3  3385 ));
 DATA(insert (   4059  1184  1184  4  3386 ));
-DATA(insert (   4059  1184  1184  11 1154 ));
-DATA(insert (   4059  1184  1184  12 1155 ));
-DATA(insert (   4059  1184  1184  13 1156 ));
-DATA(insert (   4059  1184  1184  14 1157 ));
 DATA(insert (   4059  1184  1114  1  3383 ));
 DATA(insert (   4059  1184  1114  2  3384 ));
 DATA(insert (   4059  1184  1114  3  3385 ));
 DATA(insert (   4059  1184  1114  4  3386 ));
-DATA(insert (   4059  1184  1114  11 2527 ));
-DATA(insert (   4059  1184  1114  12 2528 ));
-DATA(insert (   4059  1184  1114  13 2531 ));
-DATA(insert (   4059  1184  1114  14 2530 ));
 DATA(insert (   4059  1184  1082  1  3383 ));
 DATA(insert (   4059  1184  1082  2  3384 ));
 DATA(insert (   4059  1184  1082  3  3385 ));
 DATA(insert (   4059  1184  1082  4  3386 ));
-DATA(insert (   4059  1184  1082  11 2377 ));
-DATA(insert (   4059  1184  1082  12 2378 ));
-DATA(insert (   4059  1184  1082  13 2381 ));
-DATA(insert (   4059  1184  1082  14 2379 ));
 
 DATA(insert (   4059  1082  1082  1  3383 ));
 DATA(insert (   4059  1082  1082  2  3384 ));
 DATA(insert (   4059  1082  1082  3  3385 ));
 DATA(insert (   4059  1082  1082  4  3386 ));
-DATA(insert (   4059  1082  1082  11 1087 ));
-DATA(insert (   4059  1082  1082  12 1088 ));
-DATA(insert (   4059  1082  1082  13 1090 ));
-DATA(insert (   4059  1082  1082  14 1089 ));
 DATA(insert (   4059  1082  1114  1  3383 ));
 DATA(insert (   4059  1082  1114  2  3384 ));
 DATA(insert (   4059  1082  1114  3  3385 ));
 DATA(insert (   4059  1082  1114  4  3386 ));
-DATA(insert (   4059  1082  1114  11 2338 ));
-DATA(insert (   4059  1082  1114  12 2339 ));
-DATA(insert (   4059  1082  1114  13 2342 ));
-DATA(insert (   4059  1082  1114  14 2341 ));
 DATA(insert (   4059  1082  1184  1  3383 ));
 DATA(insert (   4059  1082  1184  2  3384 ));
 DATA(insert (   4059  1082  1184  3  3385 ));
 DATA(insert (   4059  1082  1184  4  3386 ));
-DATA(insert (   4059  1082  1184  11 2351 ));
-DATA(insert (   4059  1082  1184  12 2352 ));
-DATA(insert (   4059  1082  1184  13 2354 ));
-DATA(insert (   4059  1082  1184  14 2353 ));
 
 /* minmax interval */
 DATA(insert (   4078  1186  1186  1  3383 ));
 DATA(insert (   4078  1186  1186  2  3384 ));
 DATA(insert (   4078  1186  1186  3  3385 ));
 DATA(insert (   4078  1186  1186  4  3386 ));
-DATA(insert (   4078  1186  1186  11 1164 ));
-DATA(insert (   4078  1186  1186  12 1165 ));
-DATA(insert (   4078  1186  1186  13 1166 ));
-DATA(insert (   4078  1186  1186  14 1167 ));
 /* minmax time with time zone */
 DATA(insert (   4058  1266  1266  1  3383 ));
 DATA(insert (   4058  1266  1266  2  3384 ));
 DATA(insert (   4058  1266  1266  3  3385 ));
 DATA(insert (   4058  1266  1266  4  3386 ));
-DATA(insert (   4058  1266  1266  11 1354 ));
-DATA(insert (   4058  1266  1266  12 1355 ));
-DATA(insert (   4058  1266  1266  13 1356 ));
-DATA(insert (   4058  1266  1266  14 1357 ));
 /* minmax bit */
 DATA(insert (   4079  1560  1560  1  3383 ));
 DATA(insert (   4079  1560  1560  2  3384 ));
 DATA(insert (   4079  1560  1560  3  3385 ));
 DATA(insert (   4079  1560  1560  4  3386 ));
-DATA(insert (   4079  1560  1560  11 1595 ));
-DATA(insert (   4079  1560  1560  12 1594 ));
-DATA(insert (   4079  1560  1560  13 1592 ));
-DATA(insert (   4079  1560  1560  14 1593 ));
 /* minmax bit varying */
 DATA(insert (   4080  1562  1562  1  3383 ));
 DATA(insert (   4080  1562  1562  2  3384 ));
 DATA(insert (   4080  1562  1562  3  3385 ));
 DATA(insert (   4080  1562  1562  4  3386 ));
-DATA(insert (   4080  1562  1562  11 1671 ));
-DATA(insert (   4080  1562  1562  12 1670 ));
-DATA(insert (   4080  1562  1562  13 1668 ));
-DATA(insert (   4080  1562  1562  14 1669 ));
 /* minmax numeric */
 DATA(insert (   4055  1700  1700  1  3383 ));
 DATA(insert (   4055  1700  1700  2  3384 ));
 DATA(insert (   4055  1700  1700  3  3385 ));
 DATA(insert (   4055  1700  1700  4  3386 ));
-DATA(insert (   4055  1700  1700  11 1722 ));
-DATA(insert (   4055  1700  1700  12 1723 ));
-DATA(insert (   4055  1700  1700  13 1721 ));
-DATA(insert (   4055  1700  1700  14 1720 ));
 /* minmax uuid */
 DATA(insert (   4081  2950  2950  1  3383 ));
 DATA(insert (   4081  2950  2950  2  3384 ));
 DATA(insert (   4081  2950  2950  3  3385 ));
 DATA(insert (   4081  2950  2950  4  3386 ));
-DATA(insert (   4081  2950  2950  11 2954 ));
-DATA(insert (   4081  2950  2950  12 2955 ));
-DATA(insert (   4081  2950  2950  13 2957 ));
-DATA(insert (   4081  2950  2950  14 2958 ));
 /* inclusion range types */
 DATA(insert (   4103  3831  3831  1  4105 ));
 DATA(insert (   4103  3831  3831  2  4106 ));
 DATA(insert (   4103  3831  3831  3  4107 ));
 DATA(insert (   4103  3831  3831  4  4108 ));
 DATA(insert (   4103  3831  3831  11 4057 ));
 DATA(insert (   4103  3831  3831  14 3859 ));
 DATA(insert (   4103  3831  3831  15 3850 ));
 /* minmax pg_lsn */
 DATA(insert (   4082  3220  3220  1  3383 ));
 DATA(insert (   4082  3220  3220  2  3384 ));
 DATA(insert (   4082  3220  3220  3  3385 ));
 DATA(insert (   4082  3220  3220  4  3386 ));
-DATA(insert (   4082  3220  3220  11 3231 ));
-DATA(insert (   4082  3220  3220  12 3232 ));
-DATA(insert (   4082  3220  3220  13 3234 ));
-DATA(insert (   4082  3220  3220  14 3235 ));
 /* inclusion box */
 DATA(insert (   4104   603   603  1  4105 ));
 DATA(insert (   4104   603   603  2  4106 ));
 DATA(insert (   4104   603   603  3  4107 ));
 DATA(insert (   4104   603   603  4  4108 ));
 DATA(insert (   4104   603   603  11 4067 ));
 DATA(insert (   4104   603   603  14  187 ));
 /* inclusion point */
 DATA(insert (   4104   600   600  1  4105 ));
 DATA(insert (   4104   600   600  2  4106 ));
diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h
index 92f8d89..145f0bd 100644
--- a/src/include/catalog/pg_opclass.h
+++ b/src/include/catalog/pg_opclass.h
@@ -231,46 +231,46 @@ DATA(insert (	4000	range_ops			PGNSP PGUID 3474  3831 t 0 ));
 DATA(insert (	4000	quad_point_ops		PGNSP PGUID 4015  600 t 0 ));
 DATA(insert (	4000	kd_point_ops		PGNSP PGUID 4016  600 f 0 ));
 DATA(insert (	4000	text_ops			PGNSP PGUID 4017  25 t 0 ));
 DATA(insert (	403		jsonb_ops			PGNSP PGUID 4033  3802 t 0 ));
 DATA(insert (	405		jsonb_ops			PGNSP PGUID 4034  3802 t 0 ));
 DATA(insert (	2742	jsonb_ops			PGNSP PGUID 4036  3802 t 25 ));
 DATA(insert (	2742	jsonb_path_ops		PGNSP PGUID 4037  3802 f 23 ));
 
 /* BRIN operator classes */
 /* no brin opclass for bool */
-DATA(insert (	3580	bytea_minmax_ops		PGNSP PGUID 4064    17 t 0 ));
-DATA(insert (	3580	char_minmax_ops			PGNSP PGUID 4062    18 t 0 ));
-DATA(insert (	3580	name_minmax_ops			PGNSP PGUID 4065    19 t 0 ));
-DATA(insert (	3580	int8_minmax_ops			PGNSP PGUID 4054    20 t 0 ));
-DATA(insert (	3580	int2_minmax_ops			PGNSP PGUID 4054    21 t 0 ));
-DATA(insert (	3580	int4_minmax_ops			PGNSP PGUID 4054    23 t 0 ));
-DATA(insert (	3580	text_minmax_ops			PGNSP PGUID 4056    25 t 0 ));
-DATA(insert (	3580	oid_minmax_ops			PGNSP PGUID 4068    26 t 0 ));
-DATA(insert (	3580	tid_minmax_ops			PGNSP PGUID 4069    27 t 0 ));
-DATA(insert (	3580	float4_minmax_ops		PGNSP PGUID 4070   700 t 0 ));
-DATA(insert (	3580	float8_minmax_ops		PGNSP PGUID 4070   701 t 0 ));
-DATA(insert (	3580	abstime_minmax_ops		PGNSP PGUID 4072   702 t 0 ));
-DATA(insert (	3580	reltime_minmax_ops		PGNSP PGUID 4073   703 t 0 ));
-DATA(insert (	3580	macaddr_minmax_ops		PGNSP PGUID 4074   829 t 0 ));
-DATA(insert (	3580	inet_minmax_ops			PGNSP PGUID 4075   869 f 0 ));
+DATA(insert (	3580	bytea_minmax_ops		PGNSP PGUID 4064    17 t 17 ));
+DATA(insert (	3580	char_minmax_ops			PGNSP PGUID 4062    18 t 18 ));
+DATA(insert (	3580	name_minmax_ops			PGNSP PGUID 4065    19 t 19 ));
+DATA(insert (	3580	int8_minmax_ops			PGNSP PGUID 4054    20 t 20 ));
+DATA(insert (	3580	int2_minmax_ops			PGNSP PGUID 4054    21 t 21 ));
+DATA(insert (	3580	int4_minmax_ops			PGNSP PGUID 4054    23 t 23 ));
+DATA(insert (	3580	text_minmax_ops			PGNSP PGUID 4056    25 t 25 ));
+DATA(insert (	3580	oid_minmax_ops			PGNSP PGUID 4068    26 t 26 ));
+DATA(insert (	3580	tid_minmax_ops			PGNSP PGUID 4069    27 t 27 ));
+DATA(insert (	3580	float4_minmax_ops		PGNSP PGUID 4070   700 t 700 ));
+DATA(insert (	3580	float8_minmax_ops		PGNSP PGUID 4070   701 t 701 ));
+DATA(insert (	3580	abstime_minmax_ops		PGNSP PGUID 4072   702 t 702 ));
+DATA(insert (	3580	reltime_minmax_ops		PGNSP PGUID 4073   703 t 703 ));
+DATA(insert (	3580	macaddr_minmax_ops		PGNSP PGUID 4074   829 t 829 ));
+DATA(insert (	3580	inet_minmax_ops			PGNSP PGUID 4075   869 f 869 ));
 DATA(insert (	3580	inet_inclusion_ops		PGNSP PGUID 4102   869 t 869 ));
-DATA(insert (	3580	bpchar_minmax_ops		PGNSP PGUID 4076  1042 t 0 ));
-DATA(insert (	3580	time_minmax_ops			PGNSP PGUID 4077  1083 t 0 ));
-DATA(insert (	3580	date_minmax_ops			PGNSP PGUID 4059  1082 t 0 ));
-DATA(insert (	3580	timestamp_minmax_ops	PGNSP PGUID 4059  1114 t 0 ));
-DATA(insert (	3580	timestamptz_minmax_ops	PGNSP PGUID 4059  1184 t 0 ));
-DATA(insert (	3580	interval_minmax_ops		PGNSP PGUID 4078  1186 t 0 ));
-DATA(insert (	3580	timetz_minmax_ops		PGNSP PGUID 4058  1266 t 0 ));
-DATA(insert (	3580	bit_minmax_ops			PGNSP PGUID 4079  1560 t 0 ));
-DATA(insert (	3580	varbit_minmax_ops		PGNSP PGUID 4080  1562 t 0 ));
-DATA(insert (	3580	numeric_minmax_ops		PGNSP PGUID 4055  1700 t 0 ));
+DATA(insert (	3580	bpchar_minmax_ops		PGNSP PGUID 4076  1042 t 1042 ));
+DATA(insert (	3580	time_minmax_ops			PGNSP PGUID 4077  1083 t 1083 ));
+DATA(insert (	3580	date_minmax_ops			PGNSP PGUID 4059  1082 t 1082 ));
+DATA(insert (	3580	timestamp_minmax_ops	PGNSP PGUID 4059  1114 t 1114 ));
+DATA(insert (	3580	timestamptz_minmax_ops	PGNSP PGUID 4059  1184 t 1184 ));
+DATA(insert (	3580	interval_minmax_ops		PGNSP PGUID 4078  1186 t 1186 ));
+DATA(insert (	3580	timetz_minmax_ops		PGNSP PGUID 4058  1266 t 1266 ));
+DATA(insert (	3580	bit_minmax_ops			PGNSP PGUID 4079  1560 t 1560 ));
+DATA(insert (	3580	varbit_minmax_ops		PGNSP PGUID 4080  1562 t 1562 ));
+DATA(insert (	3580	numeric_minmax_ops		PGNSP PGUID 4055  1700 t 1700 ));
 /* no brin opclass for record, anyarray */
-DATA(insert (	3580	uuid_minmax_ops			PGNSP PGUID 4081  2950 t 0 ));
+DATA(insert (	3580	uuid_minmax_ops			PGNSP PGUID 4081  2950 t 2950 ));
 DATA(insert (	3580	range_inclusion_ops		PGNSP PGUID 4103  3831 t 3831 ));
-DATA(insert (	3580	pg_lsn_minmax_ops		PGNSP PGUID 4082  3220 t 0 ));
+DATA(insert (	3580	pg_lsn_minmax_ops		PGNSP PGUID 4082  3220 t 3220 ));
 /* no brin opclass for enum, tsvector, tsquery, jsonb */
 DATA(insert (	3580	box_inclusion_ops		PGNSP PGUID 4104   603 t 603 ));
 DATA(insert (	3580	point_box_inclusion_ops	PGNSP PGUID 4104   600 t 603 ));
 /* no brin opclass for the geometric types except box and point */
 
 #endif   /* PG_OPCLASS_H */
-- 
2.3.2

