1515#include "postgres.h"
1616
1717#include "access/skey.h"
18+ #include "catalog/pg_collation.h"
1819
1920
2021/*
@@ -33,6 +34,7 @@ ScanKeyEntryInitialize(ScanKey entry,
3334AttrNumber attributeNumber ,
3435StrategyNumber strategy ,
3536Oid subtype ,
37+ Oid collation ,
3638RegProcedure procedure ,
3739Datum argument )
3840{
@@ -42,7 +44,10 @@ ScanKeyEntryInitialize(ScanKey entry,
4244entry -> sk_subtype = subtype ;
4345entry -> sk_argument = argument ;
4446if (RegProcedureIsValid (procedure ))
47+ {
4548fmgr_info (procedure ,& entry -> sk_func );
49+ entry -> sk_func .fn_collation = collation ;
50+ }
4651else
4752{
4853Assert (flags & (SK_SEARCHNULL |SK_SEARCHNOTNULL ));
@@ -53,12 +58,16 @@ ScanKeyEntryInitialize(ScanKey entry,
5358/*
5459 * ScanKeyInit
5560 *Shorthand version of ScanKeyEntryInitialize: flags and subtype
56- *are assumed to be zero (the usual value).
61+ *are assumed to be zero (the usual value), and collation is defaulted .
5762 *
5863 * This is the recommended version for hardwired lookups in system catalogs.
5964 * It cannot handle NULL arguments, unary operators, or nondefault operators,
6065 * but we need none of those features for most hardwired lookups.
6166 *
67+ * We set collation to DEFAULT_COLLATION_OID always. This is appropriate
68+ * for textual columns in system catalogs, and it will be ignored for
69+ * non-textual columns, so it's not worth trying to be more finicky.
70+ *
6271 * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
6372 * itself, because that's what will be used for any subsidiary info attached
6473 * to the ScanKey's FmgrInfo record.
@@ -76,6 +85,7 @@ ScanKeyInit(ScanKey entry,
7685entry -> sk_subtype = InvalidOid ;
7786entry -> sk_argument = argument ;
7887fmgr_info (procedure ,& entry -> sk_func );
88+ entry -> sk_func .fn_collation = DEFAULT_COLLATION_OID ;
7989}
8090
8191/*
@@ -93,6 +103,7 @@ ScanKeyEntryInitializeWithInfo(ScanKey entry,
93103AttrNumber attributeNumber ,
94104StrategyNumber strategy ,
95105Oid subtype ,
106+ Oid collation ,
96107FmgrInfo * finfo ,
97108Datum argument )
98109{
@@ -102,17 +113,5 @@ ScanKeyEntryInitializeWithInfo(ScanKey entry,
102113entry -> sk_subtype = subtype ;
103114entry -> sk_argument = argument ;
104115fmgr_info_copy (& entry -> sk_func ,finfo ,CurrentMemoryContext );
105- }
106-
107- /*
108- * ScanKeyEntryInitializeCollation
109- *
110- * Initialize the collation of a scan key. This is just a notational
111- * convenience and small abstraction.
112- */
113- void
114- ScanKeyEntryInitializeCollation (ScanKey entry ,
115- Oid collation )
116- {
117116entry -> sk_func .fn_collation = collation ;
118117}