diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-11-05 17:32:29 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-11-05 17:32:29 -0400 |
commit | 1b00dd0ea0f392b08fa50f9fcaf60e8f20d26dfd (patch) | |
tree | 375d212f660d10341b4c50bfe8364ce0397fa1a3 /src | |
parent | 34ca0905706422c191b3b0afef6e1c5f54399833 (diff) | |
download | postgresql-1b00dd0ea0f392b08fa50f9fcaf60e8f20d26dfd.tar.gz postgresql-1b00dd0ea0f392b08fa50f9fcaf60e8f20d26dfd.zip |
Improve minor error-handling details in pltcl.
Don't ask Tcl_GetIndexFromObj to store an error message in the interpreter
in cases where the next argument isn't necessarily one of the options
we're asking it to check for. At best that is a waste of time, and at
worst it might cause an inappropriate error result to get left behind.
Be sure to check for valid syntax (ie, no command arguments) in
pltcl_SPI_lastoid.
Extracted from a larger and otherwise-unrelated patch.
Jim Nasby
Patch: <f2134651-14b3-efeb-f274-c69f3c084031@BlueTreble.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/pl/tcl/pltcl.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index d2368904900..9d72f47f592 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -2138,7 +2138,7 @@ pltcl_SPI_execute(ClientData cdata, Tcl_Interp *interp, i = 1; while (i < objc) { - if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", + if (Tcl_GetIndexFromObj(NULL, objv[i], options, NULL, TCL_EXACT, &optIndex) != TCL_OK) break; @@ -2484,7 +2484,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp, i = 1; while (i < objc) { - if (Tcl_GetIndexFromObj(interp, objv[i], options, "option", + if (Tcl_GetIndexFromObj(NULL, objv[i], options, NULL, TCL_EXACT, &optIndex) != TCL_OK) break; @@ -2667,6 +2667,15 @@ static int pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { + /* + * Check call syntax + */ + if (objc != 1) + { + Tcl_WrongNumArgs(interp, 1, objv, ""); + return TCL_ERROR; + } + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(SPI_lastoid)); return TCL_OK; } |