@@ -94,7 +94,7 @@ refresh_pathman_relation_info(Oid relid,
94
94
* NOTE: Trick clang analyzer (first access without NULL pointer check).
95
95
* Access to field 'valid' results in a dereference of a null pointer.
96
96
*/
97
- prel -> cmp_proc = InvalidOid ;
97
+ prel -> cmp_proc = InvalidOid ;
98
98
99
99
/* Clear outdated resources */
100
100
if (found_entry && PrelIsValid (prel ))
@@ -104,6 +104,23 @@ refresh_pathman_relation_info(Oid relid,
104
104
FreeRangesArray (prel );
105
105
}
106
106
107
+ /* Try locking parent, exit fast if 'allow_incomplete' */
108
+ if (allow_incomplete )
109
+ {
110
+ if (!ConditionalLockRelationOid (relid , lockmode ))
111
+ return NULL ; /* leave an invalid entry */
112
+ }
113
+ else LockRelationOid (relid , lockmode );
114
+
115
+ /* Check if parent exists */
116
+ if (!SearchSysCacheExists1 (RELOID , ObjectIdGetDatum (relid )))
117
+ {
118
+ /* Nope, it doesn't, remove this entry and exit */
119
+ UnlockRelationOid (relid , lockmode );
120
+ remove_pathman_relation_info (relid );
121
+ return NULL ; /* exit */
122
+ }
123
+
107
124
/* First we assume that this entry is invalid */
108
125
prel -> valid = false;
109
126
@@ -137,23 +154,6 @@ refresh_pathman_relation_info(Oid relid,
137
154
prel -> cmp_proc = typcache -> cmp_proc ;
138
155
prel -> hash_proc = typcache -> hash_proc ;
139
156
140
- /* Try locking parent, exit fast if 'allow_incomplete' */
141
- if (allow_incomplete )
142
- {
143
- if (!ConditionalLockRelationOid (relid , lockmode ))
144
- return NULL ; /* leave an invalid entry */
145
- }
146
- else LockRelationOid (relid , lockmode );
147
-
148
- /* Check if parent exists */
149
- if (!SearchSysCacheExists1 (RELOID , ObjectIdGetDatum (relid )))
150
- {
151
- /* Nope, it doesn't, remove this entry and exit */
152
- UnlockRelationOid (relid , lockmode );
153
- remove_pathman_relation_info (relid );
154
- return NULL ; /* exit */
155
- }
156
-
157
157
/* Try searching for children (don't wait if we can't lock) */
158
158
switch (find_inheritance_children_array (relid , lockmode ,
159
159
allow_incomplete ,
@@ -189,10 +189,16 @@ refresh_pathman_relation_info(Oid relid,
189
189
*/
190
190
fill_prel_with_partitions (prel_children , prel_children_count , prel );
191
191
192
- /* Add "partition+parent" pair to cache */
192
+ /* Peform some actions for each child */
193
193
for (i = 0 ; i < prel_children_count ; i ++ )
194
+ {
195
+ /* Add "partition+parent" pair to cache */
194
196
cache_parent_of_partition (prel_children [i ], relid );
195
197
198
+ /* Now it's time to unlock this child */
199
+ UnlockRelationOid (prel_children [i ], lockmode );
200
+ }
201
+
196
202
pfree (prel_children );
197
203
198
204
/* Read additional parameters ('enable_parent' and 'auto' at the moment) */
0 commit comments