@@ -183,7 +183,6 @@ typedef struct RI_CompareHashEntry
183183 * ----------
184184 */
185185static HTAB * ri_constraint_cache = NULL ;
186- static long ri_constraint_cache_seq_count = 0 ;
187186static HTAB * ri_query_cache = NULL ;
188187static HTAB * ri_compare_cache = NULL ;
189188
@@ -216,7 +215,6 @@ static bool ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
216215static bool ri_AttributesEqual (Oid eq_opr , Oid typeid ,
217216 Datum oldvalue , Datum newvalue );
218217
219- static void ri_InitConstraintCache (void );
220218static void ri_InitHashTables (void );
221219static void InvalidateConstraintCacheCallBack (Datum arg , int cacheid , uint32 hashvalue );
222220static SPIPlanPtr ri_FetchPreparedPlan (RI_QueryKey * key );
@@ -2947,20 +2945,6 @@ InvalidateConstraintCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
29472945
29482946 Assert (ri_constraint_cache != NULL );
29492947
2950- /*
2951- * Prevent an O(N^2) problem when creating large amounts of foreign
2952- * key constraints with ALTER TABLE, like it happens at the end of
2953- * a pg_dump with hundred-thousands of tables having references.
2954- */
2955- ri_constraint_cache_seq_count += hash_get_num_entries (ri_constraint_cache );
2956- if (ri_constraint_cache_seq_count > 1000000 )
2957- {
2958- hash_destroy (ri_constraint_cache );
2959- ri_InitConstraintCache ();
2960- ri_constraint_cache_seq_count = 0 ;
2961- return ;
2962- }
2963-
29642948 hash_seq_init (& status , ri_constraint_cache );
29652949 while ((hentry = (RI_ConstraintInfo * ) hash_seq_search (& status )) != NULL )
29662950 {
@@ -3380,15 +3364,13 @@ ri_NullCheck(HeapTuple tup,
33803364
33813365
33823366/* ----------
3383- * ri_InitConstraintCache
3384- *
3385- * Initialize ri_constraint_cache when new or being rebuilt.
3367+ * ri_InitHashTables -
33863368 *
3387- * This needs to be done from two places, so split it out to prevent drift .
3369+ * Initialize our internal hash tables .
33883370 * ----------
33893371 */
33903372static void
3391- ri_InitConstraintCache (void )
3373+ ri_InitHashTables (void )
33923374{
33933375 HASHCTL ctl ;
33943376
@@ -3398,20 +3380,6 @@ ri_InitConstraintCache(void)
33983380 ri_constraint_cache = hash_create ("RI constraint cache" ,
33993381 RI_INIT_CONSTRAINTHASHSIZE ,
34003382 & ctl , HASH_ELEM | HASH_BLOBS );
3401- }
3402-
3403- /* ----------
3404- * ri_InitHashTables -
3405- *
3406- * Initialize our internal hash tables.
3407- * ----------
3408- */
3409- static void
3410- ri_InitHashTables (void )
3411- {
3412- HASHCTL ctl ;
3413-
3414- ri_InitConstraintCache ();
34153383
34163384 /* Arrange to flush cache on pg_constraint changes */
34173385 CacheRegisterSyscacheCallback (CONSTROID ,
0 commit comments