Skip to content

Commit a93a846

Browse files
committed
Merge branch 'master_pgdump_bug' into rel_1_3_beta
2 parents cff45b5 + f0ed244 commit a93a846

File tree

7 files changed

+250
-23
lines changed

7 files changed

+250
-23
lines changed

src/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ pathman_relcache_hook(Datum arg, Oid relid)
605605
return;
606606

607607
/* Invalidation event for PATHMAN_CONFIG table (probably DROP) */
608-
if (relid == get_pathman_config_relid())
608+
if (relid == get_pathman_config_relid(false))
609609
delay_pathman_shutdown();
610610

611611
/* Invalidate PartParentInfo cache if needed */

src/init.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ pathman_config_contains_relation(Oid relid, Datum *values, bool *isnull,
676676
ObjectIdGetDatum(relid));
677677

678678
/* Open PATHMAN_CONFIG with latest snapshot available */
679-
rel = heap_open(get_pathman_config_relid(), AccessShareLock);
679+
rel = heap_open(get_pathman_config_relid(false), AccessShareLock);
680680

681681
/* Check that 'partrel' column is if regclass type */
682682
Assert(RelationGetDescr(rel)->
@@ -750,7 +750,7 @@ read_pathman_params(Oid relid, Datum *values, bool *isnull)
750750
BTEqualStrategyNumber, F_OIDEQ,
751751
ObjectIdGetDatum(relid));
752752

753-
rel = heap_open(get_pathman_config_params_relid(), AccessShareLock);
753+
rel = heap_open(get_pathman_config_params_relid(false), AccessShareLock);
754754
snapshot = RegisterSnapshot(GetLatestSnapshot());
755755
scan = heap_beginscan(rel, snapshot, 1, key);
756756

@@ -789,7 +789,7 @@ read_pathman_config(void)
789789
HeapTuple htup;
790790

791791
/* Open PATHMAN_CONFIG with latest snapshot available */
792-
rel = heap_open(get_pathman_config_relid(), AccessShareLock);
792+
rel = heap_open(get_pathman_config_relid(false), AccessShareLock);
793793

794794
/* Check that 'partrel' column is if regclass type */
795795
Assert(RelationGetDescr(rel)->

src/pathman.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ extern Oid pathman_config_params_relid;
8585
/*
8686
* Just to clarify our intentions (return the corresponding relid).
8787
*/
88-
Oid get_pathman_config_relid(void);
89-
Oid get_pathman_config_params_relid(void);
88+
Oid get_pathman_config_relid(bool invalid_is_ok);
89+
Oid get_pathman_config_params_relid(bool invalid_is_ok);
9090

9191
/*
9292
* pg_pathman's global state structure.

src/pg_pathman.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,16 +1922,32 @@ generate_mergeappend_paths(PlannerInfo *root, RelOptInfo *rel,
19221922
* Get cached PATHMAN_CONFIG relation Oid.
19231923
*/
19241924
Oid
1925-
get_pathman_config_relid(void)
1925+
get_pathman_config_relid(bool invalid_is_ok)
19261926
{
1927+
/* Raise ERROR if Oid is invalid */
1928+
if (!OidIsValid(pathman_config_relid) && !invalid_is_ok)
1929+
elog(ERROR,
1930+
(!IsPathmanInitialized() ?
1931+
"pg_pathman is not initialized yet" :
1932+
"unexpected error in function "
1933+
CppAsString(get_pathman_config_relid)));
1934+
19271935
return pathman_config_relid;
19281936
}
19291937

19301938
/*
19311939
* Get cached PATHMAN_CONFIG_PARAMS relation Oid.
19321940
*/
19331941
Oid
1934-
get_pathman_config_params_relid(void)
1942+
get_pathman_config_params_relid(bool invalid_is_ok)
19351943
{
1944+
/* Raise ERROR if Oid is invalid */
1945+
if (!OidIsValid(pathman_config_relid) && !invalid_is_ok)
1946+
elog(ERROR,
1947+
(!IsPathmanInitialized() ?
1948+
"pg_pathman is not initialized yet" :
1949+
"unexpected error in function "
1950+
CppAsString(get_pathman_config_params_relid)));
1951+
19361952
return pathman_config_params_relid;
19371953
}

src/pl_funcs.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ show_partition_list_internal(PG_FUNCTION_ARGS)
285285
usercxt = (show_partition_list_cxt *) palloc(sizeof(show_partition_list_cxt));
286286

287287
/* Open PATHMAN_CONFIG with latest snapshot available */
288-
usercxt->pathman_config = heap_open(get_pathman_config_relid(),
288+
usercxt->pathman_config = heap_open(get_pathman_config_relid(false),
289289
AccessShareLock);
290290
usercxt->snapshot = RegisterSnapshot(GetLatestSnapshot());
291291
usercxt->pathman_config_scan = heap_beginscan(usercxt->pathman_config,
@@ -637,7 +637,7 @@ add_to_pathman_config(PG_FUNCTION_ARGS)
637637
isnull[Anum_pathman_config_range_interval - 1] = PG_ARGISNULL(2);
638638

639639
/* Insert new row into PATHMAN_CONFIG */
640-
pathman_config = heap_open(get_pathman_config_relid(), RowExclusiveLock);
640+
pathman_config = heap_open(get_pathman_config_relid(false), RowExclusiveLock);
641641
htup = heap_form_tuple(RelationGetDescr(pathman_config), values, isnull);
642642
simple_heap_insert(pathman_config, htup);
643643
indstate = CatalogOpenIndexes(pathman_config);
@@ -685,11 +685,18 @@ Datum
685685
pathman_config_params_trigger_func(PG_FUNCTION_ARGS)
686686
{
687687
TriggerData *trigdata = (TriggerData *) fcinfo->context;
688-
Oid pathman_config_params = get_pathman_config_params_relid();
688+
Oid pathman_config_params;
689689
Oid partrel;
690690
Datum partrel_datum;
691691
bool partrel_isnull;
692692

693+
/* Fetch Oid of PATHMAN_CONFIG_PARAMS */
694+
pathman_config_params = get_pathman_config_params_relid(true);
695+
696+
/* Handle "pg_pathman.enabled = t" case */
697+
if (!OidIsValid(pathman_config_params))
698+
goto pathman_config_params_trigger_func_return;
699+
693700
/* Handle user calls */
694701
if (!CALLED_AS_TRIGGER(fcinfo))
695702
elog(ERROR, "this function should not be called directly");
@@ -718,6 +725,7 @@ pathman_config_params_trigger_func(PG_FUNCTION_ARGS)
718725
if (check_relation_exists(partrel))
719726
CacheInvalidateRelcacheByRelid(partrel);
720727

728+
pathman_config_params_trigger_func_return:
721729
/* Return the tuple we've been given */
722730
if (trigdata->tg_event & TRIGGER_EVENT_UPDATE)
723731
PG_RETURN_POINTER(trigdata->tg_newtuple);

src/relation_info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ finish_delayed_invalidation(void)
417417

418418
/* Check that PATHMAN_CONFIG table has indeed been dropped */
419419
if (cur_pathman_config_relid == InvalidOid ||
420-
cur_pathman_config_relid != get_pathman_config_relid())
420+
cur_pathman_config_relid != get_pathman_config_relid(true))
421421
{
422422
/* Ok, let's unload pg_pathman's config */
423423
unload_config();

0 commit comments

Comments
 (0)