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

Commitb0a55e4

Browse files
committed
Change internal RelFileNode references to RelFileNumber or RelFileLocator.
We have been using the term RelFileNode to refer to either (1) theinteger that is used to name the sequence of files for a certain relationwithin the directory set aside for that tablespace/database combination;or (2) that value plus the OIDs of the tablespace and database; oroccasionally (3) the whole series of files created for a relationbased on those values. Using the same name for more than one thing isconfusing.Replace RelFileNode with RelFileNumber when we're talking about just thesingle number, i.e. (1) from above, and with RelFileLocator when we'retalking about all the things that are needed to locate a relation's fileson disk, i.e. (2) from above. In the places where we refer to (3) asa relfilenode, instead refer to "relation storage".Since there is a ton of SQL code in the world that knows aboutpg_class.relfilenode, don't change the name of that column, or of otherSQL-facing things that derive their name from it.On the other hand, do adjust closely-related internal terminology. Forexample, the structure member names dbNode and spcNode appear to bederived from the fact that the structure itself was called RelFileNode,so change those to dbOid and spcOid. Likewise, various variables withnames like rnode and relnode get renamed appropriately, according tohow they're being used in context.Hopefully, this is clearer than before. It is also preparation forfuture patches that intend to widen the relfilenumber fields from itscurrent width of 32 bits. Variables that store a relfilenumber are nowdeclared as type RelFileNumber rather than type Oid; right now, theseare the same, but that can now more easily be changed.Dilip Kumar, per an idea from me. Reviewed also by Andres Freund.I fixed some whitespace issues, changed a couple of words in acomment, and made one other minor correction.Discussion:http://postgr.es/m/CA+TgmoamOtXbVAQf9hWFzonUo6bhhjS6toZQd7HZ-pmojtAmag@mail.gmail.comDiscussion:http://postgr.es/m/CA+Tgmobp7+7kmi4gkq7Y+4AM9fTvL+O1oQ4-5gFTT+6Ng-dQ=g@mail.gmail.comDiscussion:http://postgr.es/m/CAFiTN-vTe79M8uDH1yprOU64MNFE+R3ODRuA+JWf27JbhY4hJw@mail.gmail.com
1 parent7775c74 commitb0a55e4

File tree

138 files changed

+1640
-1606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+1640
-1606
lines changed

‎contrib/bloom/blinsert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ blbuildempty(Relation index)
179179
PageSetChecksumInplace(metapage,BLOOM_METAPAGE_BLKNO);
180180
smgrwrite(RelationGetSmgr(index),INIT_FORKNUM,BLOOM_METAPAGE_BLKNO,
181181
(char*)metapage, true);
182-
log_newpage(&(RelationGetSmgr(index))->smgr_rnode.node,INIT_FORKNUM,
182+
log_newpage(&(RelationGetSmgr(index))->smgr_rlocator.locator,INIT_FORKNUM,
183183
BLOOM_METAPAGE_BLKNO,metapage, true);
184184

185185
/*

‎contrib/oid2name/oid2name.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct options
3030
{
3131
eary*tables;
3232
eary*oids;
33-
eary*filenodes;
33+
eary*filenumbers;
3434

3535
boolquiet;
3636
boolsystables;
@@ -125,9 +125,9 @@ get_opts(int argc, char **argv, struct options *my_opts)
125125
my_opts->dbname=pg_strdup(optarg);
126126
break;
127127

128-
/* specify onefilenode to show */
128+
/* specify onefilenumber to show */
129129
case'f':
130-
add_one_elt(optarg,my_opts->filenodes);
130+
add_one_elt(optarg,my_opts->filenumbers);
131131
break;
132132

133133
/* host to connect to */
@@ -494,7 +494,7 @@ sql_exec_dumpalltables(PGconn *conn, struct options *opts)
494494
}
495495

496496
/*
497-
* Show oid,filenode, name, schema and tablespace for each of the
497+
* Show oid,filenumber, name, schema and tablespace for each of the
498498
* given objects in the current database.
499499
*/
500500
void
@@ -504,31 +504,32 @@ sql_exec_searchtables(PGconn *conn, struct options *opts)
504504
char*qualifiers,
505505
*ptr;
506506
char*comma_oids,
507-
*comma_filenodes,
507+
*comma_filenumbers,
508508
*comma_tables;
509509
boolwritten= false;
510510
char*addfields=",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\" ";
511511

512-
/* get tables qualifiers, whether names,filenodes, or OIDs */
512+
/* get tables qualifiers, whether names,filenumbers, or OIDs */
513513
comma_oids=get_comma_elts(opts->oids);
514514
comma_tables=get_comma_elts(opts->tables);
515-
comma_filenodes=get_comma_elts(opts->filenodes);
515+
comma_filenumbers=get_comma_elts(opts->filenumbers);
516516

517517
/* 80 extra chars for SQL expression */
518518
qualifiers= (char*)pg_malloc(strlen(comma_oids)+strlen(comma_tables)+
519-
strlen(comma_filenodes)+80);
519+
strlen(comma_filenumbers)+80);
520520
ptr=qualifiers;
521521

522522
if (opts->oids->num>0)
523523
{
524524
ptr+=sprintf(ptr,"c.oid IN (%s)",comma_oids);
525525
written= true;
526526
}
527-
if (opts->filenodes->num>0)
527+
if (opts->filenumbers->num>0)
528528
{
529529
if (written)
530530
ptr+=sprintf(ptr," OR ");
531-
ptr+=sprintf(ptr,"pg_catalog.pg_relation_filenode(c.oid) IN (%s)",comma_filenodes);
531+
ptr+=sprintf(ptr,"pg_catalog.pg_relation_filenode(c.oid) IN (%s)",
532+
comma_filenumbers);
532533
written= true;
533534
}
534535
if (opts->tables->num>0)
@@ -539,7 +540,7 @@ sql_exec_searchtables(PGconn *conn, struct options *opts)
539540
}
540541
free(comma_oids);
541542
free(comma_tables);
542-
free(comma_filenodes);
543+
free(comma_filenumbers);
543544

544545
/* now build the query */
545546
todo=psprintf("SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s\n"
@@ -588,11 +589,11 @@ main(int argc, char **argv)
588589

589590
my_opts->oids= (eary*)pg_malloc(sizeof(eary));
590591
my_opts->tables= (eary*)pg_malloc(sizeof(eary));
591-
my_opts->filenodes= (eary*)pg_malloc(sizeof(eary));
592+
my_opts->filenumbers= (eary*)pg_malloc(sizeof(eary));
592593

593594
my_opts->oids->num=my_opts->oids->alloc=0;
594595
my_opts->tables->num=my_opts->tables->alloc=0;
595-
my_opts->filenodes->num=my_opts->filenodes->alloc=0;
596+
my_opts->filenumbers->num=my_opts->filenumbers->alloc=0;
596597

597598
/* parse the opts */
598599
get_opts(argc,argv,my_opts);
@@ -618,7 +619,7 @@ main(int argc, char **argv)
618619
/* display the given elements in the database */
619620
if (my_opts->oids->num>0||
620621
my_opts->tables->num>0||
621-
my_opts->filenodes->num>0)
622+
my_opts->filenumbers->num>0)
622623
{
623624
if (!my_opts->quiet)
624625
printf("From database \"%s\":\n",my_opts->dbname);

‎contrib/pg_buffercache/pg_buffercache_pages.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ PG_MODULE_MAGIC;
2626
typedefstruct
2727
{
2828
uint32bufferid;
29-
Oidrelfilenode;
29+
RelFileNumberrelfilenumber;
3030
Oidreltablespace;
3131
Oidreldatabase;
3232
ForkNumberforknum;
@@ -153,9 +153,9 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
153153
buf_state=LockBufHdr(bufHdr);
154154

155155
fctx->record[i].bufferid=BufferDescriptorGetBuffer(bufHdr);
156-
fctx->record[i].relfilenode=bufHdr->tag.rnode.relNode;
157-
fctx->record[i].reltablespace=bufHdr->tag.rnode.spcNode;
158-
fctx->record[i].reldatabase=bufHdr->tag.rnode.dbNode;
156+
fctx->record[i].relfilenumber=bufHdr->tag.rlocator.relNumber;
157+
fctx->record[i].reltablespace=bufHdr->tag.rlocator.spcOid;
158+
fctx->record[i].reldatabase=bufHdr->tag.rlocator.dbOid;
159159
fctx->record[i].forknum=bufHdr->tag.forkNum;
160160
fctx->record[i].blocknum=bufHdr->tag.blockNum;
161161
fctx->record[i].usagecount=BUF_STATE_GET_USAGECOUNT(buf_state);
@@ -209,7 +209,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
209209
}
210210
else
211211
{
212-
values[1]=ObjectIdGetDatum(fctx->record[i].relfilenode);
212+
values[1]=ObjectIdGetDatum(fctx->record[i].relfilenumber);
213213
nulls[1]= false;
214214
values[2]=ObjectIdGetDatum(fctx->record[i].reltablespace);
215215
nulls[2]= false;

‎contrib/pg_prewarm/autoprewarm.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#include"utils/guc.h"
5353
#include"utils/memutils.h"
5454
#include"utils/rel.h"
55-
#include"utils/relfilenodemap.h"
55+
#include"utils/relfilenumbermap.h"
5656
#include"utils/resowner.h"
5757

5858
#defineAUTOPREWARM_FILE "autoprewarm.blocks"
@@ -62,7 +62,7 @@ typedef struct BlockInfoRecord
6262
{
6363
Oiddatabase;
6464
Oidtablespace;
65-
Oidfilenode;
65+
RelFileNumberfilenumber;
6666
ForkNumberforknum;
6767
BlockNumberblocknum;
6868
}BlockInfoRecord;
@@ -347,7 +347,7 @@ apw_load_buffers(void)
347347
unsignedforknum;
348348

349349
if (fscanf(file,"%u,%u,%u,%u,%u\n",&blkinfo[i].database,
350-
&blkinfo[i].tablespace,&blkinfo[i].filenode,
350+
&blkinfo[i].tablespace,&blkinfo[i].filenumber,
351351
&forknum,&blkinfo[i].blocknum)!=5)
352352
ereport(ERROR,
353353
(errmsg("autoprewarm block dump file is corrupted at line %d",
@@ -494,7 +494,7 @@ autoprewarm_database_main(Datum main_arg)
494494
* relation. Note that rel will be NULL if try_relation_open failed
495495
* previously; in that case, there is nothing to close.
496496
*/
497-
if (old_blk!=NULL&&old_blk->filenode!=blk->filenode&&
497+
if (old_blk!=NULL&&old_blk->filenumber!=blk->filenumber&&
498498
rel!=NULL)
499499
{
500500
relation_close(rel,AccessShareLock);
@@ -506,13 +506,13 @@ autoprewarm_database_main(Datum main_arg)
506506
* Try to open each new relation, but only once, when we first
507507
* encounter it. If it's been dropped, skip the associated blocks.
508508
*/
509-
if (old_blk==NULL||old_blk->filenode!=blk->filenode)
509+
if (old_blk==NULL||old_blk->filenumber!=blk->filenumber)
510510
{
511511
Oidreloid;
512512

513513
Assert(rel==NULL);
514514
StartTransactionCommand();
515-
reloid=RelidByRelfilenode(blk->tablespace,blk->filenode);
515+
reloid=RelidByRelfilenumber(blk->tablespace,blk->filenumber);
516516
if (OidIsValid(reloid))
517517
rel=try_relation_open(reloid,AccessShareLock);
518518

@@ -527,7 +527,7 @@ autoprewarm_database_main(Datum main_arg)
527527

528528
/* Once per fork, check for fork existence and size. */
529529
if (old_blk==NULL||
530-
old_blk->filenode!=blk->filenode||
530+
old_blk->filenumber!=blk->filenumber||
531531
old_blk->forknum!=blk->forknum)
532532
{
533533
/*
@@ -631,9 +631,9 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
631631
if (buf_state&BM_TAG_VALID&&
632632
((buf_state&BM_PERMANENT)||dump_unlogged))
633633
{
634-
block_info_array[num_blocks].database=bufHdr->tag.rnode.dbNode;
635-
block_info_array[num_blocks].tablespace=bufHdr->tag.rnode.spcNode;
636-
block_info_array[num_blocks].filenode=bufHdr->tag.rnode.relNode;
634+
block_info_array[num_blocks].database=bufHdr->tag.rlocator.dbOid;
635+
block_info_array[num_blocks].tablespace=bufHdr->tag.rlocator.spcOid;
636+
block_info_array[num_blocks].filenumber=bufHdr->tag.rlocator.relNumber;
637637
block_info_array[num_blocks].forknum=bufHdr->tag.forkNum;
638638
block_info_array[num_blocks].blocknum=bufHdr->tag.blockNum;
639639
++num_blocks;
@@ -671,7 +671,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
671671
ret=fprintf(file,"%u,%u,%u,%u,%u\n",
672672
block_info_array[i].database,
673673
block_info_array[i].tablespace,
674-
block_info_array[i].filenode,
674+
block_info_array[i].filenumber,
675675
(uint32)block_info_array[i].forknum,
676676
block_info_array[i].blocknum);
677677
if (ret<0)
@@ -900,7 +900,7 @@ do { \
900900
* We depend on all records for a particular database being consecutive
901901
* in the dump file; each per-database worker will preload blocks until
902902
* it sees a block for some other database. Sorting by tablespace,
903-
*filenode, forknum, and blocknum isn't critical for correctness, but
903+
*filenumber, forknum, and blocknum isn't critical for correctness, but
904904
* helps us get a sequential I/O pattern.
905905
*/
906906
staticint
@@ -911,7 +911,7 @@ apw_compare_blockinfo(const void *p, const void *q)
911911

912912
cmp_member_elem(database);
913913
cmp_member_elem(tablespace);
914-
cmp_member_elem(filenode);
914+
cmp_member_elem(filenumber);
915915
cmp_member_elem(forknum);
916916
cmp_member_elem(blocknum);
917917

‎contrib/pg_visibility/pg_visibility.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ pg_truncate_visibility_map(PG_FUNCTION_ARGS)
407407
xl_smgr_truncatexlrec;
408408

409409
xlrec.blkno=0;
410-
xlrec.rnode=rel->rd_node;
410+
xlrec.rlocator=rel->rd_locator;
411411
xlrec.flags=SMGR_TRUNCATE_VM;
412412

413413
XLogBeginInsert();

‎src/backend/access/common/syncscan.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ booltrace_syncscan = false;
9090
*/
9191
typedefstructss_scan_location_t
9292
{
93-
RelFileNoderelfilenode;/* identity of a relation */
93+
RelFileLocatorrelfilelocator;/* identity of a relation */
9494
BlockNumberlocation;/* last-reported location in the relation */
9595
}ss_scan_location_t;
9696

@@ -115,7 +115,7 @@ typedef struct ss_scan_locations_t
115115
staticss_scan_locations_t*scan_locations;
116116

117117
/* prototypes for internal functions */
118-
staticBlockNumberss_search(RelFileNoderelfilenode,
118+
staticBlockNumberss_search(RelFileLocatorrelfilelocator,
119119
BlockNumberlocation,boolset);
120120

121121

@@ -159,9 +159,9 @@ SyncScanShmemInit(void)
159159
* these invalid entries will fall off the LRU list and get
160160
* replaced with real entries.
161161
*/
162-
item->location.relfilenode.spcNode=InvalidOid;
163-
item->location.relfilenode.dbNode=InvalidOid;
164-
item->location.relfilenode.relNode=InvalidOid;
162+
item->location.relfilelocator.spcOid=InvalidOid;
163+
item->location.relfilelocator.dbOid=InvalidOid;
164+
item->location.relfilelocator.relNumber=InvalidRelFileNumber;
165165
item->location.location=InvalidBlockNumber;
166166

167167
item->prev= (i>0) ?
@@ -176,10 +176,10 @@ SyncScanShmemInit(void)
176176

177177
/*
178178
* ss_search --- search the scan_locations structure for an entry with the
179-
*givenrelfilenode.
179+
*givenrelfilelocator.
180180
*
181181
* If "set" is true, the location is updated to the given location. If no
182-
* entry for the givenrelfilenode is found, it will be created at the head
182+
* entry for the givenrelfilelocator is found, it will be created at the head
183183
* of the list with the given location, even if "set" is false.
184184
*
185185
* In any case, the location after possible update is returned.
@@ -188,7 +188,7 @@ SyncScanShmemInit(void)
188188
* data structure.
189189
*/
190190
staticBlockNumber
191-
ss_search(RelFileNoderelfilenode,BlockNumberlocation,boolset)
191+
ss_search(RelFileLocatorrelfilelocator,BlockNumberlocation,boolset)
192192
{
193193
ss_lru_item_t*item;
194194

@@ -197,7 +197,8 @@ ss_search(RelFileNode relfilenode, BlockNumber location, bool set)
197197
{
198198
boolmatch;
199199

200-
match=RelFileNodeEquals(item->location.relfilenode,relfilenode);
200+
match=RelFileLocatorEquals(item->location.relfilelocator,
201+
relfilelocator);
201202

202203
if (match||item->next==NULL)
203204
{
@@ -207,7 +208,7 @@ ss_search(RelFileNode relfilenode, BlockNumber location, bool set)
207208
*/
208209
if (!match)
209210
{
210-
item->location.relfilenode=relfilenode;
211+
item->location.relfilelocator=relfilelocator;
211212
item->location.location=location;
212213
}
213214
elseif (set)
@@ -255,7 +256,7 @@ ss_get_location(Relation rel, BlockNumber relnblocks)
255256
BlockNumberstartloc;
256257

257258
LWLockAcquire(SyncScanLock,LW_EXCLUSIVE);
258-
startloc=ss_search(rel->rd_node,0, false);
259+
startloc=ss_search(rel->rd_locator,0, false);
259260
LWLockRelease(SyncScanLock);
260261

261262
/*
@@ -281,8 +282,8 @@ ss_get_location(Relation rel, BlockNumber relnblocks)
281282
* ss_report_location --- update the current scan location
282283
*
283284
* Writes an entry into the shared Sync Scan state of the form
284-
* (relfilenode, blocknumber), overwriting any existing entry for the
285-
* samerelfilenode.
285+
* (relfilelocator, blocknumber), overwriting any existing entry for the
286+
* samerelfilelocator.
286287
*/
287288
void
288289
ss_report_location(Relationrel,BlockNumberlocation)
@@ -309,7 +310,7 @@ ss_report_location(Relation rel, BlockNumber location)
309310
{
310311
if (LWLockConditionalAcquire(SyncScanLock,LW_EXCLUSIVE))
311312
{
312-
(void)ss_search(rel->rd_node,location, true);
313+
(void)ss_search(rel->rd_locator,location, true);
313314
LWLockRelease(SyncScanLock);
314315
}
315316
#ifdefTRACE_SYNCSCAN

‎src/backend/access/gin/ginbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ ginPlaceToPage(GinBtree btree, GinBtreeStack *stack,
470470
savedRightLink=GinPageGetOpaque(page)->rightlink;
471471

472472
/* Begin setting up WAL record */
473-
data.node=btree->index->rd_node;
473+
data.locator=btree->index->rd_locator;
474474
data.flags=xlflags;
475475
if (BufferIsValid(childbuf))
476476
{

‎src/backend/access/gin/ginfast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector)
235235

236236
needWal=RelationNeedsWAL(index);
237237

238-
data.node=index->rd_node;
238+
data.locator=index->rd_locator;
239239
data.ntuples=0;
240240
data.newRightlink=data.prevTail=InvalidBlockNumber;
241241

‎src/backend/access/gin/ginutil.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ ginUpdateStats(Relation index, const GinStatsData *stats, bool is_build)
688688
XLogRecPtrrecptr;
689689
ginxlogUpdateMetadata;
690690

691-
data.node=index->rd_node;
691+
data.locator=index->rd_locator;
692692
data.ntuples=0;
693693
data.newRightlink=data.prevTail=InvalidBlockNumber;
694694
memcpy(&data.metadata,metadata,sizeof(GinMetaPageData));

‎src/backend/access/gin/ginxlog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ ginRedoInsertEntry(Buffer buffer, bool isLeaf, BlockNumber rightblkno, void *rda
9595

9696
if (PageAddItem(page, (Item)itup,IndexTupleSize(itup),offset, false, false)==InvalidOffsetNumber)
9797
{
98-
RelFileNodenode;
98+
RelFileLocatorlocator;
9999
ForkNumberforknum;
100100
BlockNumberblknum;
101101

102-
BufferGetTag(buffer,&node,&forknum,&blknum);
102+
BufferGetTag(buffer,&locator,&forknum,&blknum);
103103
elog(ERROR,"failed to add item to index page in %u/%u/%u",
104-
node.spcNode,node.dbNode,node.relNode);
104+
locator.spcOid,locator.dbOid,locator.relNumber);
105105
}
106106
}
107107

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp