15
15
#include "postgres.h"
16
16
17
17
#include "access/skey.h"
18
+ #include "catalog/pg_collation.h"
18
19
19
20
20
21
/*
@@ -33,6 +34,7 @@ ScanKeyEntryInitialize(ScanKey entry,
33
34
AttrNumber attributeNumber ,
34
35
StrategyNumber strategy ,
35
36
Oid subtype ,
37
+ Oid collation ,
36
38
RegProcedure procedure ,
37
39
Datum argument )
38
40
{
@@ -42,7 +44,10 @@ ScanKeyEntryInitialize(ScanKey entry,
42
44
entry -> sk_subtype = subtype ;
43
45
entry -> sk_argument = argument ;
44
46
if (RegProcedureIsValid (procedure ))
47
+ {
45
48
fmgr_info (procedure , & entry -> sk_func );
49
+ entry -> sk_func .fn_collation = collation ;
50
+ }
46
51
else
47
52
{
48
53
Assert (flags & (SK_SEARCHNULL | SK_SEARCHNOTNULL ));
@@ -53,12 +58,16 @@ ScanKeyEntryInitialize(ScanKey entry,
53
58
/*
54
59
* ScanKeyInit
55
60
* 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 .
57
62
*
58
63
* This is the recommended version for hardwired lookups in system catalogs.
59
64
* It cannot handle NULL arguments, unary operators, or nondefault operators,
60
65
* but we need none of those features for most hardwired lookups.
61
66
*
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
+ *
62
71
* Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
63
72
* itself, because that's what will be used for any subsidiary info attached
64
73
* to the ScanKey's FmgrInfo record.
@@ -76,6 +85,7 @@ ScanKeyInit(ScanKey entry,
76
85
entry -> sk_subtype = InvalidOid ;
77
86
entry -> sk_argument = argument ;
78
87
fmgr_info (procedure , & entry -> sk_func );
88
+ entry -> sk_func .fn_collation = DEFAULT_COLLATION_OID ;
79
89
}
80
90
81
91
/*
@@ -93,6 +103,7 @@ ScanKeyEntryInitializeWithInfo(ScanKey entry,
93
103
AttrNumber attributeNumber ,
94
104
StrategyNumber strategy ,
95
105
Oid subtype ,
106
+ Oid collation ,
96
107
FmgrInfo * finfo ,
97
108
Datum argument )
98
109
{
@@ -102,17 +113,5 @@ ScanKeyEntryInitializeWithInfo(ScanKey entry,
102
113
entry -> sk_subtype = subtype ;
103
114
entry -> sk_argument = argument ;
104
115
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
- {
117
116
entry -> sk_func .fn_collation = collation ;
118
117
}
0 commit comments