mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Per-column collation support
This adds collation support for columns and domains, a COLLATE clause to override it per expression, and B-tree index support. Peter Eisentraut reviewed by Pavel Stehule, Itagaki Takahiro, Robert Haas, Noah Misch
This commit is contained in:
@ -78,6 +78,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
||||
bool retset;
|
||||
int nvargs;
|
||||
FuncDetailCode fdresult;
|
||||
Oid funccollid;
|
||||
|
||||
/*
|
||||
* Most of the rest of the parser just assumes that functions do not have
|
||||
@ -343,6 +344,12 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
||||
/* perform the necessary typecasting of arguments */
|
||||
make_fn_arguments(pstate, fargs, actual_arg_types, declared_arg_types);
|
||||
|
||||
/* XXX: If we knew which functions required collation information,
|
||||
* we could selectively set the last argument to true here. */
|
||||
funccollid = select_common_collation(pstate, fargs, false);
|
||||
if (!OidIsValid(funccollid))
|
||||
funccollid = get_typcollation(rettype);
|
||||
|
||||
/*
|
||||
* If it's a variadic function call, transform the last nvargs arguments
|
||||
* into an array --- unless it's an "any" variadic.
|
||||
@ -383,6 +390,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
||||
funcexpr->funcretset = retset;
|
||||
funcexpr->funcformat = COERCE_EXPLICIT_CALL;
|
||||
funcexpr->args = fargs;
|
||||
funcexpr->collid = funccollid;
|
||||
funcexpr->location = location;
|
||||
|
||||
retval = (Node *) funcexpr;
|
||||
@ -396,6 +404,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
||||
aggref->aggtype = rettype;
|
||||
/* args, aggorder, aggdistinct will be set by transformAggregateCall */
|
||||
aggref->aggstar = agg_star;
|
||||
aggref->collid = funccollid;
|
||||
/* agglevelsup will be set by transformAggregateCall */
|
||||
aggref->location = location;
|
||||
|
||||
@ -453,6 +462,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
||||
/* winref will be set by transformWindowFuncCall */
|
||||
wfunc->winstar = agg_star;
|
||||
wfunc->winagg = (fdresult == FUNCDETAIL_AGGREGATE);
|
||||
wfunc->collid = funccollid;
|
||||
wfunc->location = location;
|
||||
|
||||
/*
|
||||
@ -1303,7 +1313,7 @@ FuncNameAsType(List *funcname)
|
||||
Oid result;
|
||||
Type typtup;
|
||||
|
||||
typtup = LookupTypeName(NULL, makeTypeNameFromNameList(funcname), NULL);
|
||||
typtup = LookupTypeName(NULL, makeTypeNameFromNameList(funcname), NULL, NULL);
|
||||
if (typtup == NULL)
|
||||
return InvalidOid;
|
||||
|
||||
@ -1380,6 +1390,7 @@ ParseComplexProjection(ParseState *pstate, char *funcname, Node *first_arg,
|
||||
fselect->fieldnum = i + 1;
|
||||
fselect->resulttype = att->atttypid;
|
||||
fselect->resulttypmod = att->atttypmod;
|
||||
fselect->resultcollation = att->attcollation;
|
||||
return (Node *) fselect;
|
||||
}
|
||||
}
|
||||
@ -1489,7 +1500,7 @@ LookupTypeNameOid(const TypeName *typename)
|
||||
Oid result;
|
||||
Type typtup;
|
||||
|
||||
typtup = LookupTypeName(NULL, typename, NULL);
|
||||
typtup = LookupTypeName(NULL, typename, NULL, NULL);
|
||||
if (typtup == NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
|
Reference in New Issue
Block a user