Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf884dca

Browse files
committed
Remove RelationSetIndexList().
In the wake of commitf912d7d, RelationSetIndexList isn't used anymore. It was always a horrid wart, so getting rid of it is very nice.We can also convert rd_indexvalid back to a plain boolean.Discussion:https://postgr.es/m/28926.1556664156@sss.pgh.pa.us
1 parentf912d7d commitf884dca

File tree

3 files changed

+12
-85
lines changed

3 files changed

+12
-85
lines changed

‎src/backend/utils/cache/relcache.c

Lines changed: 10 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3058,18 +3058,6 @@ AtEOXact_cleanup(Relation relation, bool isCommit)
30583058
* Likewise, reset the hint about the relfilenode being new.
30593059
*/
30603060
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-
}
30733061
}
30743062

30753063
/*
@@ -3170,18 +3158,6 @@ AtEOSubXact_cleanup(Relation relation, bool isCommit,
31703158
else
31713159
relation->rd_newRelfilenodeSubid=InvalidSubTransactionId;
31723160
}
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-
}
31853161
}
31863162

31873163

@@ -4337,7 +4313,7 @@ RelationGetFKeyList(Relation relation)
43374313
* The index list is created only if someone requests it. We scan pg_index
43384314
* to find relevant indexes, and add the list to the relcache entry so that
43394315
* 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 to0,
4316+
* relcache entry will delete the old list and set rd_indexvalid tofalse,
43414317
* so that we must recompute the index list on next request. This handles
43424318
* creation or deletion of an index.
43434319
*
@@ -4377,7 +4353,7 @@ RelationGetIndexList(Relation relation)
43774353
MemoryContextoldcxt;
43784354

43794355
/* Quick exit if we already computed the list. */
4380-
if (relation->rd_indexvalid!=0)
4356+
if (relation->rd_indexvalid)
43814357
returnlist_copy(relation->rd_indexlist);
43824358

43834359
/*
@@ -4448,7 +4424,7 @@ RelationGetIndexList(Relation relation)
44484424
relation->rd_replidindex=candidateIndex;
44494425
else
44504426
relation->rd_replidindex=InvalidOid;
4451-
relation->rd_indexvalid=1;
4427+
relation->rd_indexvalid=true;
44524428
MemoryContextSwitchTo(oldcxt);
44534429

44544430
/* Don't leak the old list, if there is one */
@@ -4572,52 +4548,6 @@ insert_ordered_oid(List *list, Oid datum)
45724548
returnlist;
45734549
}
45744550

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(Relationrelation,List*indexIds)
4598-
{
4599-
MemoryContextoldcxt;
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-
46214551
/*
46224552
* RelationGetPrimaryKeyIndex -- get OID of the relation's primary key index
46234553
*
@@ -4628,12 +4558,12 @@ RelationGetPrimaryKeyIndex(Relation relation)
46284558
{
46294559
List*ilist;
46304560

4631-
if (relation->rd_indexvalid==0)
4561+
if (!relation->rd_indexvalid)
46324562
{
46334563
/* RelationGetIndexList does the heavy lifting. */
46344564
ilist=RelationGetIndexList(relation);
46354565
list_free(ilist);
4636-
Assert(relation->rd_indexvalid!=0);
4566+
Assert(relation->rd_indexvalid);
46374567
}
46384568

46394569
returnrelation->rd_pkindex;
@@ -4649,12 +4579,12 @@ RelationGetReplicaIndex(Relation relation)
46494579
{
46504580
List*ilist;
46514581

4652-
if (relation->rd_indexvalid==0)
4582+
if (!relation->rd_indexvalid)
46534583
{
46544584
/* RelationGetIndexList does the heavy lifting. */
46554585
ilist=RelationGetIndexList(relation);
46564586
list_free(ilist);
4657-
Assert(relation->rd_indexvalid!=0);
4587+
Assert(relation->rd_indexvalid);
46584588
}
46594589

46604590
returnrelation->rd_replidindex;
@@ -5668,9 +5598,7 @@ load_relcache_init_file(bool shared)
56685598
rel->rd_refcnt=1;
56695599
else
56705600
rel->rd_refcnt=0;
5671-
rel->rd_indexvalid=0;
5672-
rel->rd_fkeylist=NIL;
5673-
rel->rd_fkeyvalid= false;
5601+
rel->rd_indexvalid= false;
56745602
rel->rd_indexlist=NIL;
56755603
rel->rd_pkindex=InvalidOid;
56765604
rel->rd_replidindex=InvalidOid;
@@ -5681,6 +5609,8 @@ load_relcache_init_file(bool shared)
56815609
rel->rd_pubactions=NULL;
56825610
rel->rd_statvalid= false;
56835611
rel->rd_statlist=NIL;
5612+
rel->rd_fkeyvalid= false;
5613+
rel->rd_fkeylist=NIL;
56845614
rel->rd_createSubid=InvalidSubTransactionId;
56855615
rel->rd_newRelfilenodeSubid=InvalidSubTransactionId;
56865616
rel->rd_amcache=NULL;

‎src/include/utils/rel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ typedef struct RelationData
6060
boolrd_islocaltemp;/* rel is a temp rel of this session */
6161
boolrd_isnailed;/* rel is nailed in cache */
6262
boolrd_isvalid;/* relcache entry is valid */
63-
charrd_indexvalid;/*state ofrd_indexlist: 0 = notvalid, 1 =
64-
*valid, 2 = temporarily forced */
63+
boolrd_indexvalid;/*isrd_indexlistvalid? (also rd_pkindex and
64+
*rd_replidindex) */
6565
boolrd_statvalid;/* is rd_statlist valid? */
6666

6767
/*

‎src/include/utils/relcache.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ extern void RelationGetExclusionInfo(Relation indexRelation,
6666
Oid**procs,
6767
uint16**strategies);
6868

69-
externvoidRelationSetIndexList(Relationrelation,
70-
List*indexIds);
71-
7269
externvoidRelationInitIndexAccessInfo(Relationrelation);
7370

7471
/* caller must include pg_publication.h */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp