diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-03-26 18:28:40 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-03-26 18:28:40 -0400 |
commit | 7208fae18f1fdb242b4fcced77a3b836e15ac3ec (patch) | |
tree | e857033e3c74a3f73de3e29720290ee721199df3 /src/backend/access/common/scankey.c | |
parent | 0c9d9e8dd655fff7bcfc401e82838b8c20c16939 (diff) | |
download | postgresql-7208fae18f1fdb242b4fcced77a3b836e15ac3ec.tar.gz postgresql-7208fae18f1fdb242b4fcced77a3b836e15ac3ec.zip |
Clean up cruft around collation initialization for tupdescs and scankeys.
I found actual bugs in GiST and plpgsql; the rest of this is cosmetic
but meant to decrease the odds of future bugs of omission.
Diffstat (limited to 'src/backend/access/common/scankey.c')
-rw-r--r-- | src/backend/access/common/scankey.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/backend/access/common/scankey.c b/src/backend/access/common/scankey.c index 41cd36fce92..b632408da47 100644 --- a/src/backend/access/common/scankey.c +++ b/src/backend/access/common/scankey.c @@ -15,6 +15,7 @@ #include "postgres.h" #include "access/skey.h" +#include "catalog/pg_collation.h" /* @@ -33,6 +34,7 @@ ScanKeyEntryInitialize(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, Oid subtype, + Oid collation, RegProcedure procedure, Datum argument) { @@ -42,7 +44,10 @@ ScanKeyEntryInitialize(ScanKey entry, entry->sk_subtype = subtype; entry->sk_argument = argument; if (RegProcedureIsValid(procedure)) + { fmgr_info(procedure, &entry->sk_func); + entry->sk_func.fn_collation = collation; + } else { Assert(flags & (SK_SEARCHNULL | SK_SEARCHNOTNULL)); @@ -53,12 +58,16 @@ ScanKeyEntryInitialize(ScanKey entry, /* * ScanKeyInit * Shorthand version of ScanKeyEntryInitialize: flags and subtype - * are assumed to be zero (the usual value). + * are assumed to be zero (the usual value), and collation is defaulted. * * This is the recommended version for hardwired lookups in system catalogs. * 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. + * * 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 * to the ScanKey's FmgrInfo record. @@ -76,6 +85,7 @@ ScanKeyInit(ScanKey entry, entry->sk_subtype = InvalidOid; entry->sk_argument = argument; fmgr_info(procedure, &entry->sk_func); + entry->sk_func.fn_collation = DEFAULT_COLLATION_OID; } /* @@ -93,6 +103,7 @@ ScanKeyEntryInitializeWithInfo(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, Oid subtype, + Oid collation, FmgrInfo *finfo, Datum argument) { @@ -102,17 +113,5 @@ ScanKeyEntryInitializeWithInfo(ScanKey entry, entry->sk_subtype = subtype; entry->sk_argument = argument; fmgr_info_copy(&entry->sk_func, finfo, CurrentMemoryContext); -} - -/* - * ScanKeyEntryInitializeCollation - * - * Initialize the collation of a scan key. This is just a notational - * convenience and small abstraction. - */ -void -ScanKeyEntryInitializeCollation(ScanKey entry, - Oid collation) -{ entry->sk_func.fn_collation = collation; } |