Skip to content

Commit add3e9c

Browse files
committed
remove dead code & fix logic in get_pathman_relation_info()
1 parent 2133015 commit add3e9c

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

src/relation_info.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ PartRelationInfo *
322322
get_pathman_relation_info(Oid relid)
323323
{
324324
PartStatusInfo *psin;
325-
bool refresh;
326325

327326
/* Should always be called in transaction */
328327
Assert(IsTransactionState());
@@ -331,24 +330,18 @@ get_pathman_relation_info(Oid relid)
331330
if (relid < FirstNormalObjectId)
332331
return NULL;
333332

334-
/* Create a new entry for this table if needed */
333+
/* Do we know anything about this relation? */
335334
psin = pathman_cache_search_relid(status_cache,
336335
relid, HASH_FIND,
337336
NULL);
338337

339-
/* Should we build a new PartRelationInfo? */
340-
refresh = psin ?
341-
(psin->prel &&
342-
!PrelIsFresh(psin->prel) &&
343-
PrelReferenceCount(psin->prel) == 0) :
344-
true;
345-
346-
if (refresh)
338+
if (!psin)
347339
{
348340
PartRelationInfo *prel = NULL;
349341
ItemPointerData iptr;
350342
Datum values[Natts_pathman_config];
351343
bool isnull[Natts_pathman_config];
344+
bool found;
352345

353346
/* Check if PATHMAN_CONFIG table contains this relation */
354347
if (pathman_config_contains_relation(relid, values, isnull, NULL, &iptr))
@@ -364,21 +357,19 @@ get_pathman_relation_info(Oid relid)
364357
prel = build_pathman_relation_info(relid, values);
365358
}
366359

367-
/* Create a new entry for this table if needed */
368-
if (!psin)
369-
{
370-
bool found;
371-
372-
psin = pathman_cache_search_relid(status_cache,
373-
relid, HASH_ENTER,
374-
&found);
375-
Assert(!found);
376-
}
360+
/* Create a new entry for this relation */
361+
psin = pathman_cache_search_relid(status_cache,
362+
relid, HASH_ENTER,
363+
&found);
364+
Assert(!found); /* it shouldn't just appear out of thin air */
377365

378366
/* Cache fresh entry */
379367
psin->prel = prel;
380368
}
381369

370+
/* Check invariants */
371+
Assert(!psin->prel || PrelIsFresh(psin->prel));
372+
382373
#ifdef USE_RELINFO_LOGGING
383374
elog(DEBUG2,
384375
"fetching %s record for parent %u [%u]",

0 commit comments

Comments
 (0)