* Add a name for a function parameter to the function's namespace */
| 1027 | * Add a name for a function parameter to the function's namespace |
| 1028 | */ |
| 1029 | static void |
| 1030 | add_parameter_name(PLpgSQL_nsitem_type itemtype, int itemno, const char *name) |
| 1031 | { |
| 1032 | /* |
| 1033 | * Before adding the name, check for duplicates. We need this even though |
| 1034 | * functioncmds.c has a similar check, because that code explicitly |
| 1035 | * doesn't complain about conflicting IN and OUT parameter names. In |
| 1036 | * plpgsql, such names are in the same namespace, so there is no way to |
| 1037 | * disambiguate. |
| 1038 | */ |
| 1039 | if (plpgsql_ns_lookup(plpgsql_ns_top(), true, |
| 1040 | name, NULL, NULL, |
| 1041 | NULL) != NULL) |
| 1042 | ereport(ERROR, |
| 1043 | (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), |
| 1044 | errmsg("parameter name \"%s\" used more than once", |
| 1045 | name))); |
| 1046 | |
| 1047 | /* OK, add the name */ |
| 1048 | plpgsql_ns_additem(itemtype, itemno, name); |
| 1049 | } |
| 1050 | |
| 1051 | /* |
| 1052 | * Add a dummy RETURN statement to the given function's body |
no test coverage detected