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

Commit97d4445

Browse files
committed
Save a few bytes by removing useless last argument to SearchCatCacheList.
There's never any value in giving a fully specified cache key toSearchCatCacheList: you might as well call SearchCatCache instead,since there could be only one match. So the maximum useful number ofkey arguments is one less than the supported number of key columns.We might as well remove the useless extra argument and save some fewbytes per call site, as well as a cycle or so per call.I believe the reason it was coded like this is that originally, callershad to write out all the dummy arguments in each call, and so it seemedless confusing if SearchCatCache and SearchCatCacheList took the samenumber of key arguments. But since commite26c539, callers only writetheir live arguments explicitly, making that a non-factor; and there'ssurely been enough time for third-party modules to adapt to that codingstyle. So this is only an ABI break not an API break for callers.Per discussion with Oliver Ford, this might also make it less confusinghow to use SearchCatCacheList correctly.Discussion:https://postgr.es/m/27788.1517069693@sss.pgh.pa.us
1 parentfc96c69 commit97d4445

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,11 @@ GetCatCacheHashValue(CatCache *cache,
15121512
*Generate a list of all tuples matching a partial key (that is,
15131513
*a key specifying just the first K of the cache's N key columns).
15141514
*
1515+
*It doesn't make any sense to specify all of the cache's key columns
1516+
*here: since the key is unique, there could be at most one match, so
1517+
*you ought to use SearchCatCache() instead. Hence this function takes
1518+
*one less Datum argument than SearchCatCache() does.
1519+
*
15151520
*The caller must not modify the list object or the pointed-to tuples,
15161521
*and must call ReleaseCatCacheList() when done with the list.
15171522
*/
@@ -1520,9 +1525,9 @@ SearchCatCacheList(CatCache *cache,
15201525
intnkeys,
15211526
Datumv1,
15221527
Datumv2,
1523-
Datumv3,
1524-
Datumv4)
1528+
Datumv3)
15251529
{
1530+
Datumv4=0;/* dummy last-column value */
15261531
Datumarguments[CATCACHE_MAXKEYS];
15271532
uint32lHashValue;
15281533
dlist_iteriter;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,14 +1418,14 @@ GetSysCacheHashValue(int cacheId,
14181418
*/
14191419
structcatclist*
14201420
SearchSysCacheList(intcacheId,intnkeys,
1421-
Datumkey1,Datumkey2,Datumkey3,Datumkey4)
1421+
Datumkey1,Datumkey2,Datumkey3)
14221422
{
14231423
if (cacheId<0||cacheId >=SysCacheSize||
14241424
!PointerIsValid(SysCache[cacheId]))
14251425
elog(ERROR,"invalid cache ID: %d",cacheId);
14261426

14271427
returnSearchCatCacheList(SysCache[cacheId],nkeys,
1428-
key1,key2,key3,key4);
1428+
key1,key2,key3);
14291429
}
14301430

14311431
/*

‎src/include/utils/catcache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ extern uint32 GetCatCacheHashValue(CatCache *cache,
214214

215215
externCatCList*SearchCatCacheList(CatCache*cache,intnkeys,
216216
Datumv1,Datumv2,
217-
Datumv3,Datumv4);
217+
Datumv3);
218218
externvoidReleaseCatCacheList(CatCList*list);
219219

220220
externvoidResetCatalogCaches(void);

‎src/include/utils/syscache.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ extern uint32 GetSysCacheHashValue(int cacheId,
157157
/* list-search interface. Users of this must import catcache.h too */
158158
structcatclist;
159159
externstructcatclist*SearchSysCacheList(intcacheId,intnkeys,
160-
Datumkey1,Datumkey2,Datumkey3,Datumkey4);
160+
Datumkey1,Datumkey2,Datumkey3);
161161

162162
externvoidSysCacheInvalidate(intcacheId,uint32hashValue);
163163

@@ -207,13 +207,11 @@ extern bool RelationSupportsSysCache(Oid relid);
207207
GetSysCacheHashValue(cacheId, key1, key2, key3, key4)
208208

209209
#defineSearchSysCacheList1(cacheId,key1) \
210-
SearchSysCacheList(cacheId, 1, key1, 0, 0, 0)
210+
SearchSysCacheList(cacheId, 1, key1, 0, 0)
211211
#defineSearchSysCacheList2(cacheId,key1,key2) \
212-
SearchSysCacheList(cacheId, 2, key1, key2, 0, 0)
212+
SearchSysCacheList(cacheId, 2, key1, key2, 0)
213213
#defineSearchSysCacheList3(cacheId,key1,key2,key3) \
214-
SearchSysCacheList(cacheId, 3, key1, key2, key3, 0)
215-
#defineSearchSysCacheList4(cacheId,key1,key2,key3,key4) \
216-
SearchSysCacheList(cacheId, 4, key1, key2, key3, key4)
214+
SearchSysCacheList(cacheId, 3, key1, key2, key3)
217215

218216
#defineReleaseSysCacheList(x)ReleaseCatCacheList(x)
219217

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp