mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
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.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user