Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d066c96

Browse files
author
Alexander Korotkov
committed
Fix in_memory utility command hook with missing_ok flag.
1 parent 039ce82 commit d066c96

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

contrib/in_memory/in_memory.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "postmaster/autovacuum.h"
2727
#include "replication/message.h"
2828
#include "storage/ipc.h"
29+
#include "storage/lmgr.h"
2930
#include "storage/lwlock.h"
3031
#include "storage/proc.h"
3132
#include "storage/shmem.h"
@@ -345,8 +346,7 @@ in_memory_utility_command(PlannedStmt *pstmt,
345346
}
346347
else if (IsA(pstmt->utilityStmt, AlterTableStmt))
347348
{
348-
AlterTableStmt *stmt = (AlterTableStmt*)pstmt->utilityStmt;
349-
RangeVar *rv;
349+
AlterTableStmt *stmt = (AlterTableStmt * )pstmt->utilityStmt;
350350
Relation rel;
351351
Oid myrelid;
352352
LOCKMODE mode;
@@ -365,20 +365,22 @@ in_memory_utility_command(PlannedStmt *pstmt,
365365
}
366366
if (mode != AccessExclusiveLock)
367367
goto done_alter_table;
368-
rv = stmt->relation;
369-
rel = heap_openrv(rv, AccessExclusiveLock);
370-
myrelid = RelationGetRelid(rel);
368+
myrelid = AlterTableLookupRelation(stmt, AccessExclusiveLock);
369+
370+
if (!OidIsValid(myrelid))
371+
goto done_alter_table;
371372

372373
if (!check_fdw_is_in_memory_relid(myrelid))
373374
{
374-
heap_close(rel, AccessExclusiveLock);
375+
UnlockRelationOid(myrelid, AccessExclusiveLock);
375376
goto done_alter_table;
376377
}
377378

379+
rel = heap_open(myrelid, NoLock);
378380
validate_fdw_alter_table_commands(myrelid, stmt->cmds, rel);
379381
call_next = true;
380382
heap_close(rel, AccessExclusiveLock);
381-
383+
382384
done_alter_table:
383385
(void)0;
384386
}

0 commit comments

Comments
 (0)