Skip to content

Commit 14e05f2

Browse files
committed
[WIP] add 'allow_incomplete' option to function refresh_pathman_relation_info()
1 parent f603e6c commit 14e05f2

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

src/init.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,9 @@ read_pathman_config(void)
752752
}
753753

754754
/* Create or update PartRelationInfo for this partitioned table */
755-
refresh_pathman_relation_info(relid, parttype, text_to_cstring(attname));
755+
refresh_pathman_relation_info(relid, parttype,
756+
text_to_cstring(attname),
757+
true); /* allow lazy prel loading */
756758
}
757759

758760
/* Clean resources */

src/pl_funcs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,9 @@ add_to_pathman_config(PG_FUNCTION_ARGS)
623623
/* Some flags might change during refresh attempt */
624624
save_pathman_init_state(&init_state);
625625

626-
refresh_pathman_relation_info(relid, parttype, text_to_cstring(attname));
626+
refresh_pathman_relation_info(relid, parttype,
627+
text_to_cstring(attname),
628+
false); /* initialize immediately */
627629
}
628630
PG_CATCH();
629631
{

src/relation_info.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ static Oid get_parent_of_partition_internal(Oid partition,
6767
const PartRelationInfo *
6868
refresh_pathman_relation_info(Oid relid,
6969
PartType partitioning_type,
70-
const char *part_column_name)
70+
const char *part_column_name,
71+
bool allow_incomplete)
7172
{
7273
const LOCKMODE lockmode = AccessShareLock;
7374
const TypeCacheEntry *typcache;
@@ -103,14 +104,14 @@ refresh_pathman_relation_info(Oid relid,
103104
}
104105

105106
/* First we assume that this entry is invalid */
106-
prel->valid = false;
107+
prel->valid = false;
107108

108109
/* Make both arrays point to NULL */
109-
prel->children = NULL;
110-
prel->ranges = NULL;
110+
prel->children = NULL;
111+
prel->ranges = NULL;
111112

112113
/* Set partitioning type */
113-
prel->parttype = partitioning_type;
114+
prel->parttype = partitioning_type;
114115

115116
/* Initialize PartRelationInfo using syscache & typcache */
116117
prel->attnum = get_attnum(relid, part_column_name);
@@ -245,9 +246,8 @@ get_pathman_relation_info(Oid relid)
245246

246247
/* Refresh partitioned table cache entry (might turn NULL) */
247248
/* TODO: possible refactoring, pass found 'prel' instead of searching */
248-
prel = refresh_pathman_relation_info(relid,
249-
part_type,
250-
attname);
249+
prel = refresh_pathman_relation_info(relid, part_type,
250+
attname, false);
251251
}
252252
/* Else clear remaining cache entry */
253253
else remove_pathman_relation_info(relid);
@@ -611,10 +611,10 @@ try_perform_parent_refresh(Oid parent)
611611
parttype = DatumGetPartType(values[Anum_pathman_config_parttype - 1]);
612612
attname = DatumGetTextP(values[Anum_pathman_config_attname - 1]);
613613

614-
/* If anything went wrong, return false (actually, it might throw ERROR) */
615-
if (!PrelIsValid(refresh_pathman_relation_info(parent, parttype,
616-
text_to_cstring(attname))))
617-
return false;
614+
/* If anything went wrong, return false (actually, it might emit ERROR) */
615+
refresh_pathman_relation_info(parent, parttype,
616+
text_to_cstring(attname),
617+
true); /* allow lazy */
618618
}
619619
/* Not a partitioned relation */
620620
else return false;

src/relation_info.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ PrelLastChild(const PartRelationInfo *prel)
120120

121121
const PartRelationInfo *refresh_pathman_relation_info(Oid relid,
122122
PartType partitioning_type,
123-
const char *part_column_name);
123+
const char *part_column_name,
124+
bool allow_incomplete);
124125
void invalidate_pathman_relation_info(Oid relid, bool *found);
125126
void remove_pathman_relation_info(Oid relid);
126127
const PartRelationInfo *get_pathman_relation_info(Oid relid);

0 commit comments

Comments
 (0)