68
68
#include "parser/parse_collate.h"
69
69
#include "parser/parse_expr.h"
70
70
#include "parser/parse_relation.h"
71
+ #include "storage/lmgr.h"
71
72
#include "storage/predicate.h"
72
73
#include "storage/smgr.h"
73
74
#include "utils/acl.h"
@@ -1760,8 +1761,7 @@ heap_drop_with_catalog(Oid relid)
1760
1761
{
1761
1762
Relation rel ;
1762
1763
HeapTuple tuple ;
1763
- Oid parentOid ;
1764
- Relation parent = NULL ;
1764
+ Oid parentOid = InvalidOid ;
1765
1765
1766
1766
/*
1767
1767
* To drop a partition safely, we must grab exclusive lock on its parent,
@@ -1776,7 +1776,7 @@ heap_drop_with_catalog(Oid relid)
1776
1776
if (((Form_pg_class ) GETSTRUCT (tuple ))-> relispartition )
1777
1777
{
1778
1778
parentOid = get_partition_parent (relid );
1779
- parent = heap_open (parentOid , AccessExclusiveLock );
1779
+ LockRelationOid (parentOid , AccessExclusiveLock );
1780
1780
}
1781
1781
1782
1782
ReleaseSysCache (tuple );
@@ -1885,14 +1885,14 @@ heap_drop_with_catalog(Oid relid)
1885
1885
*/
1886
1886
DeleteRelationTuple (relid );
1887
1887
1888
- if (parent )
1888
+ if (OidIsValid ( parentOid ) )
1889
1889
{
1890
1890
/*
1891
1891
* Invalidate the parent's relcache so that the partition is no longer
1892
1892
* included in its partition descriptor.
1893
1893
*/
1894
- CacheInvalidateRelcache ( parent );
1895
- heap_close ( parent , NoLock ); /* keep the lock */
1894
+ CacheInvalidateRelcacheByRelid ( parentOid );
1895
+ /* keep the lock */
1896
1896
}
1897
1897
}
1898
1898
0 commit comments