summaryrefslogtreecommitdiff
path: root/src/backend/access/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/common')
-rw-r--r--src/backend/access/common/scankey.c25
-rw-r--r--src/backend/access/common/tupdesc.c10
2 files changed, 19 insertions, 16 deletions
diff --git a/src/backend/access/common/scankey.c b/src/backend/access/common/scankey.c
index 41cd36fce9..b632408da4 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;
}
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index d78b08381e..c06a0271ca 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -427,6 +427,10 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
* TupleDescInitEntry
* This function initializes a single attribute structure in
* a previously allocated tuple descriptor.
+ *
+ * Note that attcollation is set to the default for the specified datatype.
+ * If a nondefault collation is needed, insert it afterwards using
+ * TupleDescInitEntryCollation.
*/
void
TupleDescInitEntry(TupleDesc desc,
@@ -496,8 +500,8 @@ TupleDescInitEntry(TupleDesc desc,
/*
* TupleDescInitEntryCollation
*
- * Fill in the collation for an attribute in a previously initialized
- * tuple descriptor.
+ * Assign a nondefault collation to a previously initialized tuple descriptor
+ * entry.
*/
void
TupleDescInitEntryCollation(TupleDesc desc,
@@ -571,9 +575,9 @@ BuildDescForRelation(List *schema)
TupleDescInitEntry(desc, attnum, attname,
atttypid, atttypmod, attdim);
- TupleDescInitEntryCollation(desc, attnum, attcollation);
/* Override TupleDescInitEntry's settings as requested */
+ TupleDescInitEntryCollation(desc, attnum, attcollation);
if (entry->storage)
desc->attrs[attnum - 1]->attstorage = entry->storage;