We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parentcfe96ae commitf3272aeCopy full SHA for f3272ae
src/backend/executor/spi.c
@@ -2217,15 +2217,21 @@ _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
2217
*/
2218
if (IsA(stmt,CreateTableAsStmt))
2219
{
2220
-Assert(strncmp(completionTag,"SELECT ",7)==0);
2221
-_SPI_current->processed=pg_strtouint64(completionTag+7,
+CreateTableAsStmt*ctastmt= (CreateTableAsStmt*)stmt;
+
2222
+if (strncmp(completionTag,"SELECT ",7)==0)
2223
+_SPI_current->processed=pg_strtouint64(completionTag+7,
2224
NULL,10);
2225
+elseif (*completionTag=='\0'&&ctastmt->if_not_exists)
2226
+_SPI_current->processed=0;
2227
+else
2228
+Assert(false);
2229
2230
/*
2231
* For historical reasons, if CREATE TABLE AS was spelled
2232
* as SELECT INTO, return a special return code.
2233
-if (((CreateTableAsStmt*)stmt)->is_select_into)
2234
+if (ctastmt->is_select_into)
2235
res=SPI_OK_SELINTO;
2236
}
2237
elseif (IsA(stmt,CopyStmt))