* Interpret the function parameter list of a CREATE FUNCTION, * CREATE PROCEDURE, or CREATE AGGREGATE statement. * * Input parameters: * parameters: list of FunctionParameter structs * languageOid: OID of function language (InvalidOid if it's CREATE AGGREGATE) * objtype: identifies type of object being created * * Results are stored into output parameters. parameterTypes must always * be
| 208 | * else it is set to the OID of the implied result type. |
| 209 | */ |
| 210 | void |
| 211 | interpret_function_parameter_list(ParseState *pstate, |
| 212 | List *parameters, |
| 213 | Oid languageOid, |
| 214 | ObjectType objtype, |
| 215 | oidvector **parameterTypes, |
| 216 | List **parameterTypes_list, |
| 217 | ArrayType **allParameterTypes, |
| 218 | ArrayType **parameterModes, |
| 219 | ArrayType **parameterNames, |
| 220 | List **inParameterNames_list, |
| 221 | List **parameterDefaults, |
| 222 | Oid *variadicArgType, |
| 223 | Oid *requiredResultType) |
| 224 | { |
| 225 | int parameterCount = list_length(parameters); |
| 226 | Oid *inTypes; |
| 227 | int inCount = 0; |
| 228 | Datum *allTypes; |
| 229 | Datum *paramModes; |
| 230 | Datum *paramNames; |
| 231 | int outCount = 0; |
| 232 | int varCount = 0; |
| 233 | int multisetCount = 0; |
| 234 | bool have_names = false; |
| 235 | bool have_defaults = false; |
| 236 | ListCell *x; |
| 237 | int i; |
| 238 | |
| 239 | *variadicArgType = InvalidOid; /* default result */ |
| 240 | *requiredResultType = InvalidOid; /* default result */ |
| 241 | |
| 242 | inTypes = (Oid *) palloc(parameterCount * sizeof(Oid)); |
| 243 | allTypes = (Datum *) palloc(parameterCount * sizeof(Datum)); |
| 244 | paramModes = (Datum *) palloc(parameterCount * sizeof(Datum)); |
| 245 | paramNames = (Datum *) palloc0(parameterCount * sizeof(Datum)); |
| 246 | *parameterDefaults = NIL; |
| 247 | |
| 248 | /* Scan the list and extract data into work arrays */ |
| 249 | i = 0; |
| 250 | foreach(x, parameters) |
| 251 | { |
| 252 | FunctionParameter *fp = (FunctionParameter *) lfirst(x); |
| 253 | TypeName *t = fp->argType; |
| 254 | FunctionParameterMode fpmode = fp->mode; |
| 255 | bool isinput = false; |
| 256 | Oid toid; |
| 257 | Type typtup; |
| 258 | AclResult aclresult; |
| 259 | |
| 260 | /* For our purposes here, a defaulted mode spec is identical to IN */ |
| 261 | if (fpmode == FUNC_PARAM_DEFAULT) |
| 262 | fpmode = FUNC_PARAM_IN; |
| 263 | |
| 264 | typtup = LookupTypeName(NULL, t, NULL, false); |
| 265 | if (typtup) |
| 266 | { |
| 267 | if (!((Form_pg_type) GETSTRUCT(typtup))->typisdefined) |
no test coverage detected