26
26
#include "postmaster/autovacuum.h"
27
27
#include "replication/message.h"
28
28
#include "storage/ipc.h"
29
+ #include "storage/lmgr.h"
29
30
#include "storage/lwlock.h"
30
31
#include "storage/proc.h"
31
32
#include "storage/shmem.h"
@@ -345,8 +346,7 @@ in_memory_utility_command(PlannedStmt *pstmt,
345
346
}
346
347
else if (IsA (pstmt -> utilityStmt , AlterTableStmt ))
347
348
{
348
- AlterTableStmt * stmt = (AlterTableStmt * )pstmt -> utilityStmt ;
349
- RangeVar * rv ;
349
+ AlterTableStmt * stmt = (AlterTableStmt * )pstmt -> utilityStmt ;
350
350
Relation rel ;
351
351
Oid myrelid ;
352
352
LOCKMODE mode ;
@@ -365,20 +365,22 @@ in_memory_utility_command(PlannedStmt *pstmt,
365
365
}
366
366
if (mode != AccessExclusiveLock )
367
367
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 ;
371
372
372
373
if (!check_fdw_is_in_memory_relid (myrelid ))
373
374
{
374
- heap_close ( rel , AccessExclusiveLock );
375
+ UnlockRelationOid ( myrelid , AccessExclusiveLock );
375
376
goto done_alter_table ;
376
377
}
377
378
379
+ rel = heap_open (myrelid , NoLock );
378
380
validate_fdw_alter_table_commands (myrelid , stmt -> cmds , rel );
379
381
call_next = true;
380
382
heap_close (rel , AccessExclusiveLock );
381
-
383
+
382
384
done_alter_table :
383
385
(void )0 ;
384
386
}
0 commit comments