8000 handle CTA if not exists in SPI · postgrespro/postgres_cluster@f3272ae · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f3272ae

Browse files
committed
handle CTA if not exists in SPI
1 parent cfe96ae commit f3272ae

File tree

1 file changed

+9
-3
lines changed
  • src/backend/executor

1 file changed

+9
-3
lines changed

src/backend/executor/spi.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,15 +2217,21 @@ _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 = pg_strtouint64(completionTag + 7,
2220+
CreateTableAsStmt *ctastmt = (CreateTableAsStmt *) stmt;
2221+
2222+
if (strncmp(completionTag, "SELECT ", 7) == 0)
2223+
_SPI_current->processed = pg_strtouint64(completionTag + 7,
22222224
NULL, 10);
2225+
else if (*completionTag == '\0' && ctastmt->if_not_exists)
2226+
_SPI_current->processed = 0;
2227+
else
2228+
Assert(false);
22232229

22242230
/*
22252231
* For historical reasons, if CREATE TABLE AS was spelled
22262232
* as SELECT INTO, return a special return code.
22272233
*/
2228-
if (((CreateTableAsStmt *) stmt)->is_select_into)
2234+
if (ctastmt->is_select_into)
22292235
res = SPI_OK_SELINTO;
22302236
}
22312237
else if (IsA(stmt, CopyStmt))

0 commit comments

Comments
 (0)
0