MCPcopy Create free account
hub / github.com/apache/cloudberry / make_fn_arguments

Function make_fn_arguments

src/backend/parser/parse_func.c:1879–1926  ·  view source on GitHub ↗

* make_fn_arguments() * * Given the actual argument expressions for a function, and the desired * input types for the function, add any necessary typecasting to the * expression tree. Caller should already have verified that casting is * allowed. * * Caution: given argument list is modified in-place. * * As with coerce_type, pstate may be NULL if no special unknown-Param * processing is

Source from the content-addressed store, hash-verified

1877 * processing is wanted.
1878 */
1879void
1880make_fn_arguments(ParseState *pstate,
1881 List *fargs,
1882 Oid *actual_arg_types,
1883 Oid *declared_arg_types)
1884{
1885 ListCell *current_fargs;
1886 int i = 0;
1887
1888 foreach(current_fargs, fargs)
1889 {
1890 /* types don't match? then force coercion using a function call... */
1891 if (actual_arg_types[i] != declared_arg_types[i])
1892 {
1893 Node *node = (Node *) lfirst(current_fargs);
1894
1895 /*
1896 * If arg is a NamedArgExpr, coerce its input expr instead --- we
1897 * want the NamedArgExpr to stay at the top level of the list.
1898 */
1899 if (IsA(node, NamedArgExpr))
1900 {
1901 NamedArgExpr *na = (NamedArgExpr *) node;
1902
1903 node = coerce_type(pstate,
1904 (Node *) na->arg,
1905 actual_arg_types[i],
1906 declared_arg_types[i], -1,
1907 COERCION_IMPLICIT,
1908 COERCE_IMPLICIT_CAST,
1909 -1);
1910 na->arg = (Expr *) node;
1911 }
1912 else
1913 {
1914 node = coerce_type(pstate,
1915 node,
1916 actual_arg_types[i],
1917 declared_arg_types[i], -1,
1918 COERCION_IMPLICIT,
1919 COERCE_IMPLICIT_CAST,
1920 -1);
1921 lfirst(current_fargs) = node;
1922 }
1923 }
1924 i++;
1925 }
1926}
1927
1928/*
1929 * FuncNameAsType -

Callers 4

make_opFunction · 0.85
make_scalar_array_opFunction · 0.85
ParseFuncOrColumnFunction · 0.85

Calls 2

coerce_typeFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected