Skip to content

Commit 94f621b

Browse files
committed
Read parents list before it could lead to segfault
1 parent 91005d0 commit 94f621b

File tree

2 files changed

+5
-26
lines changed

2 files changed

+5
-26
lines changed

src/include/compat/pg_compat.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static inline void mult_result_handler() { elog(ERROR, ERR_PART_ATTR_MULTIPLE_RE
322322
/*
323323
* extract_actual_join_clauses()
324324
*/
325-
#if (PG_VERSION_NUM >= 100004) || \
325+
#if (PG_VERSION_NUM >= 100003) || \
326326
(PG_VERSION_NUM < 100000 && PG_VERSION_NUM >= 90609) || \
327327
(PG_VERSION_NUM < 90600 && PG_VERSION_NUM >= 90513)
328328
#define extract_actual_join_clauses_compat(restrictinfo_list, \

src/relation_info.c

+4-25
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,6 @@ finish_delayed_invalidation(void)
991991
{
992992
Oid *parents = NULL;
993993
int parents_count = 0;
994-
bool parents_fetched = false;
995994
ListCell *lc;
996995

997996
AcceptInvalidationMessages();
@@ -1017,26 +1016,19 @@ finish_delayed_invalidation(void)
10171016

10181017
/* Disregard all remaining invalidation jobs */
10191018
delayed_invalidation_whole_cache = false;
1020-
free_invalidation_lists();
10211019

1022-
/* No need to continue, exit */
1023-
return;
1020+
goto end;
10241021
}
10251022
}
10261023

1024+
parents = read_parent_oids(&parents_count);
1025+
10271026
/* We might be asked to perform a complete cache invalidation */
10281027
if (delayed_invalidation_whole_cache)
10291028
{
10301029
/* Unset 'invalidation_whole_cache' flag */
10311030
delayed_invalidation_whole_cache = false;
10321031

1033-
/* Fetch all partitioned tables */
1034-
if (!parents_fetched)
1035-
{
1036-
parents = read_parent_oids(&parents_count);
1037-
parents_fetched = true;
1038-
}
1039-
10401032
/* Invalidate live entries and remove dead ones */
10411033
invalidate_pathman_relation_info_cache(parents, parents_count);
10421034
}
@@ -1050,13 +1042,6 @@ finish_delayed_invalidation(void)
10501042
if (IsToastNamespace(get_rel_namespace(parent)))
10511043
continue;
10521044

1053-
/* Fetch all partitioned tables */
1054-
if (!parents_fetched)
1055-
{
1056-
parents = read_parent_oids(&parents_count);
1057-
parents_fetched = true;
1058-
}
1059-
10601045
/* Check if parent still exists */
10611046
if (bsearch_oid(parent, parents, parents_count))
10621047
/* get_pathman_relation_info() will refresh this entry */
@@ -1074,13 +1059,6 @@ finish_delayed_invalidation(void)
10741059
if (IsToastNamespace(get_rel_namespace(vague_rel)))
10751060
continue;
10761061

1077-
/* Fetch all partitioned tables */
1078-
if (!parents_fetched)
1079-
{
1080-
parents = read_parent_oids(&parents_count);
1081-
parents_fetched = true;
1082-
}
1083-
10841062
/* It might be a partitioned table or a partition */
10851063
if (!try_invalidate_parent(vague_rel, parents, parents_count))
10861064
{
@@ -1117,6 +1095,7 @@ finish_delayed_invalidation(void)
11171095
}
11181096
}
11191097

1098+
end:
11201099
/* Finally, free invalidation jobs lists */
11211100
free_invalidation_lists();
11221101

0 commit comments

Comments
 (0)