@@ -3058,18 +3058,6 @@ AtEOXact_cleanup(Relation relation, bool isCommit)
3058
3058
* Likewise, reset the hint about the relfilenode being new.
3059
3059
*/
3060
3060
relation -> rd_newRelfilenodeSubid = InvalidSubTransactionId ;
3061
-
3062
- /*
3063
- * Flush any temporary index list.
3064
- */
3065
- if (relation -> rd_indexvalid == 2 )
3066
- {
3067
- list_free (relation -> rd_indexlist );
3068
- relation -> rd_indexlist = NIL ;
3069
- relation -> rd_pkindex = InvalidOid ;
3070
- relation -> rd_replidindex = InvalidOid ;
3071
- relation -> rd_indexvalid = 0 ;
3072
- }
3073
3061
}
3074
3062
3075
3063
/*
@@ -3170,18 +3158,6 @@ AtEOSubXact_cleanup(Relation relation, bool isCommit,
3170
3158
else
3171
3159
relation -> rd_newRelfilenodeSubid = InvalidSubTransactionId ;
3172
3160
}
3173
-
3174
- /*
3175
- * Flush any temporary index list.
3176
- */
3177
- if (relation -> rd_indexvalid == 2 )
3178
- {
3179
- list_free (relation -> rd_indexlist );
3180
- relation -> rd_indexlist = NIL ;
3181
- relation -> rd_pkindex = InvalidOid ;
3182
- relation -> rd_replidindex = InvalidOid ;
3183
- relation -> rd_indexvalid = 0 ;
3184
- }
3185
3161
}
3186
3162
3187
3163
@@ -4337,7 +4313,7 @@ RelationGetFKeyList(Relation relation)
4337
4313
* The index list is created only if someone requests it. We scan pg_index
4338
4314
* to find relevant indexes, and add the list to the relcache entry so that
4339
4315
* we won't have to compute it again. Note that shared cache inval of a
4340
- * relcache entry will delete the old list and set rd_indexvalid to 0 ,
4316
+ * relcache entry will delete the old list and set rd_indexvalid to false ,
4341
4317
* so that we must recompute the index list on next request. This handles
4342
4318
* creation or deletion of an index.
4343
4319
*
@@ -4377,7 +4353,7 @@ RelationGetIndexList(Relation relation)
4377
4353
MemoryContext oldcxt ;
4378
4354
4379
4355
/* Quick exit if we already computed the list. */
4380
- if (relation -> rd_indexvalid != 0 )
4356
+ if (relation -> rd_indexvalid )
4381
4357
return list_copy (relation -> rd_indexlist );
4382
4358
4383
4359
/*
@@ -4448,7 +4424,7 @@ RelationGetIndexList(Relation relation)
4448
4424
relation -> rd_replidindex = candidateIndex ;
4449
4425
else
4450
4426
relation -> rd_replidindex = InvalidOid ;
4451
- relation -> rd_indexvalid = 1 ;
4427
+ relation -> rd_indexvalid = true ;
4452
4428
MemoryContextSwitchTo (oldcxt );
4453
4429
4454
4430
/* Don't leak the old list, if there is one */
@@ -4572,52 +4548,6 @@ insert_ordered_oid(List *list, Oid datum)
4572
4548
return list ;
4573
4549
}
4574
4550
4575
- /*
4576
- * RelationSetIndexList -- externally force the index list contents
4577
- *
4578
- * This is used to temporarily override what we think the set of valid
4579
- * indexes is (including the presence or absence of an OID index).
4580
- * The forcing will be valid only until transaction commit or abort.
4581
- *
4582
- * This should only be applied to nailed relations, because in a non-nailed
4583
- * relation the hacked index list could be lost at any time due to SI
4584
- * messages. In practice it is only used on pg_class (see REINDEX).
4585
- *
4586
- * It is up to the caller to make sure the given list is correctly ordered.
4587
- *
4588
- * We deliberately do not change rd_indexattr here: even when operating
4589
- * with a temporary partial index list, HOT-update decisions must be made
4590
- * correctly with respect to the full index set. It is up to the caller
4591
- * to ensure that a correct rd_indexattr set has been cached before first
4592
- * calling RelationSetIndexList; else a subsequent inquiry might cause a
4593
- * wrong rd_indexattr set to get computed and cached. Likewise, we do not
4594
- * touch rd_keyattr, rd_pkattr or rd_idattr.
4595
- */
4596
- void
4597
- RelationSetIndexList (Relation relation , List * indexIds )
4598
- {
4599
- MemoryContext oldcxt ;
4600
-
4601
- Assert (relation -> rd_isnailed );
4602
- /* Copy the list into the cache context (could fail for lack of mem) */
4603
- oldcxt = MemoryContextSwitchTo (CacheMemoryContext );
4604
- indexIds = list_copy (indexIds );
4605
- MemoryContextSwitchTo (oldcxt );
4606
- /* Okay to replace old list */
4607
- list_free (relation -> rd_indexlist );
4608
- relation -> rd_indexlist = indexIds ;
4609
-
4610
- /*
4611
- * For the moment, assume the target rel hasn't got a pk or replica index.
4612
- * We'll load them on demand in the API that wraps access to them.
4613
- */
4614
- relation -> rd_pkindex = InvalidOid ;
4615
- relation -> rd_replidindex = InvalidOid ;
4616
- relation -> rd_indexvalid = 2 ; /* mark list as forced */
4617
- /* Flag relation as needing eoxact cleanup (to reset the list) */
4618
- EOXactListAdd (relation );
4619
- }
4620
-
4621
4551
/*
4622
4552
* RelationGetPrimaryKeyIndex -- get OID of the relation's primary key index
4623
4553
*
@@ -4628,12 +4558,12 @@ RelationGetPrimaryKeyIndex(Relation relation)
4628
4558
{
4629
4559
List * ilist ;
4630
4560
4631
- if (relation -> rd_indexvalid == 0 )
4561
+ if (! relation -> rd_indexvalid )
4632
4562
{
4633
4563
/* RelationGetIndexList does the heavy lifting. */
4634
4564
ilist = RelationGetIndexList (relation );
4635
4565
list_free (ilist );
4636
- Assert (relation -> rd_indexvalid != 0 );
4566
+ Assert (relation -> rd_indexvalid );
4637
4567
}
4638
4568
4639
4569
return relation -> rd_pkindex ;
@@ -4649,12 +4579,12 @@ RelationGetReplicaIndex(Relation relation)
4649
4579
{
4650
4580
List * ilist ;
4651
4581
4652
- if (relation -> rd_indexvalid == 0 )
4582
+ if (! relation -> rd_indexvalid )
4653
4583
{
4654
4584
/* RelationGetIndexList does the heavy lifting. */
4655
4585
ilist = RelationGetIndexList (relation );
4656
4586
list_free (ilist );
4657
- Assert (relation -> rd_indexvalid != 0 );
4587
+ Assert (relation -> rd_indexvalid );
4658
4588
}
4659
4589
4660
4590
return relation -> rd_replidindex ;
@@ -5668,9 +5598,7 @@ load_relcache_init_file(bool shared)
5668
5598
rel -> rd_refcnt = 1 ;
5669
5599
else
5670
5600
rel -> rd_refcnt = 0 ;
5671
- rel -> rd_indexvalid = 0 ;
5672
- rel -> rd_fkeylist = NIL ;
5673
- rel -> rd_fkeyvalid = false;
5601
+ rel -> rd_indexvalid = false;
5674
5602
rel -> rd_indexlist = NIL ;
5675
5603
rel -> rd_pkindex = InvalidOid ;
5676
5604
rel -> rd_replidindex = InvalidOid ;
@@ -5681,6 +5609,8 @@ load_relcache_init_file(bool shared)
5681
5609
rel -> rd_pubactions = NULL ;
5682
5610
rel -> rd_statvalid = false;
5683
5611
rel -> rd_statlist = NIL ;
5612
+ rel -> rd_fkeyvalid = false;
5613
+ rel -> rd_fkeylist = NIL ;
5684
5614
rel -> rd_createSubid = InvalidSubTransactionId ;
5685
5615
rel -> rd_newRelfilenodeSubid = InvalidSubTransactionId ;
5686
5616
rel -> rd_amcache = NULL ;
0 commit comments