mirror of
https://github.com/postgres/postgres.git
synced 2025-08-24 09:27:52 +03:00
Add construct_array_builtin, deconstruct_array_builtin
There were many calls to construct_array() and deconstruct_array() for built-in types, for example, when dealing with system catalog columns. These all hardcoded the type attributes necessary to pass to these functions. To simplify this a bit, add construct_array_builtin(), deconstruct_array_builtin() as wrappers that centralize this hardcoded knowledge. This simplifies many call sites and reduces the amount of hardcoded stuff that is spread around. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/2914356f-9e5f-8c59-2995-5997fc48bcba%40enterprisedb.com
This commit is contained in:
@@ -468,10 +468,8 @@ interpret_function_parameter_list(ParseState *pstate,
|
||||
|
||||
if (outCount > 0 || varCount > 0)
|
||||
{
|
||||
*allParameterTypes = construct_array(allTypes, parameterCount, OIDOID,
|
||||
sizeof(Oid), true, TYPALIGN_INT);
|
||||
*parameterModes = construct_array(paramModes, parameterCount, CHAROID,
|
||||
1, true, TYPALIGN_CHAR);
|
||||
*allParameterTypes = construct_array_builtin(allTypes, parameterCount, OIDOID);
|
||||
*parameterModes = construct_array_builtin(paramModes, parameterCount, CHAROID);
|
||||
if (outCount > 1)
|
||||
*requiredResultType = RECORDOID;
|
||||
/* otherwise we set requiredResultType correctly above */
|
||||
@@ -489,8 +487,7 @@ interpret_function_parameter_list(ParseState *pstate,
|
||||
if (paramNames[i] == PointerGetDatum(NULL))
|
||||
paramNames[i] = CStringGetTextDatum("");
|
||||
}
|
||||
*parameterNames = construct_array(paramNames, parameterCount, TEXTOID,
|
||||
-1, false, TYPALIGN_INT);
|
||||
*parameterNames = construct_array_builtin(paramNames, parameterCount, TEXTOID);
|
||||
}
|
||||
else
|
||||
*parameterNames = NULL;
|
||||
@@ -1222,8 +1219,7 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
|
||||
i = 0;
|
||||
foreach(lc, trftypes_list)
|
||||
arr[i++] = ObjectIdGetDatum(lfirst_oid(lc));
|
||||
trftypes = construct_array(arr, list_length(trftypes_list),
|
||||
OIDOID, sizeof(Oid), true, TYPALIGN_INT);
|
||||
trftypes = construct_array_builtin(arr, list_length(trftypes_list), OIDOID);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user