Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit079013f

Browse files
committed
Fix _SPI_execute_plan() for CREATE TABLE IF NOT EXISTS foo AS ...
When IF NOT EXISTS was added to CREATE TABLE AS, this logic didn't getthe memo, possibly resulting in an Assert failure. It looks like therewould have been no ill effects in a non-Assert build, though. Back-patchto 9.5 where the IF NOT EXISTS option was added.Stas Kelvich
1 parent8207c6b commit079013f

File tree

1 file changed

+12
-4
lines changed
  • src/backend/executor

1 file changed

+12
-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
elseif (IsA(stmt,CopyStmt))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp