Repository: incubator-hawq Updated Branches: refs/heads/master 2ae1c9569 -> aaafcab84
HAWQ-815. KeyError while compiling PLPython function due to deletion of non-existent record from Python global dict Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/aaafcab8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/aaafcab8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/aaafcab8 Branch: refs/heads/master Commit: aaafcab8476d8de116b58e4a10fe04427e7f5504 Parents: 2ae1c95 Author: Ruilong Huo <[email protected]> Authored: Tue Jun 14 23:15:07 2016 +0800 Committer: Ruilong Huo <[email protected]> Committed: Thu Jun 16 10:14:49 2016 +0800 ---------------------------------------------------------------------- src/pl/plpython/plpython.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/aaafcab8/src/pl/plpython/plpython.c ---------------------------------------------------------------------- diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index e27c664..80bda83 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -1457,13 +1457,25 @@ static void PLy_function_delete_args(PLyProcedure *proc) { int i; + PyObject *arg; if (!proc->argnames) return; for (i = 0; i < proc->nargs; i++) + { if (proc->argnames[i]) - PyDict_DelItemString(proc->globals, proc->argnames[i]); + { + arg = PyString_FromString(proc->argnames[i]); + + /* Deleting the item only if it exists in the dictionaty */ + if (PyDict_Contains(proc->globals, arg)) + { + PyDict_DelItem(proc->globals, arg); + } + Py_DECREF(arg); + } + } } /* @@ -1985,12 +1997,12 @@ PLy_procedure_munge_source(const char *name, const char *src) } } - pyelog(INFO, "After searching the start of the string, index is: %d sf is: %d endquote is: %c", i, sf, cendquote); + pyelog(INFO, "After searching the start of the string, index is: %d sf is: %d endquote is: %c", (int)i, sf, cendquote); /* now copy all characters to the destination buffer if we see the beginning of a string */ while (sf != STRING_BEGIN_NOT_YET && sf != STRING_SEEN_END && i < olen) { - pyelog(INFO, "copying src[%d]=%c", i, src[i]); + pyelog(INFO, "copying src[%d]=%c", (int)i, src[i]); BOUNDED_PTR_ASSIGN_INC(mp, mrc + mlen, src[i]); @@ -2019,7 +2031,7 @@ PLy_procedure_munge_source(const char *name, const char *src) i++; } - pyelog(INFO, "After searching the END of the string, index is: %d sf is: %d", i, sf); + pyelog(INFO, "After searching the END of the string, index is: %d sf is: %d", (int)i, sf); if (i == olen) break;
