aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/relcache.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-06-07 17:21:17 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-06-07 17:21:17 -0400
commit77ba610805e7ef9ba9c9a593ea8b1ca8f98f8bcb (patch)
tree1c607e007c59f23ab471bb790e1237cf8d849e5e /src/backend/utils/cache/relcache.c
parent5c6d2a5e7c83bf6e157fe4ca0ab9b123012289e9 (diff)
downloadpostgresql-77ba610805e7ef9ba9c9a593ea8b1ca8f98f8bcb.tar.gz
postgresql-77ba610805e7ef9ba9c9a593ea8b1ca8f98f8bcb.zip
Revert "Use Foreign Key relationships to infer multi-column join selectivity".
This commit reverts 137805f89 as well as the associated commits 015e88942, 5306df283, and 68d704edb. We found multiple bugs in this feature, and there was concern about possible planner slowdown (though to be fair, exhibiting a very large slowdown proved difficult). The way forward requires a considerable rewrite, which may or may not be possible to accomplish in time for beta2. In my judgment reviewing the rewrite will be easier to accomplish starting from a clean slate, so let's temporarily revert what's there now. This also leaves us in a safe state if it turns out to be necessary to postpone the rewrite to the next development cycle. Discussion: <20160429102531.GA13701@huehner.biz>
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r--src/backend/utils/cache/relcache.c75
1 files changed, 0 insertions, 75 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 79cc3df590a..1b7b99548c5 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2031,7 +2031,6 @@ RelationDestroyRelation(Relation relation, bool remember_tupdesc)
FreeTupleDesc(relation->rd_att);
}
list_free(relation->rd_indexlist);
- list_free(relation->rd_fkeylist);
bms_free(relation->rd_indexattr);
bms_free(relation->rd_keyattr);
bms_free(relation->rd_idattr);
@@ -3958,79 +3957,6 @@ RelationGetIndexList(Relation relation)
}
/*
- * RelationGetFKeyList -- get a list of foreign key oids
- *
- * Use an index scan on pg_constraint to load in FK definitions,
- * intended for use within the planner, not for enforcing FKs.
- *
- * Data is ordered by Oid, though this is not critical at this point
- * since we do not lock the referenced relations.
- */
-List *
-RelationGetFKeyList(Relation relation)
-{
- Relation conrel;
- SysScanDesc conscan;
- ScanKeyData skey;
- HeapTuple htup;
- List *result;
- List *oldlist;
- MemoryContext oldcxt;
-
- /* Quick exit if we already computed the list. */
- if (relation->rd_fkeylist)
- return list_copy(relation->rd_fkeylist);
-
- /* Fast path if no FKs... if it doesn't have a trigger, it can't have a FK */
- if (!relation->rd_rel->relhastriggers)
- return NIL;
- /*
- * We build the list we intend to return (in the caller's context) while
- * doing the scan. After successfully completing the scan, we copy that
- * list into the relcache entry. This avoids cache-context memory leakage
- * if we get some sort of error partway through.
- */
- result = NIL;
-
- /* Prepare to scan pg_constraint for entries having conrelid = this rel. */
- ScanKeyInit(&skey,
- Anum_pg_constraint_conrelid,
- BTEqualStrategyNumber, F_OIDEQ,
- ObjectIdGetDatum(RelationGetRelid(relation)));
-
- conrel = heap_open(ConstraintRelationId, AccessShareLock);
- conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true,
- NULL, 1, &skey);
-
- while (HeapTupleIsValid(htup = systable_getnext(conscan)))
- {
- Form_pg_constraint constraint = (Form_pg_constraint) GETSTRUCT(htup);
-
- /* return only foreign keys */
- if (constraint->contype != CONSTRAINT_FOREIGN)
- continue;
-
- /* Add FK's OID to result list in the proper order */
- result = insert_ordered_oid(result, HeapTupleGetOid(htup));
- }
-
- systable_endscan(conscan);
-
- heap_close(conrel, AccessShareLock);
-
- /* Now save a copy of the completed list in the relcache entry. */
- oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
- oldlist = relation->rd_fkeylist;
- relation->rd_fkeylist = list_copy(result);
- MemoryContextSwitchTo(oldcxt);
-
- /* Don't leak the old list, if there is one */
- list_free(oldlist);
-
- return result;
-}
-
-/*
* insert_ordered_oid
* Insert a new Oid into a sorted list of Oids, preserving ordering
*
@@ -4994,7 +4920,6 @@ load_relcache_init_file(bool shared)
rel->rd_indexattr = NULL;
rel->rd_keyattr = NULL;
rel->rd_idattr = NULL;
- rel->rd_fkeylist = NIL;
rel->rd_createSubid = InvalidSubTransactionId;
rel->rd_newRelfilenodeSubid = InvalidSubTransactionId;
rel->rd_amcache = NULL;