aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/array_typanalyze.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/array_typanalyze.c')
-rw-r--r--src/backend/utils/adt/array_typanalyze.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/backend/utils/adt/array_typanalyze.c b/src/backend/utils/adt/array_typanalyze.c
index 92e38b870f5..c4a1fef3a2f 100644
--- a/src/backend/utils/adt/array_typanalyze.c
+++ b/src/backend/utils/adt/array_typanalyze.c
@@ -15,7 +15,6 @@
#include "postgres.h"
#include "access/tuptoaster.h"
-#include "catalog/pg_collation.h"
#include "commands/vacuum.h"
#include "utils/array.h"
#include "utils/builtins.h"
@@ -39,6 +38,7 @@ typedef struct
/* Information about array element type */
Oid type_id; /* element type's OID */
Oid eq_opr; /* default equality operator's OID */
+ Oid coll_id; /* collation to use */
bool typbyval; /* physical properties of element type */
int16 typlen;
char typalign;
@@ -135,6 +135,7 @@ array_typanalyze(PG_FUNCTION_ARGS)
extra_data = (ArrayAnalyzeExtraData *) palloc(sizeof(ArrayAnalyzeExtraData));
extra_data->type_id = typentry->type_id;
extra_data->eq_opr = typentry->eq_opr;
+ extra_data->coll_id = stats->attrcollid; /* collation we should use */
extra_data->typbyval = typentry->typbyval;
extra_data->typlen = typentry->typlen;
extra_data->typalign = typentry->typalign;
@@ -560,6 +561,7 @@ compute_array_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
stats->stakind[slot_idx] = STATISTIC_KIND_MCELEM;
stats->staop[slot_idx] = extra_data->eq_opr;
+ stats->stacoll[slot_idx] = extra_data->coll_id;
stats->stanumbers[slot_idx] = mcelem_freqs;
/* See above comment about extra stanumber entries */
stats->numnumbers[slot_idx] = num_mcelem + 3;
@@ -661,6 +663,7 @@ compute_array_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
stats->stakind[slot_idx] = STATISTIC_KIND_DECHIST;
stats->staop[slot_idx] = extra_data->eq_opr;
+ stats->stacoll[slot_idx] = extra_data->coll_id;
stats->stanumbers[slot_idx] = hist;
stats->numnumbers[slot_idx] = num_hist + 1;
slot_idx++;
@@ -703,7 +706,7 @@ prune_element_hashtable(HTAB *elements_tab, int b_current)
/*
* Hash function for elements.
*
- * We use the element type's default hash opclass, and the default collation
+ * We use the element type's default hash opclass, and the column collation
* if the type is collation-sensitive.
*/
static uint32
@@ -712,7 +715,9 @@ element_hash(const void *key, Size keysize)
Datum d = *((const Datum *) key);
Datum h;
- h = FunctionCall1Coll(array_extra_data->hash, DEFAULT_COLLATION_OID, d);
+ h = FunctionCall1Coll(array_extra_data->hash,
+ array_extra_data->coll_id,
+ d);
return DatumGetUInt32(h);
}
@@ -729,7 +734,7 @@ element_match(const void *key1, const void *key2, Size keysize)
/*
* Comparison function for elements.
*
- * We use the element type's default btree opclass, and the default collation
+ * We use the element type's default btree opclass, and the column collation
* if the type is collation-sensitive.
*
* XXX consider using SortSupport infrastructure
@@ -741,7 +746,9 @@ element_compare(const void *key1, const void *key2)
Datum d2 = *((const Datum *) key2);
Datum c;
- c = FunctionCall2Coll(array_extra_data->cmp, DEFAULT_COLLATION_OID, d1, d2);
+ c = FunctionCall2Coll(array_extra_data->cmp,
+ array_extra_data->coll_id,
+ d1, d2);
return DatumGetInt32(c);
}