mirror of
https://github.com/postgres/postgres.git
synced 2025-11-26 23:43:30 +03:00
Fix a number of places that produced XX000 errors in the regression tests.
It's against project policy to use elog() for user-facing errors, or to omit an errcode() selection for errors that aren't supposed to be "can't happen" cases. Fix all the violations of this policy that result in ERRCODE_INTERNAL_ERROR log entries during the standard regression tests, as errors that can reliably be triggered from SQL surely should be considered user-facing. I also looked through all the files touched by this commit and fixed other nearby problems of the same ilk. I do not claim to have fixed all violations of the policy, just the ones in these files. In a few places I also changed existing ERRCODE choices that didn't seem particularly appropriate; mainly replacing ERRCODE_SYNTAX_ERROR by something more specific. Back-patch to 9.5, but no further; changing ERRCODE assignments in stable branches doesn't seem like a good idea.
This commit is contained in:
@@ -662,11 +662,13 @@ PLy_modify_tuple(PLyProcedure *proc, PyObject *pltd, TriggerData *tdata,
|
||||
{
|
||||
if ((plntup = PyDict_GetItemString(pltd, "new")) == NULL)
|
||||
ereport(ERROR,
|
||||
(errmsg("TD[\"new\"] deleted, cannot modify row")));
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("TD[\"new\"] deleted, cannot modify row")));
|
||||
Py_INCREF(plntup);
|
||||
if (!PyDict_Check(plntup))
|
||||
ereport(ERROR,
|
||||
(errmsg("TD[\"new\"] is not a dictionary")));
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("TD[\"new\"] is not a dictionary")));
|
||||
|
||||
plkeys = PyDict_Keys(plntup);
|
||||
natts = PyList_Size(plkeys);
|
||||
@@ -690,13 +692,15 @@ PLy_modify_tuple(PLyProcedure *proc, PyObject *pltd, TriggerData *tdata,
|
||||
else
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errmsg("TD[\"new\"] dictionary key at ordinal position %d is not a string", i)));
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("TD[\"new\"] dictionary key at ordinal position %d is not a string", i)));
|
||||
plattstr = NULL; /* keep compiler quiet */
|
||||
}
|
||||
attn = SPI_fnumber(tupdesc, plattstr);
|
||||
if (attn == SPI_ERROR_NOATTRIBUTE)
|
||||
ereport(ERROR,
|
||||
(errmsg("key \"%s\" found in TD[\"new\"] does not exist as a column in the triggering row",
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("key \"%s\" found in TD[\"new\"] does not exist as a column in the triggering row",
|
||||
plattstr)));
|
||||
atti = attn - 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user