aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/spgist/spgutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/spgist/spgutils.c')
-rw-r--r--src/backend/access/spgist/spgutils.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c
index 03a9cd36e63..3235d215e1a 100644
--- a/src/backend/access/spgist/spgutils.c
+++ b/src/backend/access/spgist/spgutils.c
@@ -25,6 +25,7 @@
#include "catalog/pg_amop.h"
#include "commands/vacuum.h"
#include "nodes/nodeFuncs.h"
+#include "parser/parse_coerce.h"
#include "storage/bufmgr.h"
#include "storage/indexfsm.h"
#include "storage/lmgr.h"
@@ -218,9 +219,20 @@ spgGetCache(Relation index)
* correctly, so believe leafType if it's given.)
*/
if (!OidIsValid(cache->config.leafType))
+ {
cache->config.leafType =
TupleDescAttr(RelationGetDescr(index), spgKeyColumn)->atttypid;
+ /*
+ * If index column type is binary-coercible to atttype (for
+ * example, it's a domain over atttype), treat it as plain atttype
+ * to avoid thinking we need to compress.
+ */
+ if (cache->config.leafType != atttype &&
+ IsBinaryCoercible(cache->config.leafType, atttype))
+ cache->config.leafType = atttype;
+ }
+
/* Get the information we need about each relevant datatype */
fillTypeDesc(&cache->attType, atttype);