@@ -182,7 +182,6 @@ typedef struct RI_CompareHashEntry
182
182
* ----------
183
183
*/
184
184
static HTAB * ri_constraint_cache = NULL ;
185
- static long ri_constraint_cache_seq_count = 0 ;
186
185
static HTAB * ri_query_cache = NULL ;
187
186
static HTAB * ri_compare_cache = NULL ;
188
187
@@ -215,7 +214,6 @@ static bool ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
215
214
static bool ri_AttributesEqual (Oid eq_opr , Oid typeid ,
216
215
Datum oldvalue , Datum newvalue );
217
216
218
- static void ri_InitConstraintCache (void );
219
217
static void ri_InitHashTables (void );
220
218
static void InvalidateConstraintCacheCallBack (Datum arg , int cacheid , uint32 hashvalue );
221
219
static SPIPlanPtr ri_FetchPreparedPlan (RI_QueryKey * key );
@@ -2934,20 +2932,6 @@ InvalidateConstraintCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
2934
2932
2935
2933
Assert (ri_constraint_cache != NULL );
2936
2934
2937
- /*
2938
- * Prevent an O(N^2) problem when creating large amounts of foreign
2939
- * key constraints with ALTER TABLE, like it happens at the end of
2940
- * a pg_dump with hundred-thousands of tables having references.
2941
- */
2942
- ri_constraint_cache_seq_count += hash_get_num_entries (ri_constraint_cache );
2943
- if (ri_constraint_cache_seq_count > 1000000 )
2944
- {
2945
- hash_destroy (ri_constraint_cache );
2946
- ri_InitConstraintCache ();
2947
- ri_constraint_cache_seq_count = 0 ;
2948
- return ;
2949
- }
2950
-
2951
2935
hash_seq_init (& status , ri_constraint_cache );
2952
2936
while ((hentry = (RI_ConstraintInfo * ) hash_seq_search (& status )) != NULL )
2953
2937
{
@@ -3343,15 +3327,13 @@ ri_NullCheck(HeapTuple tup,
3343
3327
3344
3328
3345
3329
/* ----------
3346
- * ri_InitConstraintCache
3347
- *
3348
- * Initialize ri_constraint_cache when new or being rebuilt.
3330
+ * ri_InitHashTables -
3349
3331
*
3350
- * This needs to be done from two places, so split it out to prevent drift .
3332
+ * Initialize our internal hash tables .
3351
3333
* ----------
3352
3334
*/
3353
3335
static void
3354
- ri_InitConstraintCache (void )
3336
+ ri_InitHashTables (void )
3355
3337
{
3356
3338
HASHCTL ctl ;
3357
3339
@@ -3362,20 +3344,6 @@ ri_InitConstraintCache(void)
3362
3344
ri_constraint_cache = hash_create ("RI constraint cache" ,
3363
3345
RI_INIT_CONSTRAINTHASHSIZE ,
3364
3346
& ctl , HASH_ELEM | HASH_FUNCTION );
3365
- }
3366
-
3367
- /* ----------
3368
- * ri_InitHashTables -
3369
- *
3370
- * Initialize our internal hash tables.
3371
- * ----------
3372
- */
3373
- static void
3374
- ri_InitHashTables (void )
3375
- {
3376
- HASHCTL ctl ;
3377
-
3378
- ri_InitConstraintCache ();
3379
3347
3380
3348
/* Arrange to flush cache on pg_constraint changes */
3381
3349
CacheRegisterSyscacheCallback (CONSTROID ,
0 commit comments