aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/common/scankey.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-12-18 12:48:15 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2018-12-18 12:48:15 -0500
commit6b0faf723647a851eaaddfed11e14861f8d0f588 (patch)
treebb3036bdfeb6b540edc985c06de023c2892c0916 /src/backend/access/common/scankey.c
parentb2d9e17768864030fb0829b55303b8b72bfd809f (diff)
downloadpostgresql-6b0faf723647a851eaaddfed11e14861f8d0f588.tar.gz
postgresql-6b0faf723647a851eaaddfed11e14861f8d0f588.zip
Make collation-aware system catalog columns use "C" collation.
Up to now we allowed text columns in system catalogs to use collation "default", but that isn't really safe because it might mean something different in template0 than it means in a database cloned from template0. In particular, this could mean that cloned pg_statistic entries for such columns weren't entirely valid, possibly leading to bogus planner estimates, though (probably) not any outright failures. In the wake of commit 5e0928005, a better solution is available: if we label such columns with "C" collation, then their pg_statistic entries will also use that collation and hence will be valid independently of the database collation. This also provides a cleaner solution for indexes on such columns than the hack added by commit 0b28ea79c: the indexes will naturally inherit "C" collation and don't have to be forced to use text_pattern_ops. Also, with the planned improvement of type "name" to be collation-aware, this policy will apply cleanly to both text and name columns. Because of the pg_statistic angle, we should also apply this policy to the tables in information_schema. This patch does that by adjusting information_schema's textual domain types to specify "C" collation. That has the user-visible effect that order-sensitive comparisons to textual information_schema view columns will now use "C" collation by default. The SQL standard says that the collation of those view columns is implementation-defined, so I think this is legal per spec. At some point this might allow for translation of such comparisons into indexable conditions on the underlying "name" columns, although additional work will be needed before that can happen. Discussion: https://postgr.es/m/19346.1544895309@sss.pgh.pa.us
Diffstat (limited to 'src/backend/access/common/scankey.c')
-rw-r--r--src/backend/access/common/scankey.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/access/common/scankey.c b/src/backend/access/common/scankey.c
index 781516c56a5..5be4fe85eb1 100644
--- a/src/backend/access/common/scankey.c
+++ b/src/backend/access/common/scankey.c
@@ -64,9 +64,9 @@ ScanKeyEntryInitialize(ScanKey entry,
* It cannot handle NULL arguments, unary operators, or nondefault operators,
* but we need none of those features for most hardwired lookups.
*
- * We set collation to DEFAULT_COLLATION_OID always. This is appropriate
- * for textual columns in system catalogs, and it will be ignored for
- * non-textual columns, so it's not worth trying to be more finicky.
+ * We set collation to C_COLLATION_OID always. This is the correct value
+ * for all collation-aware columns in system catalogs, and it will be ignored
+ * for other column types, so it's not worth trying to be more finicky.
*
* Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
* itself, because that's what will be used for any subsidiary info attached
@@ -83,7 +83,7 @@ ScanKeyInit(ScanKey entry,
entry->sk_attno = attributeNumber;
entry->sk_strategy = strategy;
entry->sk_subtype = InvalidOid;
- entry->sk_collation = DEFAULT_COLLATION_OID;
+ entry->sk_collation = C_COLLATION_OID;
entry->sk_argument = argument;
fmgr_info(procedure, &entry->sk_func);
}