diff options
Diffstat (limited to 'src/backend/statistics')
| -rw-r--r-- | src/backend/statistics/dependencies.c | 5 | ||||
| -rw-r--r-- | src/backend/statistics/extended_stats.c | 8 | ||||
| -rw-r--r-- | src/backend/statistics/mvdistinct.c | 5 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/backend/statistics/dependencies.c b/src/backend/statistics/dependencies.c index 140783cfb3a..58d0df20f69 100644 --- a/src/backend/statistics/dependencies.c +++ b/src/backend/statistics/dependencies.c @@ -252,6 +252,9 @@ dependency_degree(int numrows, HeapTuple *rows, int k, AttrNumber *dependency, * (b) split the data into groups by first (k-1) columns * * (c) for each group count different values in the last column + * + * We use the column data types' default sort operators and collations; + * perhaps at some point it'd be worth using column-specific collations? */ /* prepare the sort function for the first dimension, and SortItem array */ @@ -266,7 +269,7 @@ dependency_degree(int numrows, HeapTuple *rows, int k, AttrNumber *dependency, colstat->attrtypid); /* prepare the sort function for this dimension */ - multi_sort_add_dimension(mss, i, type->lt_opr); + multi_sort_add_dimension(mss, i, type->lt_opr, type->typcollation); /* accumulate all the data for both columns into an array and sort it */ for (j = 0; j < numrows; j++) diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index 5dcee95250a..082f0506da0 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -363,18 +363,18 @@ multi_sort_init(int ndims) } /* - * Prepare sort support info using the given sort operator + * Prepare sort support info using the given sort operator and collation * at the position 'sortdim' */ void -multi_sort_add_dimension(MultiSortSupport mss, int sortdim, Oid oper) +multi_sort_add_dimension(MultiSortSupport mss, int sortdim, + Oid oper, Oid collation) { SortSupport ssup = &mss->ssup[sortdim]; ssup->ssup_cxt = CurrentMemoryContext; - ssup->ssup_collation = DEFAULT_COLLATION_OID; + ssup->ssup_collation = collation; ssup->ssup_nulls_first = false; - ssup->ssup_cxt = CurrentMemoryContext; PrepareSortSupportFromOrderingOp(oper, ssup); } diff --git a/src/backend/statistics/mvdistinct.c b/src/backend/statistics/mvdistinct.c index 593c2198396..3071e42d864 100644 --- a/src/backend/statistics/mvdistinct.c +++ b/src/backend/statistics/mvdistinct.c @@ -454,6 +454,9 @@ ndistinct_for_combination(double totalrows, int numrows, HeapTuple *rows, /* * For each dimension, set up sort-support and fill in the values from the * sample data. + * + * We use the column data types' default sort operators and collations; + * perhaps at some point it'd be worth using column-specific collations? */ for (i = 0; i < k; i++) { @@ -466,7 +469,7 @@ ndistinct_for_combination(double totalrows, int numrows, HeapTuple *rows, colstat->attrtypid); /* prepare the sort function for this dimension */ - multi_sort_add_dimension(mss, i, type->lt_opr); + multi_sort_add_dimension(mss, i, type->lt_opr, type->typcollation); /* accumulate all the data for this dimension into the arrays */ for (j = 0; j < numrows; j++) |
