mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Convert the reg* input functions to report (most) errors softly.
This is not really complete, but it catches most cases of practical interest. The main omissions are: * regtype, regprocedure, and regoperator parse type names by calling the main grammar, so any grammar-detected syntax error will still be a hard error. Also, if one includes a type modifier in such a type specification, errors detected by the typmodin function will be hard errors. * Lookup errors are handled just by passing missing_ok = true to the relevant catalog lookup function. Because we've used quite a restrictive definition of "missing_ok", this means that edge cases such as "the named schema exists, but you lack USAGE permission on it" are still hard errors. It would make sense to me to replace most/all missing_ok parameters with an escontext parameter and then allow these additional lookup failure cases to be trapped too. But that's a job for some other day. Discussion: https://postgr.es/m/3342239.1671988406@sss.pgh.pa.us
This commit is contained in:
@ -3613,7 +3613,7 @@ plperl_spi_prepare(char *query, int argc, SV **argv)
|
||||
char *typstr;
|
||||
|
||||
typstr = sv2cstr(argv[i]);
|
||||
parseTypeString(typstr, &typId, &typmod, false);
|
||||
(void) parseTypeString(typstr, &typId, &typmod, NULL);
|
||||
pfree(typstr);
|
||||
|
||||
getTypeInputInfo(typId, &typInput, &typIOParam);
|
||||
|
@ -3725,7 +3725,7 @@ parse_datatype(const char *string, int location)
|
||||
error_context_stack = &syntax_errcontext;
|
||||
|
||||
/* Let the main parser try to parse it under standard SQL rules */
|
||||
typeName = typeStringToTypeName(string);
|
||||
typeName = typeStringToTypeName(string, NULL);
|
||||
typenameTypeIdAndMod(NULL, typeName, &type_id, &typmod);
|
||||
|
||||
/* Restore former ereport callback */
|
||||
|
@ -105,7 +105,7 @@ PLy_spi_prepare(PyObject *self, PyObject *args)
|
||||
*information for input conversion.
|
||||
********************************************************/
|
||||
|
||||
parseTypeString(sptr, &typeId, &typmod, false);
|
||||
(void) parseTypeString(sptr, &typeId, &typmod, NULL);
|
||||
|
||||
Py_DECREF(optr);
|
||||
|
||||
|
@ -615,7 +615,7 @@ call_pltcl_start_proc(Oid prolang, bool pltrusted)
|
||||
error_context_stack = &errcallback;
|
||||
|
||||
/* Parse possibly-qualified identifier and look up the function */
|
||||
namelist = stringToQualifiedNameList(start_proc);
|
||||
namelist = stringToQualifiedNameList(start_proc, NULL);
|
||||
procOid = LookupFuncName(namelist, 0, NULL, false);
|
||||
|
||||
/* Current user must have permission to call function */
|
||||
@ -2603,7 +2603,8 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
|
||||
typIOParam;
|
||||
int32 typmod;
|
||||
|
||||
parseTypeString(Tcl_GetString(argsObj[i]), &typId, &typmod, false);
|
||||
(void) parseTypeString(Tcl_GetString(argsObj[i]),
|
||||
&typId, &typmod, NULL);
|
||||
|
||||
getTypeInputInfo(typId, &typInput, &typIOParam);
|
||||
|
||||
|
Reference in New Issue
Block a user