Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b0a55e4

Browse files
committed
Change internal RelFileNode references to RelFileNumber or RelFileLocator.
We have been using the term RelFileNode to refer to either (1) the integer that is used to name the sequence of files for a certain relation within the directory set aside for that tablespace/database combination; or (2) that value plus the OIDs of the tablespace and database; or occasionally (3) the whole series of files created for a relation based on those values. Using the same name for more than one thing is confusing. Replace RelFileNode with RelFileNumber when we're talking about just the single number, i.e. (1) from above, and with RelFileLocator when we're talking about all the things that are needed to locate a relation's files on disk, i.e. (2) from above. In the places where we refer to (3) as a relfilenode, instead refer to "relation storage". Since there is a ton of SQL code in the world that knows about pg_class.relfilenode, don't change the name of that column, or of other SQL-facing things that derive their name from it. On the other hand, do adjust closely-related internal terminology. For example, the structure member names dbNode and spcNode appear to be derived from the fact that the structure itself was called RelFileNode, so change those to dbOid and spcOid. Likewise, various variables with names like rnode and relnode get renamed appropriately, according to how they're being used in context. Hopefully, this is clearer than before. It is also preparation for future patches that intend to widen the relfilenumber fields from its current width of 32 bits. Variables that store a relfilenumber are now declared as type RelFileNumber rather than type Oid; right now, these are 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 a comment, and made one other minor correction. Discussion: http://postgr.es/m/CA+TgmoamOtXbVAQf9hWFzonUo6bhhjS6toZQd7HZ-pmojtAmag@mail.gmail.com Discussion: http://postgr.es/m/CA+Tgmobp7+7kmi4gkq7Y+4AM9fTvL+O1oQ4-5gFTT+6Ng-dQ=g@mail.gmail.com Discussion: http://postgr.es/m/CAFiTN-vTe79M8uDH1yprOU64MNFE+R3ODRuA+JWf27JbhY4hJw@mail.gmail.com
1 parent 7775c74 commit b0a55e4

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

+1-1
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

+15-14
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
bool quiet;
3636
bool systables;
@@ -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 one filenode to show */
128+
/* specify one filenumber 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
bool written = 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

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ PG_MODULE_MAGIC;
2626
typedef struct
2727
{
2828
uint32 bufferid;
29-
Oid relfilenode;
29+
RelFileNumber relfilenumber;
3030
Oid reltablespace;
3131
Oid reldatabase;
3232
ForkNumber forknum;
@@ -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

+13-13
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
#define AUTOPREWARM_FILE "autoprewarm.blocks"
@@ -62,7 +62,7 @@ typedef struct BlockInfoRecord
6262
{
6363
Oid database;
6464
Oid tablespace;
65-
Oid filenode;
65+
RelFileNumber filenumber;
6666
ForkNumber forknum;
6767
BlockNumber blocknum;
6868
} BlockInfoRecord;
@@ -347,7 +347,7 @@ apw_load_buffers(void)
347347
unsigned forknum;
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
Oid reloid;
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
static int
@@ -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

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ pg_truncate_visibility_map(PG_FUNCTION_ARGS)
407407
xl_smgr_truncate xlrec;
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

+15-14
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ bool trace_syncscan = false;
9090
*/
9191
typedef struct ss_scan_location_t
9292
{
93-
RelFileNode relfilenode; /* identity of a relation */
93+
RelFileLocator relfilelocator; /* identity of a relation */
9494
BlockNumber location; /* last-reported location in the relation */
9595
} ss_scan_location_t;
9696

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

117117
/* prototypes for internal functions */
118-
static BlockNumber ss_search(RelFileNode relfilenode,
118+
static BlockNumber ss_search(RelFileLocator relfilelocator,
119119
BlockNumber location, bool set);
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-
* given relfilenode.
179+
* given relfilelocator.
180180
*
181181
* If "set" is true, the location is updated to the given location. If no
182-
* entry for the given relfilenode is found, it will be created at the head
182+
* entry for the given relfilelocator 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
static BlockNumber
191-
ss_search(RelFileNode relfilenode, BlockNumber location, bool set)
191+
ss_search(RelFileLocator relfilelocator, BlockNumber location, bool set)
192192
{
193193
ss_lru_item_t *item;
194194

@@ -197,7 +197,8 @@ ss_search(RelFileNode relfilenode, BlockNumber location, bool set)
197197
{
198198
bool match;
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
else if (set)
@@ -255,7 +256,7 @@ ss_get_location(Relation rel, BlockNumber relnblocks)
255256
BlockNumber startloc;
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-
* same relfilenode.
285+
* (relfilelocator, blocknumber), overwriting any existing entry for the
286+
* same relfilelocator.
286287
*/
287288
void
288289
ss_report_location(Relation rel, BlockNumber location)
@@ -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
#ifdef TRACE_SYNCSCAN

src/backend/access/gin/ginbtree.c

+1-1
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

+1-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ ginUpdateStats(Relation index, const GinStatsData *stats, bool is_build)
688688
XLogRecPtr recptr;
689689
ginxlogUpdateMeta data;
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

+3-3
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-
RelFileNode node;
98+
RelFileLocator locator;
9999
ForkNumber forknum;
100100
BlockNumber blknum;
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)