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

Commit41d87d8

Browse files
committed
lock parent pefore first access to its structure, don't forget to unlock children
1 parentaa162a1 commit41d87d8

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

‎src/relation_info.c

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ refresh_pathman_relation_info(Oid relid,
9494
* NOTE: Trick clang analyzer (first access without NULL pointer check).
9595
* Access to field 'valid' results in a dereference of a null pointer.
9696
*/
97-
prel->cmp_proc=InvalidOid;
97+
prel->cmp_proc=InvalidOid;
9898

9999
/* Clear outdated resources */
100100
if (found_entry&&PrelIsValid(prel))
@@ -104,6 +104,23 @@ refresh_pathman_relation_info(Oid relid,
104104
FreeRangesArray(prel);
105105
}
106106

107+
/* Try locking parent, exit fast if 'allow_incomplete' */
108+
if (allow_incomplete)
109+
{
110+
if (!ConditionalLockRelationOid(relid,lockmode))
111+
returnNULL;/* leave an invalid entry */
112+
}
113+
elseLockRelationOid(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+
returnNULL;/* exit */
122+
}
123+
107124
/* First we assume that this entry is invalid */
108125
prel->valid= false;
109126

@@ -137,23 +154,6 @@ refresh_pathman_relation_info(Oid relid,
137154
prel->cmp_proc=typcache->cmp_proc;
138155
prel->hash_proc=typcache->hash_proc;
139156

140-
/* Try locking parent, exit fast if 'allow_incomplete' */
141-
if (allow_incomplete)
142-
{
143-
if (!ConditionalLockRelationOid(relid,lockmode))
144-
returnNULL;/* leave an invalid entry */
145-
}
146-
elseLockRelationOid(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-
returnNULL;/* exit */
155-
}
156-
157157
/* Try searching for children (don't wait if we can't lock) */
158158
switch (find_inheritance_children_array(relid,lockmode,
159159
allow_incomplete,
@@ -189,10 +189,16 @@ refresh_pathman_relation_info(Oid relid,
189189
*/
190190
fill_prel_with_partitions(prel_children,prel_children_count,prel);
191191

192-
/*Add "partition+parent" pair to cache */
192+
/*Peform some actions for each child */
193193
for (i=0;i<prel_children_count;i++)
194+
{
195+
/* Add "partition+parent" pair to cache */
194196
cache_parent_of_partition(prel_children[i],relid);
195197

198+
/* Now it's time to unlock this child */
199+
UnlockRelationOid(prel_children[i],lockmode);
200+
}
201+
196202
pfree(prel_children);
197203

198204
/* Read additional parameters ('enable_parent' and 'auto' at the moment) */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp