Skip to content

Commit 8933d19

Browse files
committed
Merge branch 'REL9_5_STABLE' into PGPRO9_5
2 parents b4967a7 + 079013f commit 8933d19

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/backend/executor/spi.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,15 +2217,23 @@ _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
22172217
*/
22182218
if (IsA(stmt, CreateTableAsStmt))
22192219
{
2220-
Assert(strncmp(completionTag, "SELECT ", 7) == 0);
2221-
_SPI_current->processed = strtoul(completionTag + 7,
2222-
NULL, 10);
2220+
CreateTableAsStmt *ctastmt = (CreateTableAsStmt *) stmt;
2221+
2222+
if (strncmp(completionTag, "SELECT ", 7) == 0)
2223+
_SPI_current->processed =
2224+
strtoul(completionTag + 7, NULL, 10);
2225+
else
2226+
{
2227+
/* Must be an IF NOT EXISTS that did nothing */
2228+
Assert(ctastmt->if_not_exists);
2229+
_SPI_current->processed = 0;
2230+
}
22232231

22242232
/*
22252233
* For historical reasons, if CREATE TABLE AS was spelled
22262234
* as SELECT INTO, return a special return code.
22272235
*/
2228-
if (((CreateTableAsStmt *) stmt)->is_select_into)
2236+
if (ctastmt->is_select_into)
22292237
res = SPI_OK_SELINTO;
22302238
}
22312239
else if (IsA(stmt, CopyStmt))

src/pl/plpython/plpy_elog.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ PLy_traceback(PyObject *e, PyObject *v, PyObject *tb,
226226

227227
PG_TRY();
228228
{
229+
/*
230+
* Ancient versions of Python (circa 2.3) contain a bug whereby
231+
* the fetches below can fail if the error indicator is set.
232+
*/
233+
PyErr_Clear();
234+
229235
lineno = PyObject_GetAttrString(tb, "tb_lineno");
230236
if (lineno == NULL)
231237
elog(ERROR, "could not get line number from Python traceback");

0 commit comments

Comments
 (0)