* 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
| 1877 | * processing is wanted. |
| 1878 | */ |
| 1879 | void |
| 1880 | make_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 - |
no test coverage detected