diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/gin_private.h | 2 | ||||
| -rw-r--r-- | src/include/access/skey.h | 17 | ||||
| -rw-r--r-- | src/include/access/valid.h | 5 | ||||
| -rw-r--r-- | src/include/fmgr.h | 171 | ||||
| -rw-r--r-- | src/include/nodes/execnodes.h | 1 | ||||
| -rw-r--r-- | src/include/utils/selfuncs.h | 3 | ||||
| -rw-r--r-- | src/include/utils/tuplesort.h | 7 |
7 files changed, 148 insertions, 58 deletions
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h index 74c1098458..06c6fa2f9c 100644 --- a/src/include/access/gin_private.h +++ b/src/include/access/gin_private.h @@ -303,6 +303,8 @@ typedef struct GinState FmgrInfo comparePartialFn[INDEX_MAX_KEYS]; /* optional method */ /* canPartialMatch[i] is true if comparePartialFn[i] is valid */ bool canPartialMatch[INDEX_MAX_KEYS]; + /* Collations to supply to the compareFns and comparePartialFns */ + Oid compareCollation[INDEX_MAX_KEYS]; } GinState; /* XLog stuff */ diff --git a/src/include/access/skey.h b/src/include/access/skey.h index 1d0071ac2d..a82e46ee0e 100644 --- a/src/include/access/skey.h +++ b/src/include/access/skey.h @@ -52,16 +52,16 @@ typedef uint16 StrategyNumber; * the operator. When using a ScanKey in a heap scan, these fields are not * used and may be set to InvalidStrategy/InvalidOid. * - * If the operator is collation-sensitive, sk_func.fn_collation must be set + * If the operator is collation-sensitive, sk_collation must be set * correctly as well. * * A ScanKey can also represent a condition "column IS NULL" or "column * IS NOT NULL"; these cases are signaled by the SK_SEARCHNULL and * SK_SEARCHNOTNULL flag bits respectively. The argument is always NULL, - * and the sk_strategy, sk_subtype, and sk_func fields are not used (unless - * set by the index AM). Currently, SK_SEARCHNULL and SK_SEARCHNOTNULL are - * supported only for index scans, not heap scans; and not all index AMs - * support them. + * and the sk_strategy, sk_subtype, sk_collation, and sk_func fields are + * not used (unless set by the index AM). Currently, SK_SEARCHNULL and + * SK_SEARCHNOTNULL are supported only for index scans, not heap scans; + * and not all index AMs support them. * * A ScanKey can also represent an ordering operator invocation, that is * an ordering requirement "ORDER BY indexedcol op constant". This looks @@ -70,8 +70,8 @@ typedef uint16 StrategyNumber; * * Note: in some places, ScanKeys are used as a convenient representation * for the invocation of an access method support procedure. In this case - * sk_strategy/sk_subtype are not meaningful, and sk_func may refer to a - * function that returns something other than boolean. + * sk_strategy/sk_subtype are not meaningful (but sk_collation can be); and + * sk_func may refer to a function that returns something other than boolean. */ typedef struct ScanKeyData { @@ -79,6 +79,7 @@ typedef struct ScanKeyData AttrNumber sk_attno; /* table or index column number */ StrategyNumber sk_strategy; /* operator strategy number */ Oid sk_subtype; /* strategy subtype */ + Oid sk_collation; /* collation to use, if needed */ FmgrInfo sk_func; /* lookup info for function to call */ Datum sk_argument; /* data to compare */ } ScanKeyData; @@ -99,7 +100,7 @@ typedef ScanKeyData *ScanKey; * sk_attno = index column number for leading column of row comparison * sk_strategy = btree strategy code for semantics of row comparison * (ie, < <= > or >=) - * sk_subtype, sk_func: not used + * sk_subtype, sk_collation, sk_func: not used * sk_argument: pointer to subsidiary ScanKey array * If the header is part of a ScanKey array that's sorted by attno, it * must be sorted according to the leading column number. diff --git a/src/include/access/valid.h b/src/include/access/valid.h index e81f4cb723..f52ff4fb17 100644 --- a/src/include/access/valid.h +++ b/src/include/access/valid.h @@ -54,8 +54,9 @@ do \ break; \ } \ \ - __test = FunctionCall2(&__cur_keys->sk_func, \ - __atp, __cur_keys->sk_argument); \ + __test = FunctionCall2Coll(&__cur_keys->sk_func, \ + __cur_keys->sk_collation, \ + __atp, __cur_keys->sk_argument); \ \ if (!DatumGetBool(__test)) \ { \ diff --git a/src/include/fmgr.h b/src/include/fmgr.h index e58060f834..60d47d97b9 100644 --- a/src/include/fmgr.h +++ b/src/include/fmgr.h @@ -41,10 +41,10 @@ typedef Datum (*PGFunction) (FunctionCallInfo fcinfo); * to be called multiple times, the lookup need be done only once and the * info struct saved for re-use. * - * Note that fn_collation and fn_expr really are parse-time-determined - * information about the arguments, rather than about the function itself. - * But it's convenient to store them here rather than in FunctionCallInfoData, - * where they might more logically belong. + * Note that fn_expr really is parse-time-determined information about the + * arguments, rather than about the function itself. But it's convenient + * to store it here rather than in FunctionCallInfoData, where it might more + * logically belong. */ typedef struct FmgrInfo { @@ -55,7 +55,6 @@ typedef struct FmgrInfo bool fn_strict; /* function is "strict" (NULL in => NULL out) */ bool fn_retset; /* function returns a set */ unsigned char fn_stats; /* collect stats if track_functions > this */ - Oid fn_collation; /* collation that function should use */ void *fn_extra; /* extra space for use by handler */ MemoryContext fn_mcxt; /* memory context to store fn_extra in */ fmNodePtr fn_expr; /* expression parse tree for call, or NULL */ @@ -69,6 +68,7 @@ typedef struct FunctionCallInfoData FmgrInfo *flinfo; /* ptr to lookup info used for this call */ fmNodePtr context; /* pass info about context of call */ fmNodePtr resultinfo; /* pass or return extra info about result */ + Oid fncollation; /* collation for function to use */ bool isnull; /* function must set true if result is NULL */ short nargs; /* # arguments actually passed */ Datum arg[FUNC_MAX_ARGS]; /* Arguments passed to function */ @@ -89,9 +89,7 @@ extern void fmgr_info(Oid functionId, FmgrInfo *finfo); extern void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt); -/* Macros for setting the fn_collation and fn_expr fields */ -#define fmgr_info_set_collation(collationId, finfo) \ - ((finfo)->fn_collation = (collationId)) +/* Convenience macro for setting the fn_expr field */ #define fmgr_info_set_expr(expr, finfo) \ ((finfo)->fn_expr = (expr)) @@ -108,11 +106,12 @@ extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo, * explicitly set each required element to false, so we don't try to zero * out the argnull[] array in the macro. */ -#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Context, Resultinfo) \ +#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo) \ do { \ (Fcinfo).flinfo = (Flinfo); \ (Fcinfo).context = (Context); \ (Fcinfo).resultinfo = (Resultinfo); \ + (Fcinfo).fncollation = (Collation); \ (Fcinfo).isnull = false; \ (Fcinfo).nargs = (Nargs); \ } while (0) @@ -150,8 +149,7 @@ extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo, /* * Get collation function should use. */ -#define PG_GET_COLLATION() \ - (fcinfo->flinfo ? fcinfo->flinfo->fn_collation : InvalidOid) +#define PG_GET_COLLATION() (fcinfo->fncollation) /* * Get number of arguments passed to function. @@ -434,56 +432,68 @@ extern int no_such_variable * directly-computed parameter list. Note that neither arguments nor result * are allowed to be NULL. */ -extern Datum DirectFunctionCall1(PGFunction func, Datum arg1); -extern Datum DirectFunctionCall2(PGFunction func, Datum arg1, Datum arg2); -extern Datum DirectFunctionCall3(PGFunction func, Datum arg1, Datum arg2, +extern Datum DirectFunctionCall1Coll(PGFunction func, Oid collation, + Datum arg1); +extern Datum DirectFunctionCall2Coll(PGFunction func, Oid collation, + Datum arg1, Datum arg2); +extern Datum DirectFunctionCall3Coll(PGFunction func, Oid collation, + Datum arg1, Datum arg2, Datum arg3); -extern Datum DirectFunctionCall4(PGFunction func, Datum arg1, Datum arg2, +extern Datum DirectFunctionCall4Coll(PGFunction func, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4); -extern Datum DirectFunctionCall5(PGFunction func, Datum arg1, Datum arg2, +extern Datum DirectFunctionCall5Coll(PGFunction func, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5); -extern Datum DirectFunctionCall6(PGFunction func, Datum arg1, Datum arg2, +extern Datum DirectFunctionCall6Coll(PGFunction func, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6); -extern Datum DirectFunctionCall7(PGFunction func, Datum arg1, Datum arg2, +extern Datum DirectFunctionCall7Coll(PGFunction func, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7); -extern Datum DirectFunctionCall8(PGFunction func, Datum arg1, Datum arg2, +extern Datum DirectFunctionCall8Coll(PGFunction func, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8); -extern Datum DirectFunctionCall9(PGFunction func, Datum arg1, Datum arg2, +extern Datum DirectFunctionCall9Coll(PGFunction func, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8, Datum arg9); -/* The same, but passing a collation to use */ -extern Datum DirectFunctionCall1WithCollation(PGFunction func, Oid collation, - Datum arg1); -extern Datum DirectFunctionCall2WithCollation(PGFunction func, Oid collation, - Datum arg1, Datum arg2); - /* These are for invocation of a previously-looked-up function with a * directly-computed parameter list. Note that neither arguments nor result * are allowed to be NULL. */ -extern Datum FunctionCall1(FmgrInfo *flinfo, Datum arg1); -extern Datum FunctionCall2(FmgrInfo *flinfo, Datum arg1, Datum arg2); -extern Datum FunctionCall3(FmgrInfo *flinfo, Datum arg1, Datum arg2, +extern Datum FunctionCall1Coll(FmgrInfo *flinfo, Oid collation, + Datum arg1); +extern Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, + Datum arg1, Datum arg2); +extern Datum FunctionCall3Coll(FmgrInfo *flinfo, Oid collation, + Datum arg1, Datum arg2, Datum arg3); -extern Datum FunctionCall4(FmgrInfo *flinfo, Datum arg1, Datum arg2, +extern Datum FunctionCall4Coll(FmgrInfo *flinfo, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4); -extern Datum FunctionCall5(FmgrInfo *flinfo, Datum arg1, Datum arg2, +extern Datum FunctionCall5Coll(FmgrInfo *flinfo, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5); -extern Datum FunctionCall6(FmgrInfo *flinfo, Datum arg1, Datum arg2, +extern Datum FunctionCall6Coll(FmgrInfo *flinfo, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6); -extern Datum FunctionCall7(FmgrInfo *flinfo, Datum arg1, Datum arg2, +extern Datum FunctionCall7Coll(FmgrInfo *flinfo, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7); -extern Datum FunctionCall8(FmgrInfo *flinfo, Datum arg1, Datum arg2, +extern Datum FunctionCall8Coll(FmgrInfo *flinfo, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8); -extern Datum FunctionCall9(FmgrInfo *flinfo, Datum arg1, Datum arg2, +extern Datum FunctionCall9Coll(FmgrInfo *flinfo, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8, Datum arg9); @@ -494,29 +504,100 @@ extern Datum FunctionCall9(FmgrInfo *flinfo, Datum arg1, Datum arg2, * by FunctionCallN(). If the same function is to be invoked repeatedly, * do the FunctionLookup() once and then use FunctionCallN(). */ -extern Datum OidFunctionCall0(Oid functionId); -extern Datum OidFunctionCall1(Oid functionId, Datum arg1); -extern Datum OidFunctionCall2(Oid functionId, Datum arg1, Datum arg2); -extern Datum OidFunctionCall3(Oid functionId, Datum arg1, Datum arg2, +extern Datum OidFunctionCall0Coll(Oid functionId, Oid collation); +extern Datum OidFunctionCall1Coll(Oid functionId, Oid collation, + Datum arg1); +extern Datum OidFunctionCall2Coll(Oid functionId, Oid collation, + Datum arg1, Datum arg2); +extern Datum OidFunctionCall3Coll(Oid functionId, Oid collation, + Datum arg1, Datum arg2, Datum arg3); -extern Datum OidFunctionCall4(Oid functionId, Datum arg1, Datum arg2, +extern Datum OidFunctionCall4Coll(Oid functionId, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4); -extern Datum OidFunctionCall5(Oid functionId, Datum arg1, Datum arg2, +extern Datum OidFunctionCall5Coll(Oid functionId, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5); -extern Datum OidFunctionCall6(Oid functionId, Datum arg1, Datum arg2, +extern Datum OidFunctionCall6Coll(Oid functionId, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6); -extern Datum OidFunctionCall7(Oid functionId, Datum arg1, Datum arg2, +extern Datum OidFunctionCall7Coll(Oid functionId, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7); -extern Datum OidFunctionCall8(Oid functionId, Datum arg1, Datum arg2, +extern Datum OidFunctionCall8Coll(Oid functionId, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8); -extern Datum OidFunctionCall9(Oid functionId, Datum arg1, Datum arg2, +extern Datum OidFunctionCall9Coll(Oid functionId, Oid collation, + Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7, Datum arg8, Datum arg9); +/* These macros allow the collation argument to be omitted (with a default of + * InvalidOid, ie, no collation). They exist mostly for backwards + * compatibility of source code. + */ +#define DirectFunctionCall1(func, arg1) \ + DirectFunctionCall1Coll(func, InvalidOid, arg1) +#define DirectFunctionCall2(func, arg1, arg2) \ + DirectFunctionCall2Coll(func, InvalidOid, arg1, arg2) +#define DirectFunctionCall3(func, arg1, arg2, arg3) \ + DirectFunctionCall3Coll(func, InvalidOid, arg1, arg2, arg3) +#define DirectFunctionCall4(func, arg1, arg2, arg3, arg4) \ + DirectFunctionCall4Coll(func, InvalidOid, arg1, arg2, arg3, arg4) +#define DirectFunctionCall5(func, arg1, arg2, arg3, arg4, arg5) \ + DirectFunctionCall5Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5) +#define DirectFunctionCall6(func, arg1, arg2, arg3, arg4, arg5, arg6) \ + DirectFunctionCall6Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6) +#define DirectFunctionCall7(func, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + DirectFunctionCall7Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7) +#define DirectFunctionCall8(func, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ + DirectFunctionCall8Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) +#define DirectFunctionCall9(func, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \ + DirectFunctionCall9Coll(func, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) +#define FunctionCall1(flinfo, arg1) \ + FunctionCall1Coll(flinfo, InvalidOid, arg1) +#define FunctionCall2(flinfo, arg1, arg2) \ + FunctionCall2Coll(flinfo, InvalidOid, arg1, arg2) +#define FunctionCall3(flinfo, arg1, arg2, arg3) \ + FunctionCall3Coll(flinfo, InvalidOid, arg1, arg2, arg3) +#define FunctionCall4(flinfo, arg1, arg2, arg3, arg4) \ + FunctionCall4Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4) +#define FunctionCall5(flinfo, arg1, arg2, arg3, arg4, arg5) \ + FunctionCall5Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5) +#define FunctionCall6(flinfo, arg1, arg2, arg3, arg4, arg5, arg6) \ + FunctionCall6Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6) +#define FunctionCall7(flinfo, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + FunctionCall7Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7) +#define FunctionCall8(flinfo, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ + FunctionCall8Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) +#define FunctionCall9(flinfo, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \ + FunctionCall9Coll(flinfo, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) +#define OidFunctionCall0(functionId) \ + OidFunctionCall0Coll(functionId, InvalidOid) +#define OidFunctionCall1(functionId, arg1) \ + OidFunctionCall1Coll(functionId, InvalidOid, arg1) +#define OidFunctionCall2(functionId, arg1, arg2) \ + OidFunctionCall2Coll(functionId, InvalidOid, arg1, arg2) +#define OidFunctionCall3(functionId, arg1, arg2, arg3) \ + OidFunctionCall3Coll(functionId, InvalidOid, arg1, arg2, arg3) +#define OidFunctionCall4(functionId, arg1, arg2, arg3, arg4) \ + OidFunctionCall4Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4) +#define OidFunctionCall5(functionId, arg1, arg2, arg3, arg4, arg5) \ + OidFunctionCall5Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5) +#define OidFunctionCall6(functionId, arg1, arg2, arg3, arg4, arg5, arg6) \ + OidFunctionCall6Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6) +#define OidFunctionCall7(functionId, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + OidFunctionCall7Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7) +#define OidFunctionCall8(functionId, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ + OidFunctionCall8Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) +#define OidFunctionCall9(functionId, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \ + OidFunctionCall9Coll(functionId, InvalidOid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + + /* Special cases for convenient invocation of datatype I/O functions. */ extern Datum InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod); diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 9c688c0368..16756616e5 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -864,6 +864,7 @@ typedef struct RowCompareExprState List *largs; /* the left-hand input arguments */ List *rargs; /* the right-hand input arguments */ FmgrInfo *funcs; /* array of comparison function info */ + Oid *collations; /* array of collations to use */ } RowCompareExprState; /* ---------------- diff --git a/src/include/utils/selfuncs.h b/src/include/utils/selfuncs.h index c1b417ad8f..dd38a0292f 100644 --- a/src/include/utils/selfuncs.h +++ b/src/include/utils/selfuncs.h @@ -135,7 +135,8 @@ extern Pattern_Prefix_Status pattern_fixed_prefix(Const *patt, Oid collation, Const **prefix, Const **rest); -extern Const *make_greater_string(const Const *str_const, FmgrInfo *ltproc); +extern Const *make_greater_string(const Const *str_const, FmgrInfo *ltproc, + Oid collation); extern Datum eqsel(PG_FUNCTION_ARGS); extern Datum neqsel(PG_FUNCTION_ARGS); diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h index a2085df869..1ebcbfe172 100644 --- a/src/include/utils/tuplesort.h +++ b/src/include/utils/tuplesort.h @@ -60,7 +60,8 @@ typedef struct Tuplesortstate Tuplesortstate; extern Tuplesortstate *tuplesort_begin_heap(TupleDesc tupDesc, int nkeys, AttrNumber *attNums, - Oid *sortOperators, Oid *collations, bool *nullsFirstFlags, + Oid *sortOperators, Oid *sortCollations, + bool *nullsFirstFlags, int workMem, bool randomAccess); extern Tuplesortstate *tuplesort_begin_cluster(TupleDesc tupDesc, Relation indexRel, @@ -72,7 +73,8 @@ extern Tuplesortstate *tuplesort_begin_index_hash(Relation indexRel, uint32 hash_mask, int workMem, bool randomAccess); extern Tuplesortstate *tuplesort_begin_datum(Oid datumType, - Oid sortOperator, Oid sortCollation, bool nullsFirstFlag, + Oid sortOperator, Oid sortCollation, + bool nullsFirstFlag, int workMem, bool randomAccess); extern void tuplesort_set_bound(Tuplesortstate *state, int64 bound); @@ -125,6 +127,7 @@ extern void SelectSortFunction(Oid sortOperator, bool nulls_first, * reverse-sort and NULLs-ordering properly. */ extern int32 ApplySortFunction(FmgrInfo *sortFunction, int sortFlags, + Oid collation, Datum datum1, bool isNull1, Datum datum2, bool isNull2); |
