mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
Support domains over composite types.
This is the last major omission in our domains feature: you can now make a domain over anything that's not a pseudotype. The major complication from an implementation standpoint is that places that might be creating tuples of a domain type now need to be prepared to apply domain_check(). It seems better that unprepared code fail with an error like "<type> is not composite" than that it silently fail to apply domain constraints. Therefore, relevant infrastructure like get_func_result_type() and lookup_rowtype_tupdesc() has been adjusted to treat domain-over-composite as a distinct case that unprepared code won't recognize, rather than just transparently treating it the same as plain composite. This isn't a 100% solution to the possibility of overlooked domain checks, but it catches most places. In passing, improve typcache.c's support for domains (it can now cache the identity of a domain's base type), and rewrite the argument handling logic in jsonfuncs.c's populate_record[set]_worker to reduce duplicative per-call lookups. I believe this is code-complete so far as the core and contrib code go. The PLs need varying amounts of work, which will be tackled in followup patches. Discussion: https://postgr.es/m/4206.1499798337@sss.pgh.pa.us
This commit is contained in:
@ -144,6 +144,10 @@ typedef struct FuncCallContext
|
||||
* get_call_result_type. Note: the cases in which rowtypes cannot be
|
||||
* determined are different from the cases for get_call_result_type.
|
||||
* Do *not* use this if you can use one of the others.
|
||||
*
|
||||
* See also get_expr_result_tupdesc(), which is a convenient wrapper around
|
||||
* get_expr_result_type() for use when the caller only cares about
|
||||
* determinable-rowtype cases.
|
||||
*----------
|
||||
*/
|
||||
|
||||
@ -152,6 +156,7 @@ typedef enum TypeFuncClass
|
||||
{
|
||||
TYPEFUNC_SCALAR, /* scalar result type */
|
||||
TYPEFUNC_COMPOSITE, /* determinable rowtype result */
|
||||
TYPEFUNC_COMPOSITE_DOMAIN, /* domain over determinable rowtype result */
|
||||
TYPEFUNC_RECORD, /* indeterminate rowtype result */
|
||||
TYPEFUNC_OTHER /* bogus type, eg pseudotype */
|
||||
} TypeFuncClass;
|
||||
@ -166,6 +171,8 @@ extern TypeFuncClass get_func_result_type(Oid functionId,
|
||||
Oid *resultTypeId,
|
||||
TupleDesc *resultTupleDesc);
|
||||
|
||||
extern TupleDesc get_expr_result_tupdesc(Node *expr, bool noError);
|
||||
|
||||
extern bool resolve_polymorphic_argtypes(int numargs, Oid *argtypes,
|
||||
char *argmodes,
|
||||
Node *call_expr);
|
||||
@ -335,7 +342,7 @@ extern void end_MultiFuncCall(PG_FUNCTION_ARGS, FuncCallContext *funcctx);
|
||||
* "VARIADIC NULL".
|
||||
*/
|
||||
extern int extract_variadic_args(FunctionCallInfo fcinfo, int variadic_start,
|
||||
bool convert_unknown, Datum **values,
|
||||
Oid **types, bool **nulls);
|
||||
bool convert_unknown, Datum **values,
|
||||
Oid **types, bool **nulls);
|
||||
|
||||
#endif /* FUNCAPI_H */
|
||||
|
Reference in New Issue
Block a user