mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Make all comparisons done for/with statistics use the default collation.
While this will give wrong answers when estimating selectivity for a comparison operator that's using a non-default collation, the estimation error probably won't be large; and anyway the former approach created estimation errors of its own by trying to use a histogram that might have been computed with some other collation. So we'll adopt this simplified approach for now and perhaps improve it sometime in the future. This patch incorporates changes from Andres Freund to make sure that selfuncs.c passes a valid collation OID to any datatype-specific function it calls, in case that function wants collation information. Said OID will now always be DEFAULT_COLLATION_OID, but at least we won't get errors.
This commit is contained in:
@@ -50,6 +50,10 @@
|
||||
* the information to be stored in a pg_statistic row for the column. Be
|
||||
* careful to allocate any pointed-to data in anl_context, which will NOT
|
||||
* be CurrentMemoryContext when compute_stats is called.
|
||||
*
|
||||
* Note: for the moment, all comparisons done for statistical purposes
|
||||
* should use the database's default collation (DEFAULT_COLLATION_OID).
|
||||
* This might change in some future release.
|
||||
*----------
|
||||
*/
|
||||
typedef struct VacAttrStats *VacAttrStatsP;
|
||||
@@ -66,13 +70,12 @@ typedef struct VacAttrStats
|
||||
* Note: do not assume that the data being analyzed has the same datatype
|
||||
* shown in attr, ie do not trust attr->atttypid, attlen, etc. This is
|
||||
* because some index opclasses store a different type than the underlying
|
||||
* column/expression. Instead use attrtypid, attrtypmod, attrcollation, and attrtype for
|
||||
* column/expression. Instead use attrtypid, attrtypmod, and attrtype for
|
||||
* information about the datatype being fed to the typanalyze function.
|
||||
*/
|
||||
Form_pg_attribute attr; /* copy of pg_attribute row for column */
|
||||
Oid attrtypid; /* type of data being analyzed */
|
||||
int32 attrtypmod; /* typmod of data being analyzed */
|
||||
Oid attrcollation; /* collation of the data being analyzed */
|
||||
Form_pg_type attrtype; /* copy of pg_type row for attrtypid */
|
||||
MemoryContext anl_context; /* where to save long-lived data */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user