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,
3334 AttrNumber attributeNumber ,
3435 StrategyNumber strategy ,
3536 Oid subtype ,
37+ Oid collation ,
3638 RegProcedure procedure ,
3739 Datum argument )
3840{
@@ -42,7 +44,10 @@ ScanKeyEntryInitialize(ScanKey entry,
4244 entry -> sk_subtype = subtype ;
4345 entry -> sk_argument = argument ;
4446 if (RegProcedureIsValid (procedure ))
47+ {
4548 fmgr_info (procedure , & entry -> sk_func );
49+ entry -> sk_func .fn_collation = collation ;
50+ }
4651 else
4752 {
4853 Assert (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,
7685 entry -> sk_subtype = InvalidOid ;
7786 entry -> sk_argument = argument ;
7887 fmgr_info (procedure , & entry -> sk_func );
88+ entry -> sk_func .fn_collation = DEFAULT_COLLATION_OID ;
7989}
8090
8191/*
@@ -93,6 +103,7 @@ ScanKeyEntryInitializeWithInfo(ScanKey entry,
93103 AttrNumber attributeNumber ,
94104 StrategyNumber strategy ,
95105 Oid subtype ,
106+ Oid collation ,
96107 FmgrInfo * finfo ,
97108 Datum argument )
98109{
@@ -102,17 +113,5 @@ ScanKeyEntryInitializeWithInfo(ScanKey entry,
102113 entry -> sk_subtype = subtype ;
103114 entry -> sk_argument = argument ;
104115 fmgr_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- {
117116 entry -> sk_func .fn_collation = collation ;
118117}
0 commit comments