summaryrefslogtreecommitdiff
path: root/src/backend/commands/statscmds.c
diff options
context:
space:
mode:
authorTomas Vondra2019-07-18 10:28:16 +0000
committerTomas Vondra2019-07-20 14:37:37 +0000
commita63378a03ec0a53c7c579dfdb3abff57811d8ced (patch)
treefbd093a828f75137a24110c6b289fa5b5423618d /src/backend/commands/statscmds.c
parente38a55ba46bbd2510baccdbaa01298cbca972b88 (diff)
Use column collation for extended statistics
The current extended statistics code was a bit confused which collation to use. When building the statistics, the collations defined as default for the data types were used (since commit 5e0928005). The MCV code was however using the column collations for MCV serialization, and then DEFAULT_COLLATION_OID when computing estimates. So overall the code was using all three possible options, inconsistently. This uses the column colation everywhere - this makes it consistent with what 5e0928005 did for regular stats. We however do not track the collations in a catalog, because we can derive them from column-level information. This may need to change in the future, e.g. after allowing statistics on expressions. Reviewed-by: Tom Lane Discussion: https://postgr.es/m/8736jdhbhc.fsf%40ansel.ydns.eu Backpatch-to: 12
Diffstat (limited to 'src/backend/commands/statscmds.c')
-rw-r--r--src/backend/commands/statscmds.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index cf406f6f96b..34d11c2a980 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -485,6 +485,10 @@ RemoveStatisticsById(Oid statsOid)
*
* For MCV lists that's not the case, as those statistics store the datums
* internally. In this case we simply reset the statistics value to NULL.
+ *
+ * Note that "type change" includes collation change, which means we can rely
+ * on the MCV list being consistent with the collation info in pg_attribute
+ * during estimation.
*/
void
UpdateStatisticsForTypeChange(Oid statsOid, Oid relationOid, int attnum,