summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/gin/ginutil.c32
-rw-r--r--src/backend/access/gin/ginvalidate.c2
-rw-r--r--src/backend/catalog/index.c19
-rw-r--r--src/include/catalog/catversion.h2
-rw-r--r--src/include/catalog/pg_amop.h3
-rw-r--r--src/include/catalog/pg_amproc.h154
-rw-r--r--src/include/catalog/pg_opclass.h31
7 files changed, 55 insertions, 188 deletions
diff --git a/src/backend/access/gin/ginutil.c b/src/backend/access/gin/ginutil.c
index d9146488c44..f07eedc0fa3 100644
--- a/src/backend/access/gin/ginutil.c
+++ b/src/backend/access/gin/ginutil.c
@@ -22,7 +22,9 @@
#include "miscadmin.h"
#include "storage/indexfsm.h"
#include "storage/lmgr.h"
+#include "utils/builtins.h"
#include "utils/index_selfuncs.h"
+#include "utils/typcache.h"
/*
@@ -105,9 +107,33 @@ initGinState(GinState *state, Relation index)
origTupdesc->attrs[i]->attcollation);
}
- fmgr_info_copy(&(state->compareFn[i]),
- index_getprocinfo(index, i + 1, GIN_COMPARE_PROC),
- CurrentMemoryContext);
+ /*
+ * If the compare proc isn't specified in the opclass definition, look
+ * up the index key type's default btree comparator.
+ */
+ if (index_getprocid(index, i + 1, GIN_COMPARE_PROC) != InvalidOid)
+ {
+ fmgr_info_copy(&(state->compareFn[i]),
+ index_getprocinfo(index, i + 1, GIN_COMPARE_PROC),
+ CurrentMemoryContext);
+ }
+ else
+ {
+ TypeCacheEntry *typentry;
+
+ typentry = lookup_type_cache(origTupdesc->attrs[i]->atttypid,
+ TYPECACHE_CMP_PROC_FINFO);
+ if (!OidIsValid(typentry->cmp_proc_finfo.fn_oid))
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_FUNCTION),
+ errmsg("could not identify a comparison function for type %s",
+ format_type_be(origTupdesc->attrs[i]->atttypid))));
+ fmgr_info_copy(&(state->compareFn[i]),
+ &(typentry->cmp_proc_finfo),
+ CurrentMemoryContext);
+ }
+
+ /* Opclass must always provide extract procs */
fmgr_info_copy(&(state->extractValueFn[i]),
index_getprocinfo(index, i + 1, GIN_EXTRACTVALUE_PROC),
CurrentMemoryContext);
diff --git a/src/backend/access/gin/ginvalidate.c b/src/backend/access/gin/ginvalidate.c
index 032508387d1..02196e0f124 100644
--- a/src/backend/access/gin/ginvalidate.c
+++ b/src/backend/access/gin/ginvalidate.c
@@ -237,7 +237,7 @@ ginvalidate(Oid opclassoid)
if (opclassgroup &&
(opclassgroup->functionset & (((uint64) 1) << i)) != 0)
continue; /* got it */
- if (i == GIN_COMPARE_PARTIAL_PROC)
+ if (i == GIN_COMPARE_PROC || i == GIN_COMPARE_PARTIAL_PROC)
continue; /* optional method */
if (i == GIN_CONSISTENT_PROC || i == GIN_TRICONSISTENT_PROC)
continue; /* don't need both, see check below loop */
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index b0b43cf02d8..08b646d8f33 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -437,11 +437,28 @@ ConstructTupleDescriptor(Relation heapRelation,
keyType = opclassTup->opckeytype;
else
keyType = amroutine->amkeytype;
+
+ /*
+ * If keytype is specified as ANYELEMENT, and opcintype is ANYARRAY,
+ * then the attribute type must be an array (else it'd not have
+ * matched this opclass); use its element type.
+ */
+ if (keyType == ANYELEMENTOID && opclassTup->opcintype == ANYARRAYOID)
+ {
+ keyType = get_base_element_type(to->atttypid);
+ if (!OidIsValid(keyType))
+ elog(ERROR, "could not get element type of array type %u",
+ to->atttypid);
+ }
+
ReleaseSysCache(tuple);
+ /*
+ * If a key type different from the heap value is specified, update
+ * the type-related fields in the index tupdesc.
+ */
if (OidIsValid(keyType) && keyType != to->atttypid)
{
- /* index value and heap value have different types */
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(keyType));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for type %u", keyType);
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index ef691c5721f..3fdd0d61295 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201609131
+#define CATALOG_VERSION_NO 201609261
#endif
diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h
index 917ed46b71a..15b629029fe 100644
--- a/src/include/catalog/pg_amop.h
+++ b/src/include/catalog/pg_amop.h
@@ -673,8 +673,7 @@ DATA(insert ( 2595 718 718 14 s 2864 783 0 ));
DATA(insert ( 2595 718 600 15 o 3291 783 1970 ));
/*
- * gin array_ops (these anyarray operators are used with all the opclasses
- * of the family)
+ * gin array_ops
*/
DATA(insert ( 2745 2277 2277 1 s 2750 2742 0 ));
DATA(insert ( 2745 2277 2277 2 s 2751 2742 0 ));
diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h
index 0cbb4163920..1b654d5be48 100644
--- a/src/include/catalog/pg_amproc.h
+++ b/src/include/catalog/pg_amproc.h
@@ -255,156 +255,10 @@ DATA(insert ( 3550 869 869 9 3573 ));
/* gin */
-DATA(insert ( 2745 1007 1007 1 351 ));
-DATA(insert ( 2745 1007 1007 2 2743 ));
-DATA(insert ( 2745 1007 1007 3 2774 ));
-DATA(insert ( 2745 1007 1007 4 2744 ));
-DATA(insert ( 2745 1007 1007 6 3920 ));
-DATA(insert ( 2745 1009 1009 1 360 ));
-DATA(insert ( 2745 1009 1009 2 2743 ));
-DATA(insert ( 2745 1009 1009 3 2774 ));
-DATA(insert ( 2745 1009 1009 4 2744 ));
-DATA(insert ( 2745 1009 1009 6 3920 ));
-DATA(insert ( 2745 1015 1015 1 360 ));
-DATA(insert ( 2745 1015 1015 2 2743 ));
-DATA(insert ( 2745 1015 1015 3 2774 ));
-DATA(insert ( 2745 1015 1015 4 2744 ));
-DATA(insert ( 2745 1015 1015 6 3920 ));
-DATA(insert ( 2745 1023 1023 1 357 ));
-DATA(insert ( 2745 1023 1023 2 2743 ));
-DATA(insert ( 2745 1023 1023 3 2774 ));
-DATA(insert ( 2745 1023 1023 4 2744 ));
-DATA(insert ( 2745 1023 1023 6 3920 ));
-DATA(insert ( 2745 1561 1561 1 1596 ));
-DATA(insert ( 2745 1561 1561 2 2743 ));
-DATA(insert ( 2745 1561 1561 3 2774 ));
-DATA(insert ( 2745 1561 1561 4 2744 ));
-DATA(insert ( 2745 1561 1561 6 3920 ));
-DATA(insert ( 2745 1000 1000 1 1693 ));
-DATA(insert ( 2745 1000 1000 2 2743 ));
-DATA(insert ( 2745 1000 1000 3 2774 ));
-DATA(insert ( 2745 1000 1000 4 2744 ));
-DATA(insert ( 2745 1000 1000 6 3920 ));
-DATA(insert ( 2745 1014 1014 1 1078 ));
-DATA(insert ( 2745 1014 1014 2 2743 ));
-DATA(insert ( 2745 1014 1014 3 2774 ));
-DATA(insert ( 2745 1014 1014 4 2744 ));
-DATA(insert ( 2745 1014 1014 6 3920 ));
-DATA(insert ( 2745 1001 1001 1 1954 ));
-DATA(insert ( 2745 1001 1001 2 2743 ));
-DATA(insert ( 2745 1001 1001 3 2774 ));
-DATA(insert ( 2745 1001 1001 4 2744 ));
-DATA(insert ( 2745 1001 1001 6 3920 ));
-DATA(insert ( 2745 1002 1002 1 358 ));
-DATA(insert ( 2745 1002 1002 2 2743 ));
-DATA(insert ( 2745 1002 1002 3 2774 ));
-DATA(insert ( 2745 1002 1002 4 2744 ));
-DATA(insert ( 2745 1002 1002 6 3920 ));
-DATA(insert ( 2745 1182 1182 1 1092 ));
-DATA(insert ( 2745 1182 1182 2 2743 ));
-DATA(insert ( 2745 1182 1182 3 2774 ));
-DATA(insert ( 2745 1182 1182 4 2744 ));
-DATA(insert ( 2745 1182 1182 6 3920 ));
-DATA(insert ( 2745 1021 1021 1 354 ));
-DATA(insert ( 2745 1021 1021 2 2743 ));
-DATA(insert ( 2745 1021 1021 3 2774 ));
-DATA(insert ( 2745 1021 1021 4 2744 ));
-DATA(insert ( 2745 1021 1021 6 3920 ));
-DATA(insert ( 2745 1022 1022 1 355 ));
-DATA(insert ( 2745 1022 1022 2 2743 ));
-DATA(insert ( 2745 1022 1022 3 2774 ));
-DATA(insert ( 2745 1022 1022 4 2744 ));
-DATA(insert ( 2745 1022 1022 6 3920 ));
-DATA(insert ( 2745 1041 1041 1 926 ));
-DATA(insert ( 2745 1041 1041 2 2743 ));
-DATA(insert ( 2745 1041 1041 3 2774 ));
-DATA(insert ( 2745 1041 1041 4 2744 ));
-DATA(insert ( 2745 1041 1041 6 3920 ));
-DATA(insert ( 2745 651 651 1 926 ));
-DATA(insert ( 2745 651 651 2 2743 ));
-DATA(insert ( 2745 651 651 3 2774 ));
-DATA(insert ( 2745 651 651 4 2744 ));
-DATA(insert ( 2745 651 651 6 3920 ));
-DATA(insert ( 2745 1005 1005 1 350 ));
-DATA(insert ( 2745 1005 1005 2 2743 ));
-DATA(insert ( 2745 1005 1005 3 2774 ));
-DATA(insert ( 2745 1005 1005 4 2744 ));
-DATA(insert ( 2745 1005 1005 6 3920 ));
-DATA(insert ( 2745 1016 1016 1 842 ));
-DATA(insert ( 2745 1016 1016 2 2743 ));
-DATA(insert ( 2745 1016 1016 3 2774 ));
-DATA(insert ( 2745 1016 1016 4 2744 ));
-DATA(insert ( 2745 1016 1016 6 3920 ));
-DATA(insert ( 2745 1187 1187 1 1315 ));
-DATA(insert ( 2745 1187 1187 2 2743 ));
-DATA(insert ( 2745 1187 1187 3 2774 ));
-DATA(insert ( 2745 1187 1187 4 2744 ));
-DATA(insert ( 2745 1187 1187 6 3920 ));
-DATA(insert ( 2745 1040 1040 1 836 ));
-DATA(insert ( 2745 1040 1040 2 2743 ));
-DATA(insert ( 2745 1040 1040 3 2774 ));
-DATA(insert ( 2745 1040 1040 4 2744 ));
-DATA(insert ( 2745 1040 1040 6 3920 ));
-DATA(insert ( 2745 1003 1003 1 359 ));
-DATA(insert ( 2745 1003 1003 2 2743 ));
-DATA(insert ( 2745 1003 1003 3 2774 ));
-DATA(insert ( 2745 1003 1003 4 2744 ));
-DATA(insert ( 2745 1003 1003 6 3920 ));
-DATA(insert ( 2745 1231 1231 1 1769 ));
-DATA(insert ( 2745 1231 1231 2 2743 ));
-DATA(insert ( 2745 1231 1231 3 2774 ));
-DATA(insert ( 2745 1231 1231 4 2744 ));
-DATA(insert ( 2745 1231 1231 6 3920 ));
-DATA(insert ( 2745 1028 1028 1 356 ));
-DATA(insert ( 2745 1028 1028 2 2743 ));
-DATA(insert ( 2745 1028 1028 3 2774 ));
-DATA(insert ( 2745 1028 1028 4 2744 ));
-DATA(insert ( 2745 1028 1028 6 3920 ));
-DATA(insert ( 2745 1013 1013 1 404 ));
-DATA(insert ( 2745 1013 1013 2 2743 ));
-DATA(insert ( 2745 1013 1013 3 2774 ));
-DATA(insert ( 2745 1013 1013 4 2744 ));
-DATA(insert ( 2745 1013 1013 6 3920 ));
-DATA(insert ( 2745 1183 1183 1 1107 ));
-DATA(insert ( 2745 1183 1183 2 2743 ));
-DATA(insert ( 2745 1183 1183 3 2774 ));
-DATA(insert ( 2745 1183 1183 4 2744 ));
-DATA(insert ( 2745 1183 1183 6 3920 ));
-DATA(insert ( 2745 1185 1185 1 1314 ));
-DATA(insert ( 2745 1185 1185 2 2743 ));
-DATA(insert ( 2745 1185 1185 3 2774 ));
-DATA(insert ( 2745 1185 1185 4 2744 ));
-DATA(insert ( 2745 1185 1185 6 3920 ));
-DATA(insert ( 2745 1270 1270 1 1358 ));
-DATA(insert ( 2745 1270 1270 2 2743 ));
-DATA(insert ( 2745 1270 1270 3 2774 ));
-DATA(insert ( 2745 1270 1270 4 2744 ));
-DATA(insert ( 2745 1270 1270 6 3920 ));
-DATA(insert ( 2745 1563 1563 1 1672 ));
-DATA(insert ( 2745 1563 1563 2 2743 ));
-DATA(insert ( 2745 1563 1563 3 2774 ));
-DATA(insert ( 2745 1563 1563 4 2744 ));
-DATA(insert ( 2745 1563 1563 6 3920 ));
-DATA(insert ( 2745 1115 1115 1 2045 ));
-DATA(insert ( 2745 1115 1115 2 2743 ));
-DATA(insert ( 2745 1115 1115 3 2774 ));
-DATA(insert ( 2745 1115 1115 4 2744 ));
-DATA(insert ( 2745 1115 1115 6 3920 ));
-DATA(insert ( 2745 791 791 1 377 ));
-DATA(insert ( 2745 791 791 2 2743 ));
-DATA(insert ( 2745 791 791 3 2774 ));
-DATA(insert ( 2745 791 791 4 2744 ));
-DATA(insert ( 2745 791 791 6 3920 ));
-DATA(insert ( 2745 1024 1024 1 380 ));
-DATA(insert ( 2745 1024 1024 2 2743 ));
-DATA(insert ( 2745 1024 1024 3 2774 ));
-DATA(insert ( 2745 1024 1024 4 2744 ));
-DATA(insert ( 2745 1024 1024 6 3920 ));
-DATA(insert ( 2745 1025 1025 1 381 ));
-DATA(insert ( 2745 1025 1025 2 2743 ));
-DATA(insert ( 2745 1025 1025 3 2774 ));
-DATA(insert ( 2745 1025 1025 4 2744 ));
-DATA(insert ( 2745 1025 1025 6 3920 ));
+DATA(insert ( 2745 2277 2277 2 2743 ));
+DATA(insert ( 2745 2277 2277 3 2774 ));
+DATA(insert ( 2745 2277 2277 4 2744 ));
+DATA(insert ( 2745 2277 2277 6 3920 ));
DATA(insert ( 3659 3614 3614 1 3724 ));
DATA(insert ( 3659 3614 3614 2 3656 ));
DATA(insert ( 3659 3614 3614 3 3657 ));
diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h
index f40b06112b1..5900cdc5b0b 100644
--- a/src/include/catalog/pg_opclass.h
+++ b/src/include/catalog/pg_opclass.h
@@ -184,36 +184,7 @@ DATA(insert ( 783 box_ops PGNSP PGUID 2593 603 t 0 ));
DATA(insert ( 783 point_ops PGNSP PGUID 1029 600 t 603 ));
DATA(insert ( 783 poly_ops PGNSP PGUID 2594 604 t 603 ));
DATA(insert ( 783 circle_ops PGNSP PGUID 2595 718 t 603 ));
-DATA(insert ( 2742 _int4_ops PGNSP PGUID 2745 1007 t 23 ));
-DATA(insert ( 2742 _text_ops PGNSP PGUID 2745 1009 t 25 ));
-DATA(insert ( 2742 _abstime_ops PGNSP PGUID 2745 1023 t 702 ));
-DATA(insert ( 2742 _bit_ops PGNSP PGUID 2745 1561 t 1560 ));
-DATA(insert ( 2742 _bool_ops PGNSP PGUID 2745 1000 t 16 ));
-DATA(insert ( 2742 _bpchar_ops PGNSP PGUID 2745 1014 t 1042 ));
-DATA(insert ( 2742 _bytea_ops PGNSP PGUID 2745 1001 t 17 ));
-DATA(insert ( 2742 _char_ops PGNSP PGUID 2745 1002 t 18 ));
-DATA(insert ( 2742 _cidr_ops PGNSP PGUID 2745 651 t 650 ));
-DATA(insert ( 2742 _date_ops PGNSP PGUID 2745 1182 t 1082 ));
-DATA(insert ( 2742 _float4_ops PGNSP PGUID 2745 1021 t 700 ));
-DATA(insert ( 2742 _float8_ops PGNSP PGUID 2745 1022 t 701 ));
-DATA(insert ( 2742 _inet_ops PGNSP PGUID 2745 1041 t 869 ));
-DATA(insert ( 2742 _int2_ops PGNSP PGUID 2745 1005 t 21 ));
-DATA(insert ( 2742 _int8_ops PGNSP PGUID 2745 1016 t 20 ));
-DATA(insert ( 2742 _interval_ops PGNSP PGUID 2745 1187 t 1186 ));
-DATA(insert ( 2742 _macaddr_ops PGNSP PGUID 2745 1040 t 829 ));
-DATA(insert ( 2742 _name_ops PGNSP PGUID 2745 1003 t 19 ));
-DATA(insert ( 2742 _numeric_ops PGNSP PGUID 2745 1231 t 1700 ));
-DATA(insert ( 2742 _oid_ops PGNSP PGUID 2745 1028 t 26 ));
-DATA(insert ( 2742 _oidvector_ops PGNSP PGUID 2745 1013 t 30 ));
-DATA(insert ( 2742 _time_ops PGNSP PGUID 2745 1183 t 1083 ));
-DATA(insert ( 2742 _timestamptz_ops PGNSP PGUID 2745 1185 t 1184 ));
-DATA(insert ( 2742 _timetz_ops PGNSP PGUID 2745 1270 t 1266 ));
-DATA(insert ( 2742 _varbit_ops PGNSP PGUID 2745 1563 t 1562 ));
-DATA(insert ( 2742 _varchar_ops PGNSP PGUID 2745 1015 t 1043 ));
-DATA(insert ( 2742 _timestamp_ops PGNSP PGUID 2745 1115 t 1114 ));
-DATA(insert ( 2742 _money_ops PGNSP PGUID 2745 791 t 790 ));
-DATA(insert ( 2742 _reltime_ops PGNSP PGUID 2745 1024 t 703 ));
-DATA(insert ( 2742 _tinterval_ops PGNSP PGUID 2745 1025 t 704 ));
+DATA(insert ( 2742 array_ops PGNSP PGUID 2745 2277 t 2283 ));
DATA(insert ( 403 uuid_ops PGNSP PGUID 2968 2950 t 0 ));
DATA(insert ( 405 uuid_ops PGNSP PGUID 2969 2950 t 0 ));
DATA(insert ( 403 pg_lsn_ops PGNSP PGUID 3253 3220 t 0 ));