From 7f1bcfb93df90adcf3c7230234fc123096e2a639 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 6 Nov 2016 19:22:12 -0500 Subject: [PATCH] Sync pltcl_build_tuple_result's error handling with pltcl_trigger_handler. Meant to do this in 26abb50c4, but forgot. --- src/pl/tcl/pltcl.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 3d529c2e7d..3e52113ee2 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -3057,11 +3057,29 @@ pltcl_build_tuple_result(Tcl_Interp *interp, Tcl_Obj **kvObjv, int kvObjc, char *fieldName = utf_e2u(Tcl_GetString(kvObjv[i])); int attn = SPI_fnumber(call_state->ret_tupdesc, fieldName); - if (attn <= 0 || call_state->ret_tupdesc->attrs[attn - 1]->attisdropped) + /* + * As in pltcl_trigger_handler, silently ignore ".tupno" if it's in + * the list but doesn't match any column name. + */ + if (attn == SPI_ERROR_NOATTRIBUTE) + { + if (strcmp(fieldName, ".tupno") == 0) + continue; ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column name/value list contains nonexistent column name \"%s\"", fieldName))); + } + + if (attn <= 0) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot set system attribute \"%s\"", + fieldName))); + + /* Ignore dropped attributes */ + if (call_state->ret_tupdesc->attrs[attn - 1]->attisdropped) + continue; values[attn - 1] = utf_e2u(Tcl_GetString(kvObjv[i + 1])); } -- 2.49.0