mirror of
https://github.com/postgres/postgres.git
synced 2025-06-05 23:56:58 +03:00
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
This commit is contained in:
parent
7775c748db
commit
b0a55e4329
@ -179,7 +179,7 @@ blbuildempty(Relation index)
|
|||||||
PageSetChecksumInplace(metapage, BLOOM_METAPAGE_BLKNO);
|
PageSetChecksumInplace(metapage, BLOOM_METAPAGE_BLKNO);
|
||||||
smgrwrite(RelationGetSmgr(index), INIT_FORKNUM, BLOOM_METAPAGE_BLKNO,
|
smgrwrite(RelationGetSmgr(index), INIT_FORKNUM, BLOOM_METAPAGE_BLKNO,
|
||||||
(char *) metapage, true);
|
(char *) metapage, true);
|
||||||
log_newpage(&(RelationGetSmgr(index))->smgr_rnode.node, INIT_FORKNUM,
|
log_newpage(&(RelationGetSmgr(index))->smgr_rlocator.locator, INIT_FORKNUM,
|
||||||
BLOOM_METAPAGE_BLKNO, metapage, true);
|
BLOOM_METAPAGE_BLKNO, metapage, true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -30,7 +30,7 @@ struct options
|
|||||||
{
|
{
|
||||||
eary *tables;
|
eary *tables;
|
||||||
eary *oids;
|
eary *oids;
|
||||||
eary *filenodes;
|
eary *filenumbers;
|
||||||
|
|
||||||
bool quiet;
|
bool quiet;
|
||||||
bool systables;
|
bool systables;
|
||||||
@ -125,9 +125,9 @@ get_opts(int argc, char **argv, struct options *my_opts)
|
|||||||
my_opts->dbname = pg_strdup(optarg);
|
my_opts->dbname = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* specify one filenode to show */
|
/* specify one filenumber to show */
|
||||||
case 'f':
|
case 'f':
|
||||||
add_one_elt(optarg, my_opts->filenodes);
|
add_one_elt(optarg, my_opts->filenumbers);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* host to connect to */
|
/* host to connect to */
|
||||||
@ -494,7 +494,7 @@ sql_exec_dumpalltables(PGconn *conn, struct options *opts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show oid, filenode, name, schema and tablespace for each of the
|
* Show oid, filenumber, name, schema and tablespace for each of the
|
||||||
* given objects in the current database.
|
* given objects in the current database.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -504,19 +504,19 @@ sql_exec_searchtables(PGconn *conn, struct options *opts)
|
|||||||
char *qualifiers,
|
char *qualifiers,
|
||||||
*ptr;
|
*ptr;
|
||||||
char *comma_oids,
|
char *comma_oids,
|
||||||
*comma_filenodes,
|
*comma_filenumbers,
|
||||||
*comma_tables;
|
*comma_tables;
|
||||||
bool written = false;
|
bool written = false;
|
||||||
char *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\" ";
|
char *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\" ";
|
||||||
|
|
||||||
/* get tables qualifiers, whether names, filenodes, or OIDs */
|
/* get tables qualifiers, whether names, filenumbers, or OIDs */
|
||||||
comma_oids = get_comma_elts(opts->oids);
|
comma_oids = get_comma_elts(opts->oids);
|
||||||
comma_tables = get_comma_elts(opts->tables);
|
comma_tables = get_comma_elts(opts->tables);
|
||||||
comma_filenodes = get_comma_elts(opts->filenodes);
|
comma_filenumbers = get_comma_elts(opts->filenumbers);
|
||||||
|
|
||||||
/* 80 extra chars for SQL expression */
|
/* 80 extra chars for SQL expression */
|
||||||
qualifiers = (char *) pg_malloc(strlen(comma_oids) + strlen(comma_tables) +
|
qualifiers = (char *) pg_malloc(strlen(comma_oids) + strlen(comma_tables) +
|
||||||
strlen(comma_filenodes) + 80);
|
strlen(comma_filenumbers) + 80);
|
||||||
ptr = qualifiers;
|
ptr = qualifiers;
|
||||||
|
|
||||||
if (opts->oids->num > 0)
|
if (opts->oids->num > 0)
|
||||||
@ -524,11 +524,12 @@ sql_exec_searchtables(PGconn *conn, struct options *opts)
|
|||||||
ptr += sprintf(ptr, "c.oid IN (%s)", comma_oids);
|
ptr += sprintf(ptr, "c.oid IN (%s)", comma_oids);
|
||||||
written = true;
|
written = true;
|
||||||
}
|
}
|
||||||
if (opts->filenodes->num > 0)
|
if (opts->filenumbers->num > 0)
|
||||||
{
|
{
|
||||||
if (written)
|
if (written)
|
||||||
ptr += sprintf(ptr, " OR ");
|
ptr += sprintf(ptr, " OR ");
|
||||||
ptr += sprintf(ptr, "pg_catalog.pg_relation_filenode(c.oid) IN (%s)", comma_filenodes);
|
ptr += sprintf(ptr, "pg_catalog.pg_relation_filenode(c.oid) IN (%s)",
|
||||||
|
comma_filenumbers);
|
||||||
written = true;
|
written = true;
|
||||||
}
|
}
|
||||||
if (opts->tables->num > 0)
|
if (opts->tables->num > 0)
|
||||||
@ -539,7 +540,7 @@ sql_exec_searchtables(PGconn *conn, struct options *opts)
|
|||||||
}
|
}
|
||||||
free(comma_oids);
|
free(comma_oids);
|
||||||
free(comma_tables);
|
free(comma_tables);
|
||||||
free(comma_filenodes);
|
free(comma_filenumbers);
|
||||||
|
|
||||||
/* now build the query */
|
/* now build the query */
|
||||||
todo = psprintf("SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s\n"
|
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)
|
|||||||
|
|
||||||
my_opts->oids = (eary *) pg_malloc(sizeof(eary));
|
my_opts->oids = (eary *) pg_malloc(sizeof(eary));
|
||||||
my_opts->tables = (eary *) pg_malloc(sizeof(eary));
|
my_opts->tables = (eary *) pg_malloc(sizeof(eary));
|
||||||
my_opts->filenodes = (eary *) pg_malloc(sizeof(eary));
|
my_opts->filenumbers = (eary *) pg_malloc(sizeof(eary));
|
||||||
|
|
||||||
my_opts->oids->num = my_opts->oids->alloc = 0;
|
my_opts->oids->num = my_opts->oids->alloc = 0;
|
||||||
my_opts->tables->num = my_opts->tables->alloc = 0;
|
my_opts->tables->num = my_opts->tables->alloc = 0;
|
||||||
my_opts->filenodes->num = my_opts->filenodes->alloc = 0;
|
my_opts->filenumbers->num = my_opts->filenumbers->alloc = 0;
|
||||||
|
|
||||||
/* parse the opts */
|
/* parse the opts */
|
||||||
get_opts(argc, argv, my_opts);
|
get_opts(argc, argv, my_opts);
|
||||||
@ -618,7 +619,7 @@ main(int argc, char **argv)
|
|||||||
/* display the given elements in the database */
|
/* display the given elements in the database */
|
||||||
if (my_opts->oids->num > 0 ||
|
if (my_opts->oids->num > 0 ||
|
||||||
my_opts->tables->num > 0 ||
|
my_opts->tables->num > 0 ||
|
||||||
my_opts->filenodes->num > 0)
|
my_opts->filenumbers->num > 0)
|
||||||
{
|
{
|
||||||
if (!my_opts->quiet)
|
if (!my_opts->quiet)
|
||||||
printf("From database \"%s\":\n", my_opts->dbname);
|
printf("From database \"%s\":\n", my_opts->dbname);
|
||||||
|
@ -26,7 +26,7 @@ PG_MODULE_MAGIC;
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32 bufferid;
|
uint32 bufferid;
|
||||||
Oid relfilenode;
|
RelFileNumber relfilenumber;
|
||||||
Oid reltablespace;
|
Oid reltablespace;
|
||||||
Oid reldatabase;
|
Oid reldatabase;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
@ -153,9 +153,9 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
|
|||||||
buf_state = LockBufHdr(bufHdr);
|
buf_state = LockBufHdr(bufHdr);
|
||||||
|
|
||||||
fctx->record[i].bufferid = BufferDescriptorGetBuffer(bufHdr);
|
fctx->record[i].bufferid = BufferDescriptorGetBuffer(bufHdr);
|
||||||
fctx->record[i].relfilenode = bufHdr->tag.rnode.relNode;
|
fctx->record[i].relfilenumber = bufHdr->tag.rlocator.relNumber;
|
||||||
fctx->record[i].reltablespace = bufHdr->tag.rnode.spcNode;
|
fctx->record[i].reltablespace = bufHdr->tag.rlocator.spcOid;
|
||||||
fctx->record[i].reldatabase = bufHdr->tag.rnode.dbNode;
|
fctx->record[i].reldatabase = bufHdr->tag.rlocator.dbOid;
|
||||||
fctx->record[i].forknum = bufHdr->tag.forkNum;
|
fctx->record[i].forknum = bufHdr->tag.forkNum;
|
||||||
fctx->record[i].blocknum = bufHdr->tag.blockNum;
|
fctx->record[i].blocknum = bufHdr->tag.blockNum;
|
||||||
fctx->record[i].usagecount = BUF_STATE_GET_USAGECOUNT(buf_state);
|
fctx->record[i].usagecount = BUF_STATE_GET_USAGECOUNT(buf_state);
|
||||||
@ -209,7 +209,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
values[1] = ObjectIdGetDatum(fctx->record[i].relfilenode);
|
values[1] = ObjectIdGetDatum(fctx->record[i].relfilenumber);
|
||||||
nulls[1] = false;
|
nulls[1] = false;
|
||||||
values[2] = ObjectIdGetDatum(fctx->record[i].reltablespace);
|
values[2] = ObjectIdGetDatum(fctx->record[i].reltablespace);
|
||||||
nulls[2] = false;
|
nulls[2] = false;
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
#include "utils/guc.h"
|
#include "utils/guc.h"
|
||||||
#include "utils/memutils.h"
|
#include "utils/memutils.h"
|
||||||
#include "utils/rel.h"
|
#include "utils/rel.h"
|
||||||
#include "utils/relfilenodemap.h"
|
#include "utils/relfilenumbermap.h"
|
||||||
#include "utils/resowner.h"
|
#include "utils/resowner.h"
|
||||||
|
|
||||||
#define AUTOPREWARM_FILE "autoprewarm.blocks"
|
#define AUTOPREWARM_FILE "autoprewarm.blocks"
|
||||||
@ -62,7 +62,7 @@ typedef struct BlockInfoRecord
|
|||||||
{
|
{
|
||||||
Oid database;
|
Oid database;
|
||||||
Oid tablespace;
|
Oid tablespace;
|
||||||
Oid filenode;
|
RelFileNumber filenumber;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
BlockNumber blocknum;
|
BlockNumber blocknum;
|
||||||
} BlockInfoRecord;
|
} BlockInfoRecord;
|
||||||
@ -347,7 +347,7 @@ apw_load_buffers(void)
|
|||||||
unsigned forknum;
|
unsigned forknum;
|
||||||
|
|
||||||
if (fscanf(file, "%u,%u,%u,%u,%u\n", &blkinfo[i].database,
|
if (fscanf(file, "%u,%u,%u,%u,%u\n", &blkinfo[i].database,
|
||||||
&blkinfo[i].tablespace, &blkinfo[i].filenode,
|
&blkinfo[i].tablespace, &blkinfo[i].filenumber,
|
||||||
&forknum, &blkinfo[i].blocknum) != 5)
|
&forknum, &blkinfo[i].blocknum) != 5)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errmsg("autoprewarm block dump file is corrupted at line %d",
|
(errmsg("autoprewarm block dump file is corrupted at line %d",
|
||||||
@ -494,7 +494,7 @@ autoprewarm_database_main(Datum main_arg)
|
|||||||
* relation. Note that rel will be NULL if try_relation_open failed
|
* relation. Note that rel will be NULL if try_relation_open failed
|
||||||
* previously; in that case, there is nothing to close.
|
* previously; in that case, there is nothing to close.
|
||||||
*/
|
*/
|
||||||
if (old_blk != NULL && old_blk->filenode != blk->filenode &&
|
if (old_blk != NULL && old_blk->filenumber != blk->filenumber &&
|
||||||
rel != NULL)
|
rel != NULL)
|
||||||
{
|
{
|
||||||
relation_close(rel, AccessShareLock);
|
relation_close(rel, AccessShareLock);
|
||||||
@ -506,13 +506,13 @@ autoprewarm_database_main(Datum main_arg)
|
|||||||
* Try to open each new relation, but only once, when we first
|
* Try to open each new relation, but only once, when we first
|
||||||
* encounter it. If it's been dropped, skip the associated blocks.
|
* encounter it. If it's been dropped, skip the associated blocks.
|
||||||
*/
|
*/
|
||||||
if (old_blk == NULL || old_blk->filenode != blk->filenode)
|
if (old_blk == NULL || old_blk->filenumber != blk->filenumber)
|
||||||
{
|
{
|
||||||
Oid reloid;
|
Oid reloid;
|
||||||
|
|
||||||
Assert(rel == NULL);
|
Assert(rel == NULL);
|
||||||
StartTransactionCommand();
|
StartTransactionCommand();
|
||||||
reloid = RelidByRelfilenode(blk->tablespace, blk->filenode);
|
reloid = RelidByRelfilenumber(blk->tablespace, blk->filenumber);
|
||||||
if (OidIsValid(reloid))
|
if (OidIsValid(reloid))
|
||||||
rel = try_relation_open(reloid, AccessShareLock);
|
rel = try_relation_open(reloid, AccessShareLock);
|
||||||
|
|
||||||
@ -527,7 +527,7 @@ autoprewarm_database_main(Datum main_arg)
|
|||||||
|
|
||||||
/* Once per fork, check for fork existence and size. */
|
/* Once per fork, check for fork existence and size. */
|
||||||
if (old_blk == NULL ||
|
if (old_blk == NULL ||
|
||||||
old_blk->filenode != blk->filenode ||
|
old_blk->filenumber != blk->filenumber ||
|
||||||
old_blk->forknum != blk->forknum)
|
old_blk->forknum != blk->forknum)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -631,9 +631,9 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
|
|||||||
if (buf_state & BM_TAG_VALID &&
|
if (buf_state & BM_TAG_VALID &&
|
||||||
((buf_state & BM_PERMANENT) || dump_unlogged))
|
((buf_state & BM_PERMANENT) || dump_unlogged))
|
||||||
{
|
{
|
||||||
block_info_array[num_blocks].database = bufHdr->tag.rnode.dbNode;
|
block_info_array[num_blocks].database = bufHdr->tag.rlocator.dbOid;
|
||||||
block_info_array[num_blocks].tablespace = bufHdr->tag.rnode.spcNode;
|
block_info_array[num_blocks].tablespace = bufHdr->tag.rlocator.spcOid;
|
||||||
block_info_array[num_blocks].filenode = bufHdr->tag.rnode.relNode;
|
block_info_array[num_blocks].filenumber = bufHdr->tag.rlocator.relNumber;
|
||||||
block_info_array[num_blocks].forknum = bufHdr->tag.forkNum;
|
block_info_array[num_blocks].forknum = bufHdr->tag.forkNum;
|
||||||
block_info_array[num_blocks].blocknum = bufHdr->tag.blockNum;
|
block_info_array[num_blocks].blocknum = bufHdr->tag.blockNum;
|
||||||
++num_blocks;
|
++num_blocks;
|
||||||
@ -671,7 +671,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
|
|||||||
ret = fprintf(file, "%u,%u,%u,%u,%u\n",
|
ret = fprintf(file, "%u,%u,%u,%u,%u\n",
|
||||||
block_info_array[i].database,
|
block_info_array[i].database,
|
||||||
block_info_array[i].tablespace,
|
block_info_array[i].tablespace,
|
||||||
block_info_array[i].filenode,
|
block_info_array[i].filenumber,
|
||||||
(uint32) block_info_array[i].forknum,
|
(uint32) block_info_array[i].forknum,
|
||||||
block_info_array[i].blocknum);
|
block_info_array[i].blocknum);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -900,7 +900,7 @@ do { \
|
|||||||
* We depend on all records for a particular database being consecutive
|
* We depend on all records for a particular database being consecutive
|
||||||
* in the dump file; each per-database worker will preload blocks until
|
* in the dump file; each per-database worker will preload blocks until
|
||||||
* it sees a block for some other database. Sorting by tablespace,
|
* it sees a block for some other database. Sorting by tablespace,
|
||||||
* filenode, forknum, and blocknum isn't critical for correctness, but
|
* filenumber, forknum, and blocknum isn't critical for correctness, but
|
||||||
* helps us get a sequential I/O pattern.
|
* helps us get a sequential I/O pattern.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
@ -911,7 +911,7 @@ apw_compare_blockinfo(const void *p, const void *q)
|
|||||||
|
|
||||||
cmp_member_elem(database);
|
cmp_member_elem(database);
|
||||||
cmp_member_elem(tablespace);
|
cmp_member_elem(tablespace);
|
||||||
cmp_member_elem(filenode);
|
cmp_member_elem(filenumber);
|
||||||
cmp_member_elem(forknum);
|
cmp_member_elem(forknum);
|
||||||
cmp_member_elem(blocknum);
|
cmp_member_elem(blocknum);
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ pg_truncate_visibility_map(PG_FUNCTION_ARGS)
|
|||||||
xl_smgr_truncate xlrec;
|
xl_smgr_truncate xlrec;
|
||||||
|
|
||||||
xlrec.blkno = 0;
|
xlrec.blkno = 0;
|
||||||
xlrec.rnode = rel->rd_node;
|
xlrec.rlocator = rel->rd_locator;
|
||||||
xlrec.flags = SMGR_TRUNCATE_VM;
|
xlrec.flags = SMGR_TRUNCATE_VM;
|
||||||
|
|
||||||
XLogBeginInsert();
|
XLogBeginInsert();
|
||||||
|
@ -90,7 +90,7 @@ bool trace_syncscan = false;
|
|||||||
*/
|
*/
|
||||||
typedef struct ss_scan_location_t
|
typedef struct ss_scan_location_t
|
||||||
{
|
{
|
||||||
RelFileNode relfilenode; /* identity of a relation */
|
RelFileLocator relfilelocator; /* identity of a relation */
|
||||||
BlockNumber location; /* last-reported location in the relation */
|
BlockNumber location; /* last-reported location in the relation */
|
||||||
} ss_scan_location_t;
|
} ss_scan_location_t;
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ typedef struct ss_scan_locations_t
|
|||||||
static ss_scan_locations_t *scan_locations;
|
static ss_scan_locations_t *scan_locations;
|
||||||
|
|
||||||
/* prototypes for internal functions */
|
/* prototypes for internal functions */
|
||||||
static BlockNumber ss_search(RelFileNode relfilenode,
|
static BlockNumber ss_search(RelFileLocator relfilelocator,
|
||||||
BlockNumber location, bool set);
|
BlockNumber location, bool set);
|
||||||
|
|
||||||
|
|
||||||
@ -159,9 +159,9 @@ SyncScanShmemInit(void)
|
|||||||
* these invalid entries will fall off the LRU list and get
|
* these invalid entries will fall off the LRU list and get
|
||||||
* replaced with real entries.
|
* replaced with real entries.
|
||||||
*/
|
*/
|
||||||
item->location.relfilenode.spcNode = InvalidOid;
|
item->location.relfilelocator.spcOid = InvalidOid;
|
||||||
item->location.relfilenode.dbNode = InvalidOid;
|
item->location.relfilelocator.dbOid = InvalidOid;
|
||||||
item->location.relfilenode.relNode = InvalidOid;
|
item->location.relfilelocator.relNumber = InvalidRelFileNumber;
|
||||||
item->location.location = InvalidBlockNumber;
|
item->location.location = InvalidBlockNumber;
|
||||||
|
|
||||||
item->prev = (i > 0) ?
|
item->prev = (i > 0) ?
|
||||||
@ -176,10 +176,10 @@ SyncScanShmemInit(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* ss_search --- search the scan_locations structure for an entry with the
|
* ss_search --- search the scan_locations structure for an entry with the
|
||||||
* given relfilenode.
|
* given relfilelocator.
|
||||||
*
|
*
|
||||||
* If "set" is true, the location is updated to the given location. If no
|
* If "set" is true, the location is updated to the given location. If no
|
||||||
* entry for the given relfilenode is found, it will be created at the head
|
* entry for the given relfilelocator is found, it will be created at the head
|
||||||
* of the list with the given location, even if "set" is false.
|
* of the list with the given location, even if "set" is false.
|
||||||
*
|
*
|
||||||
* In any case, the location after possible update is returned.
|
* In any case, the location after possible update is returned.
|
||||||
@ -188,7 +188,7 @@ SyncScanShmemInit(void)
|
|||||||
* data structure.
|
* data structure.
|
||||||
*/
|
*/
|
||||||
static BlockNumber
|
static BlockNumber
|
||||||
ss_search(RelFileNode relfilenode, BlockNumber location, bool set)
|
ss_search(RelFileLocator relfilelocator, BlockNumber location, bool set)
|
||||||
{
|
{
|
||||||
ss_lru_item_t *item;
|
ss_lru_item_t *item;
|
||||||
|
|
||||||
@ -197,7 +197,8 @@ ss_search(RelFileNode relfilenode, BlockNumber location, bool set)
|
|||||||
{
|
{
|
||||||
bool match;
|
bool match;
|
||||||
|
|
||||||
match = RelFileNodeEquals(item->location.relfilenode, relfilenode);
|
match = RelFileLocatorEquals(item->location.relfilelocator,
|
||||||
|
relfilelocator);
|
||||||
|
|
||||||
if (match || item->next == NULL)
|
if (match || item->next == NULL)
|
||||||
{
|
{
|
||||||
@ -207,7 +208,7 @@ ss_search(RelFileNode relfilenode, BlockNumber location, bool set)
|
|||||||
*/
|
*/
|
||||||
if (!match)
|
if (!match)
|
||||||
{
|
{
|
||||||
item->location.relfilenode = relfilenode;
|
item->location.relfilelocator = relfilelocator;
|
||||||
item->location.location = location;
|
item->location.location = location;
|
||||||
}
|
}
|
||||||
else if (set)
|
else if (set)
|
||||||
@ -255,7 +256,7 @@ ss_get_location(Relation rel, BlockNumber relnblocks)
|
|||||||
BlockNumber startloc;
|
BlockNumber startloc;
|
||||||
|
|
||||||
LWLockAcquire(SyncScanLock, LW_EXCLUSIVE);
|
LWLockAcquire(SyncScanLock, LW_EXCLUSIVE);
|
||||||
startloc = ss_search(rel->rd_node, 0, false);
|
startloc = ss_search(rel->rd_locator, 0, false);
|
||||||
LWLockRelease(SyncScanLock);
|
LWLockRelease(SyncScanLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -281,8 +282,8 @@ ss_get_location(Relation rel, BlockNumber relnblocks)
|
|||||||
* ss_report_location --- update the current scan location
|
* ss_report_location --- update the current scan location
|
||||||
*
|
*
|
||||||
* Writes an entry into the shared Sync Scan state of the form
|
* Writes an entry into the shared Sync Scan state of the form
|
||||||
* (relfilenode, blocknumber), overwriting any existing entry for the
|
* (relfilelocator, blocknumber), overwriting any existing entry for the
|
||||||
* same relfilenode.
|
* same relfilelocator.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ss_report_location(Relation rel, BlockNumber location)
|
ss_report_location(Relation rel, BlockNumber location)
|
||||||
@ -309,7 +310,7 @@ ss_report_location(Relation rel, BlockNumber location)
|
|||||||
{
|
{
|
||||||
if (LWLockConditionalAcquire(SyncScanLock, LW_EXCLUSIVE))
|
if (LWLockConditionalAcquire(SyncScanLock, LW_EXCLUSIVE))
|
||||||
{
|
{
|
||||||
(void) ss_search(rel->rd_node, location, true);
|
(void) ss_search(rel->rd_locator, location, true);
|
||||||
LWLockRelease(SyncScanLock);
|
LWLockRelease(SyncScanLock);
|
||||||
}
|
}
|
||||||
#ifdef TRACE_SYNCSCAN
|
#ifdef TRACE_SYNCSCAN
|
||||||
|
@ -470,7 +470,7 @@ ginPlaceToPage(GinBtree btree, GinBtreeStack *stack,
|
|||||||
savedRightLink = GinPageGetOpaque(page)->rightlink;
|
savedRightLink = GinPageGetOpaque(page)->rightlink;
|
||||||
|
|
||||||
/* Begin setting up WAL record */
|
/* Begin setting up WAL record */
|
||||||
data.node = btree->index->rd_node;
|
data.locator = btree->index->rd_locator;
|
||||||
data.flags = xlflags;
|
data.flags = xlflags;
|
||||||
if (BufferIsValid(childbuf))
|
if (BufferIsValid(childbuf))
|
||||||
{
|
{
|
||||||
|
@ -235,7 +235,7 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector)
|
|||||||
|
|
||||||
needWal = RelationNeedsWAL(index);
|
needWal = RelationNeedsWAL(index);
|
||||||
|
|
||||||
data.node = index->rd_node;
|
data.locator = index->rd_locator;
|
||||||
data.ntuples = 0;
|
data.ntuples = 0;
|
||||||
data.newRightlink = data.prevTail = InvalidBlockNumber;
|
data.newRightlink = data.prevTail = InvalidBlockNumber;
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ ginUpdateStats(Relation index, const GinStatsData *stats, bool is_build)
|
|||||||
XLogRecPtr recptr;
|
XLogRecPtr recptr;
|
||||||
ginxlogUpdateMeta data;
|
ginxlogUpdateMeta data;
|
||||||
|
|
||||||
data.node = index->rd_node;
|
data.locator = index->rd_locator;
|
||||||
data.ntuples = 0;
|
data.ntuples = 0;
|
||||||
data.newRightlink = data.prevTail = InvalidBlockNumber;
|
data.newRightlink = data.prevTail = InvalidBlockNumber;
|
||||||
memcpy(&data.metadata, metadata, sizeof(GinMetaPageData));
|
memcpy(&data.metadata, metadata, sizeof(GinMetaPageData));
|
||||||
|
@ -95,13 +95,13 @@ ginRedoInsertEntry(Buffer buffer, bool isLeaf, BlockNumber rightblkno, void *rda
|
|||||||
|
|
||||||
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), offset, false, false) == InvalidOffsetNumber)
|
if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), offset, false, false) == InvalidOffsetNumber)
|
||||||
{
|
{
|
||||||
RelFileNode node;
|
RelFileLocator locator;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
BlockNumber blknum;
|
BlockNumber blknum;
|
||||||
|
|
||||||
BufferGetTag(buffer, &node, &forknum, &blknum);
|
BufferGetTag(buffer, &locator, &forknum, &blknum);
|
||||||
elog(ERROR, "failed to add item to index page in %u/%u/%u",
|
elog(ERROR, "failed to add item to index page in %u/%u/%u",
|
||||||
node.spcNode, node.dbNode, node.relNode);
|
locator.spcOid, locator.dbOid, locator.relNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ gist_indexsortbuild(GISTBuildState *state)
|
|||||||
smgrwrite(RelationGetSmgr(state->indexrel), MAIN_FORKNUM, GIST_ROOT_BLKNO,
|
smgrwrite(RelationGetSmgr(state->indexrel), MAIN_FORKNUM, GIST_ROOT_BLKNO,
|
||||||
levelstate->pages[0], true);
|
levelstate->pages[0], true);
|
||||||
if (RelationNeedsWAL(state->indexrel))
|
if (RelationNeedsWAL(state->indexrel))
|
||||||
log_newpage(&state->indexrel->rd_node, MAIN_FORKNUM, GIST_ROOT_BLKNO,
|
log_newpage(&state->indexrel->rd_locator, MAIN_FORKNUM, GIST_ROOT_BLKNO,
|
||||||
levelstate->pages[0], true);
|
levelstate->pages[0], true);
|
||||||
|
|
||||||
pfree(levelstate->pages[0]);
|
pfree(levelstate->pages[0]);
|
||||||
@ -663,7 +663,7 @@ gist_indexsortbuild_flush_ready_pages(GISTBuildState *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (RelationNeedsWAL(state->indexrel))
|
if (RelationNeedsWAL(state->indexrel))
|
||||||
log_newpages(&state->indexrel->rd_node, MAIN_FORKNUM, state->ready_num_pages,
|
log_newpages(&state->indexrel->rd_locator, MAIN_FORKNUM, state->ready_num_pages,
|
||||||
state->ready_blknos, state->ready_pages, true);
|
state->ready_blknos, state->ready_pages, true);
|
||||||
|
|
||||||
for (int i = 0; i < state->ready_num_pages; i++)
|
for (int i = 0; i < state->ready_num_pages; i++)
|
||||||
|
@ -191,11 +191,12 @@ gistRedoDeleteRecord(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
if (InHotStandby)
|
if (InHotStandby)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, NULL);
|
XLogRecGetBlockTag(record, 0, &rlocator, NULL, NULL);
|
||||||
|
|
||||||
ResolveRecoveryConflictWithSnapshot(xldata->latestRemovedXid, rnode);
|
ResolveRecoveryConflictWithSnapshot(xldata->latestRemovedXid,
|
||||||
|
rlocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
|
if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
|
||||||
@ -395,7 +396,7 @@ gistRedoPageReuse(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
if (InHotStandby)
|
if (InHotStandby)
|
||||||
ResolveRecoveryConflictWithSnapshotFullXid(xlrec->latestRemovedFullXid,
|
ResolveRecoveryConflictWithSnapshotFullXid(xlrec->latestRemovedFullXid,
|
||||||
xlrec->node);
|
xlrec->locator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -607,7 +608,7 @@ gistXLogPageReuse(Relation rel, BlockNumber blkno, FullTransactionId latestRemov
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* XLOG stuff */
|
/* XLOG stuff */
|
||||||
xlrec_reuse.node = rel->rd_node;
|
xlrec_reuse.locator = rel->rd_locator;
|
||||||
xlrec_reuse.block = blkno;
|
xlrec_reuse.block = blkno;
|
||||||
xlrec_reuse.latestRemovedFullXid = latestRemovedXid;
|
xlrec_reuse.latestRemovedFullXid = latestRemovedXid;
|
||||||
|
|
||||||
|
@ -999,10 +999,10 @@ hash_xlog_vacuum_one_page(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
if (InHotStandby)
|
if (InHotStandby)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, NULL);
|
XLogRecGetBlockTag(record, 0, &rlocator, NULL, NULL);
|
||||||
ResolveRecoveryConflictWithSnapshot(xldata->latestRemovedXid, rnode);
|
ResolveRecoveryConflictWithSnapshot(xldata->latestRemovedXid, rlocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
action = XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &buffer);
|
action = XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &buffer);
|
||||||
|
@ -428,7 +428,7 @@ _hash_init(Relation rel, double num_tuples, ForkNumber forkNum)
|
|||||||
MarkBufferDirty(buf);
|
MarkBufferDirty(buf);
|
||||||
|
|
||||||
if (use_wal)
|
if (use_wal)
|
||||||
log_newpage(&rel->rd_node,
|
log_newpage(&rel->rd_locator,
|
||||||
forkNum,
|
forkNum,
|
||||||
blkno,
|
blkno,
|
||||||
BufferGetPage(buf),
|
BufferGetPage(buf),
|
||||||
@ -1019,7 +1019,7 @@ _hash_alloc_buckets(Relation rel, BlockNumber firstblock, uint32 nblocks)
|
|||||||
ovflopaque->hasho_page_id = HASHO_PAGE_ID;
|
ovflopaque->hasho_page_id = HASHO_PAGE_ID;
|
||||||
|
|
||||||
if (RelationNeedsWAL(rel))
|
if (RelationNeedsWAL(rel))
|
||||||
log_newpage(&rel->rd_node,
|
log_newpage(&rel->rd_locator,
|
||||||
MAIN_FORKNUM,
|
MAIN_FORKNUM,
|
||||||
lastblock,
|
lastblock,
|
||||||
zerobuf.data,
|
zerobuf.data,
|
||||||
|
@ -8189,7 +8189,7 @@ log_heap_freeze(Relation reln, Buffer buffer, TransactionId cutoff_xid,
|
|||||||
* heap_buffer, if necessary.
|
* heap_buffer, if necessary.
|
||||||
*/
|
*/
|
||||||
XLogRecPtr
|
XLogRecPtr
|
||||||
log_heap_visible(RelFileNode rnode, Buffer heap_buffer, Buffer vm_buffer,
|
log_heap_visible(RelFileLocator rlocator, Buffer heap_buffer, Buffer vm_buffer,
|
||||||
TransactionId cutoff_xid, uint8 vmflags)
|
TransactionId cutoff_xid, uint8 vmflags)
|
||||||
{
|
{
|
||||||
xl_heap_visible xlrec;
|
xl_heap_visible xlrec;
|
||||||
@ -8454,7 +8454,7 @@ log_heap_new_cid(Relation relation, HeapTuple tup)
|
|||||||
Assert(tup->t_tableOid != InvalidOid);
|
Assert(tup->t_tableOid != InvalidOid);
|
||||||
|
|
||||||
xlrec.top_xid = GetTopTransactionId();
|
xlrec.top_xid = GetTopTransactionId();
|
||||||
xlrec.target_node = relation->rd_node;
|
xlrec.target_locator = relation->rd_locator;
|
||||||
xlrec.target_tid = tup->t_self;
|
xlrec.target_tid = tup->t_self;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -8623,18 +8623,18 @@ heap_xlog_prune(XLogReaderState *record)
|
|||||||
XLogRecPtr lsn = record->EndRecPtr;
|
XLogRecPtr lsn = record->EndRecPtr;
|
||||||
xl_heap_prune *xlrec = (xl_heap_prune *) XLogRecGetData(record);
|
xl_heap_prune *xlrec = (xl_heap_prune *) XLogRecGetData(record);
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
XLogRedoAction action;
|
XLogRedoAction action;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno);
|
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &blkno);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We're about to remove tuples. In Hot Standby mode, ensure that there's
|
* We're about to remove tuples. In Hot Standby mode, ensure that there's
|
||||||
* no queries running for which the removed tuples are still visible.
|
* no queries running for which the removed tuples are still visible.
|
||||||
*/
|
*/
|
||||||
if (InHotStandby)
|
if (InHotStandby)
|
||||||
ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid, rnode);
|
ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid, rlocator);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have a full-page image, restore it (using a cleanup lock) and
|
* If we have a full-page image, restore it (using a cleanup lock) and
|
||||||
@ -8694,7 +8694,7 @@ heap_xlog_prune(XLogReaderState *record)
|
|||||||
* Do this regardless of a full-page image being applied, since the
|
* Do this regardless of a full-page image being applied, since the
|
||||||
* FSM data is not in the page anyway.
|
* FSM data is not in the page anyway.
|
||||||
*/
|
*/
|
||||||
XLogRecordPageWithFreeSpace(rnode, blkno, freespace);
|
XLogRecordPageWithFreeSpace(rlocator, blkno, freespace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8751,9 +8751,9 @@ heap_xlog_vacuum(XLogReaderState *record)
|
|||||||
if (BufferIsValid(buffer))
|
if (BufferIsValid(buffer))
|
||||||
{
|
{
|
||||||
Size freespace = PageGetHeapFreeSpace(BufferGetPage(buffer));
|
Size freespace = PageGetHeapFreeSpace(BufferGetPage(buffer));
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno);
|
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &blkno);
|
||||||
|
|
||||||
UnlockReleaseBuffer(buffer);
|
UnlockReleaseBuffer(buffer);
|
||||||
|
|
||||||
@ -8766,7 +8766,7 @@ heap_xlog_vacuum(XLogReaderState *record)
|
|||||||
* Do this regardless of a full-page image being applied, since the
|
* Do this regardless of a full-page image being applied, since the
|
||||||
* FSM data is not in the page anyway.
|
* FSM data is not in the page anyway.
|
||||||
*/
|
*/
|
||||||
XLogRecordPageWithFreeSpace(rnode, blkno, freespace);
|
XLogRecordPageWithFreeSpace(rlocator, blkno, freespace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8786,11 +8786,11 @@ heap_xlog_visible(XLogReaderState *record)
|
|||||||
Buffer vmbuffer = InvalidBuffer;
|
Buffer vmbuffer = InvalidBuffer;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
Page page;
|
Page page;
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
XLogRedoAction action;
|
XLogRedoAction action;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 1, &rnode, NULL, &blkno);
|
XLogRecGetBlockTag(record, 1, &rlocator, NULL, &blkno);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there are any Hot Standby transactions running that have an xmin
|
* If there are any Hot Standby transactions running that have an xmin
|
||||||
@ -8802,7 +8802,7 @@ heap_xlog_visible(XLogReaderState *record)
|
|||||||
* rather than killing the transaction outright.
|
* rather than killing the transaction outright.
|
||||||
*/
|
*/
|
||||||
if (InHotStandby)
|
if (InHotStandby)
|
||||||
ResolveRecoveryConflictWithSnapshot(xlrec->cutoff_xid, rnode);
|
ResolveRecoveryConflictWithSnapshot(xlrec->cutoff_xid, rlocator);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the heap page, if it still exists. If the heap file has dropped or
|
* Read the heap page, if it still exists. If the heap file has dropped or
|
||||||
@ -8865,7 +8865,7 @@ heap_xlog_visible(XLogReaderState *record)
|
|||||||
* FSM data is not in the page anyway.
|
* FSM data is not in the page anyway.
|
||||||
*/
|
*/
|
||||||
if (xlrec->flags & VISIBILITYMAP_VALID_BITS)
|
if (xlrec->flags & VISIBILITYMAP_VALID_BITS)
|
||||||
XLogRecordPageWithFreeSpace(rnode, blkno, space);
|
XLogRecordPageWithFreeSpace(rlocator, blkno, space);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -8890,7 +8890,7 @@ heap_xlog_visible(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
LockBuffer(vmbuffer, BUFFER_LOCK_UNLOCK);
|
LockBuffer(vmbuffer, BUFFER_LOCK_UNLOCK);
|
||||||
|
|
||||||
reln = CreateFakeRelcacheEntry(rnode);
|
reln = CreateFakeRelcacheEntry(rlocator);
|
||||||
visibilitymap_pin(reln, blkno, &vmbuffer);
|
visibilitymap_pin(reln, blkno, &vmbuffer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -8933,13 +8933,13 @@ heap_xlog_freeze_page(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
if (InHotStandby)
|
if (InHotStandby)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
TransactionId latestRemovedXid = cutoff_xid;
|
TransactionId latestRemovedXid = cutoff_xid;
|
||||||
|
|
||||||
TransactionIdRetreat(latestRemovedXid);
|
TransactionIdRetreat(latestRemovedXid);
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, NULL);
|
XLogRecGetBlockTag(record, 0, &rlocator, NULL, NULL);
|
||||||
ResolveRecoveryConflictWithSnapshot(latestRemovedXid, rnode);
|
ResolveRecoveryConflictWithSnapshot(latestRemovedXid, rlocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
|
if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
|
||||||
@ -9007,10 +9007,10 @@ heap_xlog_delete(XLogReaderState *record)
|
|||||||
ItemId lp = NULL;
|
ItemId lp = NULL;
|
||||||
HeapTupleHeader htup;
|
HeapTupleHeader htup;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
RelFileNode target_node;
|
RelFileLocator target_locator;
|
||||||
ItemPointerData target_tid;
|
ItemPointerData target_tid;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &target_node, NULL, &blkno);
|
XLogRecGetBlockTag(record, 0, &target_locator, NULL, &blkno);
|
||||||
ItemPointerSetBlockNumber(&target_tid, blkno);
|
ItemPointerSetBlockNumber(&target_tid, blkno);
|
||||||
ItemPointerSetOffsetNumber(&target_tid, xlrec->offnum);
|
ItemPointerSetOffsetNumber(&target_tid, xlrec->offnum);
|
||||||
|
|
||||||
@ -9020,7 +9020,7 @@ heap_xlog_delete(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
if (xlrec->flags & XLH_DELETE_ALL_VISIBLE_CLEARED)
|
if (xlrec->flags & XLH_DELETE_ALL_VISIBLE_CLEARED)
|
||||||
{
|
{
|
||||||
Relation reln = CreateFakeRelcacheEntry(target_node);
|
Relation reln = CreateFakeRelcacheEntry(target_locator);
|
||||||
Buffer vmbuffer = InvalidBuffer;
|
Buffer vmbuffer = InvalidBuffer;
|
||||||
|
|
||||||
visibilitymap_pin(reln, blkno, &vmbuffer);
|
visibilitymap_pin(reln, blkno, &vmbuffer);
|
||||||
@ -9086,12 +9086,12 @@ heap_xlog_insert(XLogReaderState *record)
|
|||||||
xl_heap_header xlhdr;
|
xl_heap_header xlhdr;
|
||||||
uint32 newlen;
|
uint32 newlen;
|
||||||
Size freespace = 0;
|
Size freespace = 0;
|
||||||
RelFileNode target_node;
|
RelFileLocator target_locator;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
ItemPointerData target_tid;
|
ItemPointerData target_tid;
|
||||||
XLogRedoAction action;
|
XLogRedoAction action;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &target_node, NULL, &blkno);
|
XLogRecGetBlockTag(record, 0, &target_locator, NULL, &blkno);
|
||||||
ItemPointerSetBlockNumber(&target_tid, blkno);
|
ItemPointerSetBlockNumber(&target_tid, blkno);
|
||||||
ItemPointerSetOffsetNumber(&target_tid, xlrec->offnum);
|
ItemPointerSetOffsetNumber(&target_tid, xlrec->offnum);
|
||||||
|
|
||||||
@ -9101,7 +9101,7 @@ heap_xlog_insert(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
if (xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED)
|
if (xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED)
|
||||||
{
|
{
|
||||||
Relation reln = CreateFakeRelcacheEntry(target_node);
|
Relation reln = CreateFakeRelcacheEntry(target_locator);
|
||||||
Buffer vmbuffer = InvalidBuffer;
|
Buffer vmbuffer = InvalidBuffer;
|
||||||
|
|
||||||
visibilitymap_pin(reln, blkno, &vmbuffer);
|
visibilitymap_pin(reln, blkno, &vmbuffer);
|
||||||
@ -9184,7 +9184,7 @@ heap_xlog_insert(XLogReaderState *record)
|
|||||||
* totally accurate anyway.
|
* totally accurate anyway.
|
||||||
*/
|
*/
|
||||||
if (action == BLK_NEEDS_REDO && freespace < BLCKSZ / 5)
|
if (action == BLK_NEEDS_REDO && freespace < BLCKSZ / 5)
|
||||||
XLogRecordPageWithFreeSpace(target_node, blkno, freespace);
|
XLogRecordPageWithFreeSpace(target_locator, blkno, freespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -9195,7 +9195,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
|
|||||||
{
|
{
|
||||||
XLogRecPtr lsn = record->EndRecPtr;
|
XLogRecPtr lsn = record->EndRecPtr;
|
||||||
xl_heap_multi_insert *xlrec;
|
xl_heap_multi_insert *xlrec;
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
Page page;
|
Page page;
|
||||||
@ -9217,7 +9217,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
xlrec = (xl_heap_multi_insert *) XLogRecGetData(record);
|
xlrec = (xl_heap_multi_insert *) XLogRecGetData(record);
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &blkno);
|
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &blkno);
|
||||||
|
|
||||||
/* check that the mutually exclusive flags are not both set */
|
/* check that the mutually exclusive flags are not both set */
|
||||||
Assert(!((xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED) &&
|
Assert(!((xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED) &&
|
||||||
@ -9229,7 +9229,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
if (xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED)
|
if (xlrec->flags & XLH_INSERT_ALL_VISIBLE_CLEARED)
|
||||||
{
|
{
|
||||||
Relation reln = CreateFakeRelcacheEntry(rnode);
|
Relation reln = CreateFakeRelcacheEntry(rlocator);
|
||||||
Buffer vmbuffer = InvalidBuffer;
|
Buffer vmbuffer = InvalidBuffer;
|
||||||
|
|
||||||
visibilitymap_pin(reln, blkno, &vmbuffer);
|
visibilitymap_pin(reln, blkno, &vmbuffer);
|
||||||
@ -9331,7 +9331,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
|
|||||||
* totally accurate anyway.
|
* totally accurate anyway.
|
||||||
*/
|
*/
|
||||||
if (action == BLK_NEEDS_REDO && freespace < BLCKSZ / 5)
|
if (action == BLK_NEEDS_REDO && freespace < BLCKSZ / 5)
|
||||||
XLogRecordPageWithFreeSpace(rnode, blkno, freespace);
|
XLogRecordPageWithFreeSpace(rlocator, blkno, freespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -9342,7 +9342,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
|||||||
{
|
{
|
||||||
XLogRecPtr lsn = record->EndRecPtr;
|
XLogRecPtr lsn = record->EndRecPtr;
|
||||||
xl_heap_update *xlrec = (xl_heap_update *) XLogRecGetData(record);
|
xl_heap_update *xlrec = (xl_heap_update *) XLogRecGetData(record);
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
BlockNumber oldblk;
|
BlockNumber oldblk;
|
||||||
BlockNumber newblk;
|
BlockNumber newblk;
|
||||||
ItemPointerData newtid;
|
ItemPointerData newtid;
|
||||||
@ -9371,7 +9371,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
|||||||
oldtup.t_data = NULL;
|
oldtup.t_data = NULL;
|
||||||
oldtup.t_len = 0;
|
oldtup.t_len = 0;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &newblk);
|
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &newblk);
|
||||||
if (XLogRecGetBlockTagExtended(record, 1, NULL, NULL, &oldblk, NULL))
|
if (XLogRecGetBlockTagExtended(record, 1, NULL, NULL, &oldblk, NULL))
|
||||||
{
|
{
|
||||||
/* HOT updates are never done across pages */
|
/* HOT updates are never done across pages */
|
||||||
@ -9388,7 +9388,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
|||||||
*/
|
*/
|
||||||
if (xlrec->flags & XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED)
|
if (xlrec->flags & XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED)
|
||||||
{
|
{
|
||||||
Relation reln = CreateFakeRelcacheEntry(rnode);
|
Relation reln = CreateFakeRelcacheEntry(rlocator);
|
||||||
Buffer vmbuffer = InvalidBuffer;
|
Buffer vmbuffer = InvalidBuffer;
|
||||||
|
|
||||||
visibilitymap_pin(reln, oldblk, &vmbuffer);
|
visibilitymap_pin(reln, oldblk, &vmbuffer);
|
||||||
@ -9472,7 +9472,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
|||||||
*/
|
*/
|
||||||
if (xlrec->flags & XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED)
|
if (xlrec->flags & XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED)
|
||||||
{
|
{
|
||||||
Relation reln = CreateFakeRelcacheEntry(rnode);
|
Relation reln = CreateFakeRelcacheEntry(rlocator);
|
||||||
Buffer vmbuffer = InvalidBuffer;
|
Buffer vmbuffer = InvalidBuffer;
|
||||||
|
|
||||||
visibilitymap_pin(reln, newblk, &vmbuffer);
|
visibilitymap_pin(reln, newblk, &vmbuffer);
|
||||||
@ -9606,7 +9606,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
|||||||
* totally accurate anyway.
|
* totally accurate anyway.
|
||||||
*/
|
*/
|
||||||
if (newaction == BLK_NEEDS_REDO && !hot_update && freespace < BLCKSZ / 5)
|
if (newaction == BLK_NEEDS_REDO && !hot_update && freespace < BLCKSZ / 5)
|
||||||
XLogRecordPageWithFreeSpace(rnode, newblk, freespace);
|
XLogRecordPageWithFreeSpace(rlocator, newblk, freespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -9662,13 +9662,13 @@ heap_xlog_lock(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
if (xlrec->flags & XLH_LOCK_ALL_FROZEN_CLEARED)
|
if (xlrec->flags & XLH_LOCK_ALL_FROZEN_CLEARED)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
Buffer vmbuffer = InvalidBuffer;
|
Buffer vmbuffer = InvalidBuffer;
|
||||||
BlockNumber block;
|
BlockNumber block;
|
||||||
Relation reln;
|
Relation reln;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &block);
|
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &block);
|
||||||
reln = CreateFakeRelcacheEntry(rnode);
|
reln = CreateFakeRelcacheEntry(rlocator);
|
||||||
|
|
||||||
visibilitymap_pin(reln, block, &vmbuffer);
|
visibilitymap_pin(reln, block, &vmbuffer);
|
||||||
visibilitymap_clear(reln, block, vmbuffer, VISIBILITYMAP_ALL_FROZEN);
|
visibilitymap_clear(reln, block, vmbuffer, VISIBILITYMAP_ALL_FROZEN);
|
||||||
@ -9735,13 +9735,13 @@ heap_xlog_lock_updated(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
if (xlrec->flags & XLH_LOCK_ALL_FROZEN_CLEARED)
|
if (xlrec->flags & XLH_LOCK_ALL_FROZEN_CLEARED)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
Buffer vmbuffer = InvalidBuffer;
|
Buffer vmbuffer = InvalidBuffer;
|
||||||
BlockNumber block;
|
BlockNumber block;
|
||||||
Relation reln;
|
Relation reln;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, &block);
|
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &block);
|
||||||
reln = CreateFakeRelcacheEntry(rnode);
|
reln = CreateFakeRelcacheEntry(rlocator);
|
||||||
|
|
||||||
visibilitymap_pin(reln, block, &vmbuffer);
|
visibilitymap_pin(reln, block, &vmbuffer);
|
||||||
visibilitymap_clear(reln, block, vmbuffer, VISIBILITYMAP_ALL_FROZEN);
|
visibilitymap_clear(reln, block, vmbuffer, VISIBILITYMAP_ALL_FROZEN);
|
||||||
|
@ -566,8 +566,8 @@ tuple_lock_retry:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
heapam_relation_set_new_filenode(Relation rel,
|
heapam_relation_set_new_filelocator(Relation rel,
|
||||||
const RelFileNode *newrnode,
|
const RelFileLocator *newrlocator,
|
||||||
char persistence,
|
char persistence,
|
||||||
TransactionId *freezeXid,
|
TransactionId *freezeXid,
|
||||||
MultiXactId *minmulti)
|
MultiXactId *minmulti)
|
||||||
@ -591,7 +591,7 @@ heapam_relation_set_new_filenode(Relation rel,
|
|||||||
*/
|
*/
|
||||||
*minmulti = GetOldestMultiXactId();
|
*minmulti = GetOldestMultiXactId();
|
||||||
|
|
||||||
srel = RelationCreateStorage(*newrnode, persistence, true);
|
srel = RelationCreateStorage(*newrlocator, persistence, true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If required, set up an init fork for an unlogged table so that it can
|
* If required, set up an init fork for an unlogged table so that it can
|
||||||
@ -608,7 +608,7 @@ heapam_relation_set_new_filenode(Relation rel,
|
|||||||
rel->rd_rel->relkind == RELKIND_MATVIEW ||
|
rel->rd_rel->relkind == RELKIND_MATVIEW ||
|
||||||
rel->rd_rel->relkind == RELKIND_TOASTVALUE);
|
rel->rd_rel->relkind == RELKIND_TOASTVALUE);
|
||||||
smgrcreate(srel, INIT_FORKNUM, false);
|
smgrcreate(srel, INIT_FORKNUM, false);
|
||||||
log_smgrcreate(newrnode, INIT_FORKNUM);
|
log_smgrcreate(newrlocator, INIT_FORKNUM);
|
||||||
smgrimmedsync(srel, INIT_FORKNUM);
|
smgrimmedsync(srel, INIT_FORKNUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,11 +622,11 @@ heapam_relation_nontransactional_truncate(Relation rel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
|
heapam_relation_copy_data(Relation rel, const RelFileLocator *newrlocator)
|
||||||
{
|
{
|
||||||
SMgrRelation dstrel;
|
SMgrRelation dstrel;
|
||||||
|
|
||||||
dstrel = smgropen(*newrnode, rel->rd_backend);
|
dstrel = smgropen(*newrlocator, rel->rd_backend);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since we copy the file directly without looking at the shared buffers,
|
* Since we copy the file directly without looking at the shared buffers,
|
||||||
@ -640,10 +640,10 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
|
|||||||
* Create and copy all forks of the relation, and schedule unlinking of
|
* Create and copy all forks of the relation, and schedule unlinking of
|
||||||
* old physical files.
|
* old physical files.
|
||||||
*
|
*
|
||||||
* NOTE: any conflict in relfilenode value will be caught in
|
* NOTE: any conflict in relfilenumber value will be caught in
|
||||||
* RelationCreateStorage().
|
* RelationCreateStorage().
|
||||||
*/
|
*/
|
||||||
RelationCreateStorage(*newrnode, rel->rd_rel->relpersistence, true);
|
RelationCreateStorage(*newrlocator, rel->rd_rel->relpersistence, true);
|
||||||
|
|
||||||
/* copy main fork */
|
/* copy main fork */
|
||||||
RelationCopyStorage(RelationGetSmgr(rel), dstrel, MAIN_FORKNUM,
|
RelationCopyStorage(RelationGetSmgr(rel), dstrel, MAIN_FORKNUM,
|
||||||
@ -664,7 +664,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
|
|||||||
if (RelationIsPermanent(rel) ||
|
if (RelationIsPermanent(rel) ||
|
||||||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
|
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
|
||||||
forkNum == INIT_FORKNUM))
|
forkNum == INIT_FORKNUM))
|
||||||
log_smgrcreate(newrnode, forkNum);
|
log_smgrcreate(newrlocator, forkNum);
|
||||||
RelationCopyStorage(RelationGetSmgr(rel), dstrel, forkNum,
|
RelationCopyStorage(RelationGetSmgr(rel), dstrel, forkNum,
|
||||||
rel->rd_rel->relpersistence);
|
rel->rd_rel->relpersistence);
|
||||||
}
|
}
|
||||||
@ -2569,7 +2569,7 @@ static const TableAmRoutine heapam_methods = {
|
|||||||
.tuple_satisfies_snapshot = heapam_tuple_satisfies_snapshot,
|
.tuple_satisfies_snapshot = heapam_tuple_satisfies_snapshot,
|
||||||
.index_delete_tuples = heap_index_delete_tuples,
|
.index_delete_tuples = heap_index_delete_tuples,
|
||||||
|
|
||||||
.relation_set_new_filenode = heapam_relation_set_new_filenode,
|
.relation_set_new_filelocator = heapam_relation_set_new_filelocator,
|
||||||
.relation_nontransactional_truncate = heapam_relation_nontransactional_truncate,
|
.relation_nontransactional_truncate = heapam_relation_nontransactional_truncate,
|
||||||
.relation_copy_data = heapam_relation_copy_data,
|
.relation_copy_data = heapam_relation_copy_data,
|
||||||
.relation_copy_for_cluster = heapam_relation_copy_for_cluster,
|
.relation_copy_for_cluster = heapam_relation_copy_for_cluster,
|
||||||
|
@ -318,7 +318,7 @@ end_heap_rewrite(RewriteState state)
|
|||||||
if (state->rs_buffer_valid)
|
if (state->rs_buffer_valid)
|
||||||
{
|
{
|
||||||
if (RelationNeedsWAL(state->rs_new_rel))
|
if (RelationNeedsWAL(state->rs_new_rel))
|
||||||
log_newpage(&state->rs_new_rel->rd_node,
|
log_newpage(&state->rs_new_rel->rd_locator,
|
||||||
MAIN_FORKNUM,
|
MAIN_FORKNUM,
|
||||||
state->rs_blockno,
|
state->rs_blockno,
|
||||||
state->rs_buffer,
|
state->rs_buffer,
|
||||||
@ -679,7 +679,7 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
|
|||||||
|
|
||||||
/* XLOG stuff */
|
/* XLOG stuff */
|
||||||
if (RelationNeedsWAL(state->rs_new_rel))
|
if (RelationNeedsWAL(state->rs_new_rel))
|
||||||
log_newpage(&state->rs_new_rel->rd_node,
|
log_newpage(&state->rs_new_rel->rd_locator,
|
||||||
MAIN_FORKNUM,
|
MAIN_FORKNUM,
|
||||||
state->rs_blockno,
|
state->rs_blockno,
|
||||||
page,
|
page,
|
||||||
@ -742,7 +742,7 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
|
|||||||
* When doing logical decoding - which relies on using cmin/cmax of catalog
|
* When doing logical decoding - which relies on using cmin/cmax of catalog
|
||||||
* tuples, via xl_heap_new_cid records - heap rewrites have to log enough
|
* tuples, via xl_heap_new_cid records - heap rewrites have to log enough
|
||||||
* information to allow the decoding backend to update its internal mapping
|
* information to allow the decoding backend to update its internal mapping
|
||||||
* of (relfilenode,ctid) => (cmin, cmax) to be correct for the rewritten heap.
|
* of (relfilelocator,ctid) => (cmin, cmax) to be correct for the rewritten heap.
|
||||||
*
|
*
|
||||||
* For that, every time we find a tuple that's been modified in a catalog
|
* For that, every time we find a tuple that's been modified in a catalog
|
||||||
* relation within the xmin horizon of any decoding slot, we log a mapping
|
* relation within the xmin horizon of any decoding slot, we log a mapping
|
||||||
@ -1080,9 +1080,9 @@ logical_rewrite_heap_tuple(RewriteState state, ItemPointerData old_tid,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* fill out mapping information */
|
/* fill out mapping information */
|
||||||
map.old_node = state->rs_old_rel->rd_node;
|
map.old_locator = state->rs_old_rel->rd_locator;
|
||||||
map.old_tid = old_tid;
|
map.old_tid = old_tid;
|
||||||
map.new_node = state->rs_new_rel->rd_node;
|
map.new_locator = state->rs_new_rel->rd_locator;
|
||||||
map.new_tid = new_tid;
|
map.new_tid = new_tid;
|
||||||
|
|
||||||
/* ---
|
/* ---
|
||||||
|
@ -283,7 +283,7 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
|
|||||||
if (XLogRecPtrIsInvalid(recptr))
|
if (XLogRecPtrIsInvalid(recptr))
|
||||||
{
|
{
|
||||||
Assert(!InRecovery);
|
Assert(!InRecovery);
|
||||||
recptr = log_heap_visible(rel->rd_node, heapBuf, vmBuf,
|
recptr = log_heap_visible(rel->rd_locator, heapBuf, vmBuf,
|
||||||
cutoff_xid, flags);
|
cutoff_xid, flags);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -668,7 +668,7 @@ vm_extend(Relation rel, BlockNumber vm_nblocks)
|
|||||||
* to keep checking for creation or extension of the file, which happens
|
* to keep checking for creation or extension of the file, which happens
|
||||||
* infrequently.
|
* infrequently.
|
||||||
*/
|
*/
|
||||||
CacheInvalidateSmgr(reln->smgr_rnode);
|
CacheInvalidateSmgr(reln->smgr_rlocator);
|
||||||
|
|
||||||
UnlockRelationForExtension(rel, ExclusiveLock);
|
UnlockRelationForExtension(rel, ExclusiveLock);
|
||||||
}
|
}
|
||||||
|
@ -836,7 +836,7 @@ _bt_log_reuse_page(Relation rel, BlockNumber blkno, FullTransactionId safexid)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* XLOG stuff */
|
/* XLOG stuff */
|
||||||
xlrec_reuse.node = rel->rd_node;
|
xlrec_reuse.locator = rel->rd_locator;
|
||||||
xlrec_reuse.block = blkno;
|
xlrec_reuse.block = blkno;
|
||||||
xlrec_reuse.latestRemovedFullXid = safexid;
|
xlrec_reuse.latestRemovedFullXid = safexid;
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ btbuildempty(Relation index)
|
|||||||
PageSetChecksumInplace(metapage, BTREE_METAPAGE);
|
PageSetChecksumInplace(metapage, BTREE_METAPAGE);
|
||||||
smgrwrite(RelationGetSmgr(index), INIT_FORKNUM, BTREE_METAPAGE,
|
smgrwrite(RelationGetSmgr(index), INIT_FORKNUM, BTREE_METAPAGE,
|
||||||
(char *) metapage, true);
|
(char *) metapage, true);
|
||||||
log_newpage(&RelationGetSmgr(index)->smgr_rnode.node, INIT_FORKNUM,
|
log_newpage(&RelationGetSmgr(index)->smgr_rlocator.locator, INIT_FORKNUM,
|
||||||
BTREE_METAPAGE, metapage, true);
|
BTREE_METAPAGE, metapage, true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -647,7 +647,7 @@ _bt_blwritepage(BTWriteState *wstate, Page page, BlockNumber blkno)
|
|||||||
if (wstate->btws_use_wal)
|
if (wstate->btws_use_wal)
|
||||||
{
|
{
|
||||||
/* We use the XLOG_FPI record type for this */
|
/* We use the XLOG_FPI record type for this */
|
||||||
log_newpage(&wstate->index->rd_node, MAIN_FORKNUM, blkno, page, true);
|
log_newpage(&wstate->index->rd_locator, MAIN_FORKNUM, blkno, page, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -664,11 +664,11 @@ btree_xlog_delete(XLogReaderState *record)
|
|||||||
*/
|
*/
|
||||||
if (InHotStandby)
|
if (InHotStandby)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &rnode, NULL, NULL);
|
XLogRecGetBlockTag(record, 0, &rlocator, NULL, NULL);
|
||||||
|
|
||||||
ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid, rnode);
|
ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid, rlocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1006,7 +1006,7 @@ btree_xlog_reuse_page(XLogReaderState *record)
|
|||||||
|
|
||||||
if (InHotStandby)
|
if (InHotStandby)
|
||||||
ResolveRecoveryConflictWithSnapshotFullXid(xlrec->latestRemovedFullXid,
|
ResolveRecoveryConflictWithSnapshotFullXid(xlrec->latestRemovedFullXid,
|
||||||
xlrec->node);
|
xlrec->locator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "access/generic_xlog.h"
|
#include "access/generic_xlog.h"
|
||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
#include "storage/relfilenode.h"
|
#include "storage/relfilelocator.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description of generic xlog record: write page regions that this record
|
* Description of generic xlog record: write page regions that this record
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include "access/ginxlog.h"
|
#include "access/ginxlog.h"
|
||||||
#include "access/xlogutils.h"
|
#include "access/xlogutils.h"
|
||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
#include "storage/relfilenode.h"
|
#include "storage/relfilelocator.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
desc_recompress_leaf(StringInfo buf, ginxlogRecompressDataLeaf *insertData)
|
desc_recompress_leaf(StringInfo buf, ginxlogRecompressDataLeaf *insertData)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include "access/gistxlog.h"
|
#include "access/gistxlog.h"
|
||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
#include "storage/relfilenode.h"
|
#include "storage/relfilelocator.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
|
out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
|
||||||
@ -27,8 +27,8 @@ static void
|
|||||||
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
|
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
|
||||||
{
|
{
|
||||||
appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%u",
|
appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%u",
|
||||||
xlrec->node.spcNode, xlrec->node.dbNode,
|
xlrec->locator.spcOid, xlrec->locator.dbOid,
|
||||||
xlrec->node.relNode, xlrec->block,
|
xlrec->locator.relNumber, xlrec->block,
|
||||||
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
|
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
|
||||||
XidFromFullTransactionId(xlrec->latestRemovedFullXid));
|
XidFromFullTransactionId(xlrec->latestRemovedFullXid));
|
||||||
}
|
}
|
||||||
|
@ -170,9 +170,9 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
|
|||||||
xl_heap_new_cid *xlrec = (xl_heap_new_cid *) rec;
|
xl_heap_new_cid *xlrec = (xl_heap_new_cid *) rec;
|
||||||
|
|
||||||
appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
|
appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
|
||||||
xlrec->target_node.spcNode,
|
xlrec->target_locator.spcOid,
|
||||||
xlrec->target_node.dbNode,
|
xlrec->target_locator.dbOid,
|
||||||
xlrec->target_node.relNode,
|
xlrec->target_locator.relNumber,
|
||||||
ItemPointerGetBlockNumber(&(xlrec->target_tid)),
|
ItemPointerGetBlockNumber(&(xlrec->target_tid)),
|
||||||
ItemPointerGetOffsetNumber(&(xlrec->target_tid)));
|
ItemPointerGetOffsetNumber(&(xlrec->target_tid)));
|
||||||
appendStringInfo(buf, "; cmin: %u, cmax: %u, combo: %u",
|
appendStringInfo(buf, "; cmin: %u, cmax: %u, combo: %u",
|
||||||
|
@ -101,8 +101,8 @@ btree_desc(StringInfo buf, XLogReaderState *record)
|
|||||||
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
|
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
|
||||||
|
|
||||||
appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%u",
|
appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%u",
|
||||||
xlrec->node.spcNode, xlrec->node.dbNode,
|
xlrec->locator.spcOid, xlrec->locator.dbOid,
|
||||||
xlrec->node.relNode,
|
xlrec->locator.relNumber,
|
||||||
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
|
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
|
||||||
XidFromFullTransactionId(xlrec->latestRemovedFullXid));
|
XidFromFullTransactionId(xlrec->latestRemovedFullXid));
|
||||||
break;
|
break;
|
||||||
|
@ -26,8 +26,8 @@ seq_desc(StringInfo buf, XLogReaderState *record)
|
|||||||
|
|
||||||
if (info == XLOG_SEQ_LOG)
|
if (info == XLOG_SEQ_LOG)
|
||||||
appendStringInfo(buf, "rel %u/%u/%u",
|
appendStringInfo(buf, "rel %u/%u/%u",
|
||||||
xlrec->node.spcNode, xlrec->node.dbNode,
|
xlrec->locator.spcOid, xlrec->locator.dbOid,
|
||||||
xlrec->node.relNode);
|
xlrec->locator.relNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
@ -26,7 +26,7 @@ smgr_desc(StringInfo buf, XLogReaderState *record)
|
|||||||
if (info == XLOG_SMGR_CREATE)
|
if (info == XLOG_SMGR_CREATE)
|
||||||
{
|
{
|
||||||
xl_smgr_create *xlrec = (xl_smgr_create *) rec;
|
xl_smgr_create *xlrec = (xl_smgr_create *) rec;
|
||||||
char *path = relpathperm(xlrec->rnode, xlrec->forkNum);
|
char *path = relpathperm(xlrec->rlocator, xlrec->forkNum);
|
||||||
|
|
||||||
appendStringInfoString(buf, path);
|
appendStringInfoString(buf, path);
|
||||||
pfree(path);
|
pfree(path);
|
||||||
@ -34,7 +34,7 @@ smgr_desc(StringInfo buf, XLogReaderState *record)
|
|||||||
else if (info == XLOG_SMGR_TRUNCATE)
|
else if (info == XLOG_SMGR_TRUNCATE)
|
||||||
{
|
{
|
||||||
xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec;
|
xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec;
|
||||||
char *path = relpathperm(xlrec->rnode, MAIN_FORKNUM);
|
char *path = relpathperm(xlrec->rlocator, MAIN_FORKNUM);
|
||||||
|
|
||||||
appendStringInfo(buf, "%s to %u blocks flags %d", path,
|
appendStringInfo(buf, "%s to %u blocks flags %d", path,
|
||||||
xlrec->blkno, xlrec->flags);
|
xlrec->blkno, xlrec->flags);
|
||||||
|
@ -73,15 +73,15 @@ ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *pars
|
|||||||
data += parsed->nsubxacts * sizeof(TransactionId);
|
data += parsed->nsubxacts * sizeof(TransactionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsed->xinfo & XACT_XINFO_HAS_RELFILENODES)
|
if (parsed->xinfo & XACT_XINFO_HAS_RELFILELOCATORS)
|
||||||
{
|
{
|
||||||
xl_xact_relfilenodes *xl_relfilenodes = (xl_xact_relfilenodes *) data;
|
xl_xact_relfilelocators *xl_rellocators = (xl_xact_relfilelocators *) data;
|
||||||
|
|
||||||
parsed->nrels = xl_relfilenodes->nrels;
|
parsed->nrels = xl_rellocators->nrels;
|
||||||
parsed->xnodes = xl_relfilenodes->xnodes;
|
parsed->xlocators = xl_rellocators->xlocators;
|
||||||
|
|
||||||
data += MinSizeOfXactRelfilenodes;
|
data += MinSizeOfXactRelfileLocators;
|
||||||
data += xl_relfilenodes->nrels * sizeof(RelFileNode);
|
data += xl_rellocators->nrels * sizeof(RelFileLocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsed->xinfo & XACT_XINFO_HAS_DROPPED_STATS)
|
if (parsed->xinfo & XACT_XINFO_HAS_DROPPED_STATS)
|
||||||
@ -179,15 +179,15 @@ ParseAbortRecord(uint8 info, xl_xact_abort *xlrec, xl_xact_parsed_abort *parsed)
|
|||||||
data += parsed->nsubxacts * sizeof(TransactionId);
|
data += parsed->nsubxacts * sizeof(TransactionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsed->xinfo & XACT_XINFO_HAS_RELFILENODES)
|
if (parsed->xinfo & XACT_XINFO_HAS_RELFILELOCATORS)
|
||||||
{
|
{
|
||||||
xl_xact_relfilenodes *xl_relfilenodes = (xl_xact_relfilenodes *) data;
|
xl_xact_relfilelocators *xl_rellocator = (xl_xact_relfilelocators *) data;
|
||||||
|
|
||||||
parsed->nrels = xl_relfilenodes->nrels;
|
parsed->nrels = xl_rellocator->nrels;
|
||||||
parsed->xnodes = xl_relfilenodes->xnodes;
|
parsed->xlocators = xl_rellocator->xlocators;
|
||||||
|
|
||||||
data += MinSizeOfXactRelfilenodes;
|
data += MinSizeOfXactRelfileLocators;
|
||||||
data += xl_relfilenodes->nrels * sizeof(RelFileNode);
|
data += xl_rellocator->nrels * sizeof(RelFileLocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsed->xinfo & XACT_XINFO_HAS_DROPPED_STATS)
|
if (parsed->xinfo & XACT_XINFO_HAS_DROPPED_STATS)
|
||||||
@ -260,11 +260,11 @@ ParsePrepareRecord(uint8 info, xl_xact_prepare *xlrec, xl_xact_parsed_prepare *p
|
|||||||
parsed->subxacts = (TransactionId *) bufptr;
|
parsed->subxacts = (TransactionId *) bufptr;
|
||||||
bufptr += MAXALIGN(xlrec->nsubxacts * sizeof(TransactionId));
|
bufptr += MAXALIGN(xlrec->nsubxacts * sizeof(TransactionId));
|
||||||
|
|
||||||
parsed->xnodes = (RelFileNode *) bufptr;
|
parsed->xlocators = (RelFileLocator *) bufptr;
|
||||||
bufptr += MAXALIGN(xlrec->ncommitrels * sizeof(RelFileNode));
|
bufptr += MAXALIGN(xlrec->ncommitrels * sizeof(RelFileLocator));
|
||||||
|
|
||||||
parsed->abortnodes = (RelFileNode *) bufptr;
|
parsed->abortlocators = (RelFileLocator *) bufptr;
|
||||||
bufptr += MAXALIGN(xlrec->nabortrels * sizeof(RelFileNode));
|
bufptr += MAXALIGN(xlrec->nabortrels * sizeof(RelFileLocator));
|
||||||
|
|
||||||
parsed->stats = (xl_xact_stats_item *) bufptr;
|
parsed->stats = (xl_xact_stats_item *) bufptr;
|
||||||
bufptr += MAXALIGN(xlrec->ncommitstats * sizeof(xl_xact_stats_item));
|
bufptr += MAXALIGN(xlrec->ncommitstats * sizeof(xl_xact_stats_item));
|
||||||
@ -278,7 +278,7 @@ ParsePrepareRecord(uint8 info, xl_xact_prepare *xlrec, xl_xact_parsed_prepare *p
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
xact_desc_relations(StringInfo buf, char *label, int nrels,
|
xact_desc_relations(StringInfo buf, char *label, int nrels,
|
||||||
RelFileNode *xnodes)
|
RelFileLocator *xlocators)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ xact_desc_relations(StringInfo buf, char *label, int nrels,
|
|||||||
appendStringInfo(buf, "; %s:", label);
|
appendStringInfo(buf, "; %s:", label);
|
||||||
for (i = 0; i < nrels; i++)
|
for (i = 0; i < nrels; i++)
|
||||||
{
|
{
|
||||||
char *path = relpathperm(xnodes[i], MAIN_FORKNUM);
|
char *path = relpathperm(xlocators[i], MAIN_FORKNUM);
|
||||||
|
|
||||||
appendStringInfo(buf, " %s", path);
|
appendStringInfo(buf, " %s", path);
|
||||||
pfree(path);
|
pfree(path);
|
||||||
@ -340,7 +340,7 @@ xact_desc_commit(StringInfo buf, uint8 info, xl_xact_commit *xlrec, RepOriginId
|
|||||||
|
|
||||||
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
|
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
|
||||||
|
|
||||||
xact_desc_relations(buf, "rels", parsed.nrels, parsed.xnodes);
|
xact_desc_relations(buf, "rels", parsed.nrels, parsed.xlocators);
|
||||||
xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
|
xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
|
||||||
xact_desc_stats(buf, "", parsed.nstats, parsed.stats);
|
xact_desc_stats(buf, "", parsed.nstats, parsed.stats);
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ xact_desc_abort(StringInfo buf, uint8 info, xl_xact_abort *xlrec, RepOriginId or
|
|||||||
|
|
||||||
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
|
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
|
||||||
|
|
||||||
xact_desc_relations(buf, "rels", parsed.nrels, parsed.xnodes);
|
xact_desc_relations(buf, "rels", parsed.nrels, parsed.xlocators);
|
||||||
xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
|
xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
|
||||||
|
|
||||||
if (parsed.xinfo & XACT_XINFO_HAS_ORIGIN)
|
if (parsed.xinfo & XACT_XINFO_HAS_ORIGIN)
|
||||||
@ -400,9 +400,9 @@ xact_desc_prepare(StringInfo buf, uint8 info, xl_xact_prepare *xlrec, RepOriginI
|
|||||||
appendStringInfo(buf, "gid %s: ", parsed.twophase_gid);
|
appendStringInfo(buf, "gid %s: ", parsed.twophase_gid);
|
||||||
appendStringInfoString(buf, timestamptz_to_str(parsed.xact_time));
|
appendStringInfoString(buf, timestamptz_to_str(parsed.xact_time));
|
||||||
|
|
||||||
xact_desc_relations(buf, "rels(commit)", parsed.nrels, parsed.xnodes);
|
xact_desc_relations(buf, "rels(commit)", parsed.nrels, parsed.xlocators);
|
||||||
xact_desc_relations(buf, "rels(abort)", parsed.nabortrels,
|
xact_desc_relations(buf, "rels(abort)", parsed.nabortrels,
|
||||||
parsed.abortnodes);
|
parsed.abortlocators);
|
||||||
xact_desc_stats(buf, "commit ", parsed.nstats, parsed.stats);
|
xact_desc_stats(buf, "commit ", parsed.nstats, parsed.stats);
|
||||||
xact_desc_stats(buf, "abort ", parsed.nabortstats, parsed.abortstats);
|
xact_desc_stats(buf, "abort ", parsed.nabortstats, parsed.abortstats);
|
||||||
xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
|
xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
|
||||||
|
@ -219,12 +219,12 @@ XLogRecGetBlockRefInfo(XLogReaderState *record, bool pretty,
|
|||||||
|
|
||||||
for (block_id = 0; block_id <= XLogRecMaxBlockId(record); block_id++)
|
for (block_id = 0; block_id <= XLogRecMaxBlockId(record); block_id++)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
BlockNumber blk;
|
BlockNumber blk;
|
||||||
|
|
||||||
if (!XLogRecGetBlockTagExtended(record, block_id,
|
if (!XLogRecGetBlockTagExtended(record, block_id,
|
||||||
&rnode, &forknum, &blk, NULL))
|
&rlocator, &forknum, &blk, NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (detailed_format)
|
if (detailed_format)
|
||||||
@ -239,7 +239,7 @@ XLogRecGetBlockRefInfo(XLogReaderState *record, bool pretty,
|
|||||||
appendStringInfo(buf,
|
appendStringInfo(buf,
|
||||||
"blkref #%d: rel %u/%u/%u fork %s blk %u",
|
"blkref #%d: rel %u/%u/%u fork %s blk %u",
|
||||||
block_id,
|
block_id,
|
||||||
rnode.spcNode, rnode.dbNode, rnode.relNode,
|
rlocator.spcOid, rlocator.dbOid, rlocator.relNumber,
|
||||||
forkNames[forknum],
|
forkNames[forknum],
|
||||||
blk);
|
blk);
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ XLogRecGetBlockRefInfo(XLogReaderState *record, bool pretty,
|
|||||||
appendStringInfo(buf,
|
appendStringInfo(buf,
|
||||||
", blkref #%d: rel %u/%u/%u fork %s blk %u",
|
", blkref #%d: rel %u/%u/%u fork %s blk %u",
|
||||||
block_id,
|
block_id,
|
||||||
rnode.spcNode, rnode.dbNode, rnode.relNode,
|
rlocator.spcOid, rlocator.dbOid, rlocator.relNumber,
|
||||||
forkNames[forknum],
|
forkNames[forknum],
|
||||||
blk);
|
blk);
|
||||||
}
|
}
|
||||||
@ -308,7 +308,7 @@ XLogRecGetBlockRefInfo(XLogReaderState *record, bool pretty,
|
|||||||
appendStringInfo(buf,
|
appendStringInfo(buf,
|
||||||
", blkref #%d: rel %u/%u/%u blk %u",
|
", blkref #%d: rel %u/%u/%u blk %u",
|
||||||
block_id,
|
block_id,
|
||||||
rnode.spcNode, rnode.dbNode, rnode.relNode,
|
rlocator.spcOid, rlocator.dbOid, rlocator.relNumber,
|
||||||
blk);
|
blk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ spgbuildempty(Relation index)
|
|||||||
PageSetChecksumInplace(page, SPGIST_METAPAGE_BLKNO);
|
PageSetChecksumInplace(page, SPGIST_METAPAGE_BLKNO);
|
||||||
smgrwrite(RelationGetSmgr(index), INIT_FORKNUM, SPGIST_METAPAGE_BLKNO,
|
smgrwrite(RelationGetSmgr(index), INIT_FORKNUM, SPGIST_METAPAGE_BLKNO,
|
||||||
(char *) page, true);
|
(char *) page, true);
|
||||||
log_newpage(&(RelationGetSmgr(index))->smgr_rnode.node, INIT_FORKNUM,
|
log_newpage(&(RelationGetSmgr(index))->smgr_rlocator.locator, INIT_FORKNUM,
|
||||||
SPGIST_METAPAGE_BLKNO, page, true);
|
SPGIST_METAPAGE_BLKNO, page, true);
|
||||||
|
|
||||||
/* Likewise for the root page. */
|
/* Likewise for the root page. */
|
||||||
@ -180,7 +180,7 @@ spgbuildempty(Relation index)
|
|||||||
PageSetChecksumInplace(page, SPGIST_ROOT_BLKNO);
|
PageSetChecksumInplace(page, SPGIST_ROOT_BLKNO);
|
||||||
smgrwrite(RelationGetSmgr(index), INIT_FORKNUM, SPGIST_ROOT_BLKNO,
|
smgrwrite(RelationGetSmgr(index), INIT_FORKNUM, SPGIST_ROOT_BLKNO,
|
||||||
(char *) page, true);
|
(char *) page, true);
|
||||||
log_newpage(&(RelationGetSmgr(index))->smgr_rnode.node, INIT_FORKNUM,
|
log_newpage(&(RelationGetSmgr(index))->smgr_rlocator.locator, INIT_FORKNUM,
|
||||||
SPGIST_ROOT_BLKNO, page, true);
|
SPGIST_ROOT_BLKNO, page, true);
|
||||||
|
|
||||||
/* Likewise for the null-tuples root page. */
|
/* Likewise for the null-tuples root page. */
|
||||||
@ -189,7 +189,7 @@ spgbuildempty(Relation index)
|
|||||||
PageSetChecksumInplace(page, SPGIST_NULL_BLKNO);
|
PageSetChecksumInplace(page, SPGIST_NULL_BLKNO);
|
||||||
smgrwrite(RelationGetSmgr(index), INIT_FORKNUM, SPGIST_NULL_BLKNO,
|
smgrwrite(RelationGetSmgr(index), INIT_FORKNUM, SPGIST_NULL_BLKNO,
|
||||||
(char *) page, true);
|
(char *) page, true);
|
||||||
log_newpage(&(RelationGetSmgr(index))->smgr_rnode.node, INIT_FORKNUM,
|
log_newpage(&(RelationGetSmgr(index))->smgr_rlocator.locator, INIT_FORKNUM,
|
||||||
SPGIST_NULL_BLKNO, page, true);
|
SPGIST_NULL_BLKNO, page, true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -877,11 +877,11 @@ spgRedoVacuumRedirect(XLogReaderState *record)
|
|||||||
{
|
{
|
||||||
if (TransactionIdIsValid(xldata->newestRedirectXid))
|
if (TransactionIdIsValid(xldata->newestRedirectXid))
|
||||||
{
|
{
|
||||||
RelFileNode node;
|
RelFileLocator locator;
|
||||||
|
|
||||||
XLogRecGetBlockTag(record, 0, &node, NULL, NULL);
|
XLogRecGetBlockTag(record, 0, &locator, NULL, NULL);
|
||||||
ResolveRecoveryConflictWithSnapshot(xldata->newestRedirectXid,
|
ResolveRecoveryConflictWithSnapshot(xldata->newestRedirectXid,
|
||||||
node);
|
locator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ GetTableAmRoutine(Oid amhandler)
|
|||||||
Assert(routine->tuple_update != NULL);
|
Assert(routine->tuple_update != NULL);
|
||||||
Assert(routine->tuple_lock != NULL);
|
Assert(routine->tuple_lock != NULL);
|
||||||
|
|
||||||
Assert(routine->relation_set_new_filenode != NULL);
|
Assert(routine->relation_set_new_filelocator != NULL);
|
||||||
Assert(routine->relation_nontransactional_truncate != NULL);
|
Assert(routine->relation_nontransactional_truncate != NULL);
|
||||||
Assert(routine->relation_copy_data != NULL);
|
Assert(routine->relation_copy_data != NULL);
|
||||||
Assert(routine->relation_copy_for_cluster != NULL);
|
Assert(routine->relation_copy_for_cluster != NULL);
|
||||||
|
@ -557,7 +557,7 @@ void XLogRegisterBuffer(uint8 block_id, Buffer buf, uint8 flags);
|
|||||||
XLogRegisterBuffer adds information about a data block to the WAL record.
|
XLogRegisterBuffer adds information about a data block to the WAL record.
|
||||||
block_id is an arbitrary number used to identify this page reference in
|
block_id is an arbitrary number used to identify this page reference in
|
||||||
the redo routine. The information needed to re-find the page at redo -
|
the redo routine. The information needed to re-find the page at redo -
|
||||||
relfilenode, fork, and block number - are included in the WAL record.
|
relfilelocator, fork, and block number - are included in the WAL record.
|
||||||
|
|
||||||
XLogInsert will automatically include a full copy of the page contents, if
|
XLogInsert will automatically include a full copy of the page contents, if
|
||||||
this is the first modification of the buffer since the last checkpoint.
|
this is the first modification of the buffer since the last checkpoint.
|
||||||
@ -692,7 +692,7 @@ by having database restart search for files that don't have any committed
|
|||||||
entry in pg_class, but that currently isn't done because of the possibility
|
entry in pg_class, but that currently isn't done because of the possibility
|
||||||
of deleting data that is useful for forensic analysis of the crash.
|
of deleting data that is useful for forensic analysis of the crash.
|
||||||
Orphan files are harmless --- at worst they waste a bit of disk space ---
|
Orphan files are harmless --- at worst they waste a bit of disk space ---
|
||||||
because we check for on-disk collisions when allocating new relfilenode
|
because we check for on-disk collisions when allocating new relfilenumber
|
||||||
OIDs. So cleaning up isn't really necessary.
|
OIDs. So cleaning up isn't really necessary.
|
||||||
|
|
||||||
3. Deleting a table, which requires an unlink() that could fail.
|
3. Deleting a table, which requires an unlink() that could fail.
|
||||||
@ -725,10 +725,10 @@ then restart recovery. This is part of the reason for not writing a WAL
|
|||||||
entry until we've successfully done the original action.
|
entry until we've successfully done the original action.
|
||||||
|
|
||||||
|
|
||||||
Skipping WAL for New RelFileNode
|
Skipping WAL for New RelFileLocator
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
Under wal_level=minimal, if a change modifies a relfilenode that ROLLBACK
|
Under wal_level=minimal, if a change modifies a relfilenumber that ROLLBACK
|
||||||
would unlink, in-tree access methods write no WAL for that change. Code that
|
would unlink, in-tree access methods write no WAL for that change. Code that
|
||||||
writes WAL without calling RelationNeedsWAL() must check for this case. This
|
writes WAL without calling RelationNeedsWAL() must check for this case. This
|
||||||
skipping is mandatory. If a WAL-writing change preceded a WAL-skipping change
|
skipping is mandatory. If a WAL-writing change preceded a WAL-skipping change
|
||||||
@ -748,9 +748,9 @@ unconditionally for permanent relations. Under these approaches, the access
|
|||||||
method callbacks must not call functions that react to RelationNeedsWAL().
|
method callbacks must not call functions that react to RelationNeedsWAL().
|
||||||
|
|
||||||
This applies only to WAL records whose replay would modify bytes stored in the
|
This applies only to WAL records whose replay would modify bytes stored in the
|
||||||
new relfilenode. It does not apply to other records about the relfilenode,
|
new relfilenumber. It does not apply to other records about the relfilenumber,
|
||||||
such as XLOG_SMGR_CREATE. Because it operates at the level of individual
|
such as XLOG_SMGR_CREATE. Because it operates at the level of individual
|
||||||
relfilenodes, RelationNeedsWAL() can differ for tightly-coupled relations.
|
relfilenumbers, RelationNeedsWAL() can differ for tightly-coupled relations.
|
||||||
Consider "CREATE TABLE t (); BEGIN; ALTER TABLE t ADD c text; ..." in which
|
Consider "CREATE TABLE t (); BEGIN; ALTER TABLE t ADD c text; ..." in which
|
||||||
ALTER TABLE adds a TOAST relation. The TOAST relation will skip WAL, while
|
ALTER TABLE adds a TOAST relation. The TOAST relation will skip WAL, while
|
||||||
the table owning it will not. ALTER TABLE SET TABLESPACE will cause a table
|
the table owning it will not. ALTER TABLE SET TABLESPACE will cause a table
|
||||||
@ -860,7 +860,7 @@ Changes to a temp table are not WAL-logged, hence could reach disk in
|
|||||||
advance of T1's commit, but we don't care since temp table contents don't
|
advance of T1's commit, but we don't care since temp table contents don't
|
||||||
survive crashes anyway.
|
survive crashes anyway.
|
||||||
|
|
||||||
Database writes that skip WAL for new relfilenodes are also safe. In these
|
Database writes that skip WAL for new relfilenumbers are also safe. In these
|
||||||
cases it's entirely possible for the data to reach disk before T1's commit,
|
cases it's entirely possible for the data to reach disk before T1's commit,
|
||||||
because T1 will fsync it down to disk without any sort of interlock. However,
|
because T1 will fsync it down to disk without any sort of interlock. However,
|
||||||
all these paths are designed to write data that no other transaction can see
|
all these paths are designed to write data that no other transaction can see
|
||||||
|
@ -126,7 +126,7 @@ worker. This includes:
|
|||||||
an index that is currently being rebuilt.
|
an index that is currently being rebuilt.
|
||||||
|
|
||||||
- Active relmapper.c mapping state. This is needed to allow consistent
|
- Active relmapper.c mapping state. This is needed to allow consistent
|
||||||
answers when fetching the current relfilenode for relation oids of
|
answers when fetching the current relfilenumber for relation oids of
|
||||||
mapped relations.
|
mapped relations.
|
||||||
|
|
||||||
To prevent unprincipled deadlocks when running in parallel mode, this code
|
To prevent unprincipled deadlocks when running in parallel mode, this code
|
||||||
|
@ -204,7 +204,7 @@ static void RecordTransactionCommitPrepared(TransactionId xid,
|
|||||||
int nchildren,
|
int nchildren,
|
||||||
TransactionId *children,
|
TransactionId *children,
|
||||||
int nrels,
|
int nrels,
|
||||||
RelFileNode *rels,
|
RelFileLocator *rels,
|
||||||
int nstats,
|
int nstats,
|
||||||
xl_xact_stats_item *stats,
|
xl_xact_stats_item *stats,
|
||||||
int ninvalmsgs,
|
int ninvalmsgs,
|
||||||
@ -215,7 +215,7 @@ static void RecordTransactionAbortPrepared(TransactionId xid,
|
|||||||
int nchildren,
|
int nchildren,
|
||||||
TransactionId *children,
|
TransactionId *children,
|
||||||
int nrels,
|
int nrels,
|
||||||
RelFileNode *rels,
|
RelFileLocator *rels,
|
||||||
int nstats,
|
int nstats,
|
||||||
xl_xact_stats_item *stats,
|
xl_xact_stats_item *stats,
|
||||||
const char *gid);
|
const char *gid);
|
||||||
@ -951,8 +951,8 @@ TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
|
|||||||
*
|
*
|
||||||
* 1. TwoPhaseFileHeader
|
* 1. TwoPhaseFileHeader
|
||||||
* 2. TransactionId[] (subtransactions)
|
* 2. TransactionId[] (subtransactions)
|
||||||
* 3. RelFileNode[] (files to be deleted at commit)
|
* 3. RelFileLocator[] (files to be deleted at commit)
|
||||||
* 4. RelFileNode[] (files to be deleted at abort)
|
* 4. RelFileLocator[] (files to be deleted at abort)
|
||||||
* 5. SharedInvalidationMessage[] (inval messages to be sent at commit)
|
* 5. SharedInvalidationMessage[] (inval messages to be sent at commit)
|
||||||
* 6. TwoPhaseRecordOnDisk
|
* 6. TwoPhaseRecordOnDisk
|
||||||
* 7. ...
|
* 7. ...
|
||||||
@ -1047,8 +1047,8 @@ StartPrepare(GlobalTransaction gxact)
|
|||||||
TransactionId xid = gxact->xid;
|
TransactionId xid = gxact->xid;
|
||||||
TwoPhaseFileHeader hdr;
|
TwoPhaseFileHeader hdr;
|
||||||
TransactionId *children;
|
TransactionId *children;
|
||||||
RelFileNode *commitrels;
|
RelFileLocator *commitrels;
|
||||||
RelFileNode *abortrels;
|
RelFileLocator *abortrels;
|
||||||
xl_xact_stats_item *abortstats = NULL;
|
xl_xact_stats_item *abortstats = NULL;
|
||||||
xl_xact_stats_item *commitstats = NULL;
|
xl_xact_stats_item *commitstats = NULL;
|
||||||
SharedInvalidationMessage *invalmsgs;
|
SharedInvalidationMessage *invalmsgs;
|
||||||
@ -1102,12 +1102,12 @@ StartPrepare(GlobalTransaction gxact)
|
|||||||
}
|
}
|
||||||
if (hdr.ncommitrels > 0)
|
if (hdr.ncommitrels > 0)
|
||||||
{
|
{
|
||||||
save_state_data(commitrels, hdr.ncommitrels * sizeof(RelFileNode));
|
save_state_data(commitrels, hdr.ncommitrels * sizeof(RelFileLocator));
|
||||||
pfree(commitrels);
|
pfree(commitrels);
|
||||||
}
|
}
|
||||||
if (hdr.nabortrels > 0)
|
if (hdr.nabortrels > 0)
|
||||||
{
|
{
|
||||||
save_state_data(abortrels, hdr.nabortrels * sizeof(RelFileNode));
|
save_state_data(abortrels, hdr.nabortrels * sizeof(RelFileLocator));
|
||||||
pfree(abortrels);
|
pfree(abortrels);
|
||||||
}
|
}
|
||||||
if (hdr.ncommitstats > 0)
|
if (hdr.ncommitstats > 0)
|
||||||
@ -1489,9 +1489,9 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
|
|||||||
TwoPhaseFileHeader *hdr;
|
TwoPhaseFileHeader *hdr;
|
||||||
TransactionId latestXid;
|
TransactionId latestXid;
|
||||||
TransactionId *children;
|
TransactionId *children;
|
||||||
RelFileNode *commitrels;
|
RelFileLocator *commitrels;
|
||||||
RelFileNode *abortrels;
|
RelFileLocator *abortrels;
|
||||||
RelFileNode *delrels;
|
RelFileLocator *delrels;
|
||||||
int ndelrels;
|
int ndelrels;
|
||||||
xl_xact_stats_item *commitstats;
|
xl_xact_stats_item *commitstats;
|
||||||
xl_xact_stats_item *abortstats;
|
xl_xact_stats_item *abortstats;
|
||||||
@ -1525,10 +1525,10 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
|
|||||||
bufptr += MAXALIGN(hdr->gidlen);
|
bufptr += MAXALIGN(hdr->gidlen);
|
||||||
children = (TransactionId *) bufptr;
|
children = (TransactionId *) bufptr;
|
||||||
bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
|
bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
|
||||||
commitrels = (RelFileNode *) bufptr;
|
commitrels = (RelFileLocator *) bufptr;
|
||||||
bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileNode));
|
bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileLocator));
|
||||||
abortrels = (RelFileNode *) bufptr;
|
abortrels = (RelFileLocator *) bufptr;
|
||||||
bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileNode));
|
bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileLocator));
|
||||||
commitstats = (xl_xact_stats_item *) bufptr;
|
commitstats = (xl_xact_stats_item *) bufptr;
|
||||||
bufptr += MAXALIGN(hdr->ncommitstats * sizeof(xl_xact_stats_item));
|
bufptr += MAXALIGN(hdr->ncommitstats * sizeof(xl_xact_stats_item));
|
||||||
abortstats = (xl_xact_stats_item *) bufptr;
|
abortstats = (xl_xact_stats_item *) bufptr;
|
||||||
@ -2100,8 +2100,8 @@ RecoverPreparedTransactions(void)
|
|||||||
bufptr += MAXALIGN(hdr->gidlen);
|
bufptr += MAXALIGN(hdr->gidlen);
|
||||||
subxids = (TransactionId *) bufptr;
|
subxids = (TransactionId *) bufptr;
|
||||||
bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
|
bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
|
||||||
bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileNode));
|
bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileLocator));
|
||||||
bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileNode));
|
bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileLocator));
|
||||||
bufptr += MAXALIGN(hdr->ncommitstats * sizeof(xl_xact_stats_item));
|
bufptr += MAXALIGN(hdr->ncommitstats * sizeof(xl_xact_stats_item));
|
||||||
bufptr += MAXALIGN(hdr->nabortstats * sizeof(xl_xact_stats_item));
|
bufptr += MAXALIGN(hdr->nabortstats * sizeof(xl_xact_stats_item));
|
||||||
bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
|
bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
|
||||||
@ -2285,7 +2285,7 @@ RecordTransactionCommitPrepared(TransactionId xid,
|
|||||||
int nchildren,
|
int nchildren,
|
||||||
TransactionId *children,
|
TransactionId *children,
|
||||||
int nrels,
|
int nrels,
|
||||||
RelFileNode *rels,
|
RelFileLocator *rels,
|
||||||
int nstats,
|
int nstats,
|
||||||
xl_xact_stats_item *stats,
|
xl_xact_stats_item *stats,
|
||||||
int ninvalmsgs,
|
int ninvalmsgs,
|
||||||
@ -2383,7 +2383,7 @@ RecordTransactionAbortPrepared(TransactionId xid,
|
|||||||
int nchildren,
|
int nchildren,
|
||||||
TransactionId *children,
|
TransactionId *children,
|
||||||
int nrels,
|
int nrels,
|
||||||
RelFileNode *rels,
|
RelFileLocator *rels,
|
||||||
int nstats,
|
int nstats,
|
||||||
xl_xact_stats_item *stats,
|
xl_xact_stats_item *stats,
|
||||||
const char *gid)
|
const char *gid)
|
||||||
|
@ -521,7 +521,7 @@ ForceTransactionIdLimitUpdate(void)
|
|||||||
* wide, counter wraparound will occur eventually, and therefore it is unwise
|
* wide, counter wraparound will occur eventually, and therefore it is unwise
|
||||||
* to assume they are unique unless precautions are taken to make them so.
|
* to assume they are unique unless precautions are taken to make them so.
|
||||||
* Hence, this routine should generally not be used directly. The only direct
|
* Hence, this routine should generally not be used directly. The only direct
|
||||||
* callers should be GetNewOidWithIndex() and GetNewRelFileNode() in
|
* callers should be GetNewOidWithIndex() and GetNewRelFileNumber() in
|
||||||
* catalog/catalog.c.
|
* catalog/catalog.c.
|
||||||
*/
|
*/
|
||||||
Oid
|
Oid
|
||||||
|
@ -1282,7 +1282,7 @@ RecordTransactionCommit(void)
|
|||||||
bool markXidCommitted = TransactionIdIsValid(xid);
|
bool markXidCommitted = TransactionIdIsValid(xid);
|
||||||
TransactionId latestXid = InvalidTransactionId;
|
TransactionId latestXid = InvalidTransactionId;
|
||||||
int nrels;
|
int nrels;
|
||||||
RelFileNode *rels;
|
RelFileLocator *rels;
|
||||||
int nchildren;
|
int nchildren;
|
||||||
TransactionId *children;
|
TransactionId *children;
|
||||||
int ndroppedstats = 0;
|
int ndroppedstats = 0;
|
||||||
@ -1705,7 +1705,7 @@ RecordTransactionAbort(bool isSubXact)
|
|||||||
TransactionId xid = GetCurrentTransactionIdIfAny();
|
TransactionId xid = GetCurrentTransactionIdIfAny();
|
||||||
TransactionId latestXid;
|
TransactionId latestXid;
|
||||||
int nrels;
|
int nrels;
|
||||||
RelFileNode *rels;
|
RelFileLocator *rels;
|
||||||
int ndroppedstats = 0;
|
int ndroppedstats = 0;
|
||||||
xl_xact_stats_item *droppedstats = NULL;
|
xl_xact_stats_item *droppedstats = NULL;
|
||||||
int nchildren;
|
int nchildren;
|
||||||
@ -5586,7 +5586,7 @@ xactGetCommittedChildren(TransactionId **ptr)
|
|||||||
XLogRecPtr
|
XLogRecPtr
|
||||||
XactLogCommitRecord(TimestampTz commit_time,
|
XactLogCommitRecord(TimestampTz commit_time,
|
||||||
int nsubxacts, TransactionId *subxacts,
|
int nsubxacts, TransactionId *subxacts,
|
||||||
int nrels, RelFileNode *rels,
|
int nrels, RelFileLocator *rels,
|
||||||
int ndroppedstats, xl_xact_stats_item *droppedstats,
|
int ndroppedstats, xl_xact_stats_item *droppedstats,
|
||||||
int nmsgs, SharedInvalidationMessage *msgs,
|
int nmsgs, SharedInvalidationMessage *msgs,
|
||||||
bool relcacheInval,
|
bool relcacheInval,
|
||||||
@ -5597,7 +5597,7 @@ XactLogCommitRecord(TimestampTz commit_time,
|
|||||||
xl_xact_xinfo xl_xinfo;
|
xl_xact_xinfo xl_xinfo;
|
||||||
xl_xact_dbinfo xl_dbinfo;
|
xl_xact_dbinfo xl_dbinfo;
|
||||||
xl_xact_subxacts xl_subxacts;
|
xl_xact_subxacts xl_subxacts;
|
||||||
xl_xact_relfilenodes xl_relfilenodes;
|
xl_xact_relfilelocators xl_relfilelocators;
|
||||||
xl_xact_stats_items xl_dropped_stats;
|
xl_xact_stats_items xl_dropped_stats;
|
||||||
xl_xact_invals xl_invals;
|
xl_xact_invals xl_invals;
|
||||||
xl_xact_twophase xl_twophase;
|
xl_xact_twophase xl_twophase;
|
||||||
@ -5651,8 +5651,8 @@ XactLogCommitRecord(TimestampTz commit_time,
|
|||||||
|
|
||||||
if (nrels > 0)
|
if (nrels > 0)
|
||||||
{
|
{
|
||||||
xl_xinfo.xinfo |= XACT_XINFO_HAS_RELFILENODES;
|
xl_xinfo.xinfo |= XACT_XINFO_HAS_RELFILELOCATORS;
|
||||||
xl_relfilenodes.nrels = nrels;
|
xl_relfilelocators.nrels = nrels;
|
||||||
info |= XLR_SPECIAL_REL_UPDATE;
|
info |= XLR_SPECIAL_REL_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5710,12 +5710,12 @@ XactLogCommitRecord(TimestampTz commit_time,
|
|||||||
nsubxacts * sizeof(TransactionId));
|
nsubxacts * sizeof(TransactionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xl_xinfo.xinfo & XACT_XINFO_HAS_RELFILENODES)
|
if (xl_xinfo.xinfo & XACT_XINFO_HAS_RELFILELOCATORS)
|
||||||
{
|
{
|
||||||
XLogRegisterData((char *) (&xl_relfilenodes),
|
XLogRegisterData((char *) (&xl_relfilelocators),
|
||||||
MinSizeOfXactRelfilenodes);
|
MinSizeOfXactRelfileLocators);
|
||||||
XLogRegisterData((char *) rels,
|
XLogRegisterData((char *) rels,
|
||||||
nrels * sizeof(RelFileNode));
|
nrels * sizeof(RelFileLocator));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xl_xinfo.xinfo & XACT_XINFO_HAS_DROPPED_STATS)
|
if (xl_xinfo.xinfo & XACT_XINFO_HAS_DROPPED_STATS)
|
||||||
@ -5758,7 +5758,7 @@ XactLogCommitRecord(TimestampTz commit_time,
|
|||||||
XLogRecPtr
|
XLogRecPtr
|
||||||
XactLogAbortRecord(TimestampTz abort_time,
|
XactLogAbortRecord(TimestampTz abort_time,
|
||||||
int nsubxacts, TransactionId *subxacts,
|
int nsubxacts, TransactionId *subxacts,
|
||||||
int nrels, RelFileNode *rels,
|
int nrels, RelFileLocator *rels,
|
||||||
int ndroppedstats, xl_xact_stats_item *droppedstats,
|
int ndroppedstats, xl_xact_stats_item *droppedstats,
|
||||||
int xactflags, TransactionId twophase_xid,
|
int xactflags, TransactionId twophase_xid,
|
||||||
const char *twophase_gid)
|
const char *twophase_gid)
|
||||||
@ -5766,7 +5766,7 @@ XactLogAbortRecord(TimestampTz abort_time,
|
|||||||
xl_xact_abort xlrec;
|
xl_xact_abort xlrec;
|
||||||
xl_xact_xinfo xl_xinfo;
|
xl_xact_xinfo xl_xinfo;
|
||||||
xl_xact_subxacts xl_subxacts;
|
xl_xact_subxacts xl_subxacts;
|
||||||
xl_xact_relfilenodes xl_relfilenodes;
|
xl_xact_relfilelocators xl_relfilelocators;
|
||||||
xl_xact_stats_items xl_dropped_stats;
|
xl_xact_stats_items xl_dropped_stats;
|
||||||
xl_xact_twophase xl_twophase;
|
xl_xact_twophase xl_twophase;
|
||||||
xl_xact_dbinfo xl_dbinfo;
|
xl_xact_dbinfo xl_dbinfo;
|
||||||
@ -5800,8 +5800,8 @@ XactLogAbortRecord(TimestampTz abort_time,
|
|||||||
|
|
||||||
if (nrels > 0)
|
if (nrels > 0)
|
||||||
{
|
{
|
||||||
xl_xinfo.xinfo |= XACT_XINFO_HAS_RELFILENODES;
|
xl_xinfo.xinfo |= XACT_XINFO_HAS_RELFILELOCATORS;
|
||||||
xl_relfilenodes.nrels = nrels;
|
xl_relfilelocators.nrels = nrels;
|
||||||
info |= XLR_SPECIAL_REL_UPDATE;
|
info |= XLR_SPECIAL_REL_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5864,12 +5864,12 @@ XactLogAbortRecord(TimestampTz abort_time,
|
|||||||
nsubxacts * sizeof(TransactionId));
|
nsubxacts * sizeof(TransactionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xl_xinfo.xinfo & XACT_XINFO_HAS_RELFILENODES)
|
if (xl_xinfo.xinfo & XACT_XINFO_HAS_RELFILELOCATORS)
|
||||||
{
|
{
|
||||||
XLogRegisterData((char *) (&xl_relfilenodes),
|
XLogRegisterData((char *) (&xl_relfilelocators),
|
||||||
MinSizeOfXactRelfilenodes);
|
MinSizeOfXactRelfileLocators);
|
||||||
XLogRegisterData((char *) rels,
|
XLogRegisterData((char *) rels,
|
||||||
nrels * sizeof(RelFileNode));
|
nrels * sizeof(RelFileLocator));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xl_xinfo.xinfo & XACT_XINFO_HAS_DROPPED_STATS)
|
if (xl_xinfo.xinfo & XACT_XINFO_HAS_DROPPED_STATS)
|
||||||
@ -6010,7 +6010,7 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
|
|||||||
XLogFlush(lsn);
|
XLogFlush(lsn);
|
||||||
|
|
||||||
/* Make sure files supposed to be dropped are dropped */
|
/* Make sure files supposed to be dropped are dropped */
|
||||||
DropRelationFiles(parsed->xnodes, parsed->nrels, true);
|
DropRelationFiles(parsed->xlocators, parsed->nrels, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsed->nstats > 0)
|
if (parsed->nstats > 0)
|
||||||
@ -6121,7 +6121,7 @@ xact_redo_abort(xl_xact_parsed_abort *parsed, TransactionId xid,
|
|||||||
*/
|
*/
|
||||||
XLogFlush(lsn);
|
XLogFlush(lsn);
|
||||||
|
|
||||||
DropRelationFiles(parsed->xnodes, parsed->nrels, true);
|
DropRelationFiles(parsed->xlocators, parsed->nrels, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsed->nstats > 0)
|
if (parsed->nstats > 0)
|
||||||
|
@ -70,7 +70,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
bool in_use; /* is this slot in use? */
|
bool in_use; /* is this slot in use? */
|
||||||
uint8 flags; /* REGBUF_* flags */
|
uint8 flags; /* REGBUF_* flags */
|
||||||
RelFileNode rnode; /* identifies the relation and block */
|
RelFileLocator rlocator; /* identifies the relation and block */
|
||||||
ForkNumber forkno;
|
ForkNumber forkno;
|
||||||
BlockNumber block;
|
BlockNumber block;
|
||||||
Page page; /* page content */
|
Page page; /* page content */
|
||||||
@ -257,7 +257,7 @@ XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
|
|||||||
|
|
||||||
regbuf = ®istered_buffers[block_id];
|
regbuf = ®istered_buffers[block_id];
|
||||||
|
|
||||||
BufferGetTag(buffer, ®buf->rnode, ®buf->forkno, ®buf->block);
|
BufferGetTag(buffer, ®buf->rlocator, ®buf->forkno, ®buf->block);
|
||||||
regbuf->page = BufferGetPage(buffer);
|
regbuf->page = BufferGetPage(buffer);
|
||||||
regbuf->flags = flags;
|
regbuf->flags = flags;
|
||||||
regbuf->rdata_tail = (XLogRecData *) ®buf->rdata_head;
|
regbuf->rdata_tail = (XLogRecData *) ®buf->rdata_head;
|
||||||
@ -278,7 +278,7 @@ XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
|
|||||||
if (i == block_id || !regbuf_old->in_use)
|
if (i == block_id || !regbuf_old->in_use)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Assert(!RelFileNodeEquals(regbuf_old->rnode, regbuf->rnode) ||
|
Assert(!RelFileLocatorEquals(regbuf_old->rlocator, regbuf->rlocator) ||
|
||||||
regbuf_old->forkno != regbuf->forkno ||
|
regbuf_old->forkno != regbuf->forkno ||
|
||||||
regbuf_old->block != regbuf->block);
|
regbuf_old->block != regbuf->block);
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
|
|||||||
* shared buffer pool (i.e. when you don't have a Buffer for it).
|
* shared buffer pool (i.e. when you don't have a Buffer for it).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
XLogRegisterBlock(uint8 block_id, RelFileNode *rnode, ForkNumber forknum,
|
XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator, ForkNumber forknum,
|
||||||
BlockNumber blknum, Page page, uint8 flags)
|
BlockNumber blknum, Page page, uint8 flags)
|
||||||
{
|
{
|
||||||
registered_buffer *regbuf;
|
registered_buffer *regbuf;
|
||||||
@ -308,7 +308,7 @@ XLogRegisterBlock(uint8 block_id, RelFileNode *rnode, ForkNumber forknum,
|
|||||||
|
|
||||||
regbuf = ®istered_buffers[block_id];
|
regbuf = ®istered_buffers[block_id];
|
||||||
|
|
||||||
regbuf->rnode = *rnode;
|
regbuf->rlocator = *rlocator;
|
||||||
regbuf->forkno = forknum;
|
regbuf->forkno = forknum;
|
||||||
regbuf->block = blknum;
|
regbuf->block = blknum;
|
||||||
regbuf->page = page;
|
regbuf->page = page;
|
||||||
@ -331,7 +331,7 @@ XLogRegisterBlock(uint8 block_id, RelFileNode *rnode, ForkNumber forknum,
|
|||||||
if (i == block_id || !regbuf_old->in_use)
|
if (i == block_id || !regbuf_old->in_use)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Assert(!RelFileNodeEquals(regbuf_old->rnode, regbuf->rnode) ||
|
Assert(!RelFileLocatorEquals(regbuf_old->rlocator, regbuf->rlocator) ||
|
||||||
regbuf_old->forkno != regbuf->forkno ||
|
regbuf_old->forkno != regbuf->forkno ||
|
||||||
regbuf_old->block != regbuf->block);
|
regbuf_old->block != regbuf->block);
|
||||||
}
|
}
|
||||||
@ -768,7 +768,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
|
|||||||
rdt_datas_last = regbuf->rdata_tail;
|
rdt_datas_last = regbuf->rdata_tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev_regbuf && RelFileNodeEquals(regbuf->rnode, prev_regbuf->rnode))
|
if (prev_regbuf && RelFileLocatorEquals(regbuf->rlocator, prev_regbuf->rlocator))
|
||||||
{
|
{
|
||||||
samerel = true;
|
samerel = true;
|
||||||
bkpb.fork_flags |= BKPBLOCK_SAME_REL;
|
bkpb.fork_flags |= BKPBLOCK_SAME_REL;
|
||||||
@ -793,8 +793,8 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
|
|||||||
}
|
}
|
||||||
if (!samerel)
|
if (!samerel)
|
||||||
{
|
{
|
||||||
memcpy(scratch, ®buf->rnode, sizeof(RelFileNode));
|
memcpy(scratch, ®buf->rlocator, sizeof(RelFileLocator));
|
||||||
scratch += sizeof(RelFileNode);
|
scratch += sizeof(RelFileLocator);
|
||||||
}
|
}
|
||||||
memcpy(scratch, ®buf->block, sizeof(BlockNumber));
|
memcpy(scratch, ®buf->block, sizeof(BlockNumber));
|
||||||
scratch += sizeof(BlockNumber);
|
scratch += sizeof(BlockNumber);
|
||||||
@ -1031,7 +1031,7 @@ XLogSaveBufferForHint(Buffer buffer, bool buffer_std)
|
|||||||
int flags = 0;
|
int flags = 0;
|
||||||
PGAlignedBlock copied_buffer;
|
PGAlignedBlock copied_buffer;
|
||||||
char *origdata = (char *) BufferGetBlock(buffer);
|
char *origdata = (char *) BufferGetBlock(buffer);
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
ForkNumber forkno;
|
ForkNumber forkno;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
@ -1058,8 +1058,8 @@ XLogSaveBufferForHint(Buffer buffer, bool buffer_std)
|
|||||||
if (buffer_std)
|
if (buffer_std)
|
||||||
flags |= REGBUF_STANDARD;
|
flags |= REGBUF_STANDARD;
|
||||||
|
|
||||||
BufferGetTag(buffer, &rnode, &forkno, &blkno);
|
BufferGetTag(buffer, &rlocator, &forkno, &blkno);
|
||||||
XLogRegisterBlock(0, &rnode, forkno, blkno, copied_buffer.data, flags);
|
XLogRegisterBlock(0, &rlocator, forkno, blkno, copied_buffer.data, flags);
|
||||||
|
|
||||||
recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI_FOR_HINT);
|
recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI_FOR_HINT);
|
||||||
}
|
}
|
||||||
@ -1080,7 +1080,7 @@ XLogSaveBufferForHint(Buffer buffer, bool buffer_std)
|
|||||||
* the unused space to be left out from the WAL record, making it smaller.
|
* the unused space to be left out from the WAL record, making it smaller.
|
||||||
*/
|
*/
|
||||||
XLogRecPtr
|
XLogRecPtr
|
||||||
log_newpage(RelFileNode *rnode, ForkNumber forkNum, BlockNumber blkno,
|
log_newpage(RelFileLocator *rlocator, ForkNumber forkNum, BlockNumber blkno,
|
||||||
Page page, bool page_std)
|
Page page, bool page_std)
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
@ -1091,7 +1091,7 @@ log_newpage(RelFileNode *rnode, ForkNumber forkNum, BlockNumber blkno,
|
|||||||
flags |= REGBUF_STANDARD;
|
flags |= REGBUF_STANDARD;
|
||||||
|
|
||||||
XLogBeginInsert();
|
XLogBeginInsert();
|
||||||
XLogRegisterBlock(0, rnode, forkNum, blkno, page, flags);
|
XLogRegisterBlock(0, rlocator, forkNum, blkno, page, flags);
|
||||||
recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI);
|
recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1112,7 +1112,7 @@ log_newpage(RelFileNode *rnode, ForkNumber forkNum, BlockNumber blkno,
|
|||||||
* because we can write multiple pages in a single WAL record.
|
* because we can write multiple pages in a single WAL record.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
log_newpages(RelFileNode *rnode, ForkNumber forkNum, int num_pages,
|
log_newpages(RelFileLocator *rlocator, ForkNumber forkNum, int num_pages,
|
||||||
BlockNumber *blknos, Page *pages, bool page_std)
|
BlockNumber *blknos, Page *pages, bool page_std)
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
@ -1142,7 +1142,7 @@ log_newpages(RelFileNode *rnode, ForkNumber forkNum, int num_pages,
|
|||||||
nbatch = 0;
|
nbatch = 0;
|
||||||
while (nbatch < XLR_MAX_BLOCK_ID && i < num_pages)
|
while (nbatch < XLR_MAX_BLOCK_ID && i < num_pages)
|
||||||
{
|
{
|
||||||
XLogRegisterBlock(nbatch, rnode, forkNum, blknos[i], pages[i], flags);
|
XLogRegisterBlock(nbatch, rlocator, forkNum, blknos[i], pages[i], flags);
|
||||||
i++;
|
i++;
|
||||||
nbatch++;
|
nbatch++;
|
||||||
}
|
}
|
||||||
@ -1177,16 +1177,16 @@ XLogRecPtr
|
|||||||
log_newpage_buffer(Buffer buffer, bool page_std)
|
log_newpage_buffer(Buffer buffer, bool page_std)
|
||||||
{
|
{
|
||||||
Page page = BufferGetPage(buffer);
|
Page page = BufferGetPage(buffer);
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
ForkNumber forkNum;
|
ForkNumber forkNum;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
/* Shared buffers should be modified in a critical section. */
|
/* Shared buffers should be modified in a critical section. */
|
||||||
Assert(CritSectionCount > 0);
|
Assert(CritSectionCount > 0);
|
||||||
|
|
||||||
BufferGetTag(buffer, &rnode, &forkNum, &blkno);
|
BufferGetTag(buffer, &rlocator, &forkNum, &blkno);
|
||||||
|
|
||||||
return log_newpage(&rnode, forkNum, blkno, page, page_std);
|
return log_newpage(&rlocator, forkNum, blkno, page, page_std);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -138,7 +138,7 @@ struct XLogPrefetcher
|
|||||||
dlist_head filter_queue;
|
dlist_head filter_queue;
|
||||||
|
|
||||||
/* Book-keeping to avoid repeat prefetches. */
|
/* Book-keeping to avoid repeat prefetches. */
|
||||||
RelFileNode recent_rnode[XLOGPREFETCHER_SEQ_WINDOW_SIZE];
|
RelFileLocator recent_rlocator[XLOGPREFETCHER_SEQ_WINDOW_SIZE];
|
||||||
BlockNumber recent_block[XLOGPREFETCHER_SEQ_WINDOW_SIZE];
|
BlockNumber recent_block[XLOGPREFETCHER_SEQ_WINDOW_SIZE];
|
||||||
int recent_idx;
|
int recent_idx;
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ struct XLogPrefetcher
|
|||||||
*/
|
*/
|
||||||
typedef struct XLogPrefetcherFilter
|
typedef struct XLogPrefetcherFilter
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
XLogRecPtr filter_until_replayed;
|
XLogRecPtr filter_until_replayed;
|
||||||
BlockNumber filter_from_block;
|
BlockNumber filter_from_block;
|
||||||
dlist_node link;
|
dlist_node link;
|
||||||
@ -187,11 +187,11 @@ typedef struct XLogPrefetchStats
|
|||||||
} XLogPrefetchStats;
|
} XLogPrefetchStats;
|
||||||
|
|
||||||
static inline void XLogPrefetcherAddFilter(XLogPrefetcher *prefetcher,
|
static inline void XLogPrefetcherAddFilter(XLogPrefetcher *prefetcher,
|
||||||
RelFileNode rnode,
|
RelFileLocator rlocator,
|
||||||
BlockNumber blockno,
|
BlockNumber blockno,
|
||||||
XLogRecPtr lsn);
|
XLogRecPtr lsn);
|
||||||
static inline bool XLogPrefetcherIsFiltered(XLogPrefetcher *prefetcher,
|
static inline bool XLogPrefetcherIsFiltered(XLogPrefetcher *prefetcher,
|
||||||
RelFileNode rnode,
|
RelFileLocator rlocator,
|
||||||
BlockNumber blockno);
|
BlockNumber blockno);
|
||||||
static inline void XLogPrefetcherCompleteFilters(XLogPrefetcher *prefetcher,
|
static inline void XLogPrefetcherCompleteFilters(XLogPrefetcher *prefetcher,
|
||||||
XLogRecPtr replaying_lsn);
|
XLogRecPtr replaying_lsn);
|
||||||
@ -365,7 +365,7 @@ XLogPrefetcherAllocate(XLogReaderState *reader)
|
|||||||
{
|
{
|
||||||
XLogPrefetcher *prefetcher;
|
XLogPrefetcher *prefetcher;
|
||||||
static HASHCTL hash_table_ctl = {
|
static HASHCTL hash_table_ctl = {
|
||||||
.keysize = sizeof(RelFileNode),
|
.keysize = sizeof(RelFileLocator),
|
||||||
.entrysize = sizeof(XLogPrefetcherFilter)
|
.entrysize = sizeof(XLogPrefetcherFilter)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -568,22 +568,23 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
|
|||||||
{
|
{
|
||||||
xl_dbase_create_file_copy_rec *xlrec =
|
xl_dbase_create_file_copy_rec *xlrec =
|
||||||
(xl_dbase_create_file_copy_rec *) record->main_data;
|
(xl_dbase_create_file_copy_rec *) record->main_data;
|
||||||
RelFileNode rnode = {InvalidOid, xlrec->db_id, InvalidOid};
|
RelFileLocator rlocator =
|
||||||
|
{InvalidOid, xlrec->db_id, InvalidRelFileNumber};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't try to prefetch anything in this database until
|
* Don't try to prefetch anything in this database until
|
||||||
* it has been created, or we might confuse the blocks of
|
* it has been created, or we might confuse the blocks of
|
||||||
* different generations, if a database OID or relfilenode
|
* different generations, if a database OID or
|
||||||
* is reused. It's also more efficient than discovering
|
* relfilenumber is reused. It's also more efficient than
|
||||||
* that relations don't exist on disk yet with ENOENT
|
* discovering that relations don't exist on disk yet with
|
||||||
* errors.
|
* ENOENT errors.
|
||||||
*/
|
*/
|
||||||
XLogPrefetcherAddFilter(prefetcher, rnode, 0, record->lsn);
|
XLogPrefetcherAddFilter(prefetcher, rlocator, 0, record->lsn);
|
||||||
|
|
||||||
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
||||||
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
||||||
"suppressing prefetch in database %u until %X/%X is replayed due to raw file copy",
|
"suppressing prefetch in database %u until %X/%X is replayed due to raw file copy",
|
||||||
rnode.dbNode,
|
rlocator.dbOid,
|
||||||
LSN_FORMAT_ARGS(record->lsn));
|
LSN_FORMAT_ARGS(record->lsn));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -601,19 +602,19 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
|
|||||||
* Don't prefetch anything for this whole relation
|
* Don't prefetch anything for this whole relation
|
||||||
* until it has been created. Otherwise we might
|
* until it has been created. Otherwise we might
|
||||||
* confuse the blocks of different generations, if a
|
* confuse the blocks of different generations, if a
|
||||||
* relfilenode is reused. This also avoids the need
|
* relfilenumber is reused. This also avoids the need
|
||||||
* to discover the problem via extra syscalls that
|
* to discover the problem via extra syscalls that
|
||||||
* report ENOENT.
|
* report ENOENT.
|
||||||
*/
|
*/
|
||||||
XLogPrefetcherAddFilter(prefetcher, xlrec->rnode, 0,
|
XLogPrefetcherAddFilter(prefetcher, xlrec->rlocator, 0,
|
||||||
record->lsn);
|
record->lsn);
|
||||||
|
|
||||||
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
||||||
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
||||||
"suppressing prefetch in relation %u/%u/%u until %X/%X is replayed, which creates the relation",
|
"suppressing prefetch in relation %u/%u/%u until %X/%X is replayed, which creates the relation",
|
||||||
xlrec->rnode.spcNode,
|
xlrec->rlocator.spcOid,
|
||||||
xlrec->rnode.dbNode,
|
xlrec->rlocator.dbOid,
|
||||||
xlrec->rnode.relNode,
|
xlrec->rlocator.relNumber,
|
||||||
LSN_FORMAT_ARGS(record->lsn));
|
LSN_FORMAT_ARGS(record->lsn));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -627,16 +628,16 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
|
|||||||
* Don't consider prefetching anything in the truncated
|
* Don't consider prefetching anything in the truncated
|
||||||
* range until the truncation has been performed.
|
* range until the truncation has been performed.
|
||||||
*/
|
*/
|
||||||
XLogPrefetcherAddFilter(prefetcher, xlrec->rnode,
|
XLogPrefetcherAddFilter(prefetcher, xlrec->rlocator,
|
||||||
xlrec->blkno,
|
xlrec->blkno,
|
||||||
record->lsn);
|
record->lsn);
|
||||||
|
|
||||||
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
||||||
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
||||||
"suppressing prefetch in relation %u/%u/%u from block %u until %X/%X is replayed, which truncates the relation",
|
"suppressing prefetch in relation %u/%u/%u from block %u until %X/%X is replayed, which truncates the relation",
|
||||||
xlrec->rnode.spcNode,
|
xlrec->rlocator.spcOid,
|
||||||
xlrec->rnode.dbNode,
|
xlrec->rlocator.dbOid,
|
||||||
xlrec->rnode.relNode,
|
xlrec->rlocator.relNumber,
|
||||||
xlrec->blkno,
|
xlrec->blkno,
|
||||||
LSN_FORMAT_ARGS(record->lsn));
|
LSN_FORMAT_ARGS(record->lsn));
|
||||||
#endif
|
#endif
|
||||||
@ -688,7 +689,7 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Should we skip prefetching this block due to a filter? */
|
/* Should we skip prefetching this block due to a filter? */
|
||||||
if (XLogPrefetcherIsFiltered(prefetcher, block->rnode, block->blkno))
|
if (XLogPrefetcherIsFiltered(prefetcher, block->rlocator, block->blkno))
|
||||||
{
|
{
|
||||||
XLogPrefetchIncrement(&SharedStats->skip_new);
|
XLogPrefetchIncrement(&SharedStats->skip_new);
|
||||||
return LRQ_NEXT_NO_IO;
|
return LRQ_NEXT_NO_IO;
|
||||||
@ -698,7 +699,7 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
|
|||||||
for (int i = 0; i < XLOGPREFETCHER_SEQ_WINDOW_SIZE; ++i)
|
for (int i = 0; i < XLOGPREFETCHER_SEQ_WINDOW_SIZE; ++i)
|
||||||
{
|
{
|
||||||
if (block->blkno == prefetcher->recent_block[i] &&
|
if (block->blkno == prefetcher->recent_block[i] &&
|
||||||
RelFileNodeEquals(block->rnode, prefetcher->recent_rnode[i]))
|
RelFileLocatorEquals(block->rlocator, prefetcher->recent_rlocator[i]))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* XXX If we also remembered where it was, we could set
|
* XXX If we also remembered where it was, we could set
|
||||||
@ -709,7 +710,7 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
|
|||||||
return LRQ_NEXT_NO_IO;
|
return LRQ_NEXT_NO_IO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prefetcher->recent_rnode[prefetcher->recent_idx] = block->rnode;
|
prefetcher->recent_rlocator[prefetcher->recent_idx] = block->rlocator;
|
||||||
prefetcher->recent_block[prefetcher->recent_idx] = block->blkno;
|
prefetcher->recent_block[prefetcher->recent_idx] = block->blkno;
|
||||||
prefetcher->recent_idx =
|
prefetcher->recent_idx =
|
||||||
(prefetcher->recent_idx + 1) % XLOGPREFETCHER_SEQ_WINDOW_SIZE;
|
(prefetcher->recent_idx + 1) % XLOGPREFETCHER_SEQ_WINDOW_SIZE;
|
||||||
@ -719,7 +720,7 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
|
|||||||
* same relation (with some scheme to handle invalidations
|
* same relation (with some scheme to handle invalidations
|
||||||
* safely), but for now we'll call smgropen() every time.
|
* safely), but for now we'll call smgropen() every time.
|
||||||
*/
|
*/
|
||||||
reln = smgropen(block->rnode, InvalidBackendId);
|
reln = smgropen(block->rlocator, InvalidBackendId);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the relation file doesn't exist on disk, for example because
|
* If the relation file doesn't exist on disk, for example because
|
||||||
@ -733,12 +734,12 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
|
|||||||
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
||||||
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
||||||
"suppressing all prefetch in relation %u/%u/%u until %X/%X is replayed, because the relation does not exist on disk",
|
"suppressing all prefetch in relation %u/%u/%u until %X/%X is replayed, because the relation does not exist on disk",
|
||||||
reln->smgr_rnode.node.spcNode,
|
reln->smgr_rlocator.locator.spcOid,
|
||||||
reln->smgr_rnode.node.dbNode,
|
reln->smgr_rlocator.locator.dbOid,
|
||||||
reln->smgr_rnode.node.relNode,
|
reln->smgr_rlocator.locator.relNumber,
|
||||||
LSN_FORMAT_ARGS(record->lsn));
|
LSN_FORMAT_ARGS(record->lsn));
|
||||||
#endif
|
#endif
|
||||||
XLogPrefetcherAddFilter(prefetcher, block->rnode, 0,
|
XLogPrefetcherAddFilter(prefetcher, block->rlocator, 0,
|
||||||
record->lsn);
|
record->lsn);
|
||||||
XLogPrefetchIncrement(&SharedStats->skip_new);
|
XLogPrefetchIncrement(&SharedStats->skip_new);
|
||||||
return LRQ_NEXT_NO_IO;
|
return LRQ_NEXT_NO_IO;
|
||||||
@ -754,13 +755,13 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
|
|||||||
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
||||||
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
||||||
"suppressing prefetch in relation %u/%u/%u from block %u until %X/%X is replayed, because the relation is too small",
|
"suppressing prefetch in relation %u/%u/%u from block %u until %X/%X is replayed, because the relation is too small",
|
||||||
reln->smgr_rnode.node.spcNode,
|
reln->smgr_rlocator.locator.spcOid,
|
||||||
reln->smgr_rnode.node.dbNode,
|
reln->smgr_rlocator.locator.dbOid,
|
||||||
reln->smgr_rnode.node.relNode,
|
reln->smgr_rlocator.locator.relNumber,
|
||||||
block->blkno,
|
block->blkno,
|
||||||
LSN_FORMAT_ARGS(record->lsn));
|
LSN_FORMAT_ARGS(record->lsn));
|
||||||
#endif
|
#endif
|
||||||
XLogPrefetcherAddFilter(prefetcher, block->rnode, block->blkno,
|
XLogPrefetcherAddFilter(prefetcher, block->rlocator, block->blkno,
|
||||||
record->lsn);
|
record->lsn);
|
||||||
XLogPrefetchIncrement(&SharedStats->skip_new);
|
XLogPrefetchIncrement(&SharedStats->skip_new);
|
||||||
return LRQ_NEXT_NO_IO;
|
return LRQ_NEXT_NO_IO;
|
||||||
@ -793,9 +794,9 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
|
|||||||
*/
|
*/
|
||||||
elog(ERROR,
|
elog(ERROR,
|
||||||
"could not prefetch relation %u/%u/%u block %u",
|
"could not prefetch relation %u/%u/%u block %u",
|
||||||
reln->smgr_rnode.node.spcNode,
|
reln->smgr_rlocator.locator.spcOid,
|
||||||
reln->smgr_rnode.node.dbNode,
|
reln->smgr_rlocator.locator.dbOid,
|
||||||
reln->smgr_rnode.node.relNode,
|
reln->smgr_rlocator.locator.relNumber,
|
||||||
block->blkno);
|
block->blkno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -852,17 +853,17 @@ pg_stat_get_recovery_prefetch(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't prefetch any blocks >= 'blockno' from a given 'rnode', until 'lsn'
|
* Don't prefetch any blocks >= 'blockno' from a given 'rlocator', until 'lsn'
|
||||||
* has been replayed.
|
* has been replayed.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
XLogPrefetcherAddFilter(XLogPrefetcher *prefetcher, RelFileNode rnode,
|
XLogPrefetcherAddFilter(XLogPrefetcher *prefetcher, RelFileLocator rlocator,
|
||||||
BlockNumber blockno, XLogRecPtr lsn)
|
BlockNumber blockno, XLogRecPtr lsn)
|
||||||
{
|
{
|
||||||
XLogPrefetcherFilter *filter;
|
XLogPrefetcherFilter *filter;
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
filter = hash_search(prefetcher->filter_table, &rnode, HASH_ENTER, &found);
|
filter = hash_search(prefetcher->filter_table, &rlocator, HASH_ENTER, &found);
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -875,9 +876,10 @@ XLogPrefetcherAddFilter(XLogPrefetcher *prefetcher, RelFileNode rnode,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We were already filtering this rnode. Extend the filter's lifetime
|
* We were already filtering this rlocator. Extend the filter's
|
||||||
* to cover this WAL record, but leave the lower of the block numbers
|
* lifetime to cover this WAL record, but leave the lower of the block
|
||||||
* there because we don't want to have to track individual blocks.
|
* numbers there because we don't want to have to track individual
|
||||||
|
* blocks.
|
||||||
*/
|
*/
|
||||||
filter->filter_until_replayed = lsn;
|
filter->filter_until_replayed = lsn;
|
||||||
dlist_delete(&filter->link);
|
dlist_delete(&filter->link);
|
||||||
@ -890,7 +892,7 @@ XLogPrefetcherAddFilter(XLogPrefetcher *prefetcher, RelFileNode rnode,
|
|||||||
* Have we replayed any records that caused us to begin filtering a block
|
* Have we replayed any records that caused us to begin filtering a block
|
||||||
* range? That means that relations should have been created, extended or
|
* range? That means that relations should have been created, extended or
|
||||||
* dropped as required, so we can stop filtering out accesses to a given
|
* dropped as required, so we can stop filtering out accesses to a given
|
||||||
* relfilenode.
|
* relfilenumber.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
XLogPrefetcherCompleteFilters(XLogPrefetcher *prefetcher, XLogRecPtr replaying_lsn)
|
XLogPrefetcherCompleteFilters(XLogPrefetcher *prefetcher, XLogRecPtr replaying_lsn)
|
||||||
@ -913,7 +915,7 @@ XLogPrefetcherCompleteFilters(XLogPrefetcher *prefetcher, XLogRecPtr replaying_l
|
|||||||
* Check if a given block should be skipped due to a filter.
|
* Check if a given block should be skipped due to a filter.
|
||||||
*/
|
*/
|
||||||
static inline bool
|
static inline bool
|
||||||
XLogPrefetcherIsFiltered(XLogPrefetcher *prefetcher, RelFileNode rnode,
|
XLogPrefetcherIsFiltered(XLogPrefetcher *prefetcher, RelFileLocator rlocator,
|
||||||
BlockNumber blockno)
|
BlockNumber blockno)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -925,13 +927,13 @@ XLogPrefetcherIsFiltered(XLogPrefetcher *prefetcher, RelFileNode rnode,
|
|||||||
XLogPrefetcherFilter *filter;
|
XLogPrefetcherFilter *filter;
|
||||||
|
|
||||||
/* See if the block range is filtered. */
|
/* See if the block range is filtered. */
|
||||||
filter = hash_search(prefetcher->filter_table, &rnode, HASH_FIND, NULL);
|
filter = hash_search(prefetcher->filter_table, &rlocator, HASH_FIND, NULL);
|
||||||
if (filter && filter->filter_from_block <= blockno)
|
if (filter && filter->filter_from_block <= blockno)
|
||||||
{
|
{
|
||||||
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
||||||
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
||||||
"prefetch of %u/%u/%u block %u suppressed; filtering until LSN %X/%X is replayed (blocks >= %u filtered)",
|
"prefetch of %u/%u/%u block %u suppressed; filtering until LSN %X/%X is replayed (blocks >= %u filtered)",
|
||||||
rnode.spcNode, rnode.dbNode, rnode.relNode, blockno,
|
rlocator.spcOid, rlocator.dbOid, rlocator.relNumber, blockno,
|
||||||
LSN_FORMAT_ARGS(filter->filter_until_replayed),
|
LSN_FORMAT_ARGS(filter->filter_until_replayed),
|
||||||
filter->filter_from_block);
|
filter->filter_from_block);
|
||||||
#endif
|
#endif
|
||||||
@ -939,15 +941,15 @@ XLogPrefetcherIsFiltered(XLogPrefetcher *prefetcher, RelFileNode rnode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* See if the whole database is filtered. */
|
/* See if the whole database is filtered. */
|
||||||
rnode.relNode = InvalidOid;
|
rlocator.relNumber = InvalidRelFileNumber;
|
||||||
rnode.spcNode = InvalidOid;
|
rlocator.spcOid = InvalidOid;
|
||||||
filter = hash_search(prefetcher->filter_table, &rnode, HASH_FIND, NULL);
|
filter = hash_search(prefetcher->filter_table, &rlocator, HASH_FIND, NULL);
|
||||||
if (filter)
|
if (filter)
|
||||||
{
|
{
|
||||||
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
#ifdef XLOGPREFETCHER_DEBUG_LEVEL
|
||||||
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
elog(XLOGPREFETCHER_DEBUG_LEVEL,
|
||||||
"prefetch of %u/%u/%u block %u suppressed; filtering until LSN %X/%X is replayed (whole database)",
|
"prefetch of %u/%u/%u block %u suppressed; filtering until LSN %X/%X is replayed (whole database)",
|
||||||
rnode.spcNode, rnode.dbNode, rnode.relNode, blockno,
|
rlocator.spcOid, rlocator.dbOid, rlocator.relNumber, blockno,
|
||||||
LSN_FORMAT_ARGS(filter->filter_until_replayed));
|
LSN_FORMAT_ARGS(filter->filter_until_replayed));
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
@ -1638,7 +1638,7 @@ DecodeXLogRecord(XLogReaderState *state,
|
|||||||
char *out;
|
char *out;
|
||||||
uint32 remaining;
|
uint32 remaining;
|
||||||
uint32 datatotal;
|
uint32 datatotal;
|
||||||
RelFileNode *rnode = NULL;
|
RelFileLocator *rlocator = NULL;
|
||||||
uint8 block_id;
|
uint8 block_id;
|
||||||
|
|
||||||
decoded->header = *record;
|
decoded->header = *record;
|
||||||
@ -1823,12 +1823,12 @@ DecodeXLogRecord(XLogReaderState *state,
|
|||||||
}
|
}
|
||||||
if (!(fork_flags & BKPBLOCK_SAME_REL))
|
if (!(fork_flags & BKPBLOCK_SAME_REL))
|
||||||
{
|
{
|
||||||
COPY_HEADER_FIELD(&blk->rnode, sizeof(RelFileNode));
|
COPY_HEADER_FIELD(&blk->rlocator, sizeof(RelFileLocator));
|
||||||
rnode = &blk->rnode;
|
rlocator = &blk->rlocator;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (rnode == NULL)
|
if (rlocator == NULL)
|
||||||
{
|
{
|
||||||
report_invalid_record(state,
|
report_invalid_record(state,
|
||||||
"BKPBLOCK_SAME_REL set but no previous rel at %X/%X",
|
"BKPBLOCK_SAME_REL set but no previous rel at %X/%X",
|
||||||
@ -1836,7 +1836,7 @@ DecodeXLogRecord(XLogReaderState *state,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
blk->rnode = *rnode;
|
blk->rlocator = *rlocator;
|
||||||
}
|
}
|
||||||
COPY_HEADER_FIELD(&blk->blkno, sizeof(BlockNumber));
|
COPY_HEADER_FIELD(&blk->blkno, sizeof(BlockNumber));
|
||||||
}
|
}
|
||||||
@ -1926,10 +1926,11 @@ err:
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id,
|
XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id,
|
||||||
RelFileNode *rnode, ForkNumber *forknum, BlockNumber *blknum)
|
RelFileLocator *rlocator, ForkNumber *forknum,
|
||||||
|
BlockNumber *blknum)
|
||||||
{
|
{
|
||||||
if (!XLogRecGetBlockTagExtended(record, block_id, rnode, forknum, blknum,
|
if (!XLogRecGetBlockTagExtended(record, block_id, rlocator, forknum,
|
||||||
NULL))
|
blknum, NULL))
|
||||||
{
|
{
|
||||||
#ifndef FRONTEND
|
#ifndef FRONTEND
|
||||||
elog(ERROR, "failed to locate backup block with ID %d in WAL record",
|
elog(ERROR, "failed to locate backup block with ID %d in WAL record",
|
||||||
@ -1945,13 +1946,13 @@ XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id,
|
|||||||
* Returns information about the block that a block reference refers to,
|
* Returns information about the block that a block reference refers to,
|
||||||
* optionally including the buffer that the block may already be in.
|
* optionally including the buffer that the block may already be in.
|
||||||
*
|
*
|
||||||
* If the WAL record contains a block reference with the given ID, *rnode,
|
* If the WAL record contains a block reference with the given ID, *rlocator,
|
||||||
* *forknum, *blknum and *prefetch_buffer are filled in (if not NULL), and
|
* *forknum, *blknum and *prefetch_buffer are filled in (if not NULL), and
|
||||||
* returns true. Otherwise returns false.
|
* returns true. Otherwise returns false.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
XLogRecGetBlockTagExtended(XLogReaderState *record, uint8 block_id,
|
XLogRecGetBlockTagExtended(XLogReaderState *record, uint8 block_id,
|
||||||
RelFileNode *rnode, ForkNumber *forknum,
|
RelFileLocator *rlocator, ForkNumber *forknum,
|
||||||
BlockNumber *blknum,
|
BlockNumber *blknum,
|
||||||
Buffer *prefetch_buffer)
|
Buffer *prefetch_buffer)
|
||||||
{
|
{
|
||||||
@ -1961,8 +1962,8 @@ XLogRecGetBlockTagExtended(XLogReaderState *record, uint8 block_id,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
bkpb = &record->record->blocks[block_id];
|
bkpb = &record->record->blocks[block_id];
|
||||||
if (rnode)
|
if (rlocator)
|
||||||
*rnode = bkpb->rnode;
|
*rlocator = bkpb->rlocator;
|
||||||
if (forknum)
|
if (forknum)
|
||||||
*forknum = bkpb->forknum;
|
*forknum = bkpb->forknum;
|
||||||
if (blknum)
|
if (blknum)
|
||||||
|
@ -2166,24 +2166,26 @@ xlog_block_info(StringInfo buf, XLogReaderState *record)
|
|||||||
/* decode block references */
|
/* decode block references */
|
||||||
for (block_id = 0; block_id <= XLogRecMaxBlockId(record); block_id++)
|
for (block_id = 0; block_id <= XLogRecMaxBlockId(record); block_id++)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
BlockNumber blk;
|
BlockNumber blk;
|
||||||
|
|
||||||
if (!XLogRecGetBlockTagExtended(record, block_id,
|
if (!XLogRecGetBlockTagExtended(record, block_id,
|
||||||
&rnode, &forknum, &blk, NULL))
|
&rlocator, &forknum, &blk, NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (forknum != MAIN_FORKNUM)
|
if (forknum != MAIN_FORKNUM)
|
||||||
appendStringInfo(buf, "; blkref #%d: rel %u/%u/%u, fork %u, blk %u",
|
appendStringInfo(buf, "; blkref #%d: rel %u/%u/%u, fork %u, blk %u",
|
||||||
block_id,
|
block_id,
|
||||||
rnode.spcNode, rnode.dbNode, rnode.relNode,
|
rlocator.spcOid, rlocator.dbOid,
|
||||||
|
rlocator.relNumber,
|
||||||
forknum,
|
forknum,
|
||||||
blk);
|
blk);
|
||||||
else
|
else
|
||||||
appendStringInfo(buf, "; blkref #%d: rel %u/%u/%u, blk %u",
|
appendStringInfo(buf, "; blkref #%d: rel %u/%u/%u, blk %u",
|
||||||
block_id,
|
block_id,
|
||||||
rnode.spcNode, rnode.dbNode, rnode.relNode,
|
rlocator.spcOid, rlocator.dbOid,
|
||||||
|
rlocator.relNumber,
|
||||||
blk);
|
blk);
|
||||||
if (XLogRecHasBlockImage(record, block_id))
|
if (XLogRecHasBlockImage(record, block_id))
|
||||||
appendStringInfoString(buf, " FPW");
|
appendStringInfoString(buf, " FPW");
|
||||||
@ -2285,7 +2287,7 @@ static void
|
|||||||
verifyBackupPageConsistency(XLogReaderState *record)
|
verifyBackupPageConsistency(XLogReaderState *record)
|
||||||
{
|
{
|
||||||
RmgrData rmgr = GetRmgr(XLogRecGetRmid(record));
|
RmgrData rmgr = GetRmgr(XLogRecGetRmid(record));
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
int block_id;
|
int block_id;
|
||||||
@ -2302,7 +2304,7 @@ verifyBackupPageConsistency(XLogReaderState *record)
|
|||||||
Page page;
|
Page page;
|
||||||
|
|
||||||
if (!XLogRecGetBlockTagExtended(record, block_id,
|
if (!XLogRecGetBlockTagExtended(record, block_id,
|
||||||
&rnode, &forknum, &blkno, NULL))
|
&rlocator, &forknum, &blkno, NULL))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* WAL record doesn't contain a block reference with the given id.
|
* WAL record doesn't contain a block reference with the given id.
|
||||||
@ -2327,7 +2329,7 @@ verifyBackupPageConsistency(XLogReaderState *record)
|
|||||||
* Read the contents from the current buffer and store it in a
|
* Read the contents from the current buffer and store it in a
|
||||||
* temporary page.
|
* temporary page.
|
||||||
*/
|
*/
|
||||||
buf = XLogReadBufferExtended(rnode, forknum, blkno,
|
buf = XLogReadBufferExtended(rlocator, forknum, blkno,
|
||||||
RBM_NORMAL_NO_LOG,
|
RBM_NORMAL_NO_LOG,
|
||||||
InvalidBuffer);
|
InvalidBuffer);
|
||||||
if (!BufferIsValid(buf))
|
if (!BufferIsValid(buf))
|
||||||
@ -2377,7 +2379,7 @@ verifyBackupPageConsistency(XLogReaderState *record)
|
|||||||
{
|
{
|
||||||
elog(FATAL,
|
elog(FATAL,
|
||||||
"inconsistent page found, rel %u/%u/%u, forknum %u, blkno %u",
|
"inconsistent page found, rel %u/%u/%u, forknum %u, blkno %u",
|
||||||
rnode.spcNode, rnode.dbNode, rnode.relNode,
|
rlocator.spcOid, rlocator.dbOid, rlocator.relNumber,
|
||||||
forknum, blkno);
|
forknum, blkno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ HotStandbyState standbyState = STANDBY_DISABLED;
|
|||||||
*/
|
*/
|
||||||
typedef struct xl_invalid_page_key
|
typedef struct xl_invalid_page_key
|
||||||
{
|
{
|
||||||
RelFileNode node; /* the relation */
|
RelFileLocator locator; /* the relation */
|
||||||
ForkNumber forkno; /* the fork number */
|
ForkNumber forkno; /* the fork number */
|
||||||
BlockNumber blkno; /* the page */
|
BlockNumber blkno; /* the page */
|
||||||
} xl_invalid_page_key;
|
} xl_invalid_page_key;
|
||||||
@ -86,10 +86,10 @@ static int read_local_xlog_page_guts(XLogReaderState *state, XLogRecPtr targetPa
|
|||||||
|
|
||||||
/* Report a reference to an invalid page */
|
/* Report a reference to an invalid page */
|
||||||
static void
|
static void
|
||||||
report_invalid_page(int elevel, RelFileNode node, ForkNumber forkno,
|
report_invalid_page(int elevel, RelFileLocator locator, ForkNumber forkno,
|
||||||
BlockNumber blkno, bool present)
|
BlockNumber blkno, bool present)
|
||||||
{
|
{
|
||||||
char *path = relpathperm(node, forkno);
|
char *path = relpathperm(locator, forkno);
|
||||||
|
|
||||||
if (present)
|
if (present)
|
||||||
elog(elevel, "page %u of relation %s is uninitialized",
|
elog(elevel, "page %u of relation %s is uninitialized",
|
||||||
@ -102,7 +102,7 @@ report_invalid_page(int elevel, RelFileNode node, ForkNumber forkno,
|
|||||||
|
|
||||||
/* Log a reference to an invalid page */
|
/* Log a reference to an invalid page */
|
||||||
static void
|
static void
|
||||||
log_invalid_page(RelFileNode node, ForkNumber forkno, BlockNumber blkno,
|
log_invalid_page(RelFileLocator locator, ForkNumber forkno, BlockNumber blkno,
|
||||||
bool present)
|
bool present)
|
||||||
{
|
{
|
||||||
xl_invalid_page_key key;
|
xl_invalid_page_key key;
|
||||||
@ -119,7 +119,7 @@ log_invalid_page(RelFileNode node, ForkNumber forkno, BlockNumber blkno,
|
|||||||
*/
|
*/
|
||||||
if (reachedConsistency)
|
if (reachedConsistency)
|
||||||
{
|
{
|
||||||
report_invalid_page(WARNING, node, forkno, blkno, present);
|
report_invalid_page(WARNING, locator, forkno, blkno, present);
|
||||||
elog(ignore_invalid_pages ? WARNING : PANIC,
|
elog(ignore_invalid_pages ? WARNING : PANIC,
|
||||||
"WAL contains references to invalid pages");
|
"WAL contains references to invalid pages");
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ log_invalid_page(RelFileNode node, ForkNumber forkno, BlockNumber blkno,
|
|||||||
* something about the XLOG record that generated the reference).
|
* something about the XLOG record that generated the reference).
|
||||||
*/
|
*/
|
||||||
if (message_level_is_interesting(DEBUG1))
|
if (message_level_is_interesting(DEBUG1))
|
||||||
report_invalid_page(DEBUG1, node, forkno, blkno, present);
|
report_invalid_page(DEBUG1, locator, forkno, blkno, present);
|
||||||
|
|
||||||
if (invalid_page_tab == NULL)
|
if (invalid_page_tab == NULL)
|
||||||
{
|
{
|
||||||
@ -147,7 +147,7 @@ log_invalid_page(RelFileNode node, ForkNumber forkno, BlockNumber blkno,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* we currently assume xl_invalid_page_key contains no padding */
|
/* we currently assume xl_invalid_page_key contains no padding */
|
||||||
key.node = node;
|
key.locator = locator;
|
||||||
key.forkno = forkno;
|
key.forkno = forkno;
|
||||||
key.blkno = blkno;
|
key.blkno = blkno;
|
||||||
hentry = (xl_invalid_page *)
|
hentry = (xl_invalid_page *)
|
||||||
@ -166,7 +166,8 @@ log_invalid_page(RelFileNode node, ForkNumber forkno, BlockNumber blkno,
|
|||||||
|
|
||||||
/* Forget any invalid pages >= minblkno, because they've been dropped */
|
/* Forget any invalid pages >= minblkno, because they've been dropped */
|
||||||
static void
|
static void
|
||||||
forget_invalid_pages(RelFileNode node, ForkNumber forkno, BlockNumber minblkno)
|
forget_invalid_pages(RelFileLocator locator, ForkNumber forkno,
|
||||||
|
BlockNumber minblkno)
|
||||||
{
|
{
|
||||||
HASH_SEQ_STATUS status;
|
HASH_SEQ_STATUS status;
|
||||||
xl_invalid_page *hentry;
|
xl_invalid_page *hentry;
|
||||||
@ -178,13 +179,13 @@ forget_invalid_pages(RelFileNode node, ForkNumber forkno, BlockNumber minblkno)
|
|||||||
|
|
||||||
while ((hentry = (xl_invalid_page *) hash_seq_search(&status)) != NULL)
|
while ((hentry = (xl_invalid_page *) hash_seq_search(&status)) != NULL)
|
||||||
{
|
{
|
||||||
if (RelFileNodeEquals(hentry->key.node, node) &&
|
if (RelFileLocatorEquals(hentry->key.locator, locator) &&
|
||||||
hentry->key.forkno == forkno &&
|
hentry->key.forkno == forkno &&
|
||||||
hentry->key.blkno >= minblkno)
|
hentry->key.blkno >= minblkno)
|
||||||
{
|
{
|
||||||
if (message_level_is_interesting(DEBUG2))
|
if (message_level_is_interesting(DEBUG2))
|
||||||
{
|
{
|
||||||
char *path = relpathperm(hentry->key.node, forkno);
|
char *path = relpathperm(hentry->key.locator, forkno);
|
||||||
|
|
||||||
elog(DEBUG2, "page %u of relation %s has been dropped",
|
elog(DEBUG2, "page %u of relation %s has been dropped",
|
||||||
hentry->key.blkno, path);
|
hentry->key.blkno, path);
|
||||||
@ -213,11 +214,11 @@ forget_invalid_pages_db(Oid dbid)
|
|||||||
|
|
||||||
while ((hentry = (xl_invalid_page *) hash_seq_search(&status)) != NULL)
|
while ((hentry = (xl_invalid_page *) hash_seq_search(&status)) != NULL)
|
||||||
{
|
{
|
||||||
if (hentry->key.node.dbNode == dbid)
|
if (hentry->key.locator.dbOid == dbid)
|
||||||
{
|
{
|
||||||
if (message_level_is_interesting(DEBUG2))
|
if (message_level_is_interesting(DEBUG2))
|
||||||
{
|
{
|
||||||
char *path = relpathperm(hentry->key.node, hentry->key.forkno);
|
char *path = relpathperm(hentry->key.locator, hentry->key.forkno);
|
||||||
|
|
||||||
elog(DEBUG2, "page %u of relation %s has been dropped",
|
elog(DEBUG2, "page %u of relation %s has been dropped",
|
||||||
hentry->key.blkno, path);
|
hentry->key.blkno, path);
|
||||||
@ -261,7 +262,7 @@ XLogCheckInvalidPages(void)
|
|||||||
*/
|
*/
|
||||||
while ((hentry = (xl_invalid_page *) hash_seq_search(&status)) != NULL)
|
while ((hentry = (xl_invalid_page *) hash_seq_search(&status)) != NULL)
|
||||||
{
|
{
|
||||||
report_invalid_page(WARNING, hentry->key.node, hentry->key.forkno,
|
report_invalid_page(WARNING, hentry->key.locator, hentry->key.forkno,
|
||||||
hentry->key.blkno, hentry->present);
|
hentry->key.blkno, hentry->present);
|
||||||
foundone = true;
|
foundone = true;
|
||||||
}
|
}
|
||||||
@ -356,7 +357,7 @@ XLogReadBufferForRedoExtended(XLogReaderState *record,
|
|||||||
Buffer *buf)
|
Buffer *buf)
|
||||||
{
|
{
|
||||||
XLogRecPtr lsn = record->EndRecPtr;
|
XLogRecPtr lsn = record->EndRecPtr;
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
Buffer prefetch_buffer;
|
Buffer prefetch_buffer;
|
||||||
@ -364,7 +365,7 @@ XLogReadBufferForRedoExtended(XLogReaderState *record,
|
|||||||
bool zeromode;
|
bool zeromode;
|
||||||
bool willinit;
|
bool willinit;
|
||||||
|
|
||||||
if (!XLogRecGetBlockTagExtended(record, block_id, &rnode, &forknum, &blkno,
|
if (!XLogRecGetBlockTagExtended(record, block_id, &rlocator, &forknum, &blkno,
|
||||||
&prefetch_buffer))
|
&prefetch_buffer))
|
||||||
{
|
{
|
||||||
/* Caller specified a bogus block_id */
|
/* Caller specified a bogus block_id */
|
||||||
@ -387,7 +388,7 @@ XLogReadBufferForRedoExtended(XLogReaderState *record,
|
|||||||
if (XLogRecBlockImageApply(record, block_id))
|
if (XLogRecBlockImageApply(record, block_id))
|
||||||
{
|
{
|
||||||
Assert(XLogRecHasBlockImage(record, block_id));
|
Assert(XLogRecHasBlockImage(record, block_id));
|
||||||
*buf = XLogReadBufferExtended(rnode, forknum, blkno,
|
*buf = XLogReadBufferExtended(rlocator, forknum, blkno,
|
||||||
get_cleanup_lock ? RBM_ZERO_AND_CLEANUP_LOCK : RBM_ZERO_AND_LOCK,
|
get_cleanup_lock ? RBM_ZERO_AND_CLEANUP_LOCK : RBM_ZERO_AND_LOCK,
|
||||||
prefetch_buffer);
|
prefetch_buffer);
|
||||||
page = BufferGetPage(*buf);
|
page = BufferGetPage(*buf);
|
||||||
@ -418,7 +419,7 @@ XLogReadBufferForRedoExtended(XLogReaderState *record,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*buf = XLogReadBufferExtended(rnode, forknum, blkno, mode, prefetch_buffer);
|
*buf = XLogReadBufferExtended(rlocator, forknum, blkno, mode, prefetch_buffer);
|
||||||
if (BufferIsValid(*buf))
|
if (BufferIsValid(*buf))
|
||||||
{
|
{
|
||||||
if (mode != RBM_ZERO_AND_LOCK && mode != RBM_ZERO_AND_CLEANUP_LOCK)
|
if (mode != RBM_ZERO_AND_LOCK && mode != RBM_ZERO_AND_CLEANUP_LOCK)
|
||||||
@ -468,7 +469,7 @@ XLogReadBufferForRedoExtended(XLogReaderState *record,
|
|||||||
* they will be invisible to tools that need to know which pages are modified.
|
* they will be invisible to tools that need to know which pages are modified.
|
||||||
*/
|
*/
|
||||||
Buffer
|
Buffer
|
||||||
XLogReadBufferExtended(RelFileNode rnode, ForkNumber forknum,
|
XLogReadBufferExtended(RelFileLocator rlocator, ForkNumber forknum,
|
||||||
BlockNumber blkno, ReadBufferMode mode,
|
BlockNumber blkno, ReadBufferMode mode,
|
||||||
Buffer recent_buffer)
|
Buffer recent_buffer)
|
||||||
{
|
{
|
||||||
@ -481,14 +482,14 @@ XLogReadBufferExtended(RelFileNode rnode, ForkNumber forknum,
|
|||||||
/* Do we have a clue where the buffer might be already? */
|
/* Do we have a clue where the buffer might be already? */
|
||||||
if (BufferIsValid(recent_buffer) &&
|
if (BufferIsValid(recent_buffer) &&
|
||||||
mode == RBM_NORMAL &&
|
mode == RBM_NORMAL &&
|
||||||
ReadRecentBuffer(rnode, forknum, blkno, recent_buffer))
|
ReadRecentBuffer(rlocator, forknum, blkno, recent_buffer))
|
||||||
{
|
{
|
||||||
buffer = recent_buffer;
|
buffer = recent_buffer;
|
||||||
goto recent_buffer_fast_path;
|
goto recent_buffer_fast_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the relation at smgr level */
|
/* Open the relation at smgr level */
|
||||||
smgr = smgropen(rnode, InvalidBackendId);
|
smgr = smgropen(rlocator, InvalidBackendId);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create the target file if it doesn't already exist. This lets us cope
|
* Create the target file if it doesn't already exist. This lets us cope
|
||||||
@ -505,7 +506,7 @@ XLogReadBufferExtended(RelFileNode rnode, ForkNumber forknum,
|
|||||||
if (blkno < lastblock)
|
if (blkno < lastblock)
|
||||||
{
|
{
|
||||||
/* page exists in file */
|
/* page exists in file */
|
||||||
buffer = ReadBufferWithoutRelcache(rnode, forknum, blkno,
|
buffer = ReadBufferWithoutRelcache(rlocator, forknum, blkno,
|
||||||
mode, NULL, true);
|
mode, NULL, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -513,7 +514,7 @@ XLogReadBufferExtended(RelFileNode rnode, ForkNumber forknum,
|
|||||||
/* hm, page doesn't exist in file */
|
/* hm, page doesn't exist in file */
|
||||||
if (mode == RBM_NORMAL)
|
if (mode == RBM_NORMAL)
|
||||||
{
|
{
|
||||||
log_invalid_page(rnode, forknum, blkno, false);
|
log_invalid_page(rlocator, forknum, blkno, false);
|
||||||
return InvalidBuffer;
|
return InvalidBuffer;
|
||||||
}
|
}
|
||||||
if (mode == RBM_NORMAL_NO_LOG)
|
if (mode == RBM_NORMAL_NO_LOG)
|
||||||
@ -530,7 +531,7 @@ XLogReadBufferExtended(RelFileNode rnode, ForkNumber forknum,
|
|||||||
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
|
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
|
||||||
ReleaseBuffer(buffer);
|
ReleaseBuffer(buffer);
|
||||||
}
|
}
|
||||||
buffer = ReadBufferWithoutRelcache(rnode, forknum,
|
buffer = ReadBufferWithoutRelcache(rlocator, forknum,
|
||||||
P_NEW, mode, NULL, true);
|
P_NEW, mode, NULL, true);
|
||||||
}
|
}
|
||||||
while (BufferGetBlockNumber(buffer) < blkno);
|
while (BufferGetBlockNumber(buffer) < blkno);
|
||||||
@ -540,7 +541,7 @@ XLogReadBufferExtended(RelFileNode rnode, ForkNumber forknum,
|
|||||||
if (mode == RBM_ZERO_AND_LOCK || mode == RBM_ZERO_AND_CLEANUP_LOCK)
|
if (mode == RBM_ZERO_AND_LOCK || mode == RBM_ZERO_AND_CLEANUP_LOCK)
|
||||||
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
|
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
|
||||||
ReleaseBuffer(buffer);
|
ReleaseBuffer(buffer);
|
||||||
buffer = ReadBufferWithoutRelcache(rnode, forknum, blkno,
|
buffer = ReadBufferWithoutRelcache(rlocator, forknum, blkno,
|
||||||
mode, NULL, true);
|
mode, NULL, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -559,7 +560,7 @@ recent_buffer_fast_path:
|
|||||||
if (PageIsNew(page))
|
if (PageIsNew(page))
|
||||||
{
|
{
|
||||||
ReleaseBuffer(buffer);
|
ReleaseBuffer(buffer);
|
||||||
log_invalid_page(rnode, forknum, blkno, true);
|
log_invalid_page(rlocator, forknum, blkno, true);
|
||||||
return InvalidBuffer;
|
return InvalidBuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -594,7 +595,7 @@ typedef FakeRelCacheEntryData *FakeRelCacheEntry;
|
|||||||
* Caller must free the returned entry with FreeFakeRelcacheEntry().
|
* Caller must free the returned entry with FreeFakeRelcacheEntry().
|
||||||
*/
|
*/
|
||||||
Relation
|
Relation
|
||||||
CreateFakeRelcacheEntry(RelFileNode rnode)
|
CreateFakeRelcacheEntry(RelFileLocator rlocator)
|
||||||
{
|
{
|
||||||
FakeRelCacheEntry fakeentry;
|
FakeRelCacheEntry fakeentry;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
@ -604,7 +605,7 @@ CreateFakeRelcacheEntry(RelFileNode rnode)
|
|||||||
rel = (Relation) fakeentry;
|
rel = (Relation) fakeentry;
|
||||||
|
|
||||||
rel->rd_rel = &fakeentry->pgc;
|
rel->rd_rel = &fakeentry->pgc;
|
||||||
rel->rd_node = rnode;
|
rel->rd_locator = rlocator;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We will never be working with temp rels during recovery or while
|
* We will never be working with temp rels during recovery or while
|
||||||
@ -615,18 +616,18 @@ CreateFakeRelcacheEntry(RelFileNode rnode)
|
|||||||
/* It must be a permanent table here */
|
/* It must be a permanent table here */
|
||||||
rel->rd_rel->relpersistence = RELPERSISTENCE_PERMANENT;
|
rel->rd_rel->relpersistence = RELPERSISTENCE_PERMANENT;
|
||||||
|
|
||||||
/* We don't know the name of the relation; use relfilenode instead */
|
/* We don't know the name of the relation; use relfilenumber instead */
|
||||||
sprintf(RelationGetRelationName(rel), "%u", rnode.relNode);
|
sprintf(RelationGetRelationName(rel), "%u", rlocator.relNumber);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We set up the lockRelId in case anything tries to lock the dummy
|
* We set up the lockRelId in case anything tries to lock the dummy
|
||||||
* relation. Note that this is fairly bogus since relNode may be
|
* relation. Note that this is fairly bogus since relNumber may be
|
||||||
* different from the relation's OID. It shouldn't really matter though.
|
* different from the relation's OID. It shouldn't really matter though.
|
||||||
* In recovery, we are running by ourselves and can't have any lock
|
* In recovery, we are running by ourselves and can't have any lock
|
||||||
* conflicts. While syncing, we already hold AccessExclusiveLock.
|
* conflicts. While syncing, we already hold AccessExclusiveLock.
|
||||||
*/
|
*/
|
||||||
rel->rd_lockInfo.lockRelId.dbId = rnode.dbNode;
|
rel->rd_lockInfo.lockRelId.dbId = rlocator.dbOid;
|
||||||
rel->rd_lockInfo.lockRelId.relId = rnode.relNode;
|
rel->rd_lockInfo.lockRelId.relId = rlocator.relNumber;
|
||||||
|
|
||||||
rel->rd_smgr = NULL;
|
rel->rd_smgr = NULL;
|
||||||
|
|
||||||
@ -652,9 +653,9 @@ FreeFakeRelcacheEntry(Relation fakerel)
|
|||||||
* any open "invalid-page" records for the relation.
|
* any open "invalid-page" records for the relation.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
XLogDropRelation(RelFileNode rnode, ForkNumber forknum)
|
XLogDropRelation(RelFileLocator rlocator, ForkNumber forknum)
|
||||||
{
|
{
|
||||||
forget_invalid_pages(rnode, forknum, 0);
|
forget_invalid_pages(rlocator, forknum, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -682,10 +683,10 @@ XLogDropDatabase(Oid dbid)
|
|||||||
* We need to clean up any open "invalid-page" records for the dropped pages.
|
* We need to clean up any open "invalid-page" records for the dropped pages.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
XLogTruncateRelation(RelFileNode rnode, ForkNumber forkNum,
|
XLogTruncateRelation(RelFileLocator rlocator, ForkNumber forkNum,
|
||||||
BlockNumber nblocks)
|
BlockNumber nblocks)
|
||||||
{
|
{
|
||||||
forget_invalid_pages(rnode, forkNum, nblocks);
|
forget_invalid_pages(rlocator, forkNum, nblocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -287,9 +287,9 @@ Boot_DeclareIndexStmt:
|
|||||||
stmt->excludeOpNames = NIL;
|
stmt->excludeOpNames = NIL;
|
||||||
stmt->idxcomment = NULL;
|
stmt->idxcomment = NULL;
|
||||||
stmt->indexOid = InvalidOid;
|
stmt->indexOid = InvalidOid;
|
||||||
stmt->oldNode = InvalidOid;
|
stmt->oldNumber = InvalidRelFileNumber;
|
||||||
stmt->oldCreateSubid = InvalidSubTransactionId;
|
stmt->oldCreateSubid = InvalidSubTransactionId;
|
||||||
stmt->oldFirstRelfilenodeSubid = InvalidSubTransactionId;
|
stmt->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
stmt->unique = false;
|
stmt->unique = false;
|
||||||
stmt->primary = false;
|
stmt->primary = false;
|
||||||
stmt->isconstraint = false;
|
stmt->isconstraint = false;
|
||||||
@ -339,9 +339,9 @@ Boot_DeclareUniqueIndexStmt:
|
|||||||
stmt->excludeOpNames = NIL;
|
stmt->excludeOpNames = NIL;
|
||||||
stmt->idxcomment = NULL;
|
stmt->idxcomment = NULL;
|
||||||
stmt->indexOid = InvalidOid;
|
stmt->indexOid = InvalidOid;
|
||||||
stmt->oldNode = InvalidOid;
|
stmt->oldNumber = InvalidRelFileNumber;
|
||||||
stmt->oldCreateSubid = InvalidSubTransactionId;
|
stmt->oldCreateSubid = InvalidSubTransactionId;
|
||||||
stmt->oldFirstRelfilenodeSubid = InvalidSubTransactionId;
|
stmt->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
stmt->unique = true;
|
stmt->unique = true;
|
||||||
stmt->primary = false;
|
stmt->primary = false;
|
||||||
stmt->isconstraint = false;
|
stmt->isconstraint = false;
|
||||||
|
@ -481,14 +481,14 @@ GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetNewRelFileNode
|
* GetNewRelFileNumber
|
||||||
* Generate a new relfilenode number that is unique within the
|
* Generate a new relfilenumber that is unique within the
|
||||||
* database of the given tablespace.
|
* database of the given tablespace.
|
||||||
*
|
*
|
||||||
* If the relfilenode will also be used as the relation's OID, pass the
|
* If the relfilenumber will also be used as the relation's OID, pass the
|
||||||
* opened pg_class catalog, and this routine will guarantee that the result
|
* opened pg_class catalog, and this routine will guarantee that the result
|
||||||
* is also an unused OID within pg_class. If the result is to be used only
|
* is also an unused OID within pg_class. If the result is to be used only
|
||||||
* as a relfilenode for an existing relation, pass NULL for pg_class.
|
* as a relfilenumber for an existing relation, pass NULL for pg_class.
|
||||||
*
|
*
|
||||||
* As with GetNewOidWithIndex(), there is some theoretical risk of a race
|
* As with GetNewOidWithIndex(), there is some theoretical risk of a race
|
||||||
* condition, but it doesn't seem worth worrying about.
|
* condition, but it doesn't seem worth worrying about.
|
||||||
@ -496,17 +496,17 @@ GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
|
|||||||
* Note: we don't support using this in bootstrap mode. All relations
|
* Note: we don't support using this in bootstrap mode. All relations
|
||||||
* created by bootstrap have preassigned OIDs, so there's no need.
|
* created by bootstrap have preassigned OIDs, so there's no need.
|
||||||
*/
|
*/
|
||||||
Oid
|
RelFileNumber
|
||||||
GetNewRelFileNode(Oid reltablespace, Relation pg_class, char relpersistence)
|
GetNewRelFileNumber(Oid reltablespace, Relation pg_class, char relpersistence)
|
||||||
{
|
{
|
||||||
RelFileNodeBackend rnode;
|
RelFileLocatorBackend rlocator;
|
||||||
char *rpath;
|
char *rpath;
|
||||||
bool collides;
|
bool collides;
|
||||||
BackendId backend;
|
BackendId backend;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we ever get here during pg_upgrade, there's something wrong; all
|
* If we ever get here during pg_upgrade, there's something wrong; all
|
||||||
* relfilenode assignments during a binary-upgrade run should be
|
* relfilenumber assignments during a binary-upgrade run should be
|
||||||
* determined by commands in the dump script.
|
* determined by commands in the dump script.
|
||||||
*/
|
*/
|
||||||
Assert(!IsBinaryUpgrade);
|
Assert(!IsBinaryUpgrade);
|
||||||
@ -522,19 +522,21 @@ GetNewRelFileNode(Oid reltablespace, Relation pg_class, char relpersistence)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(ERROR, "invalid relpersistence: %c", relpersistence);
|
elog(ERROR, "invalid relpersistence: %c", relpersistence);
|
||||||
return InvalidOid; /* placate compiler */
|
return InvalidRelFileNumber; /* placate compiler */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This logic should match RelationInitPhysicalAddr */
|
/* This logic should match RelationInitPhysicalAddr */
|
||||||
rnode.node.spcNode = reltablespace ? reltablespace : MyDatabaseTableSpace;
|
rlocator.locator.spcOid = reltablespace ? reltablespace : MyDatabaseTableSpace;
|
||||||
rnode.node.dbNode = (rnode.node.spcNode == GLOBALTABLESPACE_OID) ? InvalidOid : MyDatabaseId;
|
rlocator.locator.dbOid =
|
||||||
|
(rlocator.locator.spcOid == GLOBALTABLESPACE_OID) ?
|
||||||
|
InvalidOid : MyDatabaseId;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The relpath will vary based on the backend ID, so we must initialize
|
* The relpath will vary based on the backend ID, so we must initialize
|
||||||
* that properly here to make sure that any collisions based on filename
|
* that properly here to make sure that any collisions based on filename
|
||||||
* are properly detected.
|
* are properly detected.
|
||||||
*/
|
*/
|
||||||
rnode.backend = backend;
|
rlocator.backend = backend;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -542,13 +544,13 @@ GetNewRelFileNode(Oid reltablespace, Relation pg_class, char relpersistence)
|
|||||||
|
|
||||||
/* Generate the OID */
|
/* Generate the OID */
|
||||||
if (pg_class)
|
if (pg_class)
|
||||||
rnode.node.relNode = GetNewOidWithIndex(pg_class, ClassOidIndexId,
|
rlocator.locator.relNumber = GetNewOidWithIndex(pg_class, ClassOidIndexId,
|
||||||
Anum_pg_class_oid);
|
Anum_pg_class_oid);
|
||||||
else
|
else
|
||||||
rnode.node.relNode = GetNewObjectId();
|
rlocator.locator.relNumber = GetNewObjectId();
|
||||||
|
|
||||||
/* Check for existing file of same name */
|
/* Check for existing file of same name */
|
||||||
rpath = relpath(rnode, MAIN_FORKNUM);
|
rpath = relpath(rlocator, MAIN_FORKNUM);
|
||||||
|
|
||||||
if (access(rpath, F_OK) == 0)
|
if (access(rpath, F_OK) == 0)
|
||||||
{
|
{
|
||||||
@ -570,7 +572,7 @@ GetNewRelFileNode(Oid reltablespace, Relation pg_class, char relpersistence)
|
|||||||
pfree(rpath);
|
pfree(rpath);
|
||||||
} while (collides);
|
} while (collides);
|
||||||
|
|
||||||
return rnode.node.relNode;
|
return rlocator.locator.relNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -77,9 +77,9 @@
|
|||||||
|
|
||||||
/* Potentially set by pg_upgrade_support functions */
|
/* Potentially set by pg_upgrade_support functions */
|
||||||
Oid binary_upgrade_next_heap_pg_class_oid = InvalidOid;
|
Oid binary_upgrade_next_heap_pg_class_oid = InvalidOid;
|
||||||
Oid binary_upgrade_next_heap_pg_class_relfilenode = InvalidOid;
|
|
||||||
Oid binary_upgrade_next_toast_pg_class_oid = InvalidOid;
|
Oid binary_upgrade_next_toast_pg_class_oid = InvalidOid;
|
||||||
Oid binary_upgrade_next_toast_pg_class_relfilenode = InvalidOid;
|
RelFileNumber binary_upgrade_next_heap_pg_class_relfilenumber = InvalidRelFileNumber;
|
||||||
|
RelFileNumber binary_upgrade_next_toast_pg_class_relfilenumber = InvalidRelFileNumber;
|
||||||
|
|
||||||
static void AddNewRelationTuple(Relation pg_class_desc,
|
static void AddNewRelationTuple(Relation pg_class_desc,
|
||||||
Relation new_rel_desc,
|
Relation new_rel_desc,
|
||||||
@ -273,7 +273,7 @@ SystemAttributeByName(const char *attname)
|
|||||||
* heap_create - Create an uncataloged heap relation
|
* heap_create - Create an uncataloged heap relation
|
||||||
*
|
*
|
||||||
* Note API change: the caller must now always provide the OID
|
* Note API change: the caller must now always provide the OID
|
||||||
* to use for the relation. The relfilenode may be (and in
|
* to use for the relation. The relfilenumber may be (and in
|
||||||
* the simplest cases is) left unspecified.
|
* the simplest cases is) left unspecified.
|
||||||
*
|
*
|
||||||
* create_storage indicates whether or not to create the storage.
|
* create_storage indicates whether or not to create the storage.
|
||||||
@ -289,7 +289,7 @@ heap_create(const char *relname,
|
|||||||
Oid relnamespace,
|
Oid relnamespace,
|
||||||
Oid reltablespace,
|
Oid reltablespace,
|
||||||
Oid relid,
|
Oid relid,
|
||||||
Oid relfilenode,
|
RelFileNumber relfilenumber,
|
||||||
Oid accessmtd,
|
Oid accessmtd,
|
||||||
TupleDesc tupDesc,
|
TupleDesc tupDesc,
|
||||||
char relkind,
|
char relkind,
|
||||||
@ -341,11 +341,11 @@ heap_create(const char *relname,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If relfilenode is unspecified by the caller then create storage
|
* If relfilenumber is unspecified by the caller then create storage
|
||||||
* with oid same as relid.
|
* with oid same as relid.
|
||||||
*/
|
*/
|
||||||
if (!OidIsValid(relfilenode))
|
if (!RelFileNumberIsValid(relfilenumber))
|
||||||
relfilenode = relid;
|
relfilenumber = relid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -368,7 +368,7 @@ heap_create(const char *relname,
|
|||||||
tupDesc,
|
tupDesc,
|
||||||
relid,
|
relid,
|
||||||
accessmtd,
|
accessmtd,
|
||||||
relfilenode,
|
relfilenumber,
|
||||||
reltablespace,
|
reltablespace,
|
||||||
shared_relation,
|
shared_relation,
|
||||||
mapped_relation,
|
mapped_relation,
|
||||||
@ -385,11 +385,11 @@ heap_create(const char *relname,
|
|||||||
if (create_storage)
|
if (create_storage)
|
||||||
{
|
{
|
||||||
if (RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind))
|
if (RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind))
|
||||||
table_relation_set_new_filenode(rel, &rel->rd_node,
|
table_relation_set_new_filelocator(rel, &rel->rd_locator,
|
||||||
relpersistence,
|
relpersistence,
|
||||||
relfrozenxid, relminmxid);
|
relfrozenxid, relminmxid);
|
||||||
else if (RELKIND_HAS_STORAGE(rel->rd_rel->relkind))
|
else if (RELKIND_HAS_STORAGE(rel->rd_rel->relkind))
|
||||||
RelationCreateStorage(rel->rd_node, relpersistence, true);
|
RelationCreateStorage(rel->rd_locator, relpersistence, true);
|
||||||
else
|
else
|
||||||
Assert(false);
|
Assert(false);
|
||||||
}
|
}
|
||||||
@ -1069,7 +1069,7 @@ AddNewRelationType(const char *typeName,
|
|||||||
* relkind: relkind for new rel
|
* relkind: relkind for new rel
|
||||||
* relpersistence: rel's persistence status (permanent, temp, or unlogged)
|
* relpersistence: rel's persistence status (permanent, temp, or unlogged)
|
||||||
* shared_relation: true if it's to be a shared relation
|
* shared_relation: true if it's to be a shared relation
|
||||||
* mapped_relation: true if the relation will use the relfilenode map
|
* mapped_relation: true if the relation will use the relfilenumber map
|
||||||
* oncommit: ON COMMIT marking (only relevant if it's a temp table)
|
* oncommit: ON COMMIT marking (only relevant if it's a temp table)
|
||||||
* reloptions: reloptions in Datum form, or (Datum) 0 if none
|
* reloptions: reloptions in Datum form, or (Datum) 0 if none
|
||||||
* use_user_acl: true if should look for user-defined default permissions;
|
* use_user_acl: true if should look for user-defined default permissions;
|
||||||
@ -1115,7 +1115,7 @@ heap_create_with_catalog(const char *relname,
|
|||||||
Oid new_type_oid;
|
Oid new_type_oid;
|
||||||
|
|
||||||
/* By default set to InvalidOid unless overridden by binary-upgrade */
|
/* By default set to InvalidOid unless overridden by binary-upgrade */
|
||||||
Oid relfilenode = InvalidOid;
|
RelFileNumber relfilenumber = InvalidRelFileNumber;
|
||||||
TransactionId relfrozenxid;
|
TransactionId relfrozenxid;
|
||||||
MultiXactId relminmxid;
|
MultiXactId relminmxid;
|
||||||
|
|
||||||
@ -1173,12 +1173,12 @@ heap_create_with_catalog(const char *relname,
|
|||||||
/*
|
/*
|
||||||
* Allocate an OID for the relation, unless we were told what to use.
|
* Allocate an OID for the relation, unless we were told what to use.
|
||||||
*
|
*
|
||||||
* The OID will be the relfilenode as well, so make sure it doesn't
|
* The OID will be the relfilenumber as well, so make sure it doesn't
|
||||||
* collide with either pg_class OIDs or existing physical files.
|
* collide with either pg_class OIDs or existing physical files.
|
||||||
*/
|
*/
|
||||||
if (!OidIsValid(relid))
|
if (!OidIsValid(relid))
|
||||||
{
|
{
|
||||||
/* Use binary-upgrade override for pg_class.oid and relfilenode */
|
/* Use binary-upgrade override for pg_class.oid and relfilenumber */
|
||||||
if (IsBinaryUpgrade)
|
if (IsBinaryUpgrade)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -1196,13 +1196,13 @@ heap_create_with_catalog(const char *relname,
|
|||||||
relid = binary_upgrade_next_toast_pg_class_oid;
|
relid = binary_upgrade_next_toast_pg_class_oid;
|
||||||
binary_upgrade_next_toast_pg_class_oid = InvalidOid;
|
binary_upgrade_next_toast_pg_class_oid = InvalidOid;
|
||||||
|
|
||||||
if (!OidIsValid(binary_upgrade_next_toast_pg_class_relfilenode))
|
if (!RelFileNumberIsValid(binary_upgrade_next_toast_pg_class_relfilenumber))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("toast relfilenode value not set when in binary upgrade mode")));
|
errmsg("toast relfilenumber value not set when in binary upgrade mode")));
|
||||||
|
|
||||||
relfilenode = binary_upgrade_next_toast_pg_class_relfilenode;
|
relfilenumber = binary_upgrade_next_toast_pg_class_relfilenumber;
|
||||||
binary_upgrade_next_toast_pg_class_relfilenode = InvalidOid;
|
binary_upgrade_next_toast_pg_class_relfilenumber = InvalidRelFileNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1217,19 +1217,19 @@ heap_create_with_catalog(const char *relname,
|
|||||||
|
|
||||||
if (RELKIND_HAS_STORAGE(relkind))
|
if (RELKIND_HAS_STORAGE(relkind))
|
||||||
{
|
{
|
||||||
if (!OidIsValid(binary_upgrade_next_heap_pg_class_relfilenode))
|
if (!RelFileNumberIsValid(binary_upgrade_next_heap_pg_class_relfilenumber))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("relfilenode value not set when in binary upgrade mode")));
|
errmsg("relfilenumber value not set when in binary upgrade mode")));
|
||||||
|
|
||||||
relfilenode = binary_upgrade_next_heap_pg_class_relfilenode;
|
relfilenumber = binary_upgrade_next_heap_pg_class_relfilenumber;
|
||||||
binary_upgrade_next_heap_pg_class_relfilenode = InvalidOid;
|
binary_upgrade_next_heap_pg_class_relfilenumber = InvalidRelFileNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OidIsValid(relid))
|
if (!OidIsValid(relid))
|
||||||
relid = GetNewRelFileNode(reltablespace, pg_class_desc,
|
relid = GetNewRelFileNumber(reltablespace, pg_class_desc,
|
||||||
relpersistence);
|
relpersistence);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1273,7 +1273,7 @@ heap_create_with_catalog(const char *relname,
|
|||||||
relnamespace,
|
relnamespace,
|
||||||
reltablespace,
|
reltablespace,
|
||||||
relid,
|
relid,
|
||||||
relfilenode,
|
relfilenumber,
|
||||||
accessmtd,
|
accessmtd,
|
||||||
tupdesc,
|
tupdesc,
|
||||||
relkind,
|
relkind,
|
||||||
|
@ -87,7 +87,8 @@
|
|||||||
|
|
||||||
/* Potentially set by pg_upgrade_support functions */
|
/* Potentially set by pg_upgrade_support functions */
|
||||||
Oid binary_upgrade_next_index_pg_class_oid = InvalidOid;
|
Oid binary_upgrade_next_index_pg_class_oid = InvalidOid;
|
||||||
Oid binary_upgrade_next_index_pg_class_relfilenode = InvalidOid;
|
RelFileNumber binary_upgrade_next_index_pg_class_relfilenumber =
|
||||||
|
InvalidRelFileNumber;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pointer-free representation of variables used when reindexing system
|
* Pointer-free representation of variables used when reindexing system
|
||||||
@ -662,8 +663,8 @@ UpdateIndexRelation(Oid indexoid,
|
|||||||
* parent index; otherwise InvalidOid.
|
* parent index; otherwise InvalidOid.
|
||||||
* parentConstraintId: if creating a constraint on a partition, the OID
|
* parentConstraintId: if creating a constraint on a partition, the OID
|
||||||
* of the constraint in the parent; otherwise InvalidOid.
|
* of the constraint in the parent; otherwise InvalidOid.
|
||||||
* relFileNode: normally, pass InvalidOid to get new storage. May be
|
* relFileNumber: normally, pass InvalidRelFileNumber to get new storage.
|
||||||
* nonzero to attach an existing valid build.
|
* May be nonzero to attach an existing valid build.
|
||||||
* indexInfo: same info executor uses to insert into the index
|
* indexInfo: same info executor uses to insert into the index
|
||||||
* indexColNames: column names to use for index (List of char *)
|
* indexColNames: column names to use for index (List of char *)
|
||||||
* accessMethodObjectId: OID of index AM to use
|
* accessMethodObjectId: OID of index AM to use
|
||||||
@ -703,7 +704,7 @@ index_create(Relation heapRelation,
|
|||||||
Oid indexRelationId,
|
Oid indexRelationId,
|
||||||
Oid parentIndexRelid,
|
Oid parentIndexRelid,
|
||||||
Oid parentConstraintId,
|
Oid parentConstraintId,
|
||||||
Oid relFileNode,
|
RelFileNumber relFileNumber,
|
||||||
IndexInfo *indexInfo,
|
IndexInfo *indexInfo,
|
||||||
List *indexColNames,
|
List *indexColNames,
|
||||||
Oid accessMethodObjectId,
|
Oid accessMethodObjectId,
|
||||||
@ -735,7 +736,7 @@ index_create(Relation heapRelation,
|
|||||||
char relkind;
|
char relkind;
|
||||||
TransactionId relfrozenxid;
|
TransactionId relfrozenxid;
|
||||||
MultiXactId relminmxid;
|
MultiXactId relminmxid;
|
||||||
bool create_storage = !OidIsValid(relFileNode);
|
bool create_storage = !RelFileNumberIsValid(relFileNumber);
|
||||||
|
|
||||||
/* constraint flags can only be set when a constraint is requested */
|
/* constraint flags can only be set when a constraint is requested */
|
||||||
Assert((constr_flags == 0) ||
|
Assert((constr_flags == 0) ||
|
||||||
@ -751,7 +752,7 @@ index_create(Relation heapRelation,
|
|||||||
/*
|
/*
|
||||||
* The index will be in the same namespace as its parent table, and is
|
* The index will be in the same namespace as its parent table, and is
|
||||||
* shared across databases if and only if the parent is. Likewise, it
|
* shared across databases if and only if the parent is. Likewise, it
|
||||||
* will use the relfilenode map if and only if the parent does; and it
|
* will use the relfilenumber map if and only if the parent does; and it
|
||||||
* inherits the parent's relpersistence.
|
* inherits the parent's relpersistence.
|
||||||
*/
|
*/
|
||||||
namespaceId = RelationGetNamespace(heapRelation);
|
namespaceId = RelationGetNamespace(heapRelation);
|
||||||
@ -902,12 +903,12 @@ index_create(Relation heapRelation,
|
|||||||
/*
|
/*
|
||||||
* Allocate an OID for the index, unless we were told what to use.
|
* Allocate an OID for the index, unless we were told what to use.
|
||||||
*
|
*
|
||||||
* The OID will be the relfilenode as well, so make sure it doesn't
|
* The OID will be the relfilenumber as well, so make sure it doesn't
|
||||||
* collide with either pg_class OIDs or existing physical files.
|
* collide with either pg_class OIDs or existing physical files.
|
||||||
*/
|
*/
|
||||||
if (!OidIsValid(indexRelationId))
|
if (!OidIsValid(indexRelationId))
|
||||||
{
|
{
|
||||||
/* Use binary-upgrade override for pg_class.oid and relfilenode */
|
/* Use binary-upgrade override for pg_class.oid and relfilenumber */
|
||||||
if (IsBinaryUpgrade)
|
if (IsBinaryUpgrade)
|
||||||
{
|
{
|
||||||
if (!OidIsValid(binary_upgrade_next_index_pg_class_oid))
|
if (!OidIsValid(binary_upgrade_next_index_pg_class_oid))
|
||||||
@ -918,14 +919,14 @@ index_create(Relation heapRelation,
|
|||||||
indexRelationId = binary_upgrade_next_index_pg_class_oid;
|
indexRelationId = binary_upgrade_next_index_pg_class_oid;
|
||||||
binary_upgrade_next_index_pg_class_oid = InvalidOid;
|
binary_upgrade_next_index_pg_class_oid = InvalidOid;
|
||||||
|
|
||||||
/* Override the index relfilenode */
|
/* Override the index relfilenumber */
|
||||||
if ((relkind == RELKIND_INDEX) &&
|
if ((relkind == RELKIND_INDEX) &&
|
||||||
(!OidIsValid(binary_upgrade_next_index_pg_class_relfilenode)))
|
(!RelFileNumberIsValid(binary_upgrade_next_index_pg_class_relfilenumber)))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("index relfilenode value not set when in binary upgrade mode")));
|
errmsg("index relfilenumber value not set when in binary upgrade mode")));
|
||||||
relFileNode = binary_upgrade_next_index_pg_class_relfilenode;
|
relFileNumber = binary_upgrade_next_index_pg_class_relfilenumber;
|
||||||
binary_upgrade_next_index_pg_class_relfilenode = InvalidOid;
|
binary_upgrade_next_index_pg_class_relfilenumber = InvalidRelFileNumber;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that we want create_storage = true for binary upgrade. The
|
* Note that we want create_storage = true for binary upgrade. The
|
||||||
@ -937,7 +938,7 @@ index_create(Relation heapRelation,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
indexRelationId =
|
indexRelationId =
|
||||||
GetNewRelFileNode(tableSpaceId, pg_class, relpersistence);
|
GetNewRelFileNumber(tableSpaceId, pg_class, relpersistence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -950,7 +951,7 @@ index_create(Relation heapRelation,
|
|||||||
namespaceId,
|
namespaceId,
|
||||||
tableSpaceId,
|
tableSpaceId,
|
||||||
indexRelationId,
|
indexRelationId,
|
||||||
relFileNode,
|
relFileNumber,
|
||||||
accessMethodObjectId,
|
accessMethodObjectId,
|
||||||
indexTupDesc,
|
indexTupDesc,
|
||||||
relkind,
|
relkind,
|
||||||
@ -1408,7 +1409,7 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
|
|||||||
InvalidOid, /* indexRelationId */
|
InvalidOid, /* indexRelationId */
|
||||||
InvalidOid, /* parentIndexRelid */
|
InvalidOid, /* parentIndexRelid */
|
||||||
InvalidOid, /* parentConstraintId */
|
InvalidOid, /* parentConstraintId */
|
||||||
InvalidOid, /* relFileNode */
|
InvalidRelFileNumber, /* relFileNumber */
|
||||||
newInfo,
|
newInfo,
|
||||||
indexColNames,
|
indexColNames,
|
||||||
indexRelation->rd_rel->relam,
|
indexRelation->rd_rel->relam,
|
||||||
@ -3024,7 +3025,7 @@ index_build(Relation heapRelation,
|
|||||||
* it -- but we must first check whether one already exists. If, for
|
* it -- but we must first check whether one already exists. If, for
|
||||||
* example, an unlogged relation is truncated in the transaction that
|
* example, an unlogged relation is truncated in the transaction that
|
||||||
* created it, or truncated twice in a subsequent transaction, the
|
* created it, or truncated twice in a subsequent transaction, the
|
||||||
* relfilenode won't change, and nothing needs to be done here.
|
* relfilenumber won't change, and nothing needs to be done here.
|
||||||
*/
|
*/
|
||||||
if (indexRelation->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
|
if (indexRelation->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
|
||||||
!smgrexists(RelationGetSmgr(indexRelation), INIT_FORKNUM))
|
!smgrexists(RelationGetSmgr(indexRelation), INIT_FORKNUM))
|
||||||
@ -3681,7 +3682,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
|
|||||||
* Schedule unlinking of the old index storage at transaction commit.
|
* Schedule unlinking of the old index storage at transaction commit.
|
||||||
*/
|
*/
|
||||||
RelationDropStorage(iRel);
|
RelationDropStorage(iRel);
|
||||||
RelationAssumeNewRelfilenode(iRel);
|
RelationAssumeNewRelfilelocator(iRel);
|
||||||
|
|
||||||
/* Make sure the reltablespace change is visible */
|
/* Make sure the reltablespace change is visible */
|
||||||
CommandCounterIncrement();
|
CommandCounterIncrement();
|
||||||
@ -3711,7 +3712,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
|
|||||||
SetReindexProcessing(heapId, indexId);
|
SetReindexProcessing(heapId, indexId);
|
||||||
|
|
||||||
/* Create a new physical relation for the index */
|
/* Create a new physical relation for the index */
|
||||||
RelationSetNewRelfilenode(iRel, persistence);
|
RelationSetNewRelfilenumber(iRel, persistence);
|
||||||
|
|
||||||
/* Initialize the index and rebuild */
|
/* Initialize the index and rebuild */
|
||||||
/* Note: we do not need to re-establish pkey setting */
|
/* Note: we do not need to re-establish pkey setting */
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
int wal_skip_threshold = 2048; /* in kilobytes */
|
int wal_skip_threshold = 2048; /* in kilobytes */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We keep a list of all relations (represented as RelFileNode values)
|
* We keep a list of all relations (represented as RelFileLocator values)
|
||||||
* that have been created or deleted in the current transaction. When
|
* that have been created or deleted in the current transaction. When
|
||||||
* a relation is created, we create the physical file immediately, but
|
* a relation is created, we create the physical file immediately, but
|
||||||
* remember it so that we can delete the file again if the current
|
* remember it so that we can delete the file again if the current
|
||||||
@ -59,7 +59,7 @@ int wal_skip_threshold = 2048; /* in kilobytes */
|
|||||||
|
|
||||||
typedef struct PendingRelDelete
|
typedef struct PendingRelDelete
|
||||||
{
|
{
|
||||||
RelFileNode relnode; /* relation that may need to be deleted */
|
RelFileLocator rlocator; /* relation that may need to be deleted */
|
||||||
BackendId backend; /* InvalidBackendId if not a temp rel */
|
BackendId backend; /* InvalidBackendId if not a temp rel */
|
||||||
bool atCommit; /* T=delete at commit; F=delete at abort */
|
bool atCommit; /* T=delete at commit; F=delete at abort */
|
||||||
int nestLevel; /* xact nesting level of request */
|
int nestLevel; /* xact nesting level of request */
|
||||||
@ -68,7 +68,7 @@ typedef struct PendingRelDelete
|
|||||||
|
|
||||||
typedef struct PendingRelSync
|
typedef struct PendingRelSync
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
bool is_truncated; /* Has the file experienced truncation? */
|
bool is_truncated; /* Has the file experienced truncation? */
|
||||||
} PendingRelSync;
|
} PendingRelSync;
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ static HTAB *pendingSyncHash = NULL;
|
|||||||
* Queue an at-commit fsync.
|
* Queue an at-commit fsync.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AddPendingSync(const RelFileNode *rnode)
|
AddPendingSync(const RelFileLocator *rlocator)
|
||||||
{
|
{
|
||||||
PendingRelSync *pending;
|
PendingRelSync *pending;
|
||||||
bool found;
|
bool found;
|
||||||
@ -91,14 +91,14 @@ AddPendingSync(const RelFileNode *rnode)
|
|||||||
{
|
{
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
ctl.keysize = sizeof(RelFileNode);
|
ctl.keysize = sizeof(RelFileLocator);
|
||||||
ctl.entrysize = sizeof(PendingRelSync);
|
ctl.entrysize = sizeof(PendingRelSync);
|
||||||
ctl.hcxt = TopTransactionContext;
|
ctl.hcxt = TopTransactionContext;
|
||||||
pendingSyncHash = hash_create("pending sync hash", 16, &ctl,
|
pendingSyncHash = hash_create("pending sync hash", 16, &ctl,
|
||||||
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
|
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
pending = hash_search(pendingSyncHash, rnode, HASH_ENTER, &found);
|
pending = hash_search(pendingSyncHash, rlocator, HASH_ENTER, &found);
|
||||||
Assert(!found);
|
Assert(!found);
|
||||||
pending->is_truncated = false;
|
pending->is_truncated = false;
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ AddPendingSync(const RelFileNode *rnode)
|
|||||||
* pass register_delete = false.
|
* pass register_delete = false.
|
||||||
*/
|
*/
|
||||||
SMgrRelation
|
SMgrRelation
|
||||||
RelationCreateStorage(RelFileNode rnode, char relpersistence,
|
RelationCreateStorage(RelFileLocator rlocator, char relpersistence,
|
||||||
bool register_delete)
|
bool register_delete)
|
||||||
{
|
{
|
||||||
SMgrRelation srel;
|
SMgrRelation srel;
|
||||||
@ -145,11 +145,11 @@ RelationCreateStorage(RelFileNode rnode, char relpersistence,
|
|||||||
return NULL; /* placate compiler */
|
return NULL; /* placate compiler */
|
||||||
}
|
}
|
||||||
|
|
||||||
srel = smgropen(rnode, backend);
|
srel = smgropen(rlocator, backend);
|
||||||
smgrcreate(srel, MAIN_FORKNUM, false);
|
smgrcreate(srel, MAIN_FORKNUM, false);
|
||||||
|
|
||||||
if (needs_wal)
|
if (needs_wal)
|
||||||
log_smgrcreate(&srel->smgr_rnode.node, MAIN_FORKNUM);
|
log_smgrcreate(&srel->smgr_rlocator.locator, MAIN_FORKNUM);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add the relation to the list of stuff to delete at abort, if we are
|
* Add the relation to the list of stuff to delete at abort, if we are
|
||||||
@ -161,7 +161,7 @@ RelationCreateStorage(RelFileNode rnode, char relpersistence,
|
|||||||
|
|
||||||
pending = (PendingRelDelete *)
|
pending = (PendingRelDelete *)
|
||||||
MemoryContextAlloc(TopMemoryContext, sizeof(PendingRelDelete));
|
MemoryContextAlloc(TopMemoryContext, sizeof(PendingRelDelete));
|
||||||
pending->relnode = rnode;
|
pending->rlocator = rlocator;
|
||||||
pending->backend = backend;
|
pending->backend = backend;
|
||||||
pending->atCommit = false; /* delete if abort */
|
pending->atCommit = false; /* delete if abort */
|
||||||
pending->nestLevel = GetCurrentTransactionNestLevel();
|
pending->nestLevel = GetCurrentTransactionNestLevel();
|
||||||
@ -172,7 +172,7 @@ RelationCreateStorage(RelFileNode rnode, char relpersistence,
|
|||||||
if (relpersistence == RELPERSISTENCE_PERMANENT && !XLogIsNeeded())
|
if (relpersistence == RELPERSISTENCE_PERMANENT && !XLogIsNeeded())
|
||||||
{
|
{
|
||||||
Assert(backend == InvalidBackendId);
|
Assert(backend == InvalidBackendId);
|
||||||
AddPendingSync(&rnode);
|
AddPendingSync(&rlocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
return srel;
|
return srel;
|
||||||
@ -182,14 +182,14 @@ RelationCreateStorage(RelFileNode rnode, char relpersistence,
|
|||||||
* Perform XLogInsert of an XLOG_SMGR_CREATE record to WAL.
|
* Perform XLogInsert of an XLOG_SMGR_CREATE record to WAL.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
log_smgrcreate(const RelFileNode *rnode, ForkNumber forkNum)
|
log_smgrcreate(const RelFileLocator *rlocator, ForkNumber forkNum)
|
||||||
{
|
{
|
||||||
xl_smgr_create xlrec;
|
xl_smgr_create xlrec;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make an XLOG entry reporting the file creation.
|
* Make an XLOG entry reporting the file creation.
|
||||||
*/
|
*/
|
||||||
xlrec.rnode = *rnode;
|
xlrec.rlocator = *rlocator;
|
||||||
xlrec.forkNum = forkNum;
|
xlrec.forkNum = forkNum;
|
||||||
|
|
||||||
XLogBeginInsert();
|
XLogBeginInsert();
|
||||||
@ -209,7 +209,7 @@ RelationDropStorage(Relation rel)
|
|||||||
/* Add the relation to the list of stuff to delete at commit */
|
/* Add the relation to the list of stuff to delete at commit */
|
||||||
pending = (PendingRelDelete *)
|
pending = (PendingRelDelete *)
|
||||||
MemoryContextAlloc(TopMemoryContext, sizeof(PendingRelDelete));
|
MemoryContextAlloc(TopMemoryContext, sizeof(PendingRelDelete));
|
||||||
pending->relnode = rel->rd_node;
|
pending->rlocator = rel->rd_locator;
|
||||||
pending->backend = rel->rd_backend;
|
pending->backend = rel->rd_backend;
|
||||||
pending->atCommit = true; /* delete if commit */
|
pending->atCommit = true; /* delete if commit */
|
||||||
pending->nestLevel = GetCurrentTransactionNestLevel();
|
pending->nestLevel = GetCurrentTransactionNestLevel();
|
||||||
@ -247,7 +247,7 @@ RelationDropStorage(Relation rel)
|
|||||||
* No-op if the relation is not among those scheduled for deletion.
|
* No-op if the relation is not among those scheduled for deletion.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
RelationPreserveStorage(RelFileNode rnode, bool atCommit)
|
RelationPreserveStorage(RelFileLocator rlocator, bool atCommit)
|
||||||
{
|
{
|
||||||
PendingRelDelete *pending;
|
PendingRelDelete *pending;
|
||||||
PendingRelDelete *prev;
|
PendingRelDelete *prev;
|
||||||
@ -257,7 +257,7 @@ RelationPreserveStorage(RelFileNode rnode, bool atCommit)
|
|||||||
for (pending = pendingDeletes; pending != NULL; pending = next)
|
for (pending = pendingDeletes; pending != NULL; pending = next)
|
||||||
{
|
{
|
||||||
next = pending->next;
|
next = pending->next;
|
||||||
if (RelFileNodeEquals(rnode, pending->relnode)
|
if (RelFileLocatorEquals(rlocator, pending->rlocator)
|
||||||
&& pending->atCommit == atCommit)
|
&& pending->atCommit == atCommit)
|
||||||
{
|
{
|
||||||
/* unlink and delete list entry */
|
/* unlink and delete list entry */
|
||||||
@ -369,7 +369,7 @@ RelationTruncate(Relation rel, BlockNumber nblocks)
|
|||||||
xl_smgr_truncate xlrec;
|
xl_smgr_truncate xlrec;
|
||||||
|
|
||||||
xlrec.blkno = nblocks;
|
xlrec.blkno = nblocks;
|
||||||
xlrec.rnode = rel->rd_node;
|
xlrec.rlocator = rel->rd_locator;
|
||||||
xlrec.flags = SMGR_TRUNCATE_ALL;
|
xlrec.flags = SMGR_TRUNCATE_ALL;
|
||||||
|
|
||||||
XLogBeginInsert();
|
XLogBeginInsert();
|
||||||
@ -428,7 +428,7 @@ RelationPreTruncate(Relation rel)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
pending = hash_search(pendingSyncHash,
|
pending = hash_search(pendingSyncHash,
|
||||||
&(RelationGetSmgr(rel)->smgr_rnode.node),
|
&(RelationGetSmgr(rel)->smgr_rlocator.locator),
|
||||||
HASH_FIND, NULL);
|
HASH_FIND, NULL);
|
||||||
if (pending)
|
if (pending)
|
||||||
pending->is_truncated = true;
|
pending->is_truncated = true;
|
||||||
@ -472,7 +472,7 @@ RelationCopyStorage(SMgrRelation src, SMgrRelation dst,
|
|||||||
* We need to log the copied data in WAL iff WAL archiving/streaming is
|
* We need to log the copied data in WAL iff WAL archiving/streaming is
|
||||||
* enabled AND it's a permanent relation. This gives the same answer as
|
* enabled AND it's a permanent relation. This gives the same answer as
|
||||||
* "RelationNeedsWAL(rel) || copying_initfork", because we know the
|
* "RelationNeedsWAL(rel) || copying_initfork", because we know the
|
||||||
* current operation created a new relfilenode.
|
* current operation created new relation storage.
|
||||||
*/
|
*/
|
||||||
use_wal = XLogIsNeeded() &&
|
use_wal = XLogIsNeeded() &&
|
||||||
(relpersistence == RELPERSISTENCE_PERMANENT || copying_initfork);
|
(relpersistence == RELPERSISTENCE_PERMANENT || copying_initfork);
|
||||||
@ -496,8 +496,8 @@ RelationCopyStorage(SMgrRelation src, SMgrRelation dst,
|
|||||||
* (errcontext callbacks shouldn't be risking any such thing, but
|
* (errcontext callbacks shouldn't be risking any such thing, but
|
||||||
* people have been known to forget that rule.)
|
* people have been known to forget that rule.)
|
||||||
*/
|
*/
|
||||||
char *relpath = relpathbackend(src->smgr_rnode.node,
|
char *relpath = relpathbackend(src->smgr_rlocator.locator,
|
||||||
src->smgr_rnode.backend,
|
src->smgr_rlocator.backend,
|
||||||
forkNum);
|
forkNum);
|
||||||
|
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -512,7 +512,7 @@ RelationCopyStorage(SMgrRelation src, SMgrRelation dst,
|
|||||||
* space.
|
* space.
|
||||||
*/
|
*/
|
||||||
if (use_wal)
|
if (use_wal)
|
||||||
log_newpage(&dst->smgr_rnode.node, forkNum, blkno, page, false);
|
log_newpage(&dst->smgr_rlocator.locator, forkNum, blkno, page, false);
|
||||||
|
|
||||||
PageSetChecksumInplace(page, blkno);
|
PageSetChecksumInplace(page, blkno);
|
||||||
|
|
||||||
@ -538,19 +538,19 @@ RelationCopyStorage(SMgrRelation src, SMgrRelation dst,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RelFileNodeSkippingWAL
|
* RelFileLocatorSkippingWAL
|
||||||
* Check if a BM_PERMANENT relfilenode is using WAL.
|
* Check if a BM_PERMANENT relfilelocator is using WAL.
|
||||||
*
|
*
|
||||||
* Changes of certain relfilenodes must not write WAL; see "Skipping WAL for
|
* Changes to certain relations must not write WAL; see "Skipping WAL for
|
||||||
* New RelFileNode" in src/backend/access/transam/README. Though it is known
|
* New RelFileLocator" in src/backend/access/transam/README. Though it is
|
||||||
* from Relation efficiently, this function is intended for the code paths not
|
* known from Relation efficiently, this function is intended for the code
|
||||||
* having access to Relation.
|
* paths not having access to Relation.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
RelFileNodeSkippingWAL(RelFileNode rnode)
|
RelFileLocatorSkippingWAL(RelFileLocator rlocator)
|
||||||
{
|
{
|
||||||
if (!pendingSyncHash ||
|
if (!pendingSyncHash ||
|
||||||
hash_search(pendingSyncHash, &rnode, HASH_FIND, NULL) == NULL)
|
hash_search(pendingSyncHash, &rlocator, HASH_FIND, NULL) == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -566,7 +566,7 @@ EstimatePendingSyncsSpace(void)
|
|||||||
long entries;
|
long entries;
|
||||||
|
|
||||||
entries = pendingSyncHash ? hash_get_num_entries(pendingSyncHash) : 0;
|
entries = pendingSyncHash ? hash_get_num_entries(pendingSyncHash) : 0;
|
||||||
return mul_size(1 + entries, sizeof(RelFileNode));
|
return mul_size(1 + entries, sizeof(RelFileLocator));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -581,57 +581,58 @@ SerializePendingSyncs(Size maxSize, char *startAddress)
|
|||||||
HASH_SEQ_STATUS scan;
|
HASH_SEQ_STATUS scan;
|
||||||
PendingRelSync *sync;
|
PendingRelSync *sync;
|
||||||
PendingRelDelete *delete;
|
PendingRelDelete *delete;
|
||||||
RelFileNode *src;
|
RelFileLocator *src;
|
||||||
RelFileNode *dest = (RelFileNode *) startAddress;
|
RelFileLocator *dest = (RelFileLocator *) startAddress;
|
||||||
|
|
||||||
if (!pendingSyncHash)
|
if (!pendingSyncHash)
|
||||||
goto terminate;
|
goto terminate;
|
||||||
|
|
||||||
/* Create temporary hash to collect active relfilenodes */
|
/* Create temporary hash to collect active relfilelocators */
|
||||||
ctl.keysize = sizeof(RelFileNode);
|
ctl.keysize = sizeof(RelFileLocator);
|
||||||
ctl.entrysize = sizeof(RelFileNode);
|
ctl.entrysize = sizeof(RelFileLocator);
|
||||||
ctl.hcxt = CurrentMemoryContext;
|
ctl.hcxt = CurrentMemoryContext;
|
||||||
tmphash = hash_create("tmp relfilenodes",
|
tmphash = hash_create("tmp relfilelocators",
|
||||||
hash_get_num_entries(pendingSyncHash), &ctl,
|
hash_get_num_entries(pendingSyncHash), &ctl,
|
||||||
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
|
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
|
||||||
|
|
||||||
/* collect all rnodes from pending syncs */
|
/* collect all rlocator from pending syncs */
|
||||||
hash_seq_init(&scan, pendingSyncHash);
|
hash_seq_init(&scan, pendingSyncHash);
|
||||||
while ((sync = (PendingRelSync *) hash_seq_search(&scan)))
|
while ((sync = (PendingRelSync *) hash_seq_search(&scan)))
|
||||||
(void) hash_search(tmphash, &sync->rnode, HASH_ENTER, NULL);
|
(void) hash_search(tmphash, &sync->rlocator, HASH_ENTER, NULL);
|
||||||
|
|
||||||
/* remove deleted rnodes */
|
/* remove deleted rnodes */
|
||||||
for (delete = pendingDeletes; delete != NULL; delete = delete->next)
|
for (delete = pendingDeletes; delete != NULL; delete = delete->next)
|
||||||
if (delete->atCommit)
|
if (delete->atCommit)
|
||||||
(void) hash_search(tmphash, (void *) &delete->relnode,
|
(void) hash_search(tmphash, (void *) &delete->rlocator,
|
||||||
HASH_REMOVE, NULL);
|
HASH_REMOVE, NULL);
|
||||||
|
|
||||||
hash_seq_init(&scan, tmphash);
|
hash_seq_init(&scan, tmphash);
|
||||||
while ((src = (RelFileNode *) hash_seq_search(&scan)))
|
while ((src = (RelFileLocator *) hash_seq_search(&scan)))
|
||||||
*dest++ = *src;
|
*dest++ = *src;
|
||||||
|
|
||||||
hash_destroy(tmphash);
|
hash_destroy(tmphash);
|
||||||
|
|
||||||
terminate:
|
terminate:
|
||||||
MemSet(dest, 0, sizeof(RelFileNode));
|
MemSet(dest, 0, sizeof(RelFileLocator));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RestorePendingSyncs
|
* RestorePendingSyncs
|
||||||
* Restore syncs within a parallel worker.
|
* Restore syncs within a parallel worker.
|
||||||
*
|
*
|
||||||
* RelationNeedsWAL() and RelFileNodeSkippingWAL() must offer the correct
|
* RelationNeedsWAL() and RelFileLocatorSkippingWAL() must offer the correct
|
||||||
* answer to parallel workers. Only smgrDoPendingSyncs() reads the
|
* answer to parallel workers. Only smgrDoPendingSyncs() reads the
|
||||||
* is_truncated field, at end of transaction. Hence, don't restore it.
|
* is_truncated field, at end of transaction. Hence, don't restore it.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
RestorePendingSyncs(char *startAddress)
|
RestorePendingSyncs(char *startAddress)
|
||||||
{
|
{
|
||||||
RelFileNode *rnode;
|
RelFileLocator *rlocator;
|
||||||
|
|
||||||
Assert(pendingSyncHash == NULL);
|
Assert(pendingSyncHash == NULL);
|
||||||
for (rnode = (RelFileNode *) startAddress; rnode->relNode != 0; rnode++)
|
for (rlocator = (RelFileLocator *) startAddress; rlocator->relNumber != 0;
|
||||||
AddPendingSync(rnode);
|
rlocator++)
|
||||||
|
AddPendingSync(rlocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -677,7 +678,7 @@ smgrDoPendingDeletes(bool isCommit)
|
|||||||
{
|
{
|
||||||
SMgrRelation srel;
|
SMgrRelation srel;
|
||||||
|
|
||||||
srel = smgropen(pending->relnode, pending->backend);
|
srel = smgropen(pending->rlocator, pending->backend);
|
||||||
|
|
||||||
/* allocate the initial array, or extend it, if needed */
|
/* allocate the initial array, or extend it, if needed */
|
||||||
if (maxrels == 0)
|
if (maxrels == 0)
|
||||||
@ -747,7 +748,7 @@ smgrDoPendingSyncs(bool isCommit, bool isParallelWorker)
|
|||||||
/* Skip syncing nodes that smgrDoPendingDeletes() will delete. */
|
/* Skip syncing nodes that smgrDoPendingDeletes() will delete. */
|
||||||
for (pending = pendingDeletes; pending != NULL; pending = pending->next)
|
for (pending = pendingDeletes; pending != NULL; pending = pending->next)
|
||||||
if (pending->atCommit)
|
if (pending->atCommit)
|
||||||
(void) hash_search(pendingSyncHash, (void *) &pending->relnode,
|
(void) hash_search(pendingSyncHash, (void *) &pending->rlocator,
|
||||||
HASH_REMOVE, NULL);
|
HASH_REMOVE, NULL);
|
||||||
|
|
||||||
hash_seq_init(&scan, pendingSyncHash);
|
hash_seq_init(&scan, pendingSyncHash);
|
||||||
@ -758,7 +759,7 @@ smgrDoPendingSyncs(bool isCommit, bool isParallelWorker)
|
|||||||
BlockNumber total_blocks = 0;
|
BlockNumber total_blocks = 0;
|
||||||
SMgrRelation srel;
|
SMgrRelation srel;
|
||||||
|
|
||||||
srel = smgropen(pendingsync->rnode, InvalidBackendId);
|
srel = smgropen(pendingsync->rlocator, InvalidBackendId);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We emit newpage WAL records for smaller relations.
|
* We emit newpage WAL records for smaller relations.
|
||||||
@ -832,7 +833,7 @@ smgrDoPendingSyncs(bool isCommit, bool isParallelWorker)
|
|||||||
* page including any unused space. ReadBufferExtended()
|
* page including any unused space. ReadBufferExtended()
|
||||||
* counts some pgstat events; unfortunately, we discard them.
|
* counts some pgstat events; unfortunately, we discard them.
|
||||||
*/
|
*/
|
||||||
rel = CreateFakeRelcacheEntry(srel->smgr_rnode.node);
|
rel = CreateFakeRelcacheEntry(srel->smgr_rlocator.locator);
|
||||||
log_newpage_range(rel, fork, 0, n, false);
|
log_newpage_range(rel, fork, 0, n, false);
|
||||||
FreeFakeRelcacheEntry(rel);
|
FreeFakeRelcacheEntry(rel);
|
||||||
}
|
}
|
||||||
@ -852,7 +853,7 @@ smgrDoPendingSyncs(bool isCommit, bool isParallelWorker)
|
|||||||
* smgrGetPendingDeletes() -- Get a list of non-temp relations to be deleted.
|
* smgrGetPendingDeletes() -- Get a list of non-temp relations to be deleted.
|
||||||
*
|
*
|
||||||
* The return value is the number of relations scheduled for termination.
|
* The return value is the number of relations scheduled for termination.
|
||||||
* *ptr is set to point to a freshly-palloc'd array of RelFileNodes.
|
* *ptr is set to point to a freshly-palloc'd array of RelFileLocators.
|
||||||
* If there are no relations to be deleted, *ptr is set to NULL.
|
* If there are no relations to be deleted, *ptr is set to NULL.
|
||||||
*
|
*
|
||||||
* Only non-temporary relations are included in the returned list. This is OK
|
* Only non-temporary relations are included in the returned list. This is OK
|
||||||
@ -866,11 +867,11 @@ smgrDoPendingSyncs(bool isCommit, bool isParallelWorker)
|
|||||||
* by upper-level transactions.
|
* by upper-level transactions.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
smgrGetPendingDeletes(bool forCommit, RelFileNode **ptr)
|
smgrGetPendingDeletes(bool forCommit, RelFileLocator **ptr)
|
||||||
{
|
{
|
||||||
int nestLevel = GetCurrentTransactionNestLevel();
|
int nestLevel = GetCurrentTransactionNestLevel();
|
||||||
int nrels;
|
int nrels;
|
||||||
RelFileNode *rptr;
|
RelFileLocator *rptr;
|
||||||
PendingRelDelete *pending;
|
PendingRelDelete *pending;
|
||||||
|
|
||||||
nrels = 0;
|
nrels = 0;
|
||||||
@ -885,14 +886,14 @@ smgrGetPendingDeletes(bool forCommit, RelFileNode **ptr)
|
|||||||
*ptr = NULL;
|
*ptr = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
rptr = (RelFileNode *) palloc(nrels * sizeof(RelFileNode));
|
rptr = (RelFileLocator *) palloc(nrels * sizeof(RelFileLocator));
|
||||||
*ptr = rptr;
|
*ptr = rptr;
|
||||||
for (pending = pendingDeletes; pending != NULL; pending = pending->next)
|
for (pending = pendingDeletes; pending != NULL; pending = pending->next)
|
||||||
{
|
{
|
||||||
if (pending->nestLevel >= nestLevel && pending->atCommit == forCommit
|
if (pending->nestLevel >= nestLevel && pending->atCommit == forCommit
|
||||||
&& pending->backend == InvalidBackendId)
|
&& pending->backend == InvalidBackendId)
|
||||||
{
|
{
|
||||||
*rptr = pending->relnode;
|
*rptr = pending->rlocator;
|
||||||
rptr++;
|
rptr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -967,7 +968,7 @@ smgr_redo(XLogReaderState *record)
|
|||||||
xl_smgr_create *xlrec = (xl_smgr_create *) XLogRecGetData(record);
|
xl_smgr_create *xlrec = (xl_smgr_create *) XLogRecGetData(record);
|
||||||
SMgrRelation reln;
|
SMgrRelation reln;
|
||||||
|
|
||||||
reln = smgropen(xlrec->rnode, InvalidBackendId);
|
reln = smgropen(xlrec->rlocator, InvalidBackendId);
|
||||||
smgrcreate(reln, xlrec->forkNum, true);
|
smgrcreate(reln, xlrec->forkNum, true);
|
||||||
}
|
}
|
||||||
else if (info == XLOG_SMGR_TRUNCATE)
|
else if (info == XLOG_SMGR_TRUNCATE)
|
||||||
@ -980,7 +981,7 @@ smgr_redo(XLogReaderState *record)
|
|||||||
int nforks = 0;
|
int nforks = 0;
|
||||||
bool need_fsm_vacuum = false;
|
bool need_fsm_vacuum = false;
|
||||||
|
|
||||||
reln = smgropen(xlrec->rnode, InvalidBackendId);
|
reln = smgropen(xlrec->rlocator, InvalidBackendId);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Forcibly create relation if it doesn't exist (which suggests that
|
* Forcibly create relation if it doesn't exist (which suggests that
|
||||||
@ -1015,11 +1016,11 @@ smgr_redo(XLogReaderState *record)
|
|||||||
nforks++;
|
nforks++;
|
||||||
|
|
||||||
/* Also tell xlogutils.c about it */
|
/* Also tell xlogutils.c about it */
|
||||||
XLogTruncateRelation(xlrec->rnode, MAIN_FORKNUM, xlrec->blkno);
|
XLogTruncateRelation(xlrec->rlocator, MAIN_FORKNUM, xlrec->blkno);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare for truncation of FSM and VM too */
|
/* Prepare for truncation of FSM and VM too */
|
||||||
rel = CreateFakeRelcacheEntry(xlrec->rnode);
|
rel = CreateFakeRelcacheEntry(xlrec->rlocator);
|
||||||
|
|
||||||
if ((xlrec->flags & SMGR_TRUNCATE_FSM) != 0 &&
|
if ((xlrec->flags & SMGR_TRUNCATE_FSM) != 0 &&
|
||||||
smgrexists(reln, FSM_FORKNUM))
|
smgrexists(reln, FSM_FORKNUM))
|
||||||
|
@ -293,7 +293,7 @@ cluster_multiple_rels(List *rtcs, ClusterParams *params)
|
|||||||
* cluster_rel
|
* cluster_rel
|
||||||
*
|
*
|
||||||
* This clusters the table by creating a new, clustered table and
|
* This clusters the table by creating a new, clustered table and
|
||||||
* swapping the relfilenodes of the new table and the old table, so
|
* swapping the relfilenumbers of the new table and the old table, so
|
||||||
* the OID of the original table is preserved. Thus we do not lose
|
* the OID of the original table is preserved. Thus we do not lose
|
||||||
* GRANT, inheritance nor references to this table (this was a bug
|
* GRANT, inheritance nor references to this table (this was a bug
|
||||||
* in releases through 7.3).
|
* in releases through 7.3).
|
||||||
@ -1025,8 +1025,8 @@ copy_table_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
|
|||||||
/*
|
/*
|
||||||
* Swap the physical files of two given relations.
|
* Swap the physical files of two given relations.
|
||||||
*
|
*
|
||||||
* We swap the physical identity (reltablespace, relfilenode) while keeping the
|
* We swap the physical identity (reltablespace, relfilenumber) while keeping
|
||||||
* same logical identities of the two relations. relpersistence is also
|
* the same logical identities of the two relations. relpersistence is also
|
||||||
* swapped, which is critical since it determines where buffers live for each
|
* swapped, which is critical since it determines where buffers live for each
|
||||||
* relation.
|
* relation.
|
||||||
*
|
*
|
||||||
@ -1061,9 +1061,9 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
|
|||||||
reltup2;
|
reltup2;
|
||||||
Form_pg_class relform1,
|
Form_pg_class relform1,
|
||||||
relform2;
|
relform2;
|
||||||
Oid relfilenode1,
|
RelFileNumber relfilenumber1,
|
||||||
relfilenode2;
|
relfilenumber2;
|
||||||
Oid swaptemp;
|
RelFileNumber swaptemp;
|
||||||
char swptmpchr;
|
char swptmpchr;
|
||||||
|
|
||||||
/* We need writable copies of both pg_class tuples. */
|
/* We need writable copies of both pg_class tuples. */
|
||||||
@ -1079,13 +1079,14 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
|
|||||||
elog(ERROR, "cache lookup failed for relation %u", r2);
|
elog(ERROR, "cache lookup failed for relation %u", r2);
|
||||||
relform2 = (Form_pg_class) GETSTRUCT(reltup2);
|
relform2 = (Form_pg_class) GETSTRUCT(reltup2);
|
||||||
|
|
||||||
relfilenode1 = relform1->relfilenode;
|
relfilenumber1 = relform1->relfilenode;
|
||||||
relfilenode2 = relform2->relfilenode;
|
relfilenumber2 = relform2->relfilenode;
|
||||||
|
|
||||||
if (OidIsValid(relfilenode1) && OidIsValid(relfilenode2))
|
if (RelFileNumberIsValid(relfilenumber1) &&
|
||||||
|
RelFileNumberIsValid(relfilenumber2))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Normal non-mapped relations: swap relfilenodes, reltablespaces,
|
* Normal non-mapped relations: swap relfilenumbers, reltablespaces,
|
||||||
* relpersistence
|
* relpersistence
|
||||||
*/
|
*/
|
||||||
Assert(!target_is_pg_class);
|
Assert(!target_is_pg_class);
|
||||||
@ -1120,7 +1121,8 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
|
|||||||
* Mapped-relation case. Here we have to swap the relation mappings
|
* Mapped-relation case. Here we have to swap the relation mappings
|
||||||
* instead of modifying the pg_class columns. Both must be mapped.
|
* instead of modifying the pg_class columns. Both must be mapped.
|
||||||
*/
|
*/
|
||||||
if (OidIsValid(relfilenode1) || OidIsValid(relfilenode2))
|
if (RelFileNumberIsValid(relfilenumber1) ||
|
||||||
|
RelFileNumberIsValid(relfilenumber2))
|
||||||
elog(ERROR, "cannot swap mapped relation \"%s\" with non-mapped relation",
|
elog(ERROR, "cannot swap mapped relation \"%s\" with non-mapped relation",
|
||||||
NameStr(relform1->relname));
|
NameStr(relform1->relname));
|
||||||
|
|
||||||
@ -1148,12 +1150,12 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
|
|||||||
/*
|
/*
|
||||||
* Fetch the mappings --- shouldn't fail, but be paranoid
|
* Fetch the mappings --- shouldn't fail, but be paranoid
|
||||||
*/
|
*/
|
||||||
relfilenode1 = RelationMapOidToFilenode(r1, relform1->relisshared);
|
relfilenumber1 = RelationMapOidToFilenumber(r1, relform1->relisshared);
|
||||||
if (!OidIsValid(relfilenode1))
|
if (!RelFileNumberIsValid(relfilenumber1))
|
||||||
elog(ERROR, "could not find relation mapping for relation \"%s\", OID %u",
|
elog(ERROR, "could not find relation mapping for relation \"%s\", OID %u",
|
||||||
NameStr(relform1->relname), r1);
|
NameStr(relform1->relname), r1);
|
||||||
relfilenode2 = RelationMapOidToFilenode(r2, relform2->relisshared);
|
relfilenumber2 = RelationMapOidToFilenumber(r2, relform2->relisshared);
|
||||||
if (!OidIsValid(relfilenode2))
|
if (!RelFileNumberIsValid(relfilenumber2))
|
||||||
elog(ERROR, "could not find relation mapping for relation \"%s\", OID %u",
|
elog(ERROR, "could not find relation mapping for relation \"%s\", OID %u",
|
||||||
NameStr(relform2->relname), r2);
|
NameStr(relform2->relname), r2);
|
||||||
|
|
||||||
@ -1161,15 +1163,15 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
|
|||||||
* Send replacement mappings to relmapper. Note these won't actually
|
* Send replacement mappings to relmapper. Note these won't actually
|
||||||
* take effect until CommandCounterIncrement.
|
* take effect until CommandCounterIncrement.
|
||||||
*/
|
*/
|
||||||
RelationMapUpdateMap(r1, relfilenode2, relform1->relisshared, false);
|
RelationMapUpdateMap(r1, relfilenumber2, relform1->relisshared, false);
|
||||||
RelationMapUpdateMap(r2, relfilenode1, relform2->relisshared, false);
|
RelationMapUpdateMap(r2, relfilenumber1, relform2->relisshared, false);
|
||||||
|
|
||||||
/* Pass OIDs of mapped r2 tables back to caller */
|
/* Pass OIDs of mapped r2 tables back to caller */
|
||||||
*mapped_tables++ = r2;
|
*mapped_tables++ = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Recognize that rel1's relfilenode (swapped from rel2) is new in this
|
* Recognize that rel1's relfilenumber (swapped from rel2) is new in this
|
||||||
* subtransaction. The rel2 storage (swapped from rel1) may or may not be
|
* subtransaction. The rel2 storage (swapped from rel1) may or may not be
|
||||||
* new.
|
* new.
|
||||||
*/
|
*/
|
||||||
@ -1180,9 +1182,9 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
|
|||||||
rel1 = relation_open(r1, NoLock);
|
rel1 = relation_open(r1, NoLock);
|
||||||
rel2 = relation_open(r2, NoLock);
|
rel2 = relation_open(r2, NoLock);
|
||||||
rel2->rd_createSubid = rel1->rd_createSubid;
|
rel2->rd_createSubid = rel1->rd_createSubid;
|
||||||
rel2->rd_newRelfilenodeSubid = rel1->rd_newRelfilenodeSubid;
|
rel2->rd_newRelfilelocatorSubid = rel1->rd_newRelfilelocatorSubid;
|
||||||
rel2->rd_firstRelfilenodeSubid = rel1->rd_firstRelfilenodeSubid;
|
rel2->rd_firstRelfilelocatorSubid = rel1->rd_firstRelfilelocatorSubid;
|
||||||
RelationAssumeNewRelfilenode(rel1);
|
RelationAssumeNewRelfilelocator(rel1);
|
||||||
relation_close(rel1, NoLock);
|
relation_close(rel1, NoLock);
|
||||||
relation_close(rel2, NoLock);
|
relation_close(rel2, NoLock);
|
||||||
}
|
}
|
||||||
@ -1523,7 +1525,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
|
|||||||
table_close(relRelation, RowExclusiveLock);
|
table_close(relRelation, RowExclusiveLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Destroy new heap with old filenode */
|
/* Destroy new heap with old filenumber */
|
||||||
object.classId = RelationRelationId;
|
object.classId = RelationRelationId;
|
||||||
object.objectId = OIDNewHeap;
|
object.objectId = OIDNewHeap;
|
||||||
object.objectSubId = 0;
|
object.objectSubId = 0;
|
||||||
|
@ -593,12 +593,12 @@ CopyFrom(CopyFromState cstate)
|
|||||||
*/
|
*/
|
||||||
if (RELKIND_HAS_STORAGE(cstate->rel->rd_rel->relkind) &&
|
if (RELKIND_HAS_STORAGE(cstate->rel->rd_rel->relkind) &&
|
||||||
(cstate->rel->rd_createSubid != InvalidSubTransactionId ||
|
(cstate->rel->rd_createSubid != InvalidSubTransactionId ||
|
||||||
cstate->rel->rd_firstRelfilenodeSubid != InvalidSubTransactionId))
|
cstate->rel->rd_firstRelfilelocatorSubid != InvalidSubTransactionId))
|
||||||
ti_options |= TABLE_INSERT_SKIP_FSM;
|
ti_options |= TABLE_INSERT_SKIP_FSM;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Optimize if new relfilenode was created in this subxact or one of its
|
* Optimize if new relation storage was created in this subxact or one of
|
||||||
* committed children and we won't see those rows later as part of an
|
* its committed children and we won't see those rows later as part of an
|
||||||
* earlier scan or command. The subxact test ensures that if this subxact
|
* earlier scan or command. The subxact test ensures that if this subxact
|
||||||
* aborts then the frozen rows won't be visible after xact cleanup. Note
|
* aborts then the frozen rows won't be visible after xact cleanup. Note
|
||||||
* that the stronger test of exactly which subtransaction created it is
|
* that the stronger test of exactly which subtransaction created it is
|
||||||
@ -640,7 +640,7 @@ CopyFrom(CopyFromState cstate)
|
|||||||
errmsg("cannot perform COPY FREEZE because of prior transaction activity")));
|
errmsg("cannot perform COPY FREEZE because of prior transaction activity")));
|
||||||
|
|
||||||
if (cstate->rel->rd_createSubid != GetCurrentSubTransactionId() &&
|
if (cstate->rel->rd_createSubid != GetCurrentSubTransactionId() &&
|
||||||
cstate->rel->rd_newRelfilenodeSubid != GetCurrentSubTransactionId())
|
cstate->rel->rd_newRelfilelocatorSubid != GetCurrentSubTransactionId())
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||||
errmsg("cannot perform COPY FREEZE because the table was not created or truncated in the current subtransaction")));
|
errmsg("cannot perform COPY FREEZE because the table was not created or truncated in the current subtransaction")));
|
||||||
|
@ -101,7 +101,7 @@ typedef struct
|
|||||||
*/
|
*/
|
||||||
typedef struct CreateDBRelInfo
|
typedef struct CreateDBRelInfo
|
||||||
{
|
{
|
||||||
RelFileNode rnode; /* physical relation identifier */
|
RelFileLocator rlocator; /* physical relation identifier */
|
||||||
Oid reloid; /* relation oid */
|
Oid reloid; /* relation oid */
|
||||||
bool permanent; /* relation is permanent or unlogged */
|
bool permanent; /* relation is permanent or unlogged */
|
||||||
} CreateDBRelInfo;
|
} CreateDBRelInfo;
|
||||||
@ -127,7 +127,7 @@ static void CreateDatabaseUsingWalLog(Oid src_dboid, Oid dboid, Oid src_tsid,
|
|||||||
static List *ScanSourceDatabasePgClass(Oid srctbid, Oid srcdbid, char *srcpath);
|
static List *ScanSourceDatabasePgClass(Oid srctbid, Oid srcdbid, char *srcpath);
|
||||||
static List *ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid,
|
static List *ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid,
|
||||||
Oid dbid, char *srcpath,
|
Oid dbid, char *srcpath,
|
||||||
List *rnodelist, Snapshot snapshot);
|
List *rlocatorlist, Snapshot snapshot);
|
||||||
static CreateDBRelInfo *ScanSourceDatabasePgClassTuple(HeapTupleData *tuple,
|
static CreateDBRelInfo *ScanSourceDatabasePgClassTuple(HeapTupleData *tuple,
|
||||||
Oid tbid, Oid dbid,
|
Oid tbid, Oid dbid,
|
||||||
char *srcpath);
|
char *srcpath);
|
||||||
@ -147,12 +147,12 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
|
|||||||
{
|
{
|
||||||
char *srcpath;
|
char *srcpath;
|
||||||
char *dstpath;
|
char *dstpath;
|
||||||
List *rnodelist = NULL;
|
List *rlocatorlist = NULL;
|
||||||
ListCell *cell;
|
ListCell *cell;
|
||||||
LockRelId srcrelid;
|
LockRelId srcrelid;
|
||||||
LockRelId dstrelid;
|
LockRelId dstrelid;
|
||||||
RelFileNode srcrnode;
|
RelFileLocator srcrlocator;
|
||||||
RelFileNode dstrnode;
|
RelFileLocator dstrlocator;
|
||||||
CreateDBRelInfo *relinfo;
|
CreateDBRelInfo *relinfo;
|
||||||
|
|
||||||
/* Get source and destination database paths. */
|
/* Get source and destination database paths. */
|
||||||
@ -165,9 +165,9 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
|
|||||||
/* Copy relmap file from source database to the destination database. */
|
/* Copy relmap file from source database to the destination database. */
|
||||||
RelationMapCopy(dst_dboid, dst_tsid, srcpath, dstpath);
|
RelationMapCopy(dst_dboid, dst_tsid, srcpath, dstpath);
|
||||||
|
|
||||||
/* Get list of relfilenodes to copy from the source database. */
|
/* Get list of relfilelocators to copy from the source database. */
|
||||||
rnodelist = ScanSourceDatabasePgClass(src_tsid, src_dboid, srcpath);
|
rlocatorlist = ScanSourceDatabasePgClass(src_tsid, src_dboid, srcpath);
|
||||||
Assert(rnodelist != NIL);
|
Assert(rlocatorlist != NIL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Database IDs will be the same for all relations so set them before
|
* Database IDs will be the same for all relations so set them before
|
||||||
@ -176,11 +176,11 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
|
|||||||
srcrelid.dbId = src_dboid;
|
srcrelid.dbId = src_dboid;
|
||||||
dstrelid.dbId = dst_dboid;
|
dstrelid.dbId = dst_dboid;
|
||||||
|
|
||||||
/* Loop over our list of relfilenodes and copy each one. */
|
/* Loop over our list of relfilelocators and copy each one. */
|
||||||
foreach(cell, rnodelist)
|
foreach(cell, rlocatorlist)
|
||||||
{
|
{
|
||||||
relinfo = lfirst(cell);
|
relinfo = lfirst(cell);
|
||||||
srcrnode = relinfo->rnode;
|
srcrlocator = relinfo->rlocator;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the relation is from the source db's default tablespace then we
|
* If the relation is from the source db's default tablespace then we
|
||||||
@ -188,13 +188,13 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
|
|||||||
* Otherwise, we need to create in the same tablespace as it is in the
|
* Otherwise, we need to create in the same tablespace as it is in the
|
||||||
* source database.
|
* source database.
|
||||||
*/
|
*/
|
||||||
if (srcrnode.spcNode == src_tsid)
|
if (srcrlocator.spcOid == src_tsid)
|
||||||
dstrnode.spcNode = dst_tsid;
|
dstrlocator.spcOid = dst_tsid;
|
||||||
else
|
else
|
||||||
dstrnode.spcNode = srcrnode.spcNode;
|
dstrlocator.spcOid = srcrlocator.spcOid;
|
||||||
|
|
||||||
dstrnode.dbNode = dst_dboid;
|
dstrlocator.dbOid = dst_dboid;
|
||||||
dstrnode.relNode = srcrnode.relNode;
|
dstrlocator.relNumber = srcrlocator.relNumber;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Acquire locks on source and target relations before copying.
|
* Acquire locks on source and target relations before copying.
|
||||||
@ -210,7 +210,7 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
|
|||||||
LockRelationId(&dstrelid, AccessShareLock);
|
LockRelationId(&dstrelid, AccessShareLock);
|
||||||
|
|
||||||
/* Copy relation storage from source to the destination. */
|
/* Copy relation storage from source to the destination. */
|
||||||
CreateAndCopyRelationData(srcrnode, dstrnode, relinfo->permanent);
|
CreateAndCopyRelationData(srcrlocator, dstrlocator, relinfo->permanent);
|
||||||
|
|
||||||
/* Release the relation locks. */
|
/* Release the relation locks. */
|
||||||
UnlockRelationId(&srcrelid, AccessShareLock);
|
UnlockRelationId(&srcrelid, AccessShareLock);
|
||||||
@ -219,7 +219,7 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
|
|||||||
|
|
||||||
pfree(srcpath);
|
pfree(srcpath);
|
||||||
pfree(dstpath);
|
pfree(dstpath);
|
||||||
list_free_deep(rnodelist);
|
list_free_deep(rlocatorlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -246,20 +246,20 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
|
|||||||
static List *
|
static List *
|
||||||
ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
|
ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
BlockNumber nblocks;
|
BlockNumber nblocks;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Oid relfilenode;
|
Oid relfilenumber;
|
||||||
Page page;
|
Page page;
|
||||||
List *rnodelist = NIL;
|
List *rlocatorlist = NIL;
|
||||||
LockRelId relid;
|
LockRelId relid;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
Snapshot snapshot;
|
Snapshot snapshot;
|
||||||
BufferAccessStrategy bstrategy;
|
BufferAccessStrategy bstrategy;
|
||||||
|
|
||||||
/* Get pg_class relfilenode. */
|
/* Get pg_class relfilenumber. */
|
||||||
relfilenode = RelationMapOidToFilenodeForDatabase(srcpath,
|
relfilenumber = RelationMapOidToFilenumberForDatabase(srcpath,
|
||||||
RelationRelationId);
|
RelationRelationId);
|
||||||
|
|
||||||
/* Don't read data into shared_buffers without holding a relation lock. */
|
/* Don't read data into shared_buffers without holding a relation lock. */
|
||||||
@ -267,10 +267,10 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
|
|||||||
relid.relId = RelationRelationId;
|
relid.relId = RelationRelationId;
|
||||||
LockRelationId(&relid, AccessShareLock);
|
LockRelationId(&relid, AccessShareLock);
|
||||||
|
|
||||||
/* Prepare a RelFileNode for the pg_class relation. */
|
/* Prepare a RelFileLocator for the pg_class relation. */
|
||||||
rnode.spcNode = tbid;
|
rlocator.spcOid = tbid;
|
||||||
rnode.dbNode = dbid;
|
rlocator.dbOid = dbid;
|
||||||
rnode.relNode = relfilenode;
|
rlocator.relNumber = relfilenumber;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can't use a real relcache entry for a relation in some other
|
* We can't use a real relcache entry for a relation in some other
|
||||||
@ -279,7 +279,7 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
|
|||||||
* used the smgr layer directly, we would have to worry about
|
* used the smgr layer directly, we would have to worry about
|
||||||
* invalidations.
|
* invalidations.
|
||||||
*/
|
*/
|
||||||
rel = CreateFakeRelcacheEntry(rnode);
|
rel = CreateFakeRelcacheEntry(rlocator);
|
||||||
nblocks = smgrnblocks(RelationGetSmgr(rel), MAIN_FORKNUM);
|
nblocks = smgrnblocks(RelationGetSmgr(rel), MAIN_FORKNUM);
|
||||||
FreeFakeRelcacheEntry(rel);
|
FreeFakeRelcacheEntry(rel);
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
|
|||||||
{
|
{
|
||||||
CHECK_FOR_INTERRUPTS();
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
|
||||||
buf = ReadBufferWithoutRelcache(rnode, MAIN_FORKNUM, blkno,
|
buf = ReadBufferWithoutRelcache(rlocator, MAIN_FORKNUM, blkno,
|
||||||
RBM_NORMAL, bstrategy, false);
|
RBM_NORMAL, bstrategy, false);
|
||||||
|
|
||||||
LockBuffer(buf, BUFFER_LOCK_SHARE);
|
LockBuffer(buf, BUFFER_LOCK_SHARE);
|
||||||
@ -310,9 +310,9 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append relevant pg_class tuples for current page to rnodelist. */
|
/* Append relevant pg_class tuples for current page to rlocatorlist. */
|
||||||
rnodelist = ScanSourceDatabasePgClassPage(page, buf, tbid, dbid,
|
rlocatorlist = ScanSourceDatabasePgClassPage(page, buf, tbid, dbid,
|
||||||
srcpath, rnodelist,
|
srcpath, rlocatorlist,
|
||||||
snapshot);
|
snapshot);
|
||||||
|
|
||||||
UnlockReleaseBuffer(buf);
|
UnlockReleaseBuffer(buf);
|
||||||
@ -321,16 +321,16 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
|
|||||||
/* Release relation lock. */
|
/* Release relation lock. */
|
||||||
UnlockRelationId(&relid, AccessShareLock);
|
UnlockRelationId(&relid, AccessShareLock);
|
||||||
|
|
||||||
return rnodelist;
|
return rlocatorlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scan one page of the source database's pg_class relation and add relevant
|
* Scan one page of the source database's pg_class relation and add relevant
|
||||||
* entries to rnodelist. The return value is the updated list.
|
* entries to rlocatorlist. The return value is the updated list.
|
||||||
*/
|
*/
|
||||||
static List *
|
static List *
|
||||||
ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid, Oid dbid,
|
ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid, Oid dbid,
|
||||||
char *srcpath, List *rnodelist,
|
char *srcpath, List *rlocatorlist,
|
||||||
Snapshot snapshot)
|
Snapshot snapshot)
|
||||||
{
|
{
|
||||||
BlockNumber blkno = BufferGetBlockNumber(buf);
|
BlockNumber blkno = BufferGetBlockNumber(buf);
|
||||||
@ -376,11 +376,11 @@ ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid, Oid dbid,
|
|||||||
relinfo = ScanSourceDatabasePgClassTuple(&tuple, tbid, dbid,
|
relinfo = ScanSourceDatabasePgClassTuple(&tuple, tbid, dbid,
|
||||||
srcpath);
|
srcpath);
|
||||||
if (relinfo != NULL)
|
if (relinfo != NULL)
|
||||||
rnodelist = lappend(rnodelist, relinfo);
|
rlocatorlist = lappend(rlocatorlist, relinfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rnodelist;
|
return rlocatorlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -397,7 +397,7 @@ ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid,
|
|||||||
{
|
{
|
||||||
CreateDBRelInfo *relinfo;
|
CreateDBRelInfo *relinfo;
|
||||||
Form_pg_class classForm;
|
Form_pg_class classForm;
|
||||||
Oid relfilenode = InvalidOid;
|
Oid relfilenumber = InvalidRelFileNumber;
|
||||||
|
|
||||||
classForm = (Form_pg_class) GETSTRUCT(tuple);
|
classForm = (Form_pg_class) GETSTRUCT(tuple);
|
||||||
|
|
||||||
@ -418,29 +418,29 @@ ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If relfilenode is valid then directly use it. Otherwise, consult the
|
* If relfilenumber is valid then directly use it. Otherwise, consult the
|
||||||
* relmap.
|
* relmap.
|
||||||
*/
|
*/
|
||||||
if (OidIsValid(classForm->relfilenode))
|
if (RelFileNumberIsValid(classForm->relfilenode))
|
||||||
relfilenode = classForm->relfilenode;
|
relfilenumber = classForm->relfilenode;
|
||||||
else
|
else
|
||||||
relfilenode = RelationMapOidToFilenodeForDatabase(srcpath,
|
relfilenumber = RelationMapOidToFilenumberForDatabase(srcpath,
|
||||||
classForm->oid);
|
classForm->oid);
|
||||||
|
|
||||||
/* We must have a valid relfilenode oid. */
|
/* We must have a valid relfilenumber. */
|
||||||
if (!OidIsValid(relfilenode))
|
if (!RelFileNumberIsValid(relfilenumber))
|
||||||
elog(ERROR, "relation with OID %u does not have a valid relfilenode",
|
elog(ERROR, "relation with OID %u does not have a valid relfilenumber",
|
||||||
classForm->oid);
|
classForm->oid);
|
||||||
|
|
||||||
/* Prepare a rel info element and add it to the list. */
|
/* Prepare a rel info element and add it to the list. */
|
||||||
relinfo = (CreateDBRelInfo *) palloc(sizeof(CreateDBRelInfo));
|
relinfo = (CreateDBRelInfo *) palloc(sizeof(CreateDBRelInfo));
|
||||||
if (OidIsValid(classForm->reltablespace))
|
if (OidIsValid(classForm->reltablespace))
|
||||||
relinfo->rnode.spcNode = classForm->reltablespace;
|
relinfo->rlocator.spcOid = classForm->reltablespace;
|
||||||
else
|
else
|
||||||
relinfo->rnode.spcNode = tbid;
|
relinfo->rlocator.spcOid = tbid;
|
||||||
|
|
||||||
relinfo->rnode.dbNode = dbid;
|
relinfo->rlocator.dbOid = dbid;
|
||||||
relinfo->rnode.relNode = relfilenode;
|
relinfo->rlocator.relNumber = relfilenumber;
|
||||||
relinfo->reloid = classForm->oid;
|
relinfo->reloid = classForm->oid;
|
||||||
|
|
||||||
/* Temporary relations were rejected above. */
|
/* Temporary relations were rejected above. */
|
||||||
@ -2867,8 +2867,8 @@ remove_dbtablespaces(Oid db_id)
|
|||||||
* try to remove that already-existing subdirectory during the cleanup in
|
* try to remove that already-existing subdirectory during the cleanup in
|
||||||
* remove_dbtablespaces. Nuking existing files seems like a bad idea, so
|
* remove_dbtablespaces. Nuking existing files seems like a bad idea, so
|
||||||
* instead we make this extra check before settling on the OID of the new
|
* instead we make this extra check before settling on the OID of the new
|
||||||
* database. This exactly parallels what GetNewRelFileNode() does for table
|
* database. This exactly parallels what GetNewRelFileNumber() does for table
|
||||||
* relfilenode values.
|
* relfilenumber values.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
check_db_file_conflict(Oid db_id)
|
check_db_file_conflict(Oid db_id)
|
||||||
|
@ -1109,10 +1109,10 @@ DefineIndex(Oid relationId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A valid stmt->oldNode implies that we already have a built form of the
|
* A valid stmt->oldNumber implies that we already have a built form of
|
||||||
* index. The caller should also decline any index build.
|
* the index. The caller should also decline any index build.
|
||||||
*/
|
*/
|
||||||
Assert(!OidIsValid(stmt->oldNode) || (skip_build && !concurrent));
|
Assert(!RelFileNumberIsValid(stmt->oldNumber) || (skip_build && !concurrent));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make the catalog entries for the index, including constraints. This
|
* Make the catalog entries for the index, including constraints. This
|
||||||
@ -1154,7 +1154,7 @@ DefineIndex(Oid relationId,
|
|||||||
indexRelationId =
|
indexRelationId =
|
||||||
index_create(rel, indexRelationName, indexRelationId, parentIndexId,
|
index_create(rel, indexRelationName, indexRelationId, parentIndexId,
|
||||||
parentConstraintId,
|
parentConstraintId,
|
||||||
stmt->oldNode, indexInfo, indexColNames,
|
stmt->oldNumber, indexInfo, indexColNames,
|
||||||
accessMethodId, tablespaceId,
|
accessMethodId, tablespaceId,
|
||||||
collationObjectId, classObjectId,
|
collationObjectId, classObjectId,
|
||||||
coloptions, reloptions,
|
coloptions, reloptions,
|
||||||
@ -1361,15 +1361,15 @@ DefineIndex(Oid relationId,
|
|||||||
* We can't use the same index name for the child index,
|
* We can't use the same index name for the child index,
|
||||||
* so clear idxname to let the recursive invocation choose
|
* so clear idxname to let the recursive invocation choose
|
||||||
* a new name. Likewise, the existing target relation
|
* a new name. Likewise, the existing target relation
|
||||||
* field is wrong, and if indexOid or oldNode are set,
|
* field is wrong, and if indexOid or oldNumber are set,
|
||||||
* they mustn't be applied to the child either.
|
* they mustn't be applied to the child either.
|
||||||
*/
|
*/
|
||||||
childStmt->idxname = NULL;
|
childStmt->idxname = NULL;
|
||||||
childStmt->relation = NULL;
|
childStmt->relation = NULL;
|
||||||
childStmt->indexOid = InvalidOid;
|
childStmt->indexOid = InvalidOid;
|
||||||
childStmt->oldNode = InvalidOid;
|
childStmt->oldNumber = InvalidRelFileNumber;
|
||||||
childStmt->oldCreateSubid = InvalidSubTransactionId;
|
childStmt->oldCreateSubid = InvalidSubTransactionId;
|
||||||
childStmt->oldFirstRelfilenodeSubid = InvalidSubTransactionId;
|
childStmt->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adjust any Vars (both in expressions and in the index's
|
* Adjust any Vars (both in expressions and in the index's
|
||||||
@ -3015,7 +3015,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
|
|||||||
* particular this eliminates all shared catalogs.).
|
* particular this eliminates all shared catalogs.).
|
||||||
*/
|
*/
|
||||||
if (RELKIND_HAS_STORAGE(classtuple->relkind) &&
|
if (RELKIND_HAS_STORAGE(classtuple->relkind) &&
|
||||||
!OidIsValid(classtuple->relfilenode))
|
!RelFileNumberIsValid(classtuple->relfilenode))
|
||||||
skip_rel = true;
|
skip_rel = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -118,7 +118,7 @@ SetMatViewPopulatedState(Relation relation, bool newstate)
|
|||||||
* ExecRefreshMatView -- execute a REFRESH MATERIALIZED VIEW command
|
* ExecRefreshMatView -- execute a REFRESH MATERIALIZED VIEW command
|
||||||
*
|
*
|
||||||
* This refreshes the materialized view by creating a new table and swapping
|
* This refreshes the materialized view by creating a new table and swapping
|
||||||
* the relfilenodes of the new table and the old materialized view, so the OID
|
* the relfilenumbers of the new table and the old materialized view, so the OID
|
||||||
* of the original materialized view is preserved. Thus we do not lose GRANT
|
* of the original materialized view is preserved. Thus we do not lose GRANT
|
||||||
* nor references to this materialized view.
|
* nor references to this materialized view.
|
||||||
*
|
*
|
||||||
|
@ -75,7 +75,7 @@ typedef struct sequence_magic
|
|||||||
typedef struct SeqTableData
|
typedef struct SeqTableData
|
||||||
{
|
{
|
||||||
Oid relid; /* pg_class OID of this sequence (hash key) */
|
Oid relid; /* pg_class OID of this sequence (hash key) */
|
||||||
Oid filenode; /* last seen relfilenode of this sequence */
|
RelFileNumber filenumber; /* last seen relfilenumber of this sequence */
|
||||||
LocalTransactionId lxid; /* xact in which we last did a seq op */
|
LocalTransactionId lxid; /* xact in which we last did a seq op */
|
||||||
bool last_valid; /* do we have a valid "last" value? */
|
bool last_valid; /* do we have a valid "last" value? */
|
||||||
int64 last; /* value last returned by nextval */
|
int64 last; /* value last returned by nextval */
|
||||||
@ -255,7 +255,7 @@ DefineSequence(ParseState *pstate, CreateSeqStmt *seq)
|
|||||||
*
|
*
|
||||||
* The change is made transactionally, so that on failure of the current
|
* The change is made transactionally, so that on failure of the current
|
||||||
* transaction, the sequence will be restored to its previous state.
|
* transaction, the sequence will be restored to its previous state.
|
||||||
* We do that by creating a whole new relfilenode for the sequence; so this
|
* We do that by creating a whole new relfilenumber for the sequence; so this
|
||||||
* works much like the rewriting forms of ALTER TABLE.
|
* works much like the rewriting forms of ALTER TABLE.
|
||||||
*
|
*
|
||||||
* Caller is assumed to have acquired AccessExclusiveLock on the sequence,
|
* Caller is assumed to have acquired AccessExclusiveLock on the sequence,
|
||||||
@ -310,7 +310,7 @@ ResetSequence(Oid seq_relid)
|
|||||||
/*
|
/*
|
||||||
* Create a new storage file for the sequence.
|
* Create a new storage file for the sequence.
|
||||||
*/
|
*/
|
||||||
RelationSetNewRelfilenode(seq_rel, seq_rel->rd_rel->relpersistence);
|
RelationSetNewRelfilenumber(seq_rel, seq_rel->rd_rel->relpersistence);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure sequence's relfrozenxid is at 0, since it won't contain any
|
* Ensure sequence's relfrozenxid is at 0, since it won't contain any
|
||||||
@ -347,9 +347,9 @@ fill_seq_with_data(Relation rel, HeapTuple tuple)
|
|||||||
{
|
{
|
||||||
SMgrRelation srel;
|
SMgrRelation srel;
|
||||||
|
|
||||||
srel = smgropen(rel->rd_node, InvalidBackendId);
|
srel = smgropen(rel->rd_locator, InvalidBackendId);
|
||||||
smgrcreate(srel, INIT_FORKNUM, false);
|
smgrcreate(srel, INIT_FORKNUM, false);
|
||||||
log_smgrcreate(&rel->rd_node, INIT_FORKNUM);
|
log_smgrcreate(&rel->rd_locator, INIT_FORKNUM);
|
||||||
fill_seq_fork_with_data(rel, tuple, INIT_FORKNUM);
|
fill_seq_fork_with_data(rel, tuple, INIT_FORKNUM);
|
||||||
FlushRelationBuffers(rel);
|
FlushRelationBuffers(rel);
|
||||||
smgrclose(srel);
|
smgrclose(srel);
|
||||||
@ -418,7 +418,7 @@ fill_seq_fork_with_data(Relation rel, HeapTuple tuple, ForkNumber forkNum)
|
|||||||
XLogBeginInsert();
|
XLogBeginInsert();
|
||||||
XLogRegisterBuffer(0, buf, REGBUF_WILL_INIT);
|
XLogRegisterBuffer(0, buf, REGBUF_WILL_INIT);
|
||||||
|
|
||||||
xlrec.node = rel->rd_node;
|
xlrec.locator = rel->rd_locator;
|
||||||
|
|
||||||
XLogRegisterData((char *) &xlrec, sizeof(xl_seq_rec));
|
XLogRegisterData((char *) &xlrec, sizeof(xl_seq_rec));
|
||||||
XLogRegisterData((char *) tuple->t_data, tuple->t_len);
|
XLogRegisterData((char *) tuple->t_data, tuple->t_len);
|
||||||
@ -509,7 +509,7 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
|
|||||||
* Create a new storage file for the sequence, making the state
|
* Create a new storage file for the sequence, making the state
|
||||||
* changes transactional.
|
* changes transactional.
|
||||||
*/
|
*/
|
||||||
RelationSetNewRelfilenode(seqrel, seqrel->rd_rel->relpersistence);
|
RelationSetNewRelfilenumber(seqrel, seqrel->rd_rel->relpersistence);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure sequence's relfrozenxid is at 0, since it won't contain any
|
* Ensure sequence's relfrozenxid is at 0, since it won't contain any
|
||||||
@ -557,7 +557,7 @@ SequenceChangePersistence(Oid relid, char newrelpersistence)
|
|||||||
GetTopTransactionId();
|
GetTopTransactionId();
|
||||||
|
|
||||||
(void) read_seq_tuple(seqrel, &buf, &seqdatatuple);
|
(void) read_seq_tuple(seqrel, &buf, &seqdatatuple);
|
||||||
RelationSetNewRelfilenode(seqrel, newrelpersistence);
|
RelationSetNewRelfilenumber(seqrel, newrelpersistence);
|
||||||
fill_seq_with_data(seqrel, &seqdatatuple);
|
fill_seq_with_data(seqrel, &seqdatatuple);
|
||||||
UnlockReleaseBuffer(buf);
|
UnlockReleaseBuffer(buf);
|
||||||
|
|
||||||
@ -836,7 +836,7 @@ nextval_internal(Oid relid, bool check_permissions)
|
|||||||
seq->is_called = true;
|
seq->is_called = true;
|
||||||
seq->log_cnt = 0;
|
seq->log_cnt = 0;
|
||||||
|
|
||||||
xlrec.node = seqrel->rd_node;
|
xlrec.locator = seqrel->rd_locator;
|
||||||
|
|
||||||
XLogRegisterData((char *) &xlrec, sizeof(xl_seq_rec));
|
XLogRegisterData((char *) &xlrec, sizeof(xl_seq_rec));
|
||||||
XLogRegisterData((char *) seqdatatuple.t_data, seqdatatuple.t_len);
|
XLogRegisterData((char *) seqdatatuple.t_data, seqdatatuple.t_len);
|
||||||
@ -1023,7 +1023,7 @@ do_setval(Oid relid, int64 next, bool iscalled)
|
|||||||
XLogBeginInsert();
|
XLogBeginInsert();
|
||||||
XLogRegisterBuffer(0, buf, REGBUF_WILL_INIT);
|
XLogRegisterBuffer(0, buf, REGBUF_WILL_INIT);
|
||||||
|
|
||||||
xlrec.node = seqrel->rd_node;
|
xlrec.locator = seqrel->rd_locator;
|
||||||
XLogRegisterData((char *) &xlrec, sizeof(xl_seq_rec));
|
XLogRegisterData((char *) &xlrec, sizeof(xl_seq_rec));
|
||||||
XLogRegisterData((char *) seqdatatuple.t_data, seqdatatuple.t_len);
|
XLogRegisterData((char *) seqdatatuple.t_data, seqdatatuple.t_len);
|
||||||
|
|
||||||
@ -1147,7 +1147,7 @@ init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel)
|
|||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
/* relid already filled in */
|
/* relid already filled in */
|
||||||
elm->filenode = InvalidOid;
|
elm->filenumber = InvalidRelFileNumber;
|
||||||
elm->lxid = InvalidLocalTransactionId;
|
elm->lxid = InvalidLocalTransactionId;
|
||||||
elm->last_valid = false;
|
elm->last_valid = false;
|
||||||
elm->last = elm->cached = 0;
|
elm->last = elm->cached = 0;
|
||||||
@ -1169,9 +1169,9 @@ init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel)
|
|||||||
* discard any cached-but-unissued values. We do not touch the currval()
|
* discard any cached-but-unissued values. We do not touch the currval()
|
||||||
* state, however.
|
* state, however.
|
||||||
*/
|
*/
|
||||||
if (seqrel->rd_rel->relfilenode != elm->filenode)
|
if (seqrel->rd_rel->relfilenode != elm->filenumber)
|
||||||
{
|
{
|
||||||
elm->filenode = seqrel->rd_rel->relfilenode;
|
elm->filenumber = seqrel->rd_rel->relfilenode;
|
||||||
elm->cached = elm->last;
|
elm->cached = elm->last;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1254,7 +1254,8 @@ read_seq_tuple(Relation rel, Buffer *buf, HeapTuple seqdatatuple)
|
|||||||
* changed. This allows ALTER SEQUENCE to behave transactionally. Currently,
|
* changed. This allows ALTER SEQUENCE to behave transactionally. Currently,
|
||||||
* the only option that doesn't cause that is OWNED BY. It's *necessary* for
|
* the only option that doesn't cause that is OWNED BY. It's *necessary* for
|
||||||
* ALTER SEQUENCE OWNED BY to not rewrite the sequence, because that would
|
* ALTER SEQUENCE OWNED BY to not rewrite the sequence, because that would
|
||||||
* break pg_upgrade by causing unwanted changes in the sequence's relfilenode.
|
* break pg_upgrade by causing unwanted changes in the sequence's
|
||||||
|
* relfilenumber.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
init_params(ParseState *pstate, List *options, bool for_identity,
|
init_params(ParseState *pstate, List *options, bool for_identity,
|
||||||
|
@ -596,7 +596,7 @@ static void ATExecForceNoForceRowSecurity(Relation rel, bool force_rls);
|
|||||||
static ObjectAddress ATExecSetCompression(AlteredTableInfo *tab, Relation rel,
|
static ObjectAddress ATExecSetCompression(AlteredTableInfo *tab, Relation rel,
|
||||||
const char *column, Node *newValue, LOCKMODE lockmode);
|
const char *column, Node *newValue, LOCKMODE lockmode);
|
||||||
|
|
||||||
static void index_copy_data(Relation rel, RelFileNode newrnode);
|
static void index_copy_data(Relation rel, RelFileLocator newrlocator);
|
||||||
static const char *storage_name(char c);
|
static const char *storage_name(char c);
|
||||||
|
|
||||||
static void RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid,
|
static void RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid,
|
||||||
@ -1986,12 +1986,12 @@ ExecuteTruncateGuts(List *explicit_rels,
|
|||||||
/*
|
/*
|
||||||
* Normally, we need a transaction-safe truncation here. However, if
|
* Normally, we need a transaction-safe truncation here. However, if
|
||||||
* the table was either created in the current (sub)transaction or has
|
* the table was either created in the current (sub)transaction or has
|
||||||
* a new relfilenode in the current (sub)transaction, then we can just
|
* a new relfilenumber in the current (sub)transaction, then we can
|
||||||
* truncate it in-place, because a rollback would cause the whole
|
* just truncate it in-place, because a rollback would cause the whole
|
||||||
* table or the current physical file to be thrown away anyway.
|
* table or the current physical file to be thrown away anyway.
|
||||||
*/
|
*/
|
||||||
if (rel->rd_createSubid == mySubid ||
|
if (rel->rd_createSubid == mySubid ||
|
||||||
rel->rd_newRelfilenodeSubid == mySubid)
|
rel->rd_newRelfilelocatorSubid == mySubid)
|
||||||
{
|
{
|
||||||
/* Immediate, non-rollbackable truncation is OK */
|
/* Immediate, non-rollbackable truncation is OK */
|
||||||
heap_truncate_one_rel(rel);
|
heap_truncate_one_rel(rel);
|
||||||
@ -2014,10 +2014,10 @@ ExecuteTruncateGuts(List *explicit_rels,
|
|||||||
* Need the full transaction-safe pushups.
|
* Need the full transaction-safe pushups.
|
||||||
*
|
*
|
||||||
* Create a new empty storage file for the relation, and assign it
|
* Create a new empty storage file for the relation, and assign it
|
||||||
* as the relfilenode value. The old storage file is scheduled for
|
* as the relfilenumber value. The old storage file is scheduled
|
||||||
* deletion at commit.
|
* for deletion at commit.
|
||||||
*/
|
*/
|
||||||
RelationSetNewRelfilenode(rel, rel->rd_rel->relpersistence);
|
RelationSetNewRelfilenumber(rel, rel->rd_rel->relpersistence);
|
||||||
|
|
||||||
heap_relid = RelationGetRelid(rel);
|
heap_relid = RelationGetRelid(rel);
|
||||||
|
|
||||||
@ -2030,7 +2030,7 @@ ExecuteTruncateGuts(List *explicit_rels,
|
|||||||
Relation toastrel = relation_open(toast_relid,
|
Relation toastrel = relation_open(toast_relid,
|
||||||
AccessExclusiveLock);
|
AccessExclusiveLock);
|
||||||
|
|
||||||
RelationSetNewRelfilenode(toastrel,
|
RelationSetNewRelfilenumber(toastrel,
|
||||||
toastrel->rd_rel->relpersistence);
|
toastrel->rd_rel->relpersistence);
|
||||||
table_close(toastrel, NoLock);
|
table_close(toastrel, NoLock);
|
||||||
}
|
}
|
||||||
@ -3315,11 +3315,11 @@ CheckRelationTableSpaceMove(Relation rel, Oid newTableSpaceId)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* SetRelationTableSpace
|
* SetRelationTableSpace
|
||||||
* Set new reltablespace and relfilenode in pg_class entry.
|
* Set new reltablespace and relfilenumber in pg_class entry.
|
||||||
*
|
*
|
||||||
* newTableSpaceId is the new tablespace for the relation, and
|
* newTableSpaceId is the new tablespace for the relation, and
|
||||||
* newRelFileNode its new filenode. If newRelFileNode is InvalidOid,
|
* newRelFilenumber its new filenumber. If newRelFilenumber is
|
||||||
* this field is not updated.
|
* InvalidRelFileNumber, this field is not updated.
|
||||||
*
|
*
|
||||||
* NOTE: The caller must hold AccessExclusiveLock on the relation.
|
* NOTE: The caller must hold AccessExclusiveLock on the relation.
|
||||||
*
|
*
|
||||||
@ -3331,7 +3331,7 @@ CheckRelationTableSpaceMove(Relation rel, Oid newTableSpaceId)
|
|||||||
void
|
void
|
||||||
SetRelationTableSpace(Relation rel,
|
SetRelationTableSpace(Relation rel,
|
||||||
Oid newTableSpaceId,
|
Oid newTableSpaceId,
|
||||||
Oid newRelFileNode)
|
RelFileNumber newRelFilenumber)
|
||||||
{
|
{
|
||||||
Relation pg_class;
|
Relation pg_class;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
@ -3351,8 +3351,8 @@ SetRelationTableSpace(Relation rel,
|
|||||||
/* Update the pg_class row. */
|
/* Update the pg_class row. */
|
||||||
rd_rel->reltablespace = (newTableSpaceId == MyDatabaseTableSpace) ?
|
rd_rel->reltablespace = (newTableSpaceId == MyDatabaseTableSpace) ?
|
||||||
InvalidOid : newTableSpaceId;
|
InvalidOid : newTableSpaceId;
|
||||||
if (OidIsValid(newRelFileNode))
|
if (RelFileNumberIsValid(newRelFilenumber))
|
||||||
rd_rel->relfilenode = newRelFileNode;
|
rd_rel->relfilenode = newRelFilenumber;
|
||||||
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
|
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5420,7 +5420,7 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode,
|
|||||||
* persistence: on one hand, we need to ensure that the buffers
|
* persistence: on one hand, we need to ensure that the buffers
|
||||||
* belonging to each of the two relations are marked with or without
|
* belonging to each of the two relations are marked with or without
|
||||||
* BM_PERMANENT properly. On the other hand, since rewriting creates
|
* BM_PERMANENT properly. On the other hand, since rewriting creates
|
||||||
* and assigns a new relfilenode, we automatically create or drop an
|
* and assigns a new relfilenumber, we automatically create or drop an
|
||||||
* init fork for the relation as appropriate.
|
* init fork for the relation as appropriate.
|
||||||
*/
|
*/
|
||||||
if (tab->rewrite > 0 && tab->relkind != RELKIND_SEQUENCE)
|
if (tab->rewrite > 0 && tab->relkind != RELKIND_SEQUENCE)
|
||||||
@ -5506,12 +5506,13 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode,
|
|||||||
* Create transient table that will receive the modified data.
|
* Create transient table that will receive the modified data.
|
||||||
*
|
*
|
||||||
* Ensure it is marked correctly as logged or unlogged. We have
|
* Ensure it is marked correctly as logged or unlogged. We have
|
||||||
* to do this here so that buffers for the new relfilenode will
|
* to do this here so that buffers for the new relfilenumber will
|
||||||
* have the right persistence set, and at the same time ensure
|
* have the right persistence set, and at the same time ensure
|
||||||
* that the original filenode's buffers will get read in with the
|
* that the original filenumbers's buffers will get read in with
|
||||||
* correct setting (i.e. the original one). Otherwise a rollback
|
* the correct setting (i.e. the original one). Otherwise a
|
||||||
* after the rewrite would possibly result with buffers for the
|
* rollback after the rewrite would possibly result with buffers
|
||||||
* original filenode having the wrong persistence setting.
|
* for the original filenumbers having the wrong persistence
|
||||||
|
* setting.
|
||||||
*
|
*
|
||||||
* NB: This relies on swap_relation_files() also swapping the
|
* NB: This relies on swap_relation_files() also swapping the
|
||||||
* persistence. That wouldn't work for pg_class, but that can't be
|
* persistence. That wouldn't work for pg_class, but that can't be
|
||||||
@ -8597,7 +8598,7 @@ ATExecAddIndex(AlteredTableInfo *tab, Relation rel,
|
|||||||
/* suppress schema rights check when rebuilding existing index */
|
/* suppress schema rights check when rebuilding existing index */
|
||||||
check_rights = !is_rebuild;
|
check_rights = !is_rebuild;
|
||||||
/* skip index build if phase 3 will do it or we're reusing an old one */
|
/* skip index build if phase 3 will do it or we're reusing an old one */
|
||||||
skip_build = tab->rewrite > 0 || OidIsValid(stmt->oldNode);
|
skip_build = tab->rewrite > 0 || RelFileNumberIsValid(stmt->oldNumber);
|
||||||
/* suppress notices when rebuilding existing index */
|
/* suppress notices when rebuilding existing index */
|
||||||
quiet = is_rebuild;
|
quiet = is_rebuild;
|
||||||
|
|
||||||
@ -8613,21 +8614,21 @@ ATExecAddIndex(AlteredTableInfo *tab, Relation rel,
|
|||||||
quiet);
|
quiet);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If TryReuseIndex() stashed a relfilenode for us, we used it for the new
|
* If TryReuseIndex() stashed a relfilenumber for us, we used it for the
|
||||||
* index instead of building from scratch. Restore associated fields.
|
* new index instead of building from scratch. Restore associated fields.
|
||||||
* This may store InvalidSubTransactionId in both fields, in which case
|
* This may store InvalidSubTransactionId in both fields, in which case
|
||||||
* relcache.c will assume it can rebuild the relcache entry. Hence, do
|
* relcache.c will assume it can rebuild the relcache entry. Hence, do
|
||||||
* this after the CCI that made catalog rows visible to any rebuild. The
|
* this after the CCI that made catalog rows visible to any rebuild. The
|
||||||
* DROP of the old edition of this index will have scheduled the storage
|
* DROP of the old edition of this index will have scheduled the storage
|
||||||
* for deletion at commit, so cancel that pending deletion.
|
* for deletion at commit, so cancel that pending deletion.
|
||||||
*/
|
*/
|
||||||
if (OidIsValid(stmt->oldNode))
|
if (RelFileNumberIsValid(stmt->oldNumber))
|
||||||
{
|
{
|
||||||
Relation irel = index_open(address.objectId, NoLock);
|
Relation irel = index_open(address.objectId, NoLock);
|
||||||
|
|
||||||
irel->rd_createSubid = stmt->oldCreateSubid;
|
irel->rd_createSubid = stmt->oldCreateSubid;
|
||||||
irel->rd_firstRelfilenodeSubid = stmt->oldFirstRelfilenodeSubid;
|
irel->rd_firstRelfilelocatorSubid = stmt->oldFirstRelfilelocatorSubid;
|
||||||
RelationPreserveStorage(irel->rd_node, true);
|
RelationPreserveStorage(irel->rd_locator, true);
|
||||||
index_close(irel, NoLock);
|
index_close(irel, NoLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13491,9 +13492,9 @@ TryReuseIndex(Oid oldId, IndexStmt *stmt)
|
|||||||
/* If it's a partitioned index, there is no storage to share. */
|
/* If it's a partitioned index, there is no storage to share. */
|
||||||
if (irel->rd_rel->relkind != RELKIND_PARTITIONED_INDEX)
|
if (irel->rd_rel->relkind != RELKIND_PARTITIONED_INDEX)
|
||||||
{
|
{
|
||||||
stmt->oldNode = irel->rd_node.relNode;
|
stmt->oldNumber = irel->rd_locator.relNumber;
|
||||||
stmt->oldCreateSubid = irel->rd_createSubid;
|
stmt->oldCreateSubid = irel->rd_createSubid;
|
||||||
stmt->oldFirstRelfilenodeSubid = irel->rd_firstRelfilenodeSubid;
|
stmt->oldFirstRelfilelocatorSubid = irel->rd_firstRelfilelocatorSubid;
|
||||||
}
|
}
|
||||||
index_close(irel, NoLock);
|
index_close(irel, NoLock);
|
||||||
}
|
}
|
||||||
@ -14340,8 +14341,8 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
|
|||||||
{
|
{
|
||||||
Relation rel;
|
Relation rel;
|
||||||
Oid reltoastrelid;
|
Oid reltoastrelid;
|
||||||
Oid newrelfilenode;
|
RelFileNumber newrelfilenumber;
|
||||||
RelFileNode newrnode;
|
RelFileLocator newrlocator;
|
||||||
List *reltoastidxids = NIL;
|
List *reltoastidxids = NIL;
|
||||||
ListCell *lc;
|
ListCell *lc;
|
||||||
|
|
||||||
@ -14370,26 +14371,26 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Relfilenodes are not unique in databases across tablespaces, so we need
|
* Relfilenumbers are not unique in databases across tablespaces, so we
|
||||||
* to allocate a new one in the new tablespace.
|
* need to allocate a new one in the new tablespace.
|
||||||
*/
|
*/
|
||||||
newrelfilenode = GetNewRelFileNode(newTableSpace, NULL,
|
newrelfilenumber = GetNewRelFileNumber(newTableSpace, NULL,
|
||||||
rel->rd_rel->relpersistence);
|
rel->rd_rel->relpersistence);
|
||||||
|
|
||||||
/* Open old and new relation */
|
/* Open old and new relation */
|
||||||
newrnode = rel->rd_node;
|
newrlocator = rel->rd_locator;
|
||||||
newrnode.relNode = newrelfilenode;
|
newrlocator.relNumber = newrelfilenumber;
|
||||||
newrnode.spcNode = newTableSpace;
|
newrlocator.spcOid = newTableSpace;
|
||||||
|
|
||||||
/* hand off to AM to actually create the new filenode and copy the data */
|
/* hand off to AM to actually create new rel storage and copy the data */
|
||||||
if (rel->rd_rel->relkind == RELKIND_INDEX)
|
if (rel->rd_rel->relkind == RELKIND_INDEX)
|
||||||
{
|
{
|
||||||
index_copy_data(rel, newrnode);
|
index_copy_data(rel, newrlocator);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Assert(RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind));
|
Assert(RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind));
|
||||||
table_relation_copy_data(rel, &newrnode);
|
table_relation_copy_data(rel, &newrlocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -14400,11 +14401,11 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
|
|||||||
* the updated pg_class entry), but that's forbidden with
|
* the updated pg_class entry), but that's forbidden with
|
||||||
* CheckRelationTableSpaceMove().
|
* CheckRelationTableSpaceMove().
|
||||||
*/
|
*/
|
||||||
SetRelationTableSpace(rel, newTableSpace, newrelfilenode);
|
SetRelationTableSpace(rel, newTableSpace, newrelfilenumber);
|
||||||
|
|
||||||
InvokeObjectPostAlterHook(RelationRelationId, RelationGetRelid(rel), 0);
|
InvokeObjectPostAlterHook(RelationRelationId, RelationGetRelid(rel), 0);
|
||||||
|
|
||||||
RelationAssumeNewRelfilenode(rel);
|
RelationAssumeNewRelfilelocator(rel);
|
||||||
|
|
||||||
relation_close(rel, NoLock);
|
relation_close(rel, NoLock);
|
||||||
|
|
||||||
@ -14630,11 +14631,11 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
index_copy_data(Relation rel, RelFileNode newrnode)
|
index_copy_data(Relation rel, RelFileLocator newrlocator)
|
||||||
{
|
{
|
||||||
SMgrRelation dstrel;
|
SMgrRelation dstrel;
|
||||||
|
|
||||||
dstrel = smgropen(newrnode, rel->rd_backend);
|
dstrel = smgropen(newrlocator, rel->rd_backend);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since we copy the file directly without looking at the shared buffers,
|
* Since we copy the file directly without looking at the shared buffers,
|
||||||
@ -14648,10 +14649,10 @@ index_copy_data(Relation rel, RelFileNode newrnode)
|
|||||||
* Create and copy all forks of the relation, and schedule unlinking of
|
* Create and copy all forks of the relation, and schedule unlinking of
|
||||||
* old physical files.
|
* old physical files.
|
||||||
*
|
*
|
||||||
* NOTE: any conflict in relfilenode value will be caught in
|
* NOTE: any conflict in relfilenumber value will be caught in
|
||||||
* RelationCreateStorage().
|
* RelationCreateStorage().
|
||||||
*/
|
*/
|
||||||
RelationCreateStorage(newrnode, rel->rd_rel->relpersistence, true);
|
RelationCreateStorage(newrlocator, rel->rd_rel->relpersistence, true);
|
||||||
|
|
||||||
/* copy main fork */
|
/* copy main fork */
|
||||||
RelationCopyStorage(RelationGetSmgr(rel), dstrel, MAIN_FORKNUM,
|
RelationCopyStorage(RelationGetSmgr(rel), dstrel, MAIN_FORKNUM,
|
||||||
@ -14672,7 +14673,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
|
|||||||
if (RelationIsPermanent(rel) ||
|
if (RelationIsPermanent(rel) ||
|
||||||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
|
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
|
||||||
forkNum == INIT_FORKNUM))
|
forkNum == INIT_FORKNUM))
|
||||||
log_smgrcreate(&newrnode, forkNum);
|
log_smgrcreate(&newrlocator, forkNum);
|
||||||
RelationCopyStorage(RelationGetSmgr(rel), dstrel, forkNum,
|
RelationCopyStorage(RelationGetSmgr(rel), dstrel, forkNum,
|
||||||
rel->rd_rel->relpersistence);
|
rel->rd_rel->relpersistence);
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
* remove the possibility of having file name conflicts, we isolate
|
* remove the possibility of having file name conflicts, we isolate
|
||||||
* files within a tablespace into database-specific subdirectories.
|
* files within a tablespace into database-specific subdirectories.
|
||||||
*
|
*
|
||||||
* To support file access via the information given in RelFileNode, we
|
* To support file access via the information given in RelFileLocator, we
|
||||||
* maintain a symbolic-link map in $PGDATA/pg_tblspc. The symlinks are
|
* maintain a symbolic-link map in $PGDATA/pg_tblspc. The symlinks are
|
||||||
* named by tablespace OIDs and point to the actual tablespace directories.
|
* named by tablespace OIDs and point to the actual tablespace directories.
|
||||||
* There is also a per-cluster version directory in each tablespace.
|
* There is also a per-cluster version directory in each tablespace.
|
||||||
* Thus the full path to an arbitrary file is
|
* Thus the full path to an arbitrary file is
|
||||||
* $PGDATA/pg_tblspc/spcoid/PG_MAJORVER_CATVER/dboid/relfilenode
|
* $PGDATA/pg_tblspc/spcoid/PG_MAJORVER_CATVER/dboid/relfilenumber
|
||||||
* e.g.
|
* e.g.
|
||||||
* $PGDATA/pg_tblspc/20981/PG_9.0_201002161/719849/83292814
|
* $PGDATA/pg_tblspc/20981/PG_9.0_201002161/719849/83292814
|
||||||
*
|
*
|
||||||
@ -25,8 +25,8 @@
|
|||||||
* tables) and pg_default (for everything else). For backwards compatibility
|
* tables) and pg_default (for everything else). For backwards compatibility
|
||||||
* and to remain functional on platforms without symlinks, these tablespaces
|
* and to remain functional on platforms without symlinks, these tablespaces
|
||||||
* are accessed specially: they are respectively
|
* are accessed specially: they are respectively
|
||||||
* $PGDATA/global/relfilenode
|
* $PGDATA/global/relfilenumber
|
||||||
* $PGDATA/base/dboid/relfilenode
|
* $PGDATA/base/dboid/relfilenumber
|
||||||
*
|
*
|
||||||
* To allow CREATE DATABASE to give a new database a default tablespace
|
* To allow CREATE DATABASE to give a new database a default tablespace
|
||||||
* that's different from the template database's default, we make the
|
* that's different from the template database's default, we make the
|
||||||
@ -115,7 +115,7 @@ static bool destroy_tablespace_directories(Oid tablespaceoid, bool redo);
|
|||||||
* re-create a database subdirectory (of $PGDATA/base) during WAL replay.
|
* re-create a database subdirectory (of $PGDATA/base) during WAL replay.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo)
|
TablespaceCreateDbspace(Oid spcOid, Oid dbOid, bool isRedo)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *dir;
|
char *dir;
|
||||||
@ -124,13 +124,13 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo)
|
|||||||
* The global tablespace doesn't have per-database subdirectories, so
|
* The global tablespace doesn't have per-database subdirectories, so
|
||||||
* nothing to do for it.
|
* nothing to do for it.
|
||||||
*/
|
*/
|
||||||
if (spcNode == GLOBALTABLESPACE_OID)
|
if (spcOid == GLOBALTABLESPACE_OID)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Assert(OidIsValid(spcNode));
|
Assert(OidIsValid(spcOid));
|
||||||
Assert(OidIsValid(dbNode));
|
Assert(OidIsValid(dbOid));
|
||||||
|
|
||||||
dir = GetDatabasePath(dbNode, spcNode);
|
dir = GetDatabasePath(dbOid, spcOid);
|
||||||
|
|
||||||
if (stat(dir, &st) < 0)
|
if (stat(dir, &st) < 0)
|
||||||
{
|
{
|
||||||
|
@ -4194,9 +4194,9 @@ _copyIndexStmt(const IndexStmt *from)
|
|||||||
COPY_NODE_FIELD(excludeOpNames);
|
COPY_NODE_FIELD(excludeOpNames);
|
||||||
COPY_STRING_FIELD(idxcomment);
|
COPY_STRING_FIELD(idxcomment);
|
||||||
COPY_SCALAR_FIELD(indexOid);
|
COPY_SCALAR_FIELD(indexOid);
|
||||||
COPY_SCALAR_FIELD(oldNode);
|
COPY_SCALAR_FIELD(oldNumber);
|
||||||
COPY_SCALAR_FIELD(oldCreateSubid);
|
COPY_SCALAR_FIELD(oldCreateSubid);
|
||||||
COPY_SCALAR_FIELD(oldFirstRelfilenodeSubid);
|
COPY_SCALAR_FIELD(oldFirstRelfilelocatorSubid);
|
||||||
COPY_SCALAR_FIELD(unique);
|
COPY_SCALAR_FIELD(unique);
|
||||||
COPY_SCALAR_FIELD(nulls_not_distinct);
|
COPY_SCALAR_FIELD(nulls_not_distinct);
|
||||||
COPY_SCALAR_FIELD(primary);
|
COPY_SCALAR_FIELD(primary);
|
||||||
|
@ -1768,9 +1768,9 @@ _equalIndexStmt(const IndexStmt *a, const IndexStmt *b)
|
|||||||
COMPARE_NODE_FIELD(excludeOpNames);
|
COMPARE_NODE_FIELD(excludeOpNames);
|
||||||
COMPARE_STRING_FIELD(idxcomment);
|
COMPARE_STRING_FIELD(idxcomment);
|
||||||
COMPARE_SCALAR_FIELD(indexOid);
|
COMPARE_SCALAR_FIELD(indexOid);
|
||||||
COMPARE_SCALAR_FIELD(oldNode);
|
COMPARE_SCALAR_FIELD(oldNumber);
|
||||||
COMPARE_SCALAR_FIELD(oldCreateSubid);
|
COMPARE_SCALAR_FIELD(oldCreateSubid);
|
||||||
COMPARE_SCALAR_FIELD(oldFirstRelfilenodeSubid);
|
COMPARE_SCALAR_FIELD(oldFirstRelfilelocatorSubid);
|
||||||
COMPARE_SCALAR_FIELD(unique);
|
COMPARE_SCALAR_FIELD(unique);
|
||||||
COMPARE_SCALAR_FIELD(nulls_not_distinct);
|
COMPARE_SCALAR_FIELD(nulls_not_distinct);
|
||||||
COMPARE_SCALAR_FIELD(primary);
|
COMPARE_SCALAR_FIELD(primary);
|
||||||
|
@ -2932,9 +2932,9 @@ _outIndexStmt(StringInfo str, const IndexStmt *node)
|
|||||||
WRITE_NODE_FIELD(excludeOpNames);
|
WRITE_NODE_FIELD(excludeOpNames);
|
||||||
WRITE_STRING_FIELD(idxcomment);
|
WRITE_STRING_FIELD(idxcomment);
|
||||||
WRITE_OID_FIELD(indexOid);
|
WRITE_OID_FIELD(indexOid);
|
||||||
WRITE_OID_FIELD(oldNode);
|
WRITE_OID_FIELD(oldNumber);
|
||||||
WRITE_UINT_FIELD(oldCreateSubid);
|
WRITE_UINT_FIELD(oldCreateSubid);
|
||||||
WRITE_UINT_FIELD(oldFirstRelfilenodeSubid);
|
WRITE_UINT_FIELD(oldFirstRelfilelocatorSubid);
|
||||||
WRITE_BOOL_FIELD(unique);
|
WRITE_BOOL_FIELD(unique);
|
||||||
WRITE_BOOL_FIELD(nulls_not_distinct);
|
WRITE_BOOL_FIELD(nulls_not_distinct);
|
||||||
WRITE_BOOL_FIELD(primary);
|
WRITE_BOOL_FIELD(primary);
|
||||||
|
@ -7990,9 +7990,9 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name
|
|||||||
n->excludeOpNames = NIL;
|
n->excludeOpNames = NIL;
|
||||||
n->idxcomment = NULL;
|
n->idxcomment = NULL;
|
||||||
n->indexOid = InvalidOid;
|
n->indexOid = InvalidOid;
|
||||||
n->oldNode = InvalidOid;
|
n->oldNumber = InvalidRelFileNumber;
|
||||||
n->oldCreateSubid = InvalidSubTransactionId;
|
n->oldCreateSubid = InvalidSubTransactionId;
|
||||||
n->oldFirstRelfilenodeSubid = InvalidSubTransactionId;
|
n->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
n->primary = false;
|
n->primary = false;
|
||||||
n->isconstraint = false;
|
n->isconstraint = false;
|
||||||
n->deferrable = false;
|
n->deferrable = false;
|
||||||
@ -8022,9 +8022,9 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name
|
|||||||
n->excludeOpNames = NIL;
|
n->excludeOpNames = NIL;
|
||||||
n->idxcomment = NULL;
|
n->idxcomment = NULL;
|
||||||
n->indexOid = InvalidOid;
|
n->indexOid = InvalidOid;
|
||||||
n->oldNode = InvalidOid;
|
n->oldNumber = InvalidRelFileNumber;
|
||||||
n->oldCreateSubid = InvalidSubTransactionId;
|
n->oldCreateSubid = InvalidSubTransactionId;
|
||||||
n->oldFirstRelfilenodeSubid = InvalidSubTransactionId;
|
n->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
n->primary = false;
|
n->primary = false;
|
||||||
n->isconstraint = false;
|
n->isconstraint = false;
|
||||||
n->deferrable = false;
|
n->deferrable = false;
|
||||||
|
@ -1578,9 +1578,9 @@ generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx,
|
|||||||
index->excludeOpNames = NIL;
|
index->excludeOpNames = NIL;
|
||||||
index->idxcomment = NULL;
|
index->idxcomment = NULL;
|
||||||
index->indexOid = InvalidOid;
|
index->indexOid = InvalidOid;
|
||||||
index->oldNode = InvalidOid;
|
index->oldNumber = InvalidRelFileNumber;
|
||||||
index->oldCreateSubid = InvalidSubTransactionId;
|
index->oldCreateSubid = InvalidSubTransactionId;
|
||||||
index->oldFirstRelfilenodeSubid = InvalidSubTransactionId;
|
index->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
index->unique = idxrec->indisunique;
|
index->unique = idxrec->indisunique;
|
||||||
index->nulls_not_distinct = idxrec->indnullsnotdistinct;
|
index->nulls_not_distinct = idxrec->indnullsnotdistinct;
|
||||||
index->primary = idxrec->indisprimary;
|
index->primary = idxrec->indisprimary;
|
||||||
@ -2199,9 +2199,9 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
|||||||
index->excludeOpNames = NIL;
|
index->excludeOpNames = NIL;
|
||||||
index->idxcomment = NULL;
|
index->idxcomment = NULL;
|
||||||
index->indexOid = InvalidOid;
|
index->indexOid = InvalidOid;
|
||||||
index->oldNode = InvalidOid;
|
index->oldNumber = InvalidRelFileNumber;
|
||||||
index->oldCreateSubid = InvalidSubTransactionId;
|
index->oldCreateSubid = InvalidSubTransactionId;
|
||||||
index->oldFirstRelfilenodeSubid = InvalidSubTransactionId;
|
index->oldFirstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
index->transformed = false;
|
index->transformed = false;
|
||||||
index->concurrent = false;
|
index->concurrent = false;
|
||||||
index->if_not_exists = false;
|
index->if_not_exists = false;
|
||||||
|
@ -1207,7 +1207,7 @@ CompactCheckpointerRequestQueue(void)
|
|||||||
* We use the request struct directly as a hashtable key. This
|
* We use the request struct directly as a hashtable key. This
|
||||||
* assumes that any padding bytes in the structs are consistently the
|
* assumes that any padding bytes in the structs are consistently the
|
||||||
* same, which should be okay because we zeroed them in
|
* same, which should be okay because we zeroed them in
|
||||||
* CheckpointerShmemInit. Note also that RelFileNode had better
|
* CheckpointerShmemInit. Note also that RelFileLocator had better
|
||||||
* contain no pad bytes.
|
* contain no pad bytes.
|
||||||
*/
|
*/
|
||||||
request = &CheckpointerShmem->requests[n];
|
request = &CheckpointerShmem->requests[n];
|
||||||
|
@ -845,7 +845,7 @@ DecodeInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
XLogReaderState *r = buf->record;
|
XLogReaderState *r = buf->record;
|
||||||
xl_heap_insert *xlrec;
|
xl_heap_insert *xlrec;
|
||||||
ReorderBufferChange *change;
|
ReorderBufferChange *change;
|
||||||
RelFileNode target_node;
|
RelFileLocator target_locator;
|
||||||
|
|
||||||
xlrec = (xl_heap_insert *) XLogRecGetData(r);
|
xlrec = (xl_heap_insert *) XLogRecGetData(r);
|
||||||
|
|
||||||
@ -857,8 +857,8 @@ DecodeInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* only interested in our database */
|
/* only interested in our database */
|
||||||
XLogRecGetBlockTag(r, 0, &target_node, NULL, NULL);
|
XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
|
||||||
if (target_node.dbNode != ctx->slot->data.database)
|
if (target_locator.dbOid != ctx->slot->data.database)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* output plugin doesn't look for this origin, no need to queue */
|
/* output plugin doesn't look for this origin, no need to queue */
|
||||||
@ -872,7 +872,7 @@ DecodeInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
change->action = REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT;
|
change->action = REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT;
|
||||||
change->origin_id = XLogRecGetOrigin(r);
|
change->origin_id = XLogRecGetOrigin(r);
|
||||||
|
|
||||||
memcpy(&change->data.tp.relnode, &target_node, sizeof(RelFileNode));
|
memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
|
||||||
|
|
||||||
tupledata = XLogRecGetBlockData(r, 0, &datalen);
|
tupledata = XLogRecGetBlockData(r, 0, &datalen);
|
||||||
tuplelen = datalen - SizeOfHeapHeader;
|
tuplelen = datalen - SizeOfHeapHeader;
|
||||||
@ -902,13 +902,13 @@ DecodeUpdate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
xl_heap_update *xlrec;
|
xl_heap_update *xlrec;
|
||||||
ReorderBufferChange *change;
|
ReorderBufferChange *change;
|
||||||
char *data;
|
char *data;
|
||||||
RelFileNode target_node;
|
RelFileLocator target_locator;
|
||||||
|
|
||||||
xlrec = (xl_heap_update *) XLogRecGetData(r);
|
xlrec = (xl_heap_update *) XLogRecGetData(r);
|
||||||
|
|
||||||
/* only interested in our database */
|
/* only interested in our database */
|
||||||
XLogRecGetBlockTag(r, 0, &target_node, NULL, NULL);
|
XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
|
||||||
if (target_node.dbNode != ctx->slot->data.database)
|
if (target_locator.dbOid != ctx->slot->data.database)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* output plugin doesn't look for this origin, no need to queue */
|
/* output plugin doesn't look for this origin, no need to queue */
|
||||||
@ -918,7 +918,7 @@ DecodeUpdate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
change = ReorderBufferGetChange(ctx->reorder);
|
change = ReorderBufferGetChange(ctx->reorder);
|
||||||
change->action = REORDER_BUFFER_CHANGE_UPDATE;
|
change->action = REORDER_BUFFER_CHANGE_UPDATE;
|
||||||
change->origin_id = XLogRecGetOrigin(r);
|
change->origin_id = XLogRecGetOrigin(r);
|
||||||
memcpy(&change->data.tp.relnode, &target_node, sizeof(RelFileNode));
|
memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
|
||||||
|
|
||||||
if (xlrec->flags & XLH_UPDATE_CONTAINS_NEW_TUPLE)
|
if (xlrec->flags & XLH_UPDATE_CONTAINS_NEW_TUPLE)
|
||||||
{
|
{
|
||||||
@ -968,13 +968,13 @@ DecodeDelete(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
XLogReaderState *r = buf->record;
|
XLogReaderState *r = buf->record;
|
||||||
xl_heap_delete *xlrec;
|
xl_heap_delete *xlrec;
|
||||||
ReorderBufferChange *change;
|
ReorderBufferChange *change;
|
||||||
RelFileNode target_node;
|
RelFileLocator target_locator;
|
||||||
|
|
||||||
xlrec = (xl_heap_delete *) XLogRecGetData(r);
|
xlrec = (xl_heap_delete *) XLogRecGetData(r);
|
||||||
|
|
||||||
/* only interested in our database */
|
/* only interested in our database */
|
||||||
XLogRecGetBlockTag(r, 0, &target_node, NULL, NULL);
|
XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
|
||||||
if (target_node.dbNode != ctx->slot->data.database)
|
if (target_locator.dbOid != ctx->slot->data.database)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* output plugin doesn't look for this origin, no need to queue */
|
/* output plugin doesn't look for this origin, no need to queue */
|
||||||
@ -990,7 +990,7 @@ DecodeDelete(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
|
|
||||||
change->origin_id = XLogRecGetOrigin(r);
|
change->origin_id = XLogRecGetOrigin(r);
|
||||||
|
|
||||||
memcpy(&change->data.tp.relnode, &target_node, sizeof(RelFileNode));
|
memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
|
||||||
|
|
||||||
/* old primary key stored */
|
/* old primary key stored */
|
||||||
if (xlrec->flags & XLH_DELETE_CONTAINS_OLD)
|
if (xlrec->flags & XLH_DELETE_CONTAINS_OLD)
|
||||||
@ -1063,7 +1063,7 @@ DecodeMultiInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
char *data;
|
char *data;
|
||||||
char *tupledata;
|
char *tupledata;
|
||||||
Size tuplelen;
|
Size tuplelen;
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
|
|
||||||
xlrec = (xl_heap_multi_insert *) XLogRecGetData(r);
|
xlrec = (xl_heap_multi_insert *) XLogRecGetData(r);
|
||||||
|
|
||||||
@ -1075,8 +1075,8 @@ DecodeMultiInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* only interested in our database */
|
/* only interested in our database */
|
||||||
XLogRecGetBlockTag(r, 0, &rnode, NULL, NULL);
|
XLogRecGetBlockTag(r, 0, &rlocator, NULL, NULL);
|
||||||
if (rnode.dbNode != ctx->slot->data.database)
|
if (rlocator.dbOid != ctx->slot->data.database)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* output plugin doesn't look for this origin, no need to queue */
|
/* output plugin doesn't look for this origin, no need to queue */
|
||||||
@ -1103,7 +1103,7 @@ DecodeMultiInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
change->action = REORDER_BUFFER_CHANGE_INSERT;
|
change->action = REORDER_BUFFER_CHANGE_INSERT;
|
||||||
change->origin_id = XLogRecGetOrigin(r);
|
change->origin_id = XLogRecGetOrigin(r);
|
||||||
|
|
||||||
memcpy(&change->data.tp.relnode, &rnode, sizeof(RelFileNode));
|
memcpy(&change->data.tp.rlocator, &rlocator, sizeof(RelFileLocator));
|
||||||
|
|
||||||
xlhdr = (xl_multi_insert_tuple *) SHORTALIGN(data);
|
xlhdr = (xl_multi_insert_tuple *) SHORTALIGN(data);
|
||||||
data = ((char *) xlhdr) + SizeOfMultiInsertTuple;
|
data = ((char *) xlhdr) + SizeOfMultiInsertTuple;
|
||||||
@ -1165,11 +1165,11 @@ DecodeSpecConfirm(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
{
|
{
|
||||||
XLogReaderState *r = buf->record;
|
XLogReaderState *r = buf->record;
|
||||||
ReorderBufferChange *change;
|
ReorderBufferChange *change;
|
||||||
RelFileNode target_node;
|
RelFileLocator target_locator;
|
||||||
|
|
||||||
/* only interested in our database */
|
/* only interested in our database */
|
||||||
XLogRecGetBlockTag(r, 0, &target_node, NULL, NULL);
|
XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
|
||||||
if (target_node.dbNode != ctx->slot->data.database)
|
if (target_locator.dbOid != ctx->slot->data.database)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* output plugin doesn't look for this origin, no need to queue */
|
/* output plugin doesn't look for this origin, no need to queue */
|
||||||
@ -1180,7 +1180,7 @@ DecodeSpecConfirm(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
|||||||
change->action = REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM;
|
change->action = REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM;
|
||||||
change->origin_id = XLogRecGetOrigin(r);
|
change->origin_id = XLogRecGetOrigin(r);
|
||||||
|
|
||||||
memcpy(&change->data.tp.relnode, &target_node, sizeof(RelFileNode));
|
memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
|
||||||
|
|
||||||
change->data.tp.clear_toast_afterwards = true;
|
change->data.tp.clear_toast_afterwards = true;
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@
|
|||||||
#include "utils/memdebug.h"
|
#include "utils/memdebug.h"
|
||||||
#include "utils/memutils.h"
|
#include "utils/memutils.h"
|
||||||
#include "utils/rel.h"
|
#include "utils/rel.h"
|
||||||
#include "utils/relfilenodemap.h"
|
#include "utils/relfilenumbermap.h"
|
||||||
|
|
||||||
|
|
||||||
/* entry for a hash table we use to map from xid to our transaction state */
|
/* entry for a hash table we use to map from xid to our transaction state */
|
||||||
@ -116,10 +116,10 @@ typedef struct ReorderBufferTXNByIdEnt
|
|||||||
ReorderBufferTXN *txn;
|
ReorderBufferTXN *txn;
|
||||||
} ReorderBufferTXNByIdEnt;
|
} ReorderBufferTXNByIdEnt;
|
||||||
|
|
||||||
/* data structures for (relfilenode, ctid) => (cmin, cmax) mapping */
|
/* data structures for (relfilelocator, ctid) => (cmin, cmax) mapping */
|
||||||
typedef struct ReorderBufferTupleCidKey
|
typedef struct ReorderBufferTupleCidKey
|
||||||
{
|
{
|
||||||
RelFileNode relnode;
|
RelFileLocator rlocator;
|
||||||
ItemPointerData tid;
|
ItemPointerData tid;
|
||||||
} ReorderBufferTupleCidKey;
|
} ReorderBufferTupleCidKey;
|
||||||
|
|
||||||
@ -1643,7 +1643,7 @@ ReorderBufferTruncateTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, bool txn_prep
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Destroy the (relfilenode, ctid) hashtable, so that we don't leak any
|
* Destroy the (relfilelocator, ctid) hashtable, so that we don't leak any
|
||||||
* memory. We could also keep the hash table and update it with new ctid
|
* memory. We could also keep the hash table and update it with new ctid
|
||||||
* values, but this seems simpler and good enough for now.
|
* values, but this seems simpler and good enough for now.
|
||||||
*/
|
*/
|
||||||
@ -1673,7 +1673,7 @@ ReorderBufferTruncateTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, bool txn_prep
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build a hash with a (relfilenode, ctid) -> (cmin, cmax) mapping for use by
|
* Build a hash with a (relfilelocator, ctid) -> (cmin, cmax) mapping for use by
|
||||||
* HeapTupleSatisfiesHistoricMVCC.
|
* HeapTupleSatisfiesHistoricMVCC.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
@ -1711,7 +1711,7 @@ ReorderBufferBuildTupleCidHash(ReorderBuffer *rb, ReorderBufferTXN *txn)
|
|||||||
/* be careful about padding */
|
/* be careful about padding */
|
||||||
memset(&key, 0, sizeof(ReorderBufferTupleCidKey));
|
memset(&key, 0, sizeof(ReorderBufferTupleCidKey));
|
||||||
|
|
||||||
key.relnode = change->data.tuplecid.node;
|
key.rlocator = change->data.tuplecid.locator;
|
||||||
|
|
||||||
ItemPointerCopy(&change->data.tuplecid.tid,
|
ItemPointerCopy(&change->data.tuplecid.tid,
|
||||||
&key.tid);
|
&key.tid);
|
||||||
@ -2140,36 +2140,36 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn,
|
|||||||
case REORDER_BUFFER_CHANGE_DELETE:
|
case REORDER_BUFFER_CHANGE_DELETE:
|
||||||
Assert(snapshot_now);
|
Assert(snapshot_now);
|
||||||
|
|
||||||
reloid = RelidByRelfilenode(change->data.tp.relnode.spcNode,
|
reloid = RelidByRelfilenumber(change->data.tp.rlocator.spcOid,
|
||||||
change->data.tp.relnode.relNode);
|
change->data.tp.rlocator.relNumber);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mapped catalog tuple without data, emitted while
|
* Mapped catalog tuple without data, emitted while
|
||||||
* catalog table was in the process of being rewritten. We
|
* catalog table was in the process of being rewritten. We
|
||||||
* can fail to look up the relfilenode, because the
|
* can fail to look up the relfilenumber, because the
|
||||||
* relmapper has no "historic" view, in contrast to the
|
* relmapper has no "historic" view, in contrast to the
|
||||||
* normal catalog during decoding. Thus repeated rewrites
|
* normal catalog during decoding. Thus repeated rewrites
|
||||||
* can cause a lookup failure. That's OK because we do not
|
* can cause a lookup failure. That's OK because we do not
|
||||||
* decode catalog changes anyway. Normally such tuples
|
* decode catalog changes anyway. Normally such tuples
|
||||||
* would be skipped over below, but we can't identify
|
* would be skipped over below, but we can't identify
|
||||||
* whether the table should be logically logged without
|
* whether the table should be logically logged without
|
||||||
* mapping the relfilenode to the oid.
|
* mapping the relfilenumber to the oid.
|
||||||
*/
|
*/
|
||||||
if (reloid == InvalidOid &&
|
if (reloid == InvalidOid &&
|
||||||
change->data.tp.newtuple == NULL &&
|
change->data.tp.newtuple == NULL &&
|
||||||
change->data.tp.oldtuple == NULL)
|
change->data.tp.oldtuple == NULL)
|
||||||
goto change_done;
|
goto change_done;
|
||||||
else if (reloid == InvalidOid)
|
else if (reloid == InvalidOid)
|
||||||
elog(ERROR, "could not map filenode \"%s\" to relation OID",
|
elog(ERROR, "could not map filenumber \"%s\" to relation OID",
|
||||||
relpathperm(change->data.tp.relnode,
|
relpathperm(change->data.tp.rlocator,
|
||||||
MAIN_FORKNUM));
|
MAIN_FORKNUM));
|
||||||
|
|
||||||
relation = RelationIdGetRelation(reloid);
|
relation = RelationIdGetRelation(reloid);
|
||||||
|
|
||||||
if (!RelationIsValid(relation))
|
if (!RelationIsValid(relation))
|
||||||
elog(ERROR, "could not open relation with OID %u (for filenode \"%s\")",
|
elog(ERROR, "could not open relation with OID %u (for filenumber \"%s\")",
|
||||||
reloid,
|
reloid,
|
||||||
relpathperm(change->data.tp.relnode,
|
relpathperm(change->data.tp.rlocator,
|
||||||
MAIN_FORKNUM));
|
MAIN_FORKNUM));
|
||||||
|
|
||||||
if (!RelationIsLogicallyLogged(relation))
|
if (!RelationIsLogicallyLogged(relation))
|
||||||
@ -3157,7 +3157,7 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add new (relfilenode, tid) -> (cmin, cmax) mappings.
|
* Add new (relfilelocator, tid) -> (cmin, cmax) mappings.
|
||||||
*
|
*
|
||||||
* We do not include this change type in memory accounting, because we
|
* We do not include this change type in memory accounting, because we
|
||||||
* keep CIDs in a separate list and do not evict them when reaching
|
* keep CIDs in a separate list and do not evict them when reaching
|
||||||
@ -3165,7 +3165,7 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ReorderBufferAddNewTupleCids(ReorderBuffer *rb, TransactionId xid,
|
ReorderBufferAddNewTupleCids(ReorderBuffer *rb, TransactionId xid,
|
||||||
XLogRecPtr lsn, RelFileNode node,
|
XLogRecPtr lsn, RelFileLocator locator,
|
||||||
ItemPointerData tid, CommandId cmin,
|
ItemPointerData tid, CommandId cmin,
|
||||||
CommandId cmax, CommandId combocid)
|
CommandId cmax, CommandId combocid)
|
||||||
{
|
{
|
||||||
@ -3174,7 +3174,7 @@ ReorderBufferAddNewTupleCids(ReorderBuffer *rb, TransactionId xid,
|
|||||||
|
|
||||||
txn = ReorderBufferTXNByXid(rb, xid, true, NULL, lsn, true);
|
txn = ReorderBufferTXNByXid(rb, xid, true, NULL, lsn, true);
|
||||||
|
|
||||||
change->data.tuplecid.node = node;
|
change->data.tuplecid.locator = locator;
|
||||||
change->data.tuplecid.tid = tid;
|
change->data.tuplecid.tid = tid;
|
||||||
change->data.tuplecid.cmin = cmin;
|
change->data.tuplecid.cmin = cmin;
|
||||||
change->data.tuplecid.cmax = cmax;
|
change->data.tuplecid.cmax = cmax;
|
||||||
@ -4839,7 +4839,7 @@ ReorderBufferToastReset(ReorderBuffer *rb, ReorderBufferTXN *txn)
|
|||||||
* need anymore.
|
* need anymore.
|
||||||
*
|
*
|
||||||
* To resolve those problems we have a per-transaction hash of (cmin,
|
* To resolve those problems we have a per-transaction hash of (cmin,
|
||||||
* cmax) tuples keyed by (relfilenode, ctid) which contains the actual
|
* cmax) tuples keyed by (relfilelocator, ctid) which contains the actual
|
||||||
* (cmin, cmax) values. That also takes care of combo CIDs by simply
|
* (cmin, cmax) values. That also takes care of combo CIDs by simply
|
||||||
* not caring about them at all. As we have the real cmin/cmax values
|
* not caring about them at all. As we have the real cmin/cmax values
|
||||||
* combo CIDs aren't interesting.
|
* combo CIDs aren't interesting.
|
||||||
@ -4870,9 +4870,9 @@ DisplayMapping(HTAB *tuplecid_data)
|
|||||||
while ((ent = (ReorderBufferTupleCidEnt *) hash_seq_search(&hstat)) != NULL)
|
while ((ent = (ReorderBufferTupleCidEnt *) hash_seq_search(&hstat)) != NULL)
|
||||||
{
|
{
|
||||||
elog(DEBUG3, "mapping: node: %u/%u/%u tid: %u/%u cmin: %u, cmax: %u",
|
elog(DEBUG3, "mapping: node: %u/%u/%u tid: %u/%u cmin: %u, cmax: %u",
|
||||||
ent->key.relnode.dbNode,
|
ent->key.rlocator.dbOid,
|
||||||
ent->key.relnode.spcNode,
|
ent->key.rlocator.spcOid,
|
||||||
ent->key.relnode.relNode,
|
ent->key.rlocator.relNumber,
|
||||||
ItemPointerGetBlockNumber(&ent->key.tid),
|
ItemPointerGetBlockNumber(&ent->key.tid),
|
||||||
ItemPointerGetOffsetNumber(&ent->key.tid),
|
ItemPointerGetOffsetNumber(&ent->key.tid),
|
||||||
ent->cmin,
|
ent->cmin,
|
||||||
@ -4932,7 +4932,7 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid, const char *fname)
|
|||||||
path, readBytes,
|
path, readBytes,
|
||||||
(int32) sizeof(LogicalRewriteMappingData))));
|
(int32) sizeof(LogicalRewriteMappingData))));
|
||||||
|
|
||||||
key.relnode = map.old_node;
|
key.rlocator = map.old_locator;
|
||||||
ItemPointerCopy(&map.old_tid,
|
ItemPointerCopy(&map.old_tid,
|
||||||
&key.tid);
|
&key.tid);
|
||||||
|
|
||||||
@ -4947,7 +4947,7 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid, const char *fname)
|
|||||||
if (!ent)
|
if (!ent)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
key.relnode = map.new_node;
|
key.rlocator = map.new_locator;
|
||||||
ItemPointerCopy(&map.new_tid,
|
ItemPointerCopy(&map.new_tid,
|
||||||
&key.tid);
|
&key.tid);
|
||||||
|
|
||||||
@ -5120,10 +5120,10 @@ ResolveCminCmaxDuringDecoding(HTAB *tuplecid_data,
|
|||||||
Assert(!BufferIsLocal(buffer));
|
Assert(!BufferIsLocal(buffer));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get relfilenode from the buffer, no convenient way to access it other
|
* get relfilelocator from the buffer, no convenient way to access it
|
||||||
* than that.
|
* other than that.
|
||||||
*/
|
*/
|
||||||
BufferGetTag(buffer, &key.relnode, &forkno, &blockno);
|
BufferGetTag(buffer, &key.rlocator, &forkno, &blockno);
|
||||||
|
|
||||||
/* tuples can only be in the main fork */
|
/* tuples can only be in the main fork */
|
||||||
Assert(forkno == MAIN_FORKNUM);
|
Assert(forkno == MAIN_FORKNUM);
|
||||||
|
@ -781,7 +781,7 @@ SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
|
|||||||
ReorderBufferXidSetCatalogChanges(builder->reorder, xid, lsn);
|
ReorderBufferXidSetCatalogChanges(builder->reorder, xid, lsn);
|
||||||
|
|
||||||
ReorderBufferAddNewTupleCids(builder->reorder, xlrec->top_xid, lsn,
|
ReorderBufferAddNewTupleCids(builder->reorder, xlrec->top_xid, lsn,
|
||||||
xlrec->target_node, xlrec->target_tid,
|
xlrec->target_locator, xlrec->target_tid,
|
||||||
xlrec->cmin, xlrec->cmax,
|
xlrec->cmin, xlrec->cmax,
|
||||||
xlrec->combocid);
|
xlrec->combocid);
|
||||||
|
|
||||||
|
@ -121,12 +121,12 @@ typedef struct CkptTsStatus
|
|||||||
* Type for array used to sort SMgrRelations
|
* Type for array used to sort SMgrRelations
|
||||||
*
|
*
|
||||||
* FlushRelationsAllBuffers shares the same comparator function with
|
* FlushRelationsAllBuffers shares the same comparator function with
|
||||||
* DropRelFileNodesAllBuffers. Pointer to this struct and RelFileNode must be
|
* DropRelFileLocatorsAllBuffers. Pointer to this struct and RelFileLocator must be
|
||||||
* compatible.
|
* compatible.
|
||||||
*/
|
*/
|
||||||
typedef struct SMgrSortArray
|
typedef struct SMgrSortArray
|
||||||
{
|
{
|
||||||
RelFileNode rnode; /* This must be the first member */
|
RelFileLocator rlocator; /* This must be the first member */
|
||||||
SMgrRelation srel;
|
SMgrRelation srel;
|
||||||
} SMgrSortArray;
|
} SMgrSortArray;
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ static BufferDesc *BufferAlloc(SMgrRelation smgr,
|
|||||||
BufferAccessStrategy strategy,
|
BufferAccessStrategy strategy,
|
||||||
bool *foundPtr);
|
bool *foundPtr);
|
||||||
static void FlushBuffer(BufferDesc *buf, SMgrRelation reln);
|
static void FlushBuffer(BufferDesc *buf, SMgrRelation reln);
|
||||||
static void FindAndDropRelFileNodeBuffers(RelFileNode rnode,
|
static void FindAndDropRelFileLocatorBuffers(RelFileLocator rlocator,
|
||||||
ForkNumber forkNum,
|
ForkNumber forkNum,
|
||||||
BlockNumber nForkBlock,
|
BlockNumber nForkBlock,
|
||||||
BlockNumber firstDelBlock);
|
BlockNumber firstDelBlock);
|
||||||
@ -492,7 +492,7 @@ static void RelationCopyStorageUsingBuffer(Relation src, Relation dst,
|
|||||||
bool isunlogged);
|
bool isunlogged);
|
||||||
static void AtProcExit_Buffers(int code, Datum arg);
|
static void AtProcExit_Buffers(int code, Datum arg);
|
||||||
static void CheckForBufferLeaks(void);
|
static void CheckForBufferLeaks(void);
|
||||||
static int rnode_comparator(const void *p1, const void *p2);
|
static int rlocator_comparator(const void *p1, const void *p2);
|
||||||
static inline int buffertag_comparator(const BufferTag *a, const BufferTag *b);
|
static inline int buffertag_comparator(const BufferTag *a, const BufferTag *b);
|
||||||
static inline int ckpt_buforder_comparator(const CkptSortItem *a, const CkptSortItem *b);
|
static inline int ckpt_buforder_comparator(const CkptSortItem *a, const CkptSortItem *b);
|
||||||
static int ts_ckpt_progress_comparator(Datum a, Datum b, void *arg);
|
static int ts_ckpt_progress_comparator(Datum a, Datum b, void *arg);
|
||||||
@ -515,7 +515,7 @@ PrefetchSharedBuffer(SMgrRelation smgr_reln,
|
|||||||
Assert(BlockNumberIsValid(blockNum));
|
Assert(BlockNumberIsValid(blockNum));
|
||||||
|
|
||||||
/* create a tag so we can lookup the buffer */
|
/* create a tag so we can lookup the buffer */
|
||||||
INIT_BUFFERTAG(newTag, smgr_reln->smgr_rnode.node,
|
INIT_BUFFERTAG(newTag, smgr_reln->smgr_rlocator.locator,
|
||||||
forkNum, blockNum);
|
forkNum, blockNum);
|
||||||
|
|
||||||
/* determine its hash code and partition lock ID */
|
/* determine its hash code and partition lock ID */
|
||||||
@ -620,7 +620,7 @@ PrefetchBuffer(Relation reln, ForkNumber forkNum, BlockNumber blockNum)
|
|||||||
* tag. In that case, the buffer is pinned and the usage count is bumped.
|
* tag. In that case, the buffer is pinned and the usage count is bumped.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
ReadRecentBuffer(RelFileNode rnode, ForkNumber forkNum, BlockNumber blockNum,
|
ReadRecentBuffer(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber blockNum,
|
||||||
Buffer recent_buffer)
|
Buffer recent_buffer)
|
||||||
{
|
{
|
||||||
BufferDesc *bufHdr;
|
BufferDesc *bufHdr;
|
||||||
@ -632,7 +632,7 @@ ReadRecentBuffer(RelFileNode rnode, ForkNumber forkNum, BlockNumber blockNum,
|
|||||||
|
|
||||||
ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
|
ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
|
||||||
ReservePrivateRefCountEntry();
|
ReservePrivateRefCountEntry();
|
||||||
INIT_BUFFERTAG(tag, rnode, forkNum, blockNum);
|
INIT_BUFFERTAG(tag, rlocator, forkNum, blockNum);
|
||||||
|
|
||||||
if (BufferIsLocal(recent_buffer))
|
if (BufferIsLocal(recent_buffer))
|
||||||
{
|
{
|
||||||
@ -786,13 +786,13 @@ ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum,
|
|||||||
* BackendId).
|
* BackendId).
|
||||||
*/
|
*/
|
||||||
Buffer
|
Buffer
|
||||||
ReadBufferWithoutRelcache(RelFileNode rnode, ForkNumber forkNum,
|
ReadBufferWithoutRelcache(RelFileLocator rlocator, ForkNumber forkNum,
|
||||||
BlockNumber blockNum, ReadBufferMode mode,
|
BlockNumber blockNum, ReadBufferMode mode,
|
||||||
BufferAccessStrategy strategy, bool permanent)
|
BufferAccessStrategy strategy, bool permanent)
|
||||||
{
|
{
|
||||||
bool hit;
|
bool hit;
|
||||||
|
|
||||||
SMgrRelation smgr = smgropen(rnode, InvalidBackendId);
|
SMgrRelation smgr = smgropen(rlocator, InvalidBackendId);
|
||||||
|
|
||||||
return ReadBuffer_common(smgr, permanent ? RELPERSISTENCE_PERMANENT :
|
return ReadBuffer_common(smgr, permanent ? RELPERSISTENCE_PERMANENT :
|
||||||
RELPERSISTENCE_UNLOGGED, forkNum, blockNum,
|
RELPERSISTENCE_UNLOGGED, forkNum, blockNum,
|
||||||
@ -824,10 +824,10 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
isExtend = (blockNum == P_NEW);
|
isExtend = (blockNum == P_NEW);
|
||||||
|
|
||||||
TRACE_POSTGRESQL_BUFFER_READ_START(forkNum, blockNum,
|
TRACE_POSTGRESQL_BUFFER_READ_START(forkNum, blockNum,
|
||||||
smgr->smgr_rnode.node.spcNode,
|
smgr->smgr_rlocator.locator.spcOid,
|
||||||
smgr->smgr_rnode.node.dbNode,
|
smgr->smgr_rlocator.locator.dbOid,
|
||||||
smgr->smgr_rnode.node.relNode,
|
smgr->smgr_rlocator.locator.relNumber,
|
||||||
smgr->smgr_rnode.backend,
|
smgr->smgr_rlocator.backend,
|
||||||
isExtend);
|
isExtend);
|
||||||
|
|
||||||
/* Substitute proper block number if caller asked for P_NEW */
|
/* Substitute proper block number if caller asked for P_NEW */
|
||||||
@ -839,7 +839,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||||
errmsg("cannot extend relation %s beyond %u blocks",
|
errmsg("cannot extend relation %s beyond %u blocks",
|
||||||
relpath(smgr->smgr_rnode, forkNum),
|
relpath(smgr->smgr_rlocator, forkNum),
|
||||||
P_NEW)));
|
P_NEW)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -886,10 +886,10 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
VacuumCostBalance += VacuumCostPageHit;
|
VacuumCostBalance += VacuumCostPageHit;
|
||||||
|
|
||||||
TRACE_POSTGRESQL_BUFFER_READ_DONE(forkNum, blockNum,
|
TRACE_POSTGRESQL_BUFFER_READ_DONE(forkNum, blockNum,
|
||||||
smgr->smgr_rnode.node.spcNode,
|
smgr->smgr_rlocator.locator.spcOid,
|
||||||
smgr->smgr_rnode.node.dbNode,
|
smgr->smgr_rlocator.locator.dbOid,
|
||||||
smgr->smgr_rnode.node.relNode,
|
smgr->smgr_rlocator.locator.relNumber,
|
||||||
smgr->smgr_rnode.backend,
|
smgr->smgr_rlocator.backend,
|
||||||
isExtend,
|
isExtend,
|
||||||
found);
|
found);
|
||||||
|
|
||||||
@ -926,7 +926,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
if (!PageIsNew((Page) bufBlock))
|
if (!PageIsNew((Page) bufBlock))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errmsg("unexpected data beyond EOF in block %u of relation %s",
|
(errmsg("unexpected data beyond EOF in block %u of relation %s",
|
||||||
blockNum, relpath(smgr->smgr_rnode, forkNum)),
|
blockNum, relpath(smgr->smgr_rlocator, forkNum)),
|
||||||
errhint("This has been seen to occur with buggy kernels; consider updating your system.")));
|
errhint("This has been seen to occur with buggy kernels; consider updating your system.")));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1028,7 +1028,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||||
errmsg("invalid page in block %u of relation %s; zeroing out page",
|
errmsg("invalid page in block %u of relation %s; zeroing out page",
|
||||||
blockNum,
|
blockNum,
|
||||||
relpath(smgr->smgr_rnode, forkNum))));
|
relpath(smgr->smgr_rlocator, forkNum))));
|
||||||
MemSet((char *) bufBlock, 0, BLCKSZ);
|
MemSet((char *) bufBlock, 0, BLCKSZ);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1036,7 +1036,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||||
errmsg("invalid page in block %u of relation %s",
|
errmsg("invalid page in block %u of relation %s",
|
||||||
blockNum,
|
blockNum,
|
||||||
relpath(smgr->smgr_rnode, forkNum))));
|
relpath(smgr->smgr_rlocator, forkNum))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1076,10 +1076,10 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
VacuumCostBalance += VacuumCostPageMiss;
|
VacuumCostBalance += VacuumCostPageMiss;
|
||||||
|
|
||||||
TRACE_POSTGRESQL_BUFFER_READ_DONE(forkNum, blockNum,
|
TRACE_POSTGRESQL_BUFFER_READ_DONE(forkNum, blockNum,
|
||||||
smgr->smgr_rnode.node.spcNode,
|
smgr->smgr_rlocator.locator.spcOid,
|
||||||
smgr->smgr_rnode.node.dbNode,
|
smgr->smgr_rlocator.locator.dbOid,
|
||||||
smgr->smgr_rnode.node.relNode,
|
smgr->smgr_rlocator.locator.relNumber,
|
||||||
smgr->smgr_rnode.backend,
|
smgr->smgr_rlocator.backend,
|
||||||
isExtend,
|
isExtend,
|
||||||
found);
|
found);
|
||||||
|
|
||||||
@ -1124,7 +1124,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
uint32 buf_state;
|
uint32 buf_state;
|
||||||
|
|
||||||
/* create a tag so we can lookup the buffer */
|
/* create a tag so we can lookup the buffer */
|
||||||
INIT_BUFFERTAG(newTag, smgr->smgr_rnode.node, forkNum, blockNum);
|
INIT_BUFFERTAG(newTag, smgr->smgr_rlocator.locator, forkNum, blockNum);
|
||||||
|
|
||||||
/* determine its hash code and partition lock ID */
|
/* determine its hash code and partition lock ID */
|
||||||
newHash = BufTableHashCode(&newTag);
|
newHash = BufTableHashCode(&newTag);
|
||||||
@ -1255,9 +1255,9 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
|
|
||||||
/* OK, do the I/O */
|
/* OK, do the I/O */
|
||||||
TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_START(forkNum, blockNum,
|
TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_START(forkNum, blockNum,
|
||||||
smgr->smgr_rnode.node.spcNode,
|
smgr->smgr_rlocator.locator.spcOid,
|
||||||
smgr->smgr_rnode.node.dbNode,
|
smgr->smgr_rlocator.locator.dbOid,
|
||||||
smgr->smgr_rnode.node.relNode);
|
smgr->smgr_rlocator.locator.relNumber);
|
||||||
|
|
||||||
FlushBuffer(buf, NULL);
|
FlushBuffer(buf, NULL);
|
||||||
LWLockRelease(BufferDescriptorGetContentLock(buf));
|
LWLockRelease(BufferDescriptorGetContentLock(buf));
|
||||||
@ -1266,9 +1266,9 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
&buf->tag);
|
&buf->tag);
|
||||||
|
|
||||||
TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_DONE(forkNum, blockNum,
|
TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_DONE(forkNum, blockNum,
|
||||||
smgr->smgr_rnode.node.spcNode,
|
smgr->smgr_rlocator.locator.spcOid,
|
||||||
smgr->smgr_rnode.node.dbNode,
|
smgr->smgr_rlocator.locator.dbOid,
|
||||||
smgr->smgr_rnode.node.relNode);
|
smgr->smgr_rlocator.locator.relNumber);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1647,7 +1647,7 @@ ReleaseAndReadBuffer(Buffer buffer,
|
|||||||
{
|
{
|
||||||
bufHdr = GetLocalBufferDescriptor(-buffer - 1);
|
bufHdr = GetLocalBufferDescriptor(-buffer - 1);
|
||||||
if (bufHdr->tag.blockNum == blockNum &&
|
if (bufHdr->tag.blockNum == blockNum &&
|
||||||
RelFileNodeEquals(bufHdr->tag.rnode, relation->rd_node) &&
|
RelFileLocatorEquals(bufHdr->tag.rlocator, relation->rd_locator) &&
|
||||||
bufHdr->tag.forkNum == forkNum)
|
bufHdr->tag.forkNum == forkNum)
|
||||||
return buffer;
|
return buffer;
|
||||||
ResourceOwnerForgetBuffer(CurrentResourceOwner, buffer);
|
ResourceOwnerForgetBuffer(CurrentResourceOwner, buffer);
|
||||||
@ -1658,7 +1658,7 @@ ReleaseAndReadBuffer(Buffer buffer,
|
|||||||
bufHdr = GetBufferDescriptor(buffer - 1);
|
bufHdr = GetBufferDescriptor(buffer - 1);
|
||||||
/* we have pin, so it's ok to examine tag without spinlock */
|
/* we have pin, so it's ok to examine tag without spinlock */
|
||||||
if (bufHdr->tag.blockNum == blockNum &&
|
if (bufHdr->tag.blockNum == blockNum &&
|
||||||
RelFileNodeEquals(bufHdr->tag.rnode, relation->rd_node) &&
|
RelFileLocatorEquals(bufHdr->tag.rlocator, relation->rd_locator) &&
|
||||||
bufHdr->tag.forkNum == forkNum)
|
bufHdr->tag.forkNum == forkNum)
|
||||||
return buffer;
|
return buffer;
|
||||||
UnpinBuffer(bufHdr, true);
|
UnpinBuffer(bufHdr, true);
|
||||||
@ -2000,8 +2000,8 @@ BufferSync(int flags)
|
|||||||
|
|
||||||
item = &CkptBufferIds[num_to_scan++];
|
item = &CkptBufferIds[num_to_scan++];
|
||||||
item->buf_id = buf_id;
|
item->buf_id = buf_id;
|
||||||
item->tsId = bufHdr->tag.rnode.spcNode;
|
item->tsId = bufHdr->tag.rlocator.spcOid;
|
||||||
item->relNode = bufHdr->tag.rnode.relNode;
|
item->relNumber = bufHdr->tag.rlocator.relNumber;
|
||||||
item->forkNum = bufHdr->tag.forkNum;
|
item->forkNum = bufHdr->tag.forkNum;
|
||||||
item->blockNum = bufHdr->tag.blockNum;
|
item->blockNum = bufHdr->tag.blockNum;
|
||||||
}
|
}
|
||||||
@ -2708,7 +2708,7 @@ PrintBufferLeakWarning(Buffer buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* theoretically we should lock the bufhdr here */
|
/* theoretically we should lock the bufhdr here */
|
||||||
path = relpathbackend(buf->tag.rnode, backend, buf->tag.forkNum);
|
path = relpathbackend(buf->tag.rlocator, backend, buf->tag.forkNum);
|
||||||
buf_state = pg_atomic_read_u32(&buf->state);
|
buf_state = pg_atomic_read_u32(&buf->state);
|
||||||
elog(WARNING,
|
elog(WARNING,
|
||||||
"buffer refcount leak: [%03d] "
|
"buffer refcount leak: [%03d] "
|
||||||
@ -2769,11 +2769,11 @@ BufferGetBlockNumber(Buffer buffer)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* BufferGetTag
|
* BufferGetTag
|
||||||
* Returns the relfilenode, fork number and block number associated with
|
* Returns the relfilelocator, fork number and block number associated with
|
||||||
* a buffer.
|
* a buffer.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BufferGetTag(Buffer buffer, RelFileNode *rnode, ForkNumber *forknum,
|
BufferGetTag(Buffer buffer, RelFileLocator *rlocator, ForkNumber *forknum,
|
||||||
BlockNumber *blknum)
|
BlockNumber *blknum)
|
||||||
{
|
{
|
||||||
BufferDesc *bufHdr;
|
BufferDesc *bufHdr;
|
||||||
@ -2787,7 +2787,7 @@ BufferGetTag(Buffer buffer, RelFileNode *rnode, ForkNumber *forknum,
|
|||||||
bufHdr = GetBufferDescriptor(buffer - 1);
|
bufHdr = GetBufferDescriptor(buffer - 1);
|
||||||
|
|
||||||
/* pinned, so OK to read tag without spinlock */
|
/* pinned, so OK to read tag without spinlock */
|
||||||
*rnode = bufHdr->tag.rnode;
|
*rlocator = bufHdr->tag.rlocator;
|
||||||
*forknum = bufHdr->tag.forkNum;
|
*forknum = bufHdr->tag.forkNum;
|
||||||
*blknum = bufHdr->tag.blockNum;
|
*blknum = bufHdr->tag.blockNum;
|
||||||
}
|
}
|
||||||
@ -2838,13 +2838,13 @@ FlushBuffer(BufferDesc *buf, SMgrRelation reln)
|
|||||||
|
|
||||||
/* Find smgr relation for buffer */
|
/* Find smgr relation for buffer */
|
||||||
if (reln == NULL)
|
if (reln == NULL)
|
||||||
reln = smgropen(buf->tag.rnode, InvalidBackendId);
|
reln = smgropen(buf->tag.rlocator, InvalidBackendId);
|
||||||
|
|
||||||
TRACE_POSTGRESQL_BUFFER_FLUSH_START(buf->tag.forkNum,
|
TRACE_POSTGRESQL_BUFFER_FLUSH_START(buf->tag.forkNum,
|
||||||
buf->tag.blockNum,
|
buf->tag.blockNum,
|
||||||
reln->smgr_rnode.node.spcNode,
|
reln->smgr_rlocator.locator.spcOid,
|
||||||
reln->smgr_rnode.node.dbNode,
|
reln->smgr_rlocator.locator.dbOid,
|
||||||
reln->smgr_rnode.node.relNode);
|
reln->smgr_rlocator.locator.relNumber);
|
||||||
|
|
||||||
buf_state = LockBufHdr(buf);
|
buf_state = LockBufHdr(buf);
|
||||||
|
|
||||||
@ -2922,9 +2922,9 @@ FlushBuffer(BufferDesc *buf, SMgrRelation reln)
|
|||||||
|
|
||||||
TRACE_POSTGRESQL_BUFFER_FLUSH_DONE(buf->tag.forkNum,
|
TRACE_POSTGRESQL_BUFFER_FLUSH_DONE(buf->tag.forkNum,
|
||||||
buf->tag.blockNum,
|
buf->tag.blockNum,
|
||||||
reln->smgr_rnode.node.spcNode,
|
reln->smgr_rlocator.locator.spcOid,
|
||||||
reln->smgr_rnode.node.dbNode,
|
reln->smgr_rlocator.locator.dbOid,
|
||||||
reln->smgr_rnode.node.relNode);
|
reln->smgr_rlocator.locator.relNumber);
|
||||||
|
|
||||||
/* Pop the error context stack */
|
/* Pop the error context stack */
|
||||||
error_context_stack = errcallback.previous;
|
error_context_stack = errcallback.previous;
|
||||||
@ -3026,7 +3026,7 @@ BufferGetLSNAtomic(Buffer buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
* DropRelFileNodeBuffers
|
* DropRelFileLocatorBuffers
|
||||||
*
|
*
|
||||||
* This function removes from the buffer pool all the pages of the
|
* This function removes from the buffer pool all the pages of the
|
||||||
* specified relation forks that have block numbers >= firstDelBlock.
|
* specified relation forks that have block numbers >= firstDelBlock.
|
||||||
@ -3047,24 +3047,24 @@ BufferGetLSNAtomic(Buffer buffer)
|
|||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
DropRelFileNodeBuffers(SMgrRelation smgr_reln, ForkNumber *forkNum,
|
DropRelFileLocatorBuffers(SMgrRelation smgr_reln, ForkNumber *forkNum,
|
||||||
int nforks, BlockNumber *firstDelBlock)
|
int nforks, BlockNumber *firstDelBlock)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
RelFileNodeBackend rnode;
|
RelFileLocatorBackend rlocator;
|
||||||
BlockNumber nForkBlock[MAX_FORKNUM];
|
BlockNumber nForkBlock[MAX_FORKNUM];
|
||||||
uint64 nBlocksToInvalidate = 0;
|
uint64 nBlocksToInvalidate = 0;
|
||||||
|
|
||||||
rnode = smgr_reln->smgr_rnode;
|
rlocator = smgr_reln->smgr_rlocator;
|
||||||
|
|
||||||
/* If it's a local relation, it's localbuf.c's problem. */
|
/* If it's a local relation, it's localbuf.c's problem. */
|
||||||
if (RelFileNodeBackendIsTemp(rnode))
|
if (RelFileLocatorBackendIsTemp(rlocator))
|
||||||
{
|
{
|
||||||
if (rnode.backend == MyBackendId)
|
if (rlocator.backend == MyBackendId)
|
||||||
{
|
{
|
||||||
for (j = 0; j < nforks; j++)
|
for (j = 0; j < nforks; j++)
|
||||||
DropRelFileNodeLocalBuffers(rnode.node, forkNum[j],
|
DropRelFileLocatorLocalBuffers(rlocator.locator, forkNum[j],
|
||||||
firstDelBlock[j]);
|
firstDelBlock[j]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -3115,7 +3115,7 @@ DropRelFileNodeBuffers(SMgrRelation smgr_reln, ForkNumber *forkNum,
|
|||||||
nBlocksToInvalidate < BUF_DROP_FULL_SCAN_THRESHOLD)
|
nBlocksToInvalidate < BUF_DROP_FULL_SCAN_THRESHOLD)
|
||||||
{
|
{
|
||||||
for (j = 0; j < nforks; j++)
|
for (j = 0; j < nforks; j++)
|
||||||
FindAndDropRelFileNodeBuffers(rnode.node, forkNum[j],
|
FindAndDropRelFileLocatorBuffers(rlocator.locator, forkNum[j],
|
||||||
nForkBlock[j], firstDelBlock[j]);
|
nForkBlock[j], firstDelBlock[j]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3138,17 +3138,17 @@ DropRelFileNodeBuffers(SMgrRelation smgr_reln, ForkNumber *forkNum,
|
|||||||
* false positives are safe because we'll recheck after getting the
|
* false positives are safe because we'll recheck after getting the
|
||||||
* buffer lock.
|
* buffer lock.
|
||||||
*
|
*
|
||||||
* We could check forkNum and blockNum as well as the rnode, but the
|
* We could check forkNum and blockNum as well as the rlocator, but
|
||||||
* incremental win from doing so seems small.
|
* the incremental win from doing so seems small.
|
||||||
*/
|
*/
|
||||||
if (!RelFileNodeEquals(bufHdr->tag.rnode, rnode.node))
|
if (!RelFileLocatorEquals(bufHdr->tag.rlocator, rlocator.locator))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
buf_state = LockBufHdr(bufHdr);
|
buf_state = LockBufHdr(bufHdr);
|
||||||
|
|
||||||
for (j = 0; j < nforks; j++)
|
for (j = 0; j < nforks; j++)
|
||||||
{
|
{
|
||||||
if (RelFileNodeEquals(bufHdr->tag.rnode, rnode.node) &&
|
if (RelFileLocatorEquals(bufHdr->tag.rlocator, rlocator.locator) &&
|
||||||
bufHdr->tag.forkNum == forkNum[j] &&
|
bufHdr->tag.forkNum == forkNum[j] &&
|
||||||
bufHdr->tag.blockNum >= firstDelBlock[j])
|
bufHdr->tag.blockNum >= firstDelBlock[j])
|
||||||
{
|
{
|
||||||
@ -3162,16 +3162,16 @@ DropRelFileNodeBuffers(SMgrRelation smgr_reln, ForkNumber *forkNum,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
* DropRelFileNodesAllBuffers
|
* DropRelFileLocatorsAllBuffers
|
||||||
*
|
*
|
||||||
* This function removes from the buffer pool all the pages of all
|
* This function removes from the buffer pool all the pages of all
|
||||||
* forks of the specified relations. It's equivalent to calling
|
* forks of the specified relations. It's equivalent to calling
|
||||||
* DropRelFileNodeBuffers once per fork per relation with
|
* DropRelFileLocatorBuffers once per fork per relation with
|
||||||
* firstDelBlock = 0.
|
* firstDelBlock = 0.
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
DropRelFileNodesAllBuffers(SMgrRelation *smgr_reln, int nnodes)
|
DropRelFileLocatorsAllBuffers(SMgrRelation *smgr_reln, int nlocators)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
@ -3179,22 +3179,22 @@ DropRelFileNodesAllBuffers(SMgrRelation *smgr_reln, int nnodes)
|
|||||||
SMgrRelation *rels;
|
SMgrRelation *rels;
|
||||||
BlockNumber (*block)[MAX_FORKNUM + 1];
|
BlockNumber (*block)[MAX_FORKNUM + 1];
|
||||||
uint64 nBlocksToInvalidate = 0;
|
uint64 nBlocksToInvalidate = 0;
|
||||||
RelFileNode *nodes;
|
RelFileLocator *locators;
|
||||||
bool cached = true;
|
bool cached = true;
|
||||||
bool use_bsearch;
|
bool use_bsearch;
|
||||||
|
|
||||||
if (nnodes == 0)
|
if (nlocators == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rels = palloc(sizeof(SMgrRelation) * nnodes); /* non-local relations */
|
rels = palloc(sizeof(SMgrRelation) * nlocators); /* non-local relations */
|
||||||
|
|
||||||
/* If it's a local relation, it's localbuf.c's problem. */
|
/* If it's a local relation, it's localbuf.c's problem. */
|
||||||
for (i = 0; i < nnodes; i++)
|
for (i = 0; i < nlocators; i++)
|
||||||
{
|
{
|
||||||
if (RelFileNodeBackendIsTemp(smgr_reln[i]->smgr_rnode))
|
if (RelFileLocatorBackendIsTemp(smgr_reln[i]->smgr_rlocator))
|
||||||
{
|
{
|
||||||
if (smgr_reln[i]->smgr_rnode.backend == MyBackendId)
|
if (smgr_reln[i]->smgr_rlocator.backend == MyBackendId)
|
||||||
DropRelFileNodeAllLocalBuffers(smgr_reln[i]->smgr_rnode.node);
|
DropRelFileLocatorAllLocalBuffers(smgr_reln[i]->smgr_rlocator.locator);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rels[n++] = smgr_reln[i];
|
rels[n++] = smgr_reln[i];
|
||||||
@ -3219,7 +3219,7 @@ DropRelFileNodesAllBuffers(SMgrRelation *smgr_reln, int nnodes)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* We can avoid scanning the entire buffer pool if we know the exact size
|
* We can avoid scanning the entire buffer pool if we know the exact size
|
||||||
* of each of the given relation forks. See DropRelFileNodeBuffers.
|
* of each of the given relation forks. See DropRelFileLocatorBuffers.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < n && cached; i++)
|
for (i = 0; i < n && cached; i++)
|
||||||
{
|
{
|
||||||
@ -3257,7 +3257,7 @@ DropRelFileNodesAllBuffers(SMgrRelation *smgr_reln, int nnodes)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* drop all the buffers for a particular relation fork */
|
/* drop all the buffers for a particular relation fork */
|
||||||
FindAndDropRelFileNodeBuffers(rels[i]->smgr_rnode.node,
|
FindAndDropRelFileLocatorBuffers(rels[i]->smgr_rlocator.locator,
|
||||||
j, block[i][j], 0);
|
j, block[i][j], 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3268,9 +3268,9 @@ DropRelFileNodesAllBuffers(SMgrRelation *smgr_reln, int nnodes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pfree(block);
|
pfree(block);
|
||||||
nodes = palloc(sizeof(RelFileNode) * n); /* non-local relations */
|
locators = palloc(sizeof(RelFileLocator) * n); /* non-local relations */
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
nodes[i] = rels[i]->smgr_rnode.node;
|
locators[i] = rels[i]->smgr_rlocator.locator;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For low number of relations to drop just use a simple walk through, to
|
* For low number of relations to drop just use a simple walk through, to
|
||||||
@ -3280,19 +3280,19 @@ DropRelFileNodesAllBuffers(SMgrRelation *smgr_reln, int nnodes)
|
|||||||
*/
|
*/
|
||||||
use_bsearch = n > RELS_BSEARCH_THRESHOLD;
|
use_bsearch = n > RELS_BSEARCH_THRESHOLD;
|
||||||
|
|
||||||
/* sort the list of rnodes if necessary */
|
/* sort the list of rlocators if necessary */
|
||||||
if (use_bsearch)
|
if (use_bsearch)
|
||||||
pg_qsort(nodes, n, sizeof(RelFileNode), rnode_comparator);
|
pg_qsort(locators, n, sizeof(RelFileLocator), rlocator_comparator);
|
||||||
|
|
||||||
for (i = 0; i < NBuffers; i++)
|
for (i = 0; i < NBuffers; i++)
|
||||||
{
|
{
|
||||||
RelFileNode *rnode = NULL;
|
RelFileLocator *rlocator = NULL;
|
||||||
BufferDesc *bufHdr = GetBufferDescriptor(i);
|
BufferDesc *bufHdr = GetBufferDescriptor(i);
|
||||||
uint32 buf_state;
|
uint32 buf_state;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As in DropRelFileNodeBuffers, an unlocked precheck should be safe
|
* As in DropRelFileLocatorBuffers, an unlocked precheck should be
|
||||||
* and saves some cycles.
|
* safe and saves some cycles.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!use_bsearch)
|
if (!use_bsearch)
|
||||||
@ -3301,37 +3301,37 @@ DropRelFileNodesAllBuffers(SMgrRelation *smgr_reln, int nnodes)
|
|||||||
|
|
||||||
for (j = 0; j < n; j++)
|
for (j = 0; j < n; j++)
|
||||||
{
|
{
|
||||||
if (RelFileNodeEquals(bufHdr->tag.rnode, nodes[j]))
|
if (RelFileLocatorEquals(bufHdr->tag.rlocator, locators[j]))
|
||||||
{
|
{
|
||||||
rnode = &nodes[j];
|
rlocator = &locators[j];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rnode = bsearch((const void *) &(bufHdr->tag.rnode),
|
rlocator = bsearch((const void *) &(bufHdr->tag.rlocator),
|
||||||
nodes, n, sizeof(RelFileNode),
|
locators, n, sizeof(RelFileLocator),
|
||||||
rnode_comparator);
|
rlocator_comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* buffer doesn't belong to any of the given relfilenodes; skip it */
|
/* buffer doesn't belong to any of the given relfilelocators; skip it */
|
||||||
if (rnode == NULL)
|
if (rlocator == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
buf_state = LockBufHdr(bufHdr);
|
buf_state = LockBufHdr(bufHdr);
|
||||||
if (RelFileNodeEquals(bufHdr->tag.rnode, (*rnode)))
|
if (RelFileLocatorEquals(bufHdr->tag.rlocator, (*rlocator)))
|
||||||
InvalidateBuffer(bufHdr); /* releases spinlock */
|
InvalidateBuffer(bufHdr); /* releases spinlock */
|
||||||
else
|
else
|
||||||
UnlockBufHdr(bufHdr, buf_state);
|
UnlockBufHdr(bufHdr, buf_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
pfree(nodes);
|
pfree(locators);
|
||||||
pfree(rels);
|
pfree(rels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
* FindAndDropRelFileNodeBuffers
|
* FindAndDropRelFileLocatorBuffers
|
||||||
*
|
*
|
||||||
* This function performs look up in BufMapping table and removes from the
|
* This function performs look up in BufMapping table and removes from the
|
||||||
* buffer pool all the pages of the specified relation fork that has block
|
* buffer pool all the pages of the specified relation fork that has block
|
||||||
@ -3340,7 +3340,7 @@ DropRelFileNodesAllBuffers(SMgrRelation *smgr_reln, int nnodes)
|
|||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
FindAndDropRelFileNodeBuffers(RelFileNode rnode, ForkNumber forkNum,
|
FindAndDropRelFileLocatorBuffers(RelFileLocator rlocator, ForkNumber forkNum,
|
||||||
BlockNumber nForkBlock,
|
BlockNumber nForkBlock,
|
||||||
BlockNumber firstDelBlock)
|
BlockNumber firstDelBlock)
|
||||||
{
|
{
|
||||||
@ -3356,7 +3356,7 @@ FindAndDropRelFileNodeBuffers(RelFileNode rnode, ForkNumber forkNum,
|
|||||||
uint32 buf_state;
|
uint32 buf_state;
|
||||||
|
|
||||||
/* create a tag so we can lookup the buffer */
|
/* create a tag so we can lookup the buffer */
|
||||||
INIT_BUFFERTAG(bufTag, rnode, forkNum, curBlock);
|
INIT_BUFFERTAG(bufTag, rlocator, forkNum, curBlock);
|
||||||
|
|
||||||
/* determine its hash code and partition lock ID */
|
/* determine its hash code and partition lock ID */
|
||||||
bufHash = BufTableHashCode(&bufTag);
|
bufHash = BufTableHashCode(&bufTag);
|
||||||
@ -3380,7 +3380,7 @@ FindAndDropRelFileNodeBuffers(RelFileNode rnode, ForkNumber forkNum,
|
|||||||
*/
|
*/
|
||||||
buf_state = LockBufHdr(bufHdr);
|
buf_state = LockBufHdr(bufHdr);
|
||||||
|
|
||||||
if (RelFileNodeEquals(bufHdr->tag.rnode, rnode) &&
|
if (RelFileLocatorEquals(bufHdr->tag.rlocator, rlocator) &&
|
||||||
bufHdr->tag.forkNum == forkNum &&
|
bufHdr->tag.forkNum == forkNum &&
|
||||||
bufHdr->tag.blockNum >= firstDelBlock)
|
bufHdr->tag.blockNum >= firstDelBlock)
|
||||||
InvalidateBuffer(bufHdr); /* releases spinlock */
|
InvalidateBuffer(bufHdr); /* releases spinlock */
|
||||||
@ -3397,7 +3397,7 @@ FindAndDropRelFileNodeBuffers(RelFileNode rnode, ForkNumber forkNum,
|
|||||||
* bothering to write them out first. This is used when we destroy a
|
* bothering to write them out first. This is used when we destroy a
|
||||||
* database, to avoid trying to flush data to disk when the directory
|
* database, to avoid trying to flush data to disk when the directory
|
||||||
* tree no longer exists. Implementation is pretty similar to
|
* tree no longer exists. Implementation is pretty similar to
|
||||||
* DropRelFileNodeBuffers() which is for destroying just one relation.
|
* DropRelFileLocatorBuffers() which is for destroying just one relation.
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -3416,14 +3416,14 @@ DropDatabaseBuffers(Oid dbid)
|
|||||||
uint32 buf_state;
|
uint32 buf_state;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As in DropRelFileNodeBuffers, an unlocked precheck should be safe
|
* As in DropRelFileLocatorBuffers, an unlocked precheck should be
|
||||||
* and saves some cycles.
|
* safe and saves some cycles.
|
||||||
*/
|
*/
|
||||||
if (bufHdr->tag.rnode.dbNode != dbid)
|
if (bufHdr->tag.rlocator.dbOid != dbid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
buf_state = LockBufHdr(bufHdr);
|
buf_state = LockBufHdr(bufHdr);
|
||||||
if (bufHdr->tag.rnode.dbNode == dbid)
|
if (bufHdr->tag.rlocator.dbOid == dbid)
|
||||||
InvalidateBuffer(bufHdr); /* releases spinlock */
|
InvalidateBuffer(bufHdr); /* releases spinlock */
|
||||||
else
|
else
|
||||||
UnlockBufHdr(bufHdr, buf_state);
|
UnlockBufHdr(bufHdr, buf_state);
|
||||||
@ -3453,7 +3453,7 @@ PrintBufferDescs(void)
|
|||||||
"[%02d] (freeNext=%d, rel=%s, "
|
"[%02d] (freeNext=%d, rel=%s, "
|
||||||
"blockNum=%u, flags=0x%x, refcount=%u %d)",
|
"blockNum=%u, flags=0x%x, refcount=%u %d)",
|
||||||
i, buf->freeNext,
|
i, buf->freeNext,
|
||||||
relpathbackend(buf->tag.rnode, InvalidBackendId, buf->tag.forkNum),
|
relpathbackend(buf->tag.rlocator, InvalidBackendId, buf->tag.forkNum),
|
||||||
buf->tag.blockNum, buf->flags,
|
buf->tag.blockNum, buf->flags,
|
||||||
buf->refcount, GetPrivateRefCount(b));
|
buf->refcount, GetPrivateRefCount(b));
|
||||||
}
|
}
|
||||||
@ -3478,7 +3478,7 @@ PrintPinnedBufs(void)
|
|||||||
"[%02d] (freeNext=%d, rel=%s, "
|
"[%02d] (freeNext=%d, rel=%s, "
|
||||||
"blockNum=%u, flags=0x%x, refcount=%u %d)",
|
"blockNum=%u, flags=0x%x, refcount=%u %d)",
|
||||||
i, buf->freeNext,
|
i, buf->freeNext,
|
||||||
relpathperm(buf->tag.rnode, buf->tag.forkNum),
|
relpathperm(buf->tag.rlocator, buf->tag.forkNum),
|
||||||
buf->tag.blockNum, buf->flags,
|
buf->tag.blockNum, buf->flags,
|
||||||
buf->refcount, GetPrivateRefCount(b));
|
buf->refcount, GetPrivateRefCount(b));
|
||||||
}
|
}
|
||||||
@ -3517,7 +3517,7 @@ FlushRelationBuffers(Relation rel)
|
|||||||
uint32 buf_state;
|
uint32 buf_state;
|
||||||
|
|
||||||
bufHdr = GetLocalBufferDescriptor(i);
|
bufHdr = GetLocalBufferDescriptor(i);
|
||||||
if (RelFileNodeEquals(bufHdr->tag.rnode, rel->rd_node) &&
|
if (RelFileLocatorEquals(bufHdr->tag.rlocator, rel->rd_locator) &&
|
||||||
((buf_state = pg_atomic_read_u32(&bufHdr->state)) &
|
((buf_state = pg_atomic_read_u32(&bufHdr->state)) &
|
||||||
(BM_VALID | BM_DIRTY)) == (BM_VALID | BM_DIRTY))
|
(BM_VALID | BM_DIRTY)) == (BM_VALID | BM_DIRTY))
|
||||||
{
|
{
|
||||||
@ -3561,16 +3561,16 @@ FlushRelationBuffers(Relation rel)
|
|||||||
bufHdr = GetBufferDescriptor(i);
|
bufHdr = GetBufferDescriptor(i);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As in DropRelFileNodeBuffers, an unlocked precheck should be safe
|
* As in DropRelFileLocatorBuffers, an unlocked precheck should be
|
||||||
* and saves some cycles.
|
* safe and saves some cycles.
|
||||||
*/
|
*/
|
||||||
if (!RelFileNodeEquals(bufHdr->tag.rnode, rel->rd_node))
|
if (!RelFileLocatorEquals(bufHdr->tag.rlocator, rel->rd_locator))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ReservePrivateRefCountEntry();
|
ReservePrivateRefCountEntry();
|
||||||
|
|
||||||
buf_state = LockBufHdr(bufHdr);
|
buf_state = LockBufHdr(bufHdr);
|
||||||
if (RelFileNodeEquals(bufHdr->tag.rnode, rel->rd_node) &&
|
if (RelFileLocatorEquals(bufHdr->tag.rlocator, rel->rd_locator) &&
|
||||||
(buf_state & (BM_VALID | BM_DIRTY)) == (BM_VALID | BM_DIRTY))
|
(buf_state & (BM_VALID | BM_DIRTY)) == (BM_VALID | BM_DIRTY))
|
||||||
{
|
{
|
||||||
PinBuffer_Locked(bufHdr);
|
PinBuffer_Locked(bufHdr);
|
||||||
@ -3608,21 +3608,21 @@ FlushRelationsAllBuffers(SMgrRelation *smgrs, int nrels)
|
|||||||
|
|
||||||
for (i = 0; i < nrels; i++)
|
for (i = 0; i < nrels; i++)
|
||||||
{
|
{
|
||||||
Assert(!RelFileNodeBackendIsTemp(smgrs[i]->smgr_rnode));
|
Assert(!RelFileLocatorBackendIsTemp(smgrs[i]->smgr_rlocator));
|
||||||
|
|
||||||
srels[i].rnode = smgrs[i]->smgr_rnode.node;
|
srels[i].rlocator = smgrs[i]->smgr_rlocator.locator;
|
||||||
srels[i].srel = smgrs[i];
|
srels[i].srel = smgrs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Save the bsearch overhead for low number of relations to sync. See
|
* Save the bsearch overhead for low number of relations to sync. See
|
||||||
* DropRelFileNodesAllBuffers for details.
|
* DropRelFileLocatorsAllBuffers for details.
|
||||||
*/
|
*/
|
||||||
use_bsearch = nrels > RELS_BSEARCH_THRESHOLD;
|
use_bsearch = nrels > RELS_BSEARCH_THRESHOLD;
|
||||||
|
|
||||||
/* sort the list of SMgrRelations if necessary */
|
/* sort the list of SMgrRelations if necessary */
|
||||||
if (use_bsearch)
|
if (use_bsearch)
|
||||||
pg_qsort(srels, nrels, sizeof(SMgrSortArray), rnode_comparator);
|
pg_qsort(srels, nrels, sizeof(SMgrSortArray), rlocator_comparator);
|
||||||
|
|
||||||
/* Make sure we can handle the pin inside the loop */
|
/* Make sure we can handle the pin inside the loop */
|
||||||
ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
|
ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
|
||||||
@ -3634,8 +3634,8 @@ FlushRelationsAllBuffers(SMgrRelation *smgrs, int nrels)
|
|||||||
uint32 buf_state;
|
uint32 buf_state;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As in DropRelFileNodeBuffers, an unlocked precheck should be safe
|
* As in DropRelFileLocatorBuffers, an unlocked precheck should be
|
||||||
* and saves some cycles.
|
* safe and saves some cycles.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!use_bsearch)
|
if (!use_bsearch)
|
||||||
@ -3644,7 +3644,7 @@ FlushRelationsAllBuffers(SMgrRelation *smgrs, int nrels)
|
|||||||
|
|
||||||
for (j = 0; j < nrels; j++)
|
for (j = 0; j < nrels; j++)
|
||||||
{
|
{
|
||||||
if (RelFileNodeEquals(bufHdr->tag.rnode, srels[j].rnode))
|
if (RelFileLocatorEquals(bufHdr->tag.rlocator, srels[j].rlocator))
|
||||||
{
|
{
|
||||||
srelent = &srels[j];
|
srelent = &srels[j];
|
||||||
break;
|
break;
|
||||||
@ -3653,19 +3653,19 @@ FlushRelationsAllBuffers(SMgrRelation *smgrs, int nrels)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
srelent = bsearch((const void *) &(bufHdr->tag.rnode),
|
srelent = bsearch((const void *) &(bufHdr->tag.rlocator),
|
||||||
srels, nrels, sizeof(SMgrSortArray),
|
srels, nrels, sizeof(SMgrSortArray),
|
||||||
rnode_comparator);
|
rlocator_comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* buffer doesn't belong to any of the given relfilenodes; skip it */
|
/* buffer doesn't belong to any of the given relfilelocators; skip it */
|
||||||
if (srelent == NULL)
|
if (srelent == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ReservePrivateRefCountEntry();
|
ReservePrivateRefCountEntry();
|
||||||
|
|
||||||
buf_state = LockBufHdr(bufHdr);
|
buf_state = LockBufHdr(bufHdr);
|
||||||
if (RelFileNodeEquals(bufHdr->tag.rnode, srelent->rnode) &&
|
if (RelFileLocatorEquals(bufHdr->tag.rlocator, srelent->rlocator) &&
|
||||||
(buf_state & (BM_VALID | BM_DIRTY)) == (BM_VALID | BM_DIRTY))
|
(buf_state & (BM_VALID | BM_DIRTY)) == (BM_VALID | BM_DIRTY))
|
||||||
{
|
{
|
||||||
PinBuffer_Locked(bufHdr);
|
PinBuffer_Locked(bufHdr);
|
||||||
@ -3729,7 +3729,7 @@ RelationCopyStorageUsingBuffer(Relation src, Relation dst, ForkNumber forkNum,
|
|||||||
CHECK_FOR_INTERRUPTS();
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
|
||||||
/* Read block from source relation. */
|
/* Read block from source relation. */
|
||||||
srcBuf = ReadBufferWithoutRelcache(src->rd_node, forkNum, blkno,
|
srcBuf = ReadBufferWithoutRelcache(src->rd_locator, forkNum, blkno,
|
||||||
RBM_NORMAL, bstrategy_src,
|
RBM_NORMAL, bstrategy_src,
|
||||||
permanent);
|
permanent);
|
||||||
srcPage = BufferGetPage(srcBuf);
|
srcPage = BufferGetPage(srcBuf);
|
||||||
@ -3740,7 +3740,7 @@ RelationCopyStorageUsingBuffer(Relation src, Relation dst, ForkNumber forkNum,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Use P_NEW to extend the destination relation. */
|
/* Use P_NEW to extend the destination relation. */
|
||||||
dstBuf = ReadBufferWithoutRelcache(dst->rd_node, forkNum, P_NEW,
|
dstBuf = ReadBufferWithoutRelcache(dst->rd_locator, forkNum, P_NEW,
|
||||||
RBM_NORMAL, bstrategy_dst,
|
RBM_NORMAL, bstrategy_dst,
|
||||||
permanent);
|
permanent);
|
||||||
LockBuffer(dstBuf, BUFFER_LOCK_EXCLUSIVE);
|
LockBuffer(dstBuf, BUFFER_LOCK_EXCLUSIVE);
|
||||||
@ -3775,8 +3775,8 @@ RelationCopyStorageUsingBuffer(Relation src, Relation dst, ForkNumber forkNum,
|
|||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CreateAndCopyRelationData(RelFileNode src_rnode, RelFileNode dst_rnode,
|
CreateAndCopyRelationData(RelFileLocator src_rlocator,
|
||||||
bool permanent)
|
RelFileLocator dst_rlocator, bool permanent)
|
||||||
{
|
{
|
||||||
Relation src_rel;
|
Relation src_rel;
|
||||||
Relation dst_rel;
|
Relation dst_rel;
|
||||||
@ -3793,8 +3793,8 @@ CreateAndCopyRelationData(RelFileNode src_rnode, RelFileNode dst_rnode,
|
|||||||
* used the smgr layer directly, we would have to worry about
|
* used the smgr layer directly, we would have to worry about
|
||||||
* invalidations.
|
* invalidations.
|
||||||
*/
|
*/
|
||||||
src_rel = CreateFakeRelcacheEntry(src_rnode);
|
src_rel = CreateFakeRelcacheEntry(src_rlocator);
|
||||||
dst_rel = CreateFakeRelcacheEntry(dst_rnode);
|
dst_rel = CreateFakeRelcacheEntry(dst_rlocator);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create and copy all forks of the relation. During create database we
|
* Create and copy all forks of the relation. During create database we
|
||||||
@ -3802,7 +3802,7 @@ CreateAndCopyRelationData(RelFileNode src_rnode, RelFileNode dst_rnode,
|
|||||||
* directory. Therefore, each individual relation doesn't need to be
|
* directory. Therefore, each individual relation doesn't need to be
|
||||||
* registered for cleanup.
|
* registered for cleanup.
|
||||||
*/
|
*/
|
||||||
RelationCreateStorage(dst_rnode, relpersistence, false);
|
RelationCreateStorage(dst_rlocator, relpersistence, false);
|
||||||
|
|
||||||
/* copy main fork. */
|
/* copy main fork. */
|
||||||
RelationCopyStorageUsingBuffer(src_rel, dst_rel, MAIN_FORKNUM, permanent);
|
RelationCopyStorageUsingBuffer(src_rel, dst_rel, MAIN_FORKNUM, permanent);
|
||||||
@ -3820,7 +3820,7 @@ CreateAndCopyRelationData(RelFileNode src_rnode, RelFileNode dst_rnode,
|
|||||||
* init fork of an unlogged relation.
|
* init fork of an unlogged relation.
|
||||||
*/
|
*/
|
||||||
if (permanent || forkNum == INIT_FORKNUM)
|
if (permanent || forkNum == INIT_FORKNUM)
|
||||||
log_smgrcreate(&dst_rnode, forkNum);
|
log_smgrcreate(&dst_rlocator, forkNum);
|
||||||
|
|
||||||
/* Copy a fork's data, block by block. */
|
/* Copy a fork's data, block by block. */
|
||||||
RelationCopyStorageUsingBuffer(src_rel, dst_rel, forkNum,
|
RelationCopyStorageUsingBuffer(src_rel, dst_rel, forkNum,
|
||||||
@ -3864,16 +3864,16 @@ FlushDatabaseBuffers(Oid dbid)
|
|||||||
bufHdr = GetBufferDescriptor(i);
|
bufHdr = GetBufferDescriptor(i);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As in DropRelFileNodeBuffers, an unlocked precheck should be safe
|
* As in DropRelFileLocatorBuffers, an unlocked precheck should be
|
||||||
* and saves some cycles.
|
* safe and saves some cycles.
|
||||||
*/
|
*/
|
||||||
if (bufHdr->tag.rnode.dbNode != dbid)
|
if (bufHdr->tag.rlocator.dbOid != dbid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ReservePrivateRefCountEntry();
|
ReservePrivateRefCountEntry();
|
||||||
|
|
||||||
buf_state = LockBufHdr(bufHdr);
|
buf_state = LockBufHdr(bufHdr);
|
||||||
if (bufHdr->tag.rnode.dbNode == dbid &&
|
if (bufHdr->tag.rlocator.dbOid == dbid &&
|
||||||
(buf_state & (BM_VALID | BM_DIRTY)) == (BM_VALID | BM_DIRTY))
|
(buf_state & (BM_VALID | BM_DIRTY)) == (BM_VALID | BM_DIRTY))
|
||||||
{
|
{
|
||||||
PinBuffer_Locked(bufHdr);
|
PinBuffer_Locked(bufHdr);
|
||||||
@ -4034,7 +4034,7 @@ MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
|
|||||||
(pg_atomic_read_u32(&bufHdr->state) & BM_PERMANENT))
|
(pg_atomic_read_u32(&bufHdr->state) & BM_PERMANENT))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If we must not write WAL, due to a relfilenode-specific
|
* If we must not write WAL, due to a relfilelocator-specific
|
||||||
* condition or being in recovery, don't dirty the page. We can
|
* condition or being in recovery, don't dirty the page. We can
|
||||||
* set the hint, just not dirty the page as a result so the hint
|
* set the hint, just not dirty the page as a result so the hint
|
||||||
* is lost when we evict the page or shutdown.
|
* is lost when we evict the page or shutdown.
|
||||||
@ -4042,7 +4042,7 @@ MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
|
|||||||
* See src/backend/storage/page/README for longer discussion.
|
* See src/backend/storage/page/README for longer discussion.
|
||||||
*/
|
*/
|
||||||
if (RecoveryInProgress() ||
|
if (RecoveryInProgress() ||
|
||||||
RelFileNodeSkippingWAL(bufHdr->tag.rnode))
|
RelFileLocatorSkippingWAL(bufHdr->tag.rlocator))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4651,7 +4651,7 @@ AbortBufferIO(void)
|
|||||||
/* Buffer is pinned, so we can read tag without spinlock */
|
/* Buffer is pinned, so we can read tag without spinlock */
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
path = relpathperm(buf->tag.rnode, buf->tag.forkNum);
|
path = relpathperm(buf->tag.rlocator, buf->tag.forkNum);
|
||||||
ereport(WARNING,
|
ereport(WARNING,
|
||||||
(errcode(ERRCODE_IO_ERROR),
|
(errcode(ERRCODE_IO_ERROR),
|
||||||
errmsg("could not write block %u of %s",
|
errmsg("could not write block %u of %s",
|
||||||
@ -4675,7 +4675,7 @@ shared_buffer_write_error_callback(void *arg)
|
|||||||
/* Buffer is pinned, so we can read the tag without locking the spinlock */
|
/* Buffer is pinned, so we can read the tag without locking the spinlock */
|
||||||
if (bufHdr != NULL)
|
if (bufHdr != NULL)
|
||||||
{
|
{
|
||||||
char *path = relpathperm(bufHdr->tag.rnode, bufHdr->tag.forkNum);
|
char *path = relpathperm(bufHdr->tag.rlocator, bufHdr->tag.forkNum);
|
||||||
|
|
||||||
errcontext("writing block %u of relation %s",
|
errcontext("writing block %u of relation %s",
|
||||||
bufHdr->tag.blockNum, path);
|
bufHdr->tag.blockNum, path);
|
||||||
@ -4693,7 +4693,7 @@ local_buffer_write_error_callback(void *arg)
|
|||||||
|
|
||||||
if (bufHdr != NULL)
|
if (bufHdr != NULL)
|
||||||
{
|
{
|
||||||
char *path = relpathbackend(bufHdr->tag.rnode, MyBackendId,
|
char *path = relpathbackend(bufHdr->tag.rlocator, MyBackendId,
|
||||||
bufHdr->tag.forkNum);
|
bufHdr->tag.forkNum);
|
||||||
|
|
||||||
errcontext("writing block %u of relation %s",
|
errcontext("writing block %u of relation %s",
|
||||||
@ -4703,27 +4703,27 @@ local_buffer_write_error_callback(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RelFileNode qsort/bsearch comparator; see RelFileNodeEquals.
|
* RelFileLocator qsort/bsearch comparator; see RelFileLocatorEquals.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
rnode_comparator(const void *p1, const void *p2)
|
rlocator_comparator(const void *p1, const void *p2)
|
||||||
{
|
{
|
||||||
RelFileNode n1 = *(const RelFileNode *) p1;
|
RelFileLocator n1 = *(const RelFileLocator *) p1;
|
||||||
RelFileNode n2 = *(const RelFileNode *) p2;
|
RelFileLocator n2 = *(const RelFileLocator *) p2;
|
||||||
|
|
||||||
if (n1.relNode < n2.relNode)
|
if (n1.relNumber < n2.relNumber)
|
||||||
return -1;
|
return -1;
|
||||||
else if (n1.relNode > n2.relNode)
|
else if (n1.relNumber > n2.relNumber)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (n1.dbNode < n2.dbNode)
|
if (n1.dbOid < n2.dbOid)
|
||||||
return -1;
|
return -1;
|
||||||
else if (n1.dbNode > n2.dbNode)
|
else if (n1.dbOid > n2.dbOid)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (n1.spcNode < n2.spcNode)
|
if (n1.spcOid < n2.spcOid)
|
||||||
return -1;
|
return -1;
|
||||||
else if (n1.spcNode > n2.spcNode)
|
else if (n1.spcOid > n2.spcOid)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@ -4789,7 +4789,7 @@ buffertag_comparator(const BufferTag *ba, const BufferTag *bb)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = rnode_comparator(&ba->rnode, &bb->rnode);
|
ret = rlocator_comparator(&ba->rlocator, &bb->rlocator);
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -4822,9 +4822,9 @@ ckpt_buforder_comparator(const CkptSortItem *a, const CkptSortItem *b)
|
|||||||
else if (a->tsId > b->tsId)
|
else if (a->tsId > b->tsId)
|
||||||
return 1;
|
return 1;
|
||||||
/* compare relation */
|
/* compare relation */
|
||||||
if (a->relNode < b->relNode)
|
if (a->relNumber < b->relNumber)
|
||||||
return -1;
|
return -1;
|
||||||
else if (a->relNode > b->relNode)
|
else if (a->relNumber > b->relNumber)
|
||||||
return 1;
|
return 1;
|
||||||
/* compare fork */
|
/* compare fork */
|
||||||
else if (a->forkNum < b->forkNum)
|
else if (a->forkNum < b->forkNum)
|
||||||
@ -4960,7 +4960,7 @@ IssuePendingWritebacks(WritebackContext *context)
|
|||||||
next = &context->pending_writebacks[i + ahead + 1];
|
next = &context->pending_writebacks[i + ahead + 1];
|
||||||
|
|
||||||
/* different file, stop */
|
/* different file, stop */
|
||||||
if (!RelFileNodeEquals(cur->tag.rnode, next->tag.rnode) ||
|
if (!RelFileLocatorEquals(cur->tag.rlocator, next->tag.rlocator) ||
|
||||||
cur->tag.forkNum != next->tag.forkNum)
|
cur->tag.forkNum != next->tag.forkNum)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -4979,7 +4979,7 @@ IssuePendingWritebacks(WritebackContext *context)
|
|||||||
i += ahead;
|
i += ahead;
|
||||||
|
|
||||||
/* and finally tell the kernel to write the data to storage */
|
/* and finally tell the kernel to write the data to storage */
|
||||||
reln = smgropen(tag.rnode, InvalidBackendId);
|
reln = smgropen(tag.rlocator, InvalidBackendId);
|
||||||
smgrwriteback(reln, tag.forkNum, tag.blockNum, nblocks);
|
smgrwriteback(reln, tag.forkNum, tag.blockNum, nblocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ PrefetchLocalBuffer(SMgrRelation smgr, ForkNumber forkNum,
|
|||||||
BufferTag newTag; /* identity of requested block */
|
BufferTag newTag; /* identity of requested block */
|
||||||
LocalBufferLookupEnt *hresult;
|
LocalBufferLookupEnt *hresult;
|
||||||
|
|
||||||
INIT_BUFFERTAG(newTag, smgr->smgr_rnode.node, forkNum, blockNum);
|
INIT_BUFFERTAG(newTag, smgr->smgr_rlocator.locator, forkNum, blockNum);
|
||||||
|
|
||||||
/* Initialize local buffers if first request in this session */
|
/* Initialize local buffers if first request in this session */
|
||||||
if (LocalBufHash == NULL)
|
if (LocalBufHash == NULL)
|
||||||
@ -117,7 +117,7 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum,
|
|||||||
bool found;
|
bool found;
|
||||||
uint32 buf_state;
|
uint32 buf_state;
|
||||||
|
|
||||||
INIT_BUFFERTAG(newTag, smgr->smgr_rnode.node, forkNum, blockNum);
|
INIT_BUFFERTAG(newTag, smgr->smgr_rlocator.locator, forkNum, blockNum);
|
||||||
|
|
||||||
/* Initialize local buffers if first request in this session */
|
/* Initialize local buffers if first request in this session */
|
||||||
if (LocalBufHash == NULL)
|
if (LocalBufHash == NULL)
|
||||||
@ -134,7 +134,7 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum,
|
|||||||
Assert(BUFFERTAGS_EQUAL(bufHdr->tag, newTag));
|
Assert(BUFFERTAGS_EQUAL(bufHdr->tag, newTag));
|
||||||
#ifdef LBDEBUG
|
#ifdef LBDEBUG
|
||||||
fprintf(stderr, "LB ALLOC (%u,%d,%d) %d\n",
|
fprintf(stderr, "LB ALLOC (%u,%d,%d) %d\n",
|
||||||
smgr->smgr_rnode.node.relNode, forkNum, blockNum, -b - 1);
|
smgr->smgr_rlocator.locator.relNumber, forkNum, blockNum, -b - 1);
|
||||||
#endif
|
#endif
|
||||||
buf_state = pg_atomic_read_u32(&bufHdr->state);
|
buf_state = pg_atomic_read_u32(&bufHdr->state);
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum,
|
|||||||
|
|
||||||
#ifdef LBDEBUG
|
#ifdef LBDEBUG
|
||||||
fprintf(stderr, "LB ALLOC (%u,%d,%d) %d\n",
|
fprintf(stderr, "LB ALLOC (%u,%d,%d) %d\n",
|
||||||
smgr->smgr_rnode.node.relNode, forkNum, blockNum,
|
smgr->smgr_rlocator.locator.relNumber, forkNum, blockNum,
|
||||||
-nextFreeLocalBuf - 1);
|
-nextFreeLocalBuf - 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum,
|
|||||||
Page localpage = (char *) LocalBufHdrGetBlock(bufHdr);
|
Page localpage = (char *) LocalBufHdrGetBlock(bufHdr);
|
||||||
|
|
||||||
/* Find smgr relation for buffer */
|
/* Find smgr relation for buffer */
|
||||||
oreln = smgropen(bufHdr->tag.rnode, MyBackendId);
|
oreln = smgropen(bufHdr->tag.rlocator, MyBackendId);
|
||||||
|
|
||||||
PageSetChecksumInplace(localpage, bufHdr->tag.blockNum);
|
PageSetChecksumInplace(localpage, bufHdr->tag.blockNum);
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ MarkLocalBufferDirty(Buffer buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DropRelFileNodeLocalBuffers
|
* DropRelFileLocatorLocalBuffers
|
||||||
* This function removes from the buffer pool all the pages of the
|
* This function removes from the buffer pool all the pages of the
|
||||||
* specified relation that have block numbers >= firstDelBlock.
|
* specified relation that have block numbers >= firstDelBlock.
|
||||||
* (In particular, with firstDelBlock = 0, all pages are removed.)
|
* (In particular, with firstDelBlock = 0, all pages are removed.)
|
||||||
@ -320,10 +320,10 @@ MarkLocalBufferDirty(Buffer buffer)
|
|||||||
* out first. Therefore, this is NOT rollback-able, and so should be
|
* out first. Therefore, this is NOT rollback-able, and so should be
|
||||||
* used only with extreme caution!
|
* used only with extreme caution!
|
||||||
*
|
*
|
||||||
* See DropRelFileNodeBuffers in bufmgr.c for more notes.
|
* See DropRelFileLocatorBuffers in bufmgr.c for more notes.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
DropRelFileNodeLocalBuffers(RelFileNode rnode, ForkNumber forkNum,
|
DropRelFileLocatorLocalBuffers(RelFileLocator rlocator, ForkNumber forkNum,
|
||||||
BlockNumber firstDelBlock)
|
BlockNumber firstDelBlock)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -337,14 +337,14 @@ DropRelFileNodeLocalBuffers(RelFileNode rnode, ForkNumber forkNum,
|
|||||||
buf_state = pg_atomic_read_u32(&bufHdr->state);
|
buf_state = pg_atomic_read_u32(&bufHdr->state);
|
||||||
|
|
||||||
if ((buf_state & BM_TAG_VALID) &&
|
if ((buf_state & BM_TAG_VALID) &&
|
||||||
RelFileNodeEquals(bufHdr->tag.rnode, rnode) &&
|
RelFileLocatorEquals(bufHdr->tag.rlocator, rlocator) &&
|
||||||
bufHdr->tag.forkNum == forkNum &&
|
bufHdr->tag.forkNum == forkNum &&
|
||||||
bufHdr->tag.blockNum >= firstDelBlock)
|
bufHdr->tag.blockNum >= firstDelBlock)
|
||||||
{
|
{
|
||||||
if (LocalRefCount[i] != 0)
|
if (LocalRefCount[i] != 0)
|
||||||
elog(ERROR, "block %u of %s is still referenced (local %u)",
|
elog(ERROR, "block %u of %s is still referenced (local %u)",
|
||||||
bufHdr->tag.blockNum,
|
bufHdr->tag.blockNum,
|
||||||
relpathbackend(bufHdr->tag.rnode, MyBackendId,
|
relpathbackend(bufHdr->tag.rlocator, MyBackendId,
|
||||||
bufHdr->tag.forkNum),
|
bufHdr->tag.forkNum),
|
||||||
LocalRefCount[i]);
|
LocalRefCount[i]);
|
||||||
/* Remove entry from hashtable */
|
/* Remove entry from hashtable */
|
||||||
@ -363,14 +363,14 @@ DropRelFileNodeLocalBuffers(RelFileNode rnode, ForkNumber forkNum,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DropRelFileNodeAllLocalBuffers
|
* DropRelFileLocatorAllLocalBuffers
|
||||||
* This function removes from the buffer pool all pages of all forks
|
* This function removes from the buffer pool all pages of all forks
|
||||||
* of the specified relation.
|
* of the specified relation.
|
||||||
*
|
*
|
||||||
* See DropRelFileNodesAllBuffers in bufmgr.c for more notes.
|
* See DropRelFileLocatorsAllBuffers in bufmgr.c for more notes.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
DropRelFileNodeAllLocalBuffers(RelFileNode rnode)
|
DropRelFileLocatorAllLocalBuffers(RelFileLocator rlocator)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -383,12 +383,12 @@ DropRelFileNodeAllLocalBuffers(RelFileNode rnode)
|
|||||||
buf_state = pg_atomic_read_u32(&bufHdr->state);
|
buf_state = pg_atomic_read_u32(&bufHdr->state);
|
||||||
|
|
||||||
if ((buf_state & BM_TAG_VALID) &&
|
if ((buf_state & BM_TAG_VALID) &&
|
||||||
RelFileNodeEquals(bufHdr->tag.rnode, rnode))
|
RelFileLocatorEquals(bufHdr->tag.rlocator, rlocator))
|
||||||
{
|
{
|
||||||
if (LocalRefCount[i] != 0)
|
if (LocalRefCount[i] != 0)
|
||||||
elog(ERROR, "block %u of %s is still referenced (local %u)",
|
elog(ERROR, "block %u of %s is still referenced (local %u)",
|
||||||
bufHdr->tag.blockNum,
|
bufHdr->tag.blockNum,
|
||||||
relpathbackend(bufHdr->tag.rnode, MyBackendId,
|
relpathbackend(bufHdr->tag.rlocator, MyBackendId,
|
||||||
bufHdr->tag.forkNum),
|
bufHdr->tag.forkNum),
|
||||||
LocalRefCount[i]);
|
LocalRefCount[i]);
|
||||||
/* Remove entry from hashtable */
|
/* Remove entry from hashtable */
|
||||||
@ -589,8 +589,8 @@ AtProcExit_LocalBuffers(void)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We shouldn't be holding any remaining pins; if we are, and assertions
|
* We shouldn't be holding any remaining pins; if we are, and assertions
|
||||||
* aren't enabled, we'll fail later in DropRelFileNodeBuffers while trying
|
* aren't enabled, we'll fail later in DropRelFileLocatorBuffers while
|
||||||
* to drop the temp rels.
|
* trying to drop the temp rels.
|
||||||
*/
|
*/
|
||||||
CheckForLocalBufferLeaks();
|
CheckForLocalBufferLeaks();
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ RecordPageWithFreeSpace(Relation rel, BlockNumber heapBlk, Size spaceAvail)
|
|||||||
* WAL replay
|
* WAL replay
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
XLogRecordPageWithFreeSpace(RelFileNode rnode, BlockNumber heapBlk,
|
XLogRecordPageWithFreeSpace(RelFileLocator rlocator, BlockNumber heapBlk,
|
||||||
Size spaceAvail)
|
Size spaceAvail)
|
||||||
{
|
{
|
||||||
int new_cat = fsm_space_avail_to_cat(spaceAvail);
|
int new_cat = fsm_space_avail_to_cat(spaceAvail);
|
||||||
@ -211,8 +211,8 @@ XLogRecordPageWithFreeSpace(RelFileNode rnode, BlockNumber heapBlk,
|
|||||||
blkno = fsm_logical_to_physical(addr);
|
blkno = fsm_logical_to_physical(addr);
|
||||||
|
|
||||||
/* If the page doesn't exist already, extend */
|
/* If the page doesn't exist already, extend */
|
||||||
buf = XLogReadBufferExtended(rnode, FSM_FORKNUM, blkno, RBM_ZERO_ON_ERROR,
|
buf = XLogReadBufferExtended(rlocator, FSM_FORKNUM, blkno,
|
||||||
InvalidBuffer);
|
RBM_ZERO_ON_ERROR, InvalidBuffer);
|
||||||
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
|
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
|
||||||
|
|
||||||
page = BufferGetPage(buf);
|
page = BufferGetPage(buf);
|
||||||
|
@ -268,13 +268,13 @@ restart:
|
|||||||
*
|
*
|
||||||
* Fix the corruption and restart.
|
* Fix the corruption and restart.
|
||||||
*/
|
*/
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
BlockNumber blknum;
|
BlockNumber blknum;
|
||||||
|
|
||||||
BufferGetTag(buf, &rnode, &forknum, &blknum);
|
BufferGetTag(buf, &rlocator, &forknum, &blknum);
|
||||||
elog(DEBUG1, "fixing corrupt FSM block %u, relation %u/%u/%u",
|
elog(DEBUG1, "fixing corrupt FSM block %u, relation %u/%u/%u",
|
||||||
blknum, rnode.spcNode, rnode.dbNode, rnode.relNode);
|
blknum, rlocator.spcOid, rlocator.dbOid, rlocator.relNumber);
|
||||||
|
|
||||||
/* make sure we hold an exclusive lock */
|
/* make sure we hold an exclusive lock */
|
||||||
if (!exclusive_lock_held)
|
if (!exclusive_lock_held)
|
||||||
|
@ -442,7 +442,7 @@ ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid, RelFileNode node)
|
ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid, RelFileLocator locator)
|
||||||
{
|
{
|
||||||
VirtualTransactionId *backends;
|
VirtualTransactionId *backends;
|
||||||
|
|
||||||
@ -461,7 +461,7 @@ ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid, RelFileNode
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
backends = GetConflictingVirtualXIDs(latestRemovedXid,
|
backends = GetConflictingVirtualXIDs(latestRemovedXid,
|
||||||
node.dbNode);
|
locator.dbOid);
|
||||||
|
|
||||||
ResolveRecoveryConflictWithVirtualXIDs(backends,
|
ResolveRecoveryConflictWithVirtualXIDs(backends,
|
||||||
PROCSIG_RECOVERY_CONFLICT_SNAPSHOT,
|
PROCSIG_RECOVERY_CONFLICT_SNAPSHOT,
|
||||||
@ -475,7 +475,7 @@ ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid, RelFileNode
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ResolveRecoveryConflictWithSnapshotFullXid(FullTransactionId latestRemovedFullXid,
|
ResolveRecoveryConflictWithSnapshotFullXid(FullTransactionId latestRemovedFullXid,
|
||||||
RelFileNode node)
|
RelFileLocator locator)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* ResolveRecoveryConflictWithSnapshot operates on 32-bit TransactionIds,
|
* ResolveRecoveryConflictWithSnapshot operates on 32-bit TransactionIds,
|
||||||
@ -493,7 +493,7 @@ ResolveRecoveryConflictWithSnapshotFullXid(FullTransactionId latestRemovedFullXi
|
|||||||
TransactionId latestRemovedXid;
|
TransactionId latestRemovedXid;
|
||||||
|
|
||||||
latestRemovedXid = XidFromFullTransactionId(latestRemovedFullXid);
|
latestRemovedXid = XidFromFullTransactionId(latestRemovedFullXid);
|
||||||
ResolveRecoveryConflictWithSnapshot(latestRemovedXid, node);
|
ResolveRecoveryConflictWithSnapshot(latestRemovedXid, locator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1997,7 +1997,7 @@ PageIsPredicateLocked(Relation relation, BlockNumber blkno)
|
|||||||
PREDICATELOCKTARGET *target;
|
PREDICATELOCKTARGET *target;
|
||||||
|
|
||||||
SET_PREDICATELOCKTARGETTAG_PAGE(targettag,
|
SET_PREDICATELOCKTARGETTAG_PAGE(targettag,
|
||||||
relation->rd_node.dbNode,
|
relation->rd_locator.dbOid,
|
||||||
relation->rd_id,
|
relation->rd_id,
|
||||||
blkno);
|
blkno);
|
||||||
|
|
||||||
@ -2576,7 +2576,7 @@ PredicateLockRelation(Relation relation, Snapshot snapshot)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SET_PREDICATELOCKTARGETTAG_RELATION(tag,
|
SET_PREDICATELOCKTARGETTAG_RELATION(tag,
|
||||||
relation->rd_node.dbNode,
|
relation->rd_locator.dbOid,
|
||||||
relation->rd_id);
|
relation->rd_id);
|
||||||
PredicateLockAcquire(&tag);
|
PredicateLockAcquire(&tag);
|
||||||
}
|
}
|
||||||
@ -2599,7 +2599,7 @@ PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SET_PREDICATELOCKTARGETTAG_PAGE(tag,
|
SET_PREDICATELOCKTARGETTAG_PAGE(tag,
|
||||||
relation->rd_node.dbNode,
|
relation->rd_locator.dbOid,
|
||||||
relation->rd_id,
|
relation->rd_id,
|
||||||
blkno);
|
blkno);
|
||||||
PredicateLockAcquire(&tag);
|
PredicateLockAcquire(&tag);
|
||||||
@ -2638,13 +2638,13 @@ PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
|
|||||||
* level lock.
|
* level lock.
|
||||||
*/
|
*/
|
||||||
SET_PREDICATELOCKTARGETTAG_RELATION(tag,
|
SET_PREDICATELOCKTARGETTAG_RELATION(tag,
|
||||||
relation->rd_node.dbNode,
|
relation->rd_locator.dbOid,
|
||||||
relation->rd_id);
|
relation->rd_id);
|
||||||
if (PredicateLockExists(&tag))
|
if (PredicateLockExists(&tag))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SET_PREDICATELOCKTARGETTAG_TUPLE(tag,
|
SET_PREDICATELOCKTARGETTAG_TUPLE(tag,
|
||||||
relation->rd_node.dbNode,
|
relation->rd_locator.dbOid,
|
||||||
relation->rd_id,
|
relation->rd_id,
|
||||||
ItemPointerGetBlockNumber(tid),
|
ItemPointerGetBlockNumber(tid),
|
||||||
ItemPointerGetOffsetNumber(tid));
|
ItemPointerGetOffsetNumber(tid));
|
||||||
@ -2974,7 +2974,7 @@ DropAllPredicateLocksFromTable(Relation relation, bool transfer)
|
|||||||
if (!PredicateLockingNeededForRelation(relation))
|
if (!PredicateLockingNeededForRelation(relation))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dbId = relation->rd_node.dbNode;
|
dbId = relation->rd_locator.dbOid;
|
||||||
relId = relation->rd_id;
|
relId = relation->rd_id;
|
||||||
if (relation->rd_index == NULL)
|
if (relation->rd_index == NULL)
|
||||||
{
|
{
|
||||||
@ -3194,11 +3194,11 @@ PredicateLockPageSplit(Relation relation, BlockNumber oldblkno,
|
|||||||
Assert(BlockNumberIsValid(newblkno));
|
Assert(BlockNumberIsValid(newblkno));
|
||||||
|
|
||||||
SET_PREDICATELOCKTARGETTAG_PAGE(oldtargettag,
|
SET_PREDICATELOCKTARGETTAG_PAGE(oldtargettag,
|
||||||
relation->rd_node.dbNode,
|
relation->rd_locator.dbOid,
|
||||||
relation->rd_id,
|
relation->rd_id,
|
||||||
oldblkno);
|
oldblkno);
|
||||||
SET_PREDICATELOCKTARGETTAG_PAGE(newtargettag,
|
SET_PREDICATELOCKTARGETTAG_PAGE(newtargettag,
|
||||||
relation->rd_node.dbNode,
|
relation->rd_locator.dbOid,
|
||||||
relation->rd_id,
|
relation->rd_id,
|
||||||
newblkno);
|
newblkno);
|
||||||
|
|
||||||
@ -4478,7 +4478,7 @@ CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber b
|
|||||||
if (tid != NULL)
|
if (tid != NULL)
|
||||||
{
|
{
|
||||||
SET_PREDICATELOCKTARGETTAG_TUPLE(targettag,
|
SET_PREDICATELOCKTARGETTAG_TUPLE(targettag,
|
||||||
relation->rd_node.dbNode,
|
relation->rd_locator.dbOid,
|
||||||
relation->rd_id,
|
relation->rd_id,
|
||||||
ItemPointerGetBlockNumber(tid),
|
ItemPointerGetBlockNumber(tid),
|
||||||
ItemPointerGetOffsetNumber(tid));
|
ItemPointerGetOffsetNumber(tid));
|
||||||
@ -4488,14 +4488,14 @@ CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber b
|
|||||||
if (blkno != InvalidBlockNumber)
|
if (blkno != InvalidBlockNumber)
|
||||||
{
|
{
|
||||||
SET_PREDICATELOCKTARGETTAG_PAGE(targettag,
|
SET_PREDICATELOCKTARGETTAG_PAGE(targettag,
|
||||||
relation->rd_node.dbNode,
|
relation->rd_locator.dbOid,
|
||||||
relation->rd_id,
|
relation->rd_id,
|
||||||
blkno);
|
blkno);
|
||||||
CheckTargetForConflictsIn(&targettag);
|
CheckTargetForConflictsIn(&targettag);
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_PREDICATELOCKTARGETTAG_RELATION(targettag,
|
SET_PREDICATELOCKTARGETTAG_RELATION(targettag,
|
||||||
relation->rd_node.dbNode,
|
relation->rd_locator.dbOid,
|
||||||
relation->rd_id);
|
relation->rd_id);
|
||||||
CheckTargetForConflictsIn(&targettag);
|
CheckTargetForConflictsIn(&targettag);
|
||||||
}
|
}
|
||||||
@ -4556,7 +4556,7 @@ CheckTableForSerializableConflictIn(Relation relation)
|
|||||||
|
|
||||||
Assert(relation->rd_index == NULL); /* not an index relation */
|
Assert(relation->rd_index == NULL); /* not an index relation */
|
||||||
|
|
||||||
dbId = relation->rd_node.dbNode;
|
dbId = relation->rd_locator.dbOid;
|
||||||
heapId = relation->rd_id;
|
heapId = relation->rd_id;
|
||||||
|
|
||||||
LWLockAcquire(SerializablePredicateListLock, LW_EXCLUSIVE);
|
LWLockAcquire(SerializablePredicateListLock, LW_EXCLUSIVE);
|
||||||
|
@ -46,7 +46,7 @@ physical relation in system catalogs.
|
|||||||
It is assumed that the main fork, fork number 0 or MAIN_FORKNUM, always
|
It is assumed that the main fork, fork number 0 or MAIN_FORKNUM, always
|
||||||
exists. Fork numbers are assigned in src/include/common/relpath.h.
|
exists. Fork numbers are assigned in src/include/common/relpath.h.
|
||||||
Functions in smgr.c and md.c take an extra fork number argument, in addition
|
Functions in smgr.c and md.c take an extra fork number argument, in addition
|
||||||
to relfilenode and block number, to identify which relation fork you want to
|
to relfilelocator and block number, to identify which relation fork you want to
|
||||||
access. Since most code wants to access the main fork, a shortcut version of
|
access. Since most code wants to access the main fork, a shortcut version of
|
||||||
ReadBuffer that accesses MAIN_FORKNUM is provided in the buffer manager for
|
ReadBuffer that accesses MAIN_FORKNUM is provided in the buffer manager for
|
||||||
convenience.
|
convenience.
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "storage/bufmgr.h"
|
#include "storage/bufmgr.h"
|
||||||
#include "storage/fd.h"
|
#include "storage/fd.h"
|
||||||
#include "storage/md.h"
|
#include "storage/md.h"
|
||||||
#include "storage/relfilenode.h"
|
#include "storage/relfilelocator.h"
|
||||||
#include "storage/smgr.h"
|
#include "storage/smgr.h"
|
||||||
#include "storage/sync.h"
|
#include "storage/sync.h"
|
||||||
#include "utils/hsearch.h"
|
#include "utils/hsearch.h"
|
||||||
@ -89,11 +89,11 @@ static MemoryContext MdCxt; /* context for all MdfdVec objects */
|
|||||||
|
|
||||||
|
|
||||||
/* Populate a file tag describing an md.c segment file. */
|
/* Populate a file tag describing an md.c segment file. */
|
||||||
#define INIT_MD_FILETAG(a,xx_rnode,xx_forknum,xx_segno) \
|
#define INIT_MD_FILETAG(a,xx_rlocator,xx_forknum,xx_segno) \
|
||||||
( \
|
( \
|
||||||
memset(&(a), 0, sizeof(FileTag)), \
|
memset(&(a), 0, sizeof(FileTag)), \
|
||||||
(a).handler = SYNC_HANDLER_MD, \
|
(a).handler = SYNC_HANDLER_MD, \
|
||||||
(a).rnode = (xx_rnode), \
|
(a).rlocator = (xx_rlocator), \
|
||||||
(a).forknum = (xx_forknum), \
|
(a).forknum = (xx_forknum), \
|
||||||
(a).segno = (xx_segno) \
|
(a).segno = (xx_segno) \
|
||||||
)
|
)
|
||||||
@ -121,14 +121,14 @@ static MemoryContext MdCxt; /* context for all MdfdVec objects */
|
|||||||
|
|
||||||
|
|
||||||
/* local routines */
|
/* local routines */
|
||||||
static void mdunlinkfork(RelFileNodeBackend rnode, ForkNumber forkNum,
|
static void mdunlinkfork(RelFileLocatorBackend rlocator, ForkNumber forkNum,
|
||||||
bool isRedo);
|
bool isRedo);
|
||||||
static MdfdVec *mdopenfork(SMgrRelation reln, ForkNumber forknum, int behavior);
|
static MdfdVec *mdopenfork(SMgrRelation reln, ForkNumber forknum, int behavior);
|
||||||
static void register_dirty_segment(SMgrRelation reln, ForkNumber forknum,
|
static void register_dirty_segment(SMgrRelation reln, ForkNumber forknum,
|
||||||
MdfdVec *seg);
|
MdfdVec *seg);
|
||||||
static void register_unlink_segment(RelFileNodeBackend rnode, ForkNumber forknum,
|
static void register_unlink_segment(RelFileLocatorBackend rlocator, ForkNumber forknum,
|
||||||
BlockNumber segno);
|
BlockNumber segno);
|
||||||
static void register_forget_request(RelFileNodeBackend rnode, ForkNumber forknum,
|
static void register_forget_request(RelFileLocatorBackend rlocator, ForkNumber forknum,
|
||||||
BlockNumber segno);
|
BlockNumber segno);
|
||||||
static void _fdvec_resize(SMgrRelation reln,
|
static void _fdvec_resize(SMgrRelation reln,
|
||||||
ForkNumber forknum,
|
ForkNumber forknum,
|
||||||
@ -199,11 +199,11 @@ mdcreate(SMgrRelation reln, ForkNumber forkNum, bool isRedo)
|
|||||||
* should be here and not in commands/tablespace.c? But that would imply
|
* should be here and not in commands/tablespace.c? But that would imply
|
||||||
* importing a lot of stuff that smgr.c oughtn't know, either.
|
* importing a lot of stuff that smgr.c oughtn't know, either.
|
||||||
*/
|
*/
|
||||||
TablespaceCreateDbspace(reln->smgr_rnode.node.spcNode,
|
TablespaceCreateDbspace(reln->smgr_rlocator.locator.spcOid,
|
||||||
reln->smgr_rnode.node.dbNode,
|
reln->smgr_rlocator.locator.dbOid,
|
||||||
isRedo);
|
isRedo);
|
||||||
|
|
||||||
path = relpath(reln->smgr_rnode, forkNum);
|
path = relpath(reln->smgr_rlocator, forkNum);
|
||||||
|
|
||||||
fd = PathNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | PG_BINARY);
|
fd = PathNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | PG_BINARY);
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ mdcreate(SMgrRelation reln, ForkNumber forkNum, bool isRedo)
|
|||||||
/*
|
/*
|
||||||
* mdunlink() -- Unlink a relation.
|
* mdunlink() -- Unlink a relation.
|
||||||
*
|
*
|
||||||
* Note that we're passed a RelFileNodeBackend --- by the time this is called,
|
* Note that we're passed a RelFileLocatorBackend --- by the time this is called,
|
||||||
* there won't be an SMgrRelation hashtable entry anymore.
|
* there won't be an SMgrRelation hashtable entry anymore.
|
||||||
*
|
*
|
||||||
* forkNum can be a fork number to delete a specific fork, or InvalidForkNumber
|
* forkNum can be a fork number to delete a specific fork, or InvalidForkNumber
|
||||||
@ -243,10 +243,10 @@ mdcreate(SMgrRelation reln, ForkNumber forkNum, bool isRedo)
|
|||||||
* For regular relations, we don't unlink the first segment file of the rel,
|
* For regular relations, we don't unlink the first segment file of the rel,
|
||||||
* but just truncate it to zero length, and record a request to unlink it after
|
* but just truncate it to zero length, and record a request to unlink it after
|
||||||
* the next checkpoint. Additional segments can be unlinked immediately,
|
* the next checkpoint. Additional segments can be unlinked immediately,
|
||||||
* however. Leaving the empty file in place prevents that relfilenode
|
* however. Leaving the empty file in place prevents that relfilenumber
|
||||||
* number from being reused. The scenario this protects us from is:
|
* from being reused. The scenario this protects us from is:
|
||||||
* 1. We delete a relation (and commit, and actually remove its file).
|
* 1. We delete a relation (and commit, and actually remove its file).
|
||||||
* 2. We create a new relation, which by chance gets the same relfilenode as
|
* 2. We create a new relation, which by chance gets the same relfilenumber as
|
||||||
* the just-deleted one (OIDs must've wrapped around for that to happen).
|
* the just-deleted one (OIDs must've wrapped around for that to happen).
|
||||||
* 3. We crash before another checkpoint occurs.
|
* 3. We crash before another checkpoint occurs.
|
||||||
* During replay, we would delete the file and then recreate it, which is fine
|
* During replay, we would delete the file and then recreate it, which is fine
|
||||||
@ -254,18 +254,18 @@ mdcreate(SMgrRelation reln, ForkNumber forkNum, bool isRedo)
|
|||||||
* But if we didn't WAL-log insertions, but instead relied on fsyncing the
|
* But if we didn't WAL-log insertions, but instead relied on fsyncing the
|
||||||
* file after populating it (as we do at wal_level=minimal), the contents of
|
* file after populating it (as we do at wal_level=minimal), the contents of
|
||||||
* the file would be lost forever. By leaving the empty file until after the
|
* the file would be lost forever. By leaving the empty file until after the
|
||||||
* next checkpoint, we prevent reassignment of the relfilenode number until
|
* next checkpoint, we prevent reassignment of the relfilenumber until it's
|
||||||
* it's safe, because relfilenode assignment skips over any existing file.
|
* safe, because relfilenumber assignment skips over any existing file.
|
||||||
*
|
*
|
||||||
* We do not need to go through this dance for temp relations, though, because
|
* We do not need to go through this dance for temp relations, though, because
|
||||||
* we never make WAL entries for temp rels, and so a temp rel poses no threat
|
* we never make WAL entries for temp rels, and so a temp rel poses no threat
|
||||||
* to the health of a regular rel that has taken over its relfilenode number.
|
* to the health of a regular rel that has taken over its relfilenumber.
|
||||||
* The fact that temp rels and regular rels have different file naming
|
* The fact that temp rels and regular rels have different file naming
|
||||||
* patterns provides additional safety.
|
* patterns provides additional safety.
|
||||||
*
|
*
|
||||||
* All the above applies only to the relation's main fork; other forks can
|
* All the above applies only to the relation's main fork; other forks can
|
||||||
* just be removed immediately, since they are not needed to prevent the
|
* just be removed immediately, since they are not needed to prevent the
|
||||||
* relfilenode number from being recycled. Also, we do not carefully
|
* relfilenumber from being recycled. Also, we do not carefully
|
||||||
* track whether other forks have been created or not, but just attempt to
|
* track whether other forks have been created or not, but just attempt to
|
||||||
* unlink them unconditionally; so we should never complain about ENOENT.
|
* unlink them unconditionally; so we should never complain about ENOENT.
|
||||||
*
|
*
|
||||||
@ -278,16 +278,16 @@ mdcreate(SMgrRelation reln, ForkNumber forkNum, bool isRedo)
|
|||||||
* we are usually not in a transaction anymore when this is called.
|
* we are usually not in a transaction anymore when this is called.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mdunlink(RelFileNodeBackend rnode, ForkNumber forkNum, bool isRedo)
|
mdunlink(RelFileLocatorBackend rlocator, ForkNumber forkNum, bool isRedo)
|
||||||
{
|
{
|
||||||
/* Now do the per-fork work */
|
/* Now do the per-fork work */
|
||||||
if (forkNum == InvalidForkNumber)
|
if (forkNum == InvalidForkNumber)
|
||||||
{
|
{
|
||||||
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
|
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
|
||||||
mdunlinkfork(rnode, forkNum, isRedo);
|
mdunlinkfork(rlocator, forkNum, isRedo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mdunlinkfork(rnode, forkNum, isRedo);
|
mdunlinkfork(rlocator, forkNum, isRedo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -315,25 +315,25 @@ do_truncate(const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mdunlinkfork(RelFileNodeBackend rnode, ForkNumber forkNum, bool isRedo)
|
mdunlinkfork(RelFileLocatorBackend rlocator, ForkNumber forkNum, bool isRedo)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
path = relpath(rnode, forkNum);
|
path = relpath(rlocator, forkNum);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete or truncate the first segment.
|
* Delete or truncate the first segment.
|
||||||
*/
|
*/
|
||||||
if (isRedo || forkNum != MAIN_FORKNUM || RelFileNodeBackendIsTemp(rnode))
|
if (isRedo || forkNum != MAIN_FORKNUM || RelFileLocatorBackendIsTemp(rlocator))
|
||||||
{
|
{
|
||||||
if (!RelFileNodeBackendIsTemp(rnode))
|
if (!RelFileLocatorBackendIsTemp(rlocator))
|
||||||
{
|
{
|
||||||
/* Prevent other backends' fds from holding on to the disk space */
|
/* Prevent other backends' fds from holding on to the disk space */
|
||||||
ret = do_truncate(path);
|
ret = do_truncate(path);
|
||||||
|
|
||||||
/* Forget any pending sync requests for the first segment */
|
/* Forget any pending sync requests for the first segment */
|
||||||
register_forget_request(rnode, forkNum, 0 /* first seg */ );
|
register_forget_request(rlocator, forkNum, 0 /* first seg */ );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -354,7 +354,7 @@ mdunlinkfork(RelFileNodeBackend rnode, ForkNumber forkNum, bool isRedo)
|
|||||||
ret = do_truncate(path);
|
ret = do_truncate(path);
|
||||||
|
|
||||||
/* Register request to unlink first segment later */
|
/* Register request to unlink first segment later */
|
||||||
register_unlink_segment(rnode, forkNum, 0 /* first seg */ );
|
register_unlink_segment(rlocator, forkNum, 0 /* first seg */ );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -373,7 +373,7 @@ mdunlinkfork(RelFileNodeBackend rnode, ForkNumber forkNum, bool isRedo)
|
|||||||
{
|
{
|
||||||
sprintf(segpath, "%s.%u", path, segno);
|
sprintf(segpath, "%s.%u", path, segno);
|
||||||
|
|
||||||
if (!RelFileNodeBackendIsTemp(rnode))
|
if (!RelFileLocatorBackendIsTemp(rlocator))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Prevent other backends' fds from holding on to the disk
|
* Prevent other backends' fds from holding on to the disk
|
||||||
@ -386,7 +386,7 @@ mdunlinkfork(RelFileNodeBackend rnode, ForkNumber forkNum, bool isRedo)
|
|||||||
* Forget any pending sync requests for this segment before we
|
* Forget any pending sync requests for this segment before we
|
||||||
* try to unlink.
|
* try to unlink.
|
||||||
*/
|
*/
|
||||||
register_forget_request(rnode, forkNum, segno);
|
register_forget_request(rlocator, forkNum, segno);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlink(segpath) < 0)
|
if (unlink(segpath) < 0)
|
||||||
@ -437,7 +437,7 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||||
errmsg("cannot extend file \"%s\" beyond %u blocks",
|
errmsg("cannot extend file \"%s\" beyond %u blocks",
|
||||||
relpath(reln->smgr_rnode, forknum),
|
relpath(reln->smgr_rlocator, forknum),
|
||||||
InvalidBlockNumber)));
|
InvalidBlockNumber)));
|
||||||
|
|
||||||
v = _mdfd_getseg(reln, forknum, blocknum, skipFsync, EXTENSION_CREATE);
|
v = _mdfd_getseg(reln, forknum, blocknum, skipFsync, EXTENSION_CREATE);
|
||||||
@ -490,7 +490,7 @@ mdopenfork(SMgrRelation reln, ForkNumber forknum, int behavior)
|
|||||||
if (reln->md_num_open_segs[forknum] > 0)
|
if (reln->md_num_open_segs[forknum] > 0)
|
||||||
return &reln->md_seg_fds[forknum][0];
|
return &reln->md_seg_fds[forknum][0];
|
||||||
|
|
||||||
path = relpath(reln->smgr_rnode, forknum);
|
path = relpath(reln->smgr_rlocator, forknum);
|
||||||
|
|
||||||
fd = PathNameOpenFile(path, O_RDWR | PG_BINARY);
|
fd = PathNameOpenFile(path, O_RDWR | PG_BINARY);
|
||||||
|
|
||||||
@ -645,10 +645,10 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
|||||||
MdfdVec *v;
|
MdfdVec *v;
|
||||||
|
|
||||||
TRACE_POSTGRESQL_SMGR_MD_READ_START(forknum, blocknum,
|
TRACE_POSTGRESQL_SMGR_MD_READ_START(forknum, blocknum,
|
||||||
reln->smgr_rnode.node.spcNode,
|
reln->smgr_rlocator.locator.spcOid,
|
||||||
reln->smgr_rnode.node.dbNode,
|
reln->smgr_rlocator.locator.dbOid,
|
||||||
reln->smgr_rnode.node.relNode,
|
reln->smgr_rlocator.locator.relNumber,
|
||||||
reln->smgr_rnode.backend);
|
reln->smgr_rlocator.backend);
|
||||||
|
|
||||||
v = _mdfd_getseg(reln, forknum, blocknum, false,
|
v = _mdfd_getseg(reln, forknum, blocknum, false,
|
||||||
EXTENSION_FAIL | EXTENSION_CREATE_RECOVERY);
|
EXTENSION_FAIL | EXTENSION_CREATE_RECOVERY);
|
||||||
@ -660,10 +660,10 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
|||||||
nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ, seekpos, WAIT_EVENT_DATA_FILE_READ);
|
nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ, seekpos, WAIT_EVENT_DATA_FILE_READ);
|
||||||
|
|
||||||
TRACE_POSTGRESQL_SMGR_MD_READ_DONE(forknum, blocknum,
|
TRACE_POSTGRESQL_SMGR_MD_READ_DONE(forknum, blocknum,
|
||||||
reln->smgr_rnode.node.spcNode,
|
reln->smgr_rlocator.locator.spcOid,
|
||||||
reln->smgr_rnode.node.dbNode,
|
reln->smgr_rlocator.locator.dbOid,
|
||||||
reln->smgr_rnode.node.relNode,
|
reln->smgr_rlocator.locator.relNumber,
|
||||||
reln->smgr_rnode.backend,
|
reln->smgr_rlocator.backend,
|
||||||
nbytes,
|
nbytes,
|
||||||
BLCKSZ);
|
BLCKSZ);
|
||||||
|
|
||||||
@ -715,10 +715,10 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
TRACE_POSTGRESQL_SMGR_MD_WRITE_START(forknum, blocknum,
|
TRACE_POSTGRESQL_SMGR_MD_WRITE_START(forknum, blocknum,
|
||||||
reln->smgr_rnode.node.spcNode,
|
reln->smgr_rlocator.locator.spcOid,
|
||||||
reln->smgr_rnode.node.dbNode,
|
reln->smgr_rlocator.locator.dbOid,
|
||||||
reln->smgr_rnode.node.relNode,
|
reln->smgr_rlocator.locator.relNumber,
|
||||||
reln->smgr_rnode.backend);
|
reln->smgr_rlocator.backend);
|
||||||
|
|
||||||
v = _mdfd_getseg(reln, forknum, blocknum, skipFsync,
|
v = _mdfd_getseg(reln, forknum, blocknum, skipFsync,
|
||||||
EXTENSION_FAIL | EXTENSION_CREATE_RECOVERY);
|
EXTENSION_FAIL | EXTENSION_CREATE_RECOVERY);
|
||||||
@ -730,10 +730,10 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
|||||||
nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ, seekpos, WAIT_EVENT_DATA_FILE_WRITE);
|
nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ, seekpos, WAIT_EVENT_DATA_FILE_WRITE);
|
||||||
|
|
||||||
TRACE_POSTGRESQL_SMGR_MD_WRITE_DONE(forknum, blocknum,
|
TRACE_POSTGRESQL_SMGR_MD_WRITE_DONE(forknum, blocknum,
|
||||||
reln->smgr_rnode.node.spcNode,
|
reln->smgr_rlocator.locator.spcOid,
|
||||||
reln->smgr_rnode.node.dbNode,
|
reln->smgr_rlocator.locator.dbOid,
|
||||||
reln->smgr_rnode.node.relNode,
|
reln->smgr_rlocator.locator.relNumber,
|
||||||
reln->smgr_rnode.backend,
|
reln->smgr_rlocator.backend,
|
||||||
nbytes,
|
nbytes,
|
||||||
BLCKSZ);
|
BLCKSZ);
|
||||||
|
|
||||||
@ -842,7 +842,7 @@ mdtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks)
|
|||||||
return;
|
return;
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errmsg("could not truncate file \"%s\" to %u blocks: it's only %u blocks now",
|
(errmsg("could not truncate file \"%s\" to %u blocks: it's only %u blocks now",
|
||||||
relpath(reln->smgr_rnode, forknum),
|
relpath(reln->smgr_rlocator, forknum),
|
||||||
nblocks, curnblk)));
|
nblocks, curnblk)));
|
||||||
}
|
}
|
||||||
if (nblocks == curnblk)
|
if (nblocks == curnblk)
|
||||||
@ -983,7 +983,7 @@ register_dirty_segment(SMgrRelation reln, ForkNumber forknum, MdfdVec *seg)
|
|||||||
{
|
{
|
||||||
FileTag tag;
|
FileTag tag;
|
||||||
|
|
||||||
INIT_MD_FILETAG(tag, reln->smgr_rnode.node, forknum, seg->mdfd_segno);
|
INIT_MD_FILETAG(tag, reln->smgr_rlocator.locator, forknum, seg->mdfd_segno);
|
||||||
|
|
||||||
/* Temp relations should never be fsync'd */
|
/* Temp relations should never be fsync'd */
|
||||||
Assert(!SmgrIsTemp(reln));
|
Assert(!SmgrIsTemp(reln));
|
||||||
@ -1005,15 +1005,15 @@ register_dirty_segment(SMgrRelation reln, ForkNumber forknum, MdfdVec *seg)
|
|||||||
* register_unlink_segment() -- Schedule a file to be deleted after next checkpoint
|
* register_unlink_segment() -- Schedule a file to be deleted after next checkpoint
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
register_unlink_segment(RelFileNodeBackend rnode, ForkNumber forknum,
|
register_unlink_segment(RelFileLocatorBackend rlocator, ForkNumber forknum,
|
||||||
BlockNumber segno)
|
BlockNumber segno)
|
||||||
{
|
{
|
||||||
FileTag tag;
|
FileTag tag;
|
||||||
|
|
||||||
INIT_MD_FILETAG(tag, rnode.node, forknum, segno);
|
INIT_MD_FILETAG(tag, rlocator.locator, forknum, segno);
|
||||||
|
|
||||||
/* Should never be used with temp relations */
|
/* Should never be used with temp relations */
|
||||||
Assert(!RelFileNodeBackendIsTemp(rnode));
|
Assert(!RelFileLocatorBackendIsTemp(rlocator));
|
||||||
|
|
||||||
RegisterSyncRequest(&tag, SYNC_UNLINK_REQUEST, true /* retryOnError */ );
|
RegisterSyncRequest(&tag, SYNC_UNLINK_REQUEST, true /* retryOnError */ );
|
||||||
}
|
}
|
||||||
@ -1022,12 +1022,12 @@ register_unlink_segment(RelFileNodeBackend rnode, ForkNumber forknum,
|
|||||||
* register_forget_request() -- forget any fsyncs for a relation fork's segment
|
* register_forget_request() -- forget any fsyncs for a relation fork's segment
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
register_forget_request(RelFileNodeBackend rnode, ForkNumber forknum,
|
register_forget_request(RelFileLocatorBackend rlocator, ForkNumber forknum,
|
||||||
BlockNumber segno)
|
BlockNumber segno)
|
||||||
{
|
{
|
||||||
FileTag tag;
|
FileTag tag;
|
||||||
|
|
||||||
INIT_MD_FILETAG(tag, rnode.node, forknum, segno);
|
INIT_MD_FILETAG(tag, rlocator.locator, forknum, segno);
|
||||||
|
|
||||||
RegisterSyncRequest(&tag, SYNC_FORGET_REQUEST, true /* retryOnError */ );
|
RegisterSyncRequest(&tag, SYNC_FORGET_REQUEST, true /* retryOnError */ );
|
||||||
}
|
}
|
||||||
@ -1039,13 +1039,13 @@ void
|
|||||||
ForgetDatabaseSyncRequests(Oid dbid)
|
ForgetDatabaseSyncRequests(Oid dbid)
|
||||||
{
|
{
|
||||||
FileTag tag;
|
FileTag tag;
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
|
|
||||||
rnode.dbNode = dbid;
|
rlocator.dbOid = dbid;
|
||||||
rnode.spcNode = 0;
|
rlocator.spcOid = 0;
|
||||||
rnode.relNode = 0;
|
rlocator.relNumber = 0;
|
||||||
|
|
||||||
INIT_MD_FILETAG(tag, rnode, InvalidForkNumber, InvalidBlockNumber);
|
INIT_MD_FILETAG(tag, rlocator, InvalidForkNumber, InvalidBlockNumber);
|
||||||
|
|
||||||
RegisterSyncRequest(&tag, SYNC_FILTER_REQUEST, true /* retryOnError */ );
|
RegisterSyncRequest(&tag, SYNC_FILTER_REQUEST, true /* retryOnError */ );
|
||||||
}
|
}
|
||||||
@ -1054,7 +1054,7 @@ ForgetDatabaseSyncRequests(Oid dbid)
|
|||||||
* DropRelationFiles -- drop files of all given relations
|
* DropRelationFiles -- drop files of all given relations
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
DropRelationFiles(RelFileNode *delrels, int ndelrels, bool isRedo)
|
DropRelationFiles(RelFileLocator *delrels, int ndelrels, bool isRedo)
|
||||||
{
|
{
|
||||||
SMgrRelation *srels;
|
SMgrRelation *srels;
|
||||||
int i;
|
int i;
|
||||||
@ -1129,7 +1129,7 @@ _mdfd_segpath(SMgrRelation reln, ForkNumber forknum, BlockNumber segno)
|
|||||||
char *path,
|
char *path,
|
||||||
*fullpath;
|
*fullpath;
|
||||||
|
|
||||||
path = relpath(reln->smgr_rnode, forknum);
|
path = relpath(reln->smgr_rlocator, forknum);
|
||||||
|
|
||||||
if (segno > 0)
|
if (segno > 0)
|
||||||
{
|
{
|
||||||
@ -1345,7 +1345,7 @@ _mdnblocks(SMgrRelation reln, ForkNumber forknum, MdfdVec *seg)
|
|||||||
int
|
int
|
||||||
mdsyncfiletag(const FileTag *ftag, char *path)
|
mdsyncfiletag(const FileTag *ftag, char *path)
|
||||||
{
|
{
|
||||||
SMgrRelation reln = smgropen(ftag->rnode, InvalidBackendId);
|
SMgrRelation reln = smgropen(ftag->rlocator, InvalidBackendId);
|
||||||
File file;
|
File file;
|
||||||
bool need_to_close;
|
bool need_to_close;
|
||||||
int result,
|
int result,
|
||||||
@ -1395,7 +1395,7 @@ mdunlinkfiletag(const FileTag *ftag, char *path)
|
|||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
/* Compute the path. */
|
/* Compute the path. */
|
||||||
p = relpathperm(ftag->rnode, MAIN_FORKNUM);
|
p = relpathperm(ftag->rlocator, MAIN_FORKNUM);
|
||||||
strlcpy(path, p, MAXPGPATH);
|
strlcpy(path, p, MAXPGPATH);
|
||||||
pfree(p);
|
pfree(p);
|
||||||
|
|
||||||
@ -1417,5 +1417,5 @@ mdfiletagmatches(const FileTag *ftag, const FileTag *candidate)
|
|||||||
* We'll return true for all candidates that have the same database OID as
|
* We'll return true for all candidates that have the same database OID as
|
||||||
* the ftag from the SYNC_FILTER_REQUEST request, so they're forgotten.
|
* the ftag from the SYNC_FILTER_REQUEST request, so they're forgotten.
|
||||||
*/
|
*/
|
||||||
return ftag->rnode.dbNode == candidate->rnode.dbNode;
|
return ftag->rlocator.dbOid == candidate->rlocator.dbOid;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ typedef struct f_smgr
|
|||||||
void (*smgr_create) (SMgrRelation reln, ForkNumber forknum,
|
void (*smgr_create) (SMgrRelation reln, ForkNumber forknum,
|
||||||
bool isRedo);
|
bool isRedo);
|
||||||
bool (*smgr_exists) (SMgrRelation reln, ForkNumber forknum);
|
bool (*smgr_exists) (SMgrRelation reln, ForkNumber forknum);
|
||||||
void (*smgr_unlink) (RelFileNodeBackend rnode, ForkNumber forknum,
|
void (*smgr_unlink) (RelFileLocatorBackend rlocator, ForkNumber forknum,
|
||||||
bool isRedo);
|
bool isRedo);
|
||||||
void (*smgr_extend) (SMgrRelation reln, ForkNumber forknum,
|
void (*smgr_extend) (SMgrRelation reln, ForkNumber forknum,
|
||||||
BlockNumber blocknum, char *buffer, bool skipFsync);
|
BlockNumber blocknum, char *buffer, bool skipFsync);
|
||||||
@ -143,9 +143,9 @@ smgrshutdown(int code, Datum arg)
|
|||||||
* This does not attempt to actually open the underlying file.
|
* This does not attempt to actually open the underlying file.
|
||||||
*/
|
*/
|
||||||
SMgrRelation
|
SMgrRelation
|
||||||
smgropen(RelFileNode rnode, BackendId backend)
|
smgropen(RelFileLocator rlocator, BackendId backend)
|
||||||
{
|
{
|
||||||
RelFileNodeBackend brnode;
|
RelFileLocatorBackend brlocator;
|
||||||
SMgrRelation reln;
|
SMgrRelation reln;
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ smgropen(RelFileNode rnode, BackendId backend)
|
|||||||
/* First time through: initialize the hash table */
|
/* First time through: initialize the hash table */
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
ctl.keysize = sizeof(RelFileNodeBackend);
|
ctl.keysize = sizeof(RelFileLocatorBackend);
|
||||||
ctl.entrysize = sizeof(SMgrRelationData);
|
ctl.entrysize = sizeof(SMgrRelationData);
|
||||||
SMgrRelationHash = hash_create("smgr relation table", 400,
|
SMgrRelationHash = hash_create("smgr relation table", 400,
|
||||||
&ctl, HASH_ELEM | HASH_BLOBS);
|
&ctl, HASH_ELEM | HASH_BLOBS);
|
||||||
@ -162,10 +162,10 @@ smgropen(RelFileNode rnode, BackendId backend)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Look up or create an entry */
|
/* Look up or create an entry */
|
||||||
brnode.node = rnode;
|
brlocator.locator = rlocator;
|
||||||
brnode.backend = backend;
|
brlocator.backend = backend;
|
||||||
reln = (SMgrRelation) hash_search(SMgrRelationHash,
|
reln = (SMgrRelation) hash_search(SMgrRelationHash,
|
||||||
(void *) &brnode,
|
(void *) &brlocator,
|
||||||
HASH_ENTER, &found);
|
HASH_ENTER, &found);
|
||||||
|
|
||||||
/* Initialize it if not present before */
|
/* Initialize it if not present before */
|
||||||
@ -267,7 +267,7 @@ smgrclose(SMgrRelation reln)
|
|||||||
dlist_delete(&reln->node);
|
dlist_delete(&reln->node);
|
||||||
|
|
||||||
if (hash_search(SMgrRelationHash,
|
if (hash_search(SMgrRelationHash,
|
||||||
(void *) &(reln->smgr_rnode),
|
(void *) &(reln->smgr_rlocator),
|
||||||
HASH_REMOVE, NULL) == NULL)
|
HASH_REMOVE, NULL) == NULL)
|
||||||
elog(ERROR, "SMgrRelation hashtable corrupted");
|
elog(ERROR, "SMgrRelation hashtable corrupted");
|
||||||
|
|
||||||
@ -335,15 +335,15 @@ smgrcloseall(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* smgrclosenode() -- Close SMgrRelation object for given RelFileNode,
|
* smgrcloserellocator() -- Close SMgrRelation object for given RelFileLocator,
|
||||||
* if one exists.
|
* if one exists.
|
||||||
*
|
*
|
||||||
* This has the same effects as smgrclose(smgropen(rnode)), but it avoids
|
* This has the same effects as smgrclose(smgropen(rlocator)), but it avoids
|
||||||
* uselessly creating a hashtable entry only to drop it again when no
|
* uselessly creating a hashtable entry only to drop it again when no
|
||||||
* such entry exists already.
|
* such entry exists already.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
smgrclosenode(RelFileNodeBackend rnode)
|
smgrcloserellocator(RelFileLocatorBackend rlocator)
|
||||||
{
|
{
|
||||||
SMgrRelation reln;
|
SMgrRelation reln;
|
||||||
|
|
||||||
@ -352,7 +352,7 @@ smgrclosenode(RelFileNodeBackend rnode)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
reln = (SMgrRelation) hash_search(SMgrRelationHash,
|
reln = (SMgrRelation) hash_search(SMgrRelationHash,
|
||||||
(void *) &rnode,
|
(void *) &rlocator,
|
||||||
HASH_FIND, NULL);
|
HASH_FIND, NULL);
|
||||||
if (reln != NULL)
|
if (reln != NULL)
|
||||||
smgrclose(reln);
|
smgrclose(reln);
|
||||||
@ -420,7 +420,7 @@ void
|
|||||||
smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
|
smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
RelFileNodeBackend *rnodes;
|
RelFileLocatorBackend *rlocators;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
|
|
||||||
if (nrels == 0)
|
if (nrels == 0)
|
||||||
@ -430,19 +430,19 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
|
|||||||
* Get rid of any remaining buffers for the relations. bufmgr will just
|
* Get rid of any remaining buffers for the relations. bufmgr will just
|
||||||
* drop them without bothering to write the contents.
|
* drop them without bothering to write the contents.
|
||||||
*/
|
*/
|
||||||
DropRelFileNodesAllBuffers(rels, nrels);
|
DropRelFileLocatorsAllBuffers(rels, nrels);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create an array which contains all relations to be dropped, and close
|
* create an array which contains all relations to be dropped, and close
|
||||||
* each relation's forks at the smgr level while at it
|
* each relation's forks at the smgr level while at it
|
||||||
*/
|
*/
|
||||||
rnodes = palloc(sizeof(RelFileNodeBackend) * nrels);
|
rlocators = palloc(sizeof(RelFileLocatorBackend) * nrels);
|
||||||
for (i = 0; i < nrels; i++)
|
for (i = 0; i < nrels; i++)
|
||||||
{
|
{
|
||||||
RelFileNodeBackend rnode = rels[i]->smgr_rnode;
|
RelFileLocatorBackend rlocator = rels[i]->smgr_rlocator;
|
||||||
int which = rels[i]->smgr_which;
|
int which = rels[i]->smgr_which;
|
||||||
|
|
||||||
rnodes[i] = rnode;
|
rlocators[i] = rlocator;
|
||||||
|
|
||||||
/* Close the forks at smgr level */
|
/* Close the forks at smgr level */
|
||||||
for (forknum = 0; forknum <= MAX_FORKNUM; forknum++)
|
for (forknum = 0; forknum <= MAX_FORKNUM; forknum++)
|
||||||
@ -458,7 +458,7 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
|
|||||||
* closed our own smgr rel.
|
* closed our own smgr rel.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nrels; i++)
|
for (i = 0; i < nrels; i++)
|
||||||
CacheInvalidateSmgr(rnodes[i]);
|
CacheInvalidateSmgr(rlocators[i]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete the physical file(s).
|
* Delete the physical file(s).
|
||||||
@ -473,10 +473,10 @@ smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
|
|||||||
int which = rels[i]->smgr_which;
|
int which = rels[i]->smgr_which;
|
||||||
|
|
||||||
for (forknum = 0; forknum <= MAX_FORKNUM; forknum++)
|
for (forknum = 0; forknum <= MAX_FORKNUM; forknum++)
|
||||||
smgrsw[which].smgr_unlink(rnodes[i], forknum, isRedo);
|
smgrsw[which].smgr_unlink(rlocators[i], forknum, isRedo);
|
||||||
}
|
}
|
||||||
|
|
||||||
pfree(rnodes);
|
pfree(rlocators);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -631,7 +631,7 @@ smgrtruncate(SMgrRelation reln, ForkNumber *forknum, int nforks, BlockNumber *nb
|
|||||||
* Get rid of any buffers for the about-to-be-deleted blocks. bufmgr will
|
* Get rid of any buffers for the about-to-be-deleted blocks. bufmgr will
|
||||||
* just drop them without bothering to write the contents.
|
* just drop them without bothering to write the contents.
|
||||||
*/
|
*/
|
||||||
DropRelFileNodeBuffers(reln, forknum, nforks, nblocks);
|
DropRelFileLocatorBuffers(reln, forknum, nforks, nblocks);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send a shared-inval message to force other backends to close any smgr
|
* Send a shared-inval message to force other backends to close any smgr
|
||||||
@ -643,7 +643,7 @@ smgrtruncate(SMgrRelation reln, ForkNumber *forknum, int nforks, BlockNumber *nb
|
|||||||
* is a performance-critical path.) As in the unlink code, we want to be
|
* is a performance-critical path.) As in the unlink code, we want to be
|
||||||
* sure the message is sent before we start changing things on-disk.
|
* sure the message is sent before we start changing things on-disk.
|
||||||
*/
|
*/
|
||||||
CacheInvalidateSmgr(reln->smgr_rnode);
|
CacheInvalidateSmgr(reln->smgr_rlocator);
|
||||||
|
|
||||||
/* Do the truncation */
|
/* Do the truncation */
|
||||||
for (i = 0; i < nforks; i++)
|
for (i = 0; i < nforks; i++)
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
#include "utils/numeric.h"
|
#include "utils/numeric.h"
|
||||||
#include "utils/rel.h"
|
#include "utils/rel.h"
|
||||||
#include "utils/relfilenodemap.h"
|
#include "utils/relfilenumbermap.h"
|
||||||
#include "utils/relmapper.h"
|
#include "utils/relmapper.h"
|
||||||
#include "utils/syscache.h"
|
#include "utils/syscache.h"
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ pg_tablespace_size_name(PG_FUNCTION_ARGS)
|
|||||||
* is no check here or at the call sites for that.
|
* is no check here or at the call sites for that.
|
||||||
*/
|
*/
|
||||||
static int64
|
static int64
|
||||||
calculate_relation_size(RelFileNode *rfn, BackendId backend, ForkNumber forknum)
|
calculate_relation_size(RelFileLocator *rfn, BackendId backend, ForkNumber forknum)
|
||||||
{
|
{
|
||||||
int64 totalsize = 0;
|
int64 totalsize = 0;
|
||||||
char *relationpath;
|
char *relationpath;
|
||||||
@ -349,7 +349,7 @@ pg_relation_size(PG_FUNCTION_ARGS)
|
|||||||
if (rel == NULL)
|
if (rel == NULL)
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
|
|
||||||
size = calculate_relation_size(&(rel->rd_node), rel->rd_backend,
|
size = calculate_relation_size(&(rel->rd_locator), rel->rd_backend,
|
||||||
forkname_to_number(text_to_cstring(forkName)));
|
forkname_to_number(text_to_cstring(forkName)));
|
||||||
|
|
||||||
relation_close(rel, AccessShareLock);
|
relation_close(rel, AccessShareLock);
|
||||||
@ -374,7 +374,7 @@ calculate_toast_table_size(Oid toastrelid)
|
|||||||
|
|
||||||
/* toast heap size, including FSM and VM size */
|
/* toast heap size, including FSM and VM size */
|
||||||
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
|
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
|
||||||
size += calculate_relation_size(&(toastRel->rd_node),
|
size += calculate_relation_size(&(toastRel->rd_locator),
|
||||||
toastRel->rd_backend, forkNum);
|
toastRel->rd_backend, forkNum);
|
||||||
|
|
||||||
/* toast index size, including FSM and VM size */
|
/* toast index size, including FSM and VM size */
|
||||||
@ -388,7 +388,7 @@ calculate_toast_table_size(Oid toastrelid)
|
|||||||
toastIdxRel = relation_open(lfirst_oid(lc),
|
toastIdxRel = relation_open(lfirst_oid(lc),
|
||||||
AccessShareLock);
|
AccessShareLock);
|
||||||
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
|
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
|
||||||
size += calculate_relation_size(&(toastIdxRel->rd_node),
|
size += calculate_relation_size(&(toastIdxRel->rd_locator),
|
||||||
toastIdxRel->rd_backend, forkNum);
|
toastIdxRel->rd_backend, forkNum);
|
||||||
|
|
||||||
relation_close(toastIdxRel, AccessShareLock);
|
relation_close(toastIdxRel, AccessShareLock);
|
||||||
@ -417,7 +417,7 @@ calculate_table_size(Relation rel)
|
|||||||
* heap size, including FSM and VM
|
* heap size, including FSM and VM
|
||||||
*/
|
*/
|
||||||
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
|
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
|
||||||
size += calculate_relation_size(&(rel->rd_node), rel->rd_backend,
|
size += calculate_relation_size(&(rel->rd_locator), rel->rd_backend,
|
||||||
forkNum);
|
forkNum);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -456,7 +456,7 @@ calculate_indexes_size(Relation rel)
|
|||||||
idxRel = relation_open(idxOid, AccessShareLock);
|
idxRel = relation_open(idxOid, AccessShareLock);
|
||||||
|
|
||||||
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
|
for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
|
||||||
size += calculate_relation_size(&(idxRel->rd_node),
|
size += calculate_relation_size(&(idxRel->rd_locator),
|
||||||
idxRel->rd_backend,
|
idxRel->rd_backend,
|
||||||
forkNum);
|
forkNum);
|
||||||
|
|
||||||
@ -850,7 +850,7 @@ Datum
|
|||||||
pg_relation_filenode(PG_FUNCTION_ARGS)
|
pg_relation_filenode(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
Oid relid = PG_GETARG_OID(0);
|
Oid relid = PG_GETARG_OID(0);
|
||||||
Oid result;
|
RelFileNumber result;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Form_pg_class relform;
|
Form_pg_class relform;
|
||||||
|
|
||||||
@ -864,29 +864,29 @@ pg_relation_filenode(PG_FUNCTION_ARGS)
|
|||||||
if (relform->relfilenode)
|
if (relform->relfilenode)
|
||||||
result = relform->relfilenode;
|
result = relform->relfilenode;
|
||||||
else /* Consult the relation mapper */
|
else /* Consult the relation mapper */
|
||||||
result = RelationMapOidToFilenode(relid,
|
result = RelationMapOidToFilenumber(relid,
|
||||||
relform->relisshared);
|
relform->relisshared);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* no storage, return NULL */
|
/* no storage, return NULL */
|
||||||
result = InvalidOid;
|
result = InvalidRelFileNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
|
|
||||||
if (!OidIsValid(result))
|
if (!RelFileNumberIsValid(result))
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
|
|
||||||
PG_RETURN_OID(result);
|
PG_RETURN_OID(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the relation via (reltablespace, relfilenode)
|
* Get the relation via (reltablespace, relfilenumber)
|
||||||
*
|
*
|
||||||
* This is expected to be used when somebody wants to match an individual file
|
* This is expected to be used when somebody wants to match an individual file
|
||||||
* on the filesystem back to its table. That's not trivially possible via
|
* on the filesystem back to its table. That's not trivially possible via
|
||||||
* pg_class, because that doesn't contain the relfilenodes of shared and nailed
|
* pg_class, because that doesn't contain the relfilenumbers of shared and nailed
|
||||||
* tables.
|
* tables.
|
||||||
*
|
*
|
||||||
* We don't fail but return NULL if we cannot find a mapping.
|
* We don't fail but return NULL if we cannot find a mapping.
|
||||||
@ -898,14 +898,14 @@ Datum
|
|||||||
pg_filenode_relation(PG_FUNCTION_ARGS)
|
pg_filenode_relation(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
Oid reltablespace = PG_GETARG_OID(0);
|
Oid reltablespace = PG_GETARG_OID(0);
|
||||||
Oid relfilenode = PG_GETARG_OID(1);
|
RelFileNumber relfilenumber = PG_GETARG_OID(1);
|
||||||
Oid heaprel;
|
Oid heaprel;
|
||||||
|
|
||||||
/* test needed so RelidByRelfilenode doesn't misbehave */
|
/* test needed so RelidByRelfilenumber doesn't misbehave */
|
||||||
if (!OidIsValid(relfilenode))
|
if (!RelFileNumberIsValid(relfilenumber))
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
|
|
||||||
heaprel = RelidByRelfilenode(reltablespace, relfilenode);
|
heaprel = RelidByRelfilenumber(reltablespace, relfilenumber);
|
||||||
|
|
||||||
if (!OidIsValid(heaprel))
|
if (!OidIsValid(heaprel))
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
@ -924,7 +924,7 @@ pg_relation_filepath(PG_FUNCTION_ARGS)
|
|||||||
Oid relid = PG_GETARG_OID(0);
|
Oid relid = PG_GETARG_OID(0);
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Form_pg_class relform;
|
Form_pg_class relform;
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
BackendId backend;
|
BackendId backend;
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
@ -937,29 +937,29 @@ pg_relation_filepath(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
/* This logic should match RelationInitPhysicalAddr */
|
/* This logic should match RelationInitPhysicalAddr */
|
||||||
if (relform->reltablespace)
|
if (relform->reltablespace)
|
||||||
rnode.spcNode = relform->reltablespace;
|
rlocator.spcOid = relform->reltablespace;
|
||||||
else
|
else
|
||||||
rnode.spcNode = MyDatabaseTableSpace;
|
rlocator.spcOid = MyDatabaseTableSpace;
|
||||||
if (rnode.spcNode == GLOBALTABLESPACE_OID)
|
if (rlocator.spcOid == GLOBALTABLESPACE_OID)
|
||||||
rnode.dbNode = InvalidOid;
|
rlocator.dbOid = InvalidOid;
|
||||||
else
|
else
|
||||||
rnode.dbNode = MyDatabaseId;
|
rlocator.dbOid = MyDatabaseId;
|
||||||
if (relform->relfilenode)
|
if (relform->relfilenode)
|
||||||
rnode.relNode = relform->relfilenode;
|
rlocator.relNumber = relform->relfilenode;
|
||||||
else /* Consult the relation mapper */
|
else /* Consult the relation mapper */
|
||||||
rnode.relNode = RelationMapOidToFilenode(relid,
|
rlocator.relNumber = RelationMapOidToFilenumber(relid,
|
||||||
relform->relisshared);
|
relform->relisshared);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* no storage, return NULL */
|
/* no storage, return NULL */
|
||||||
rnode.relNode = InvalidOid;
|
rlocator.relNumber = InvalidRelFileNumber;
|
||||||
/* some compilers generate warnings without these next two lines */
|
/* some compilers generate warnings without these next two lines */
|
||||||
rnode.dbNode = InvalidOid;
|
rlocator.dbOid = InvalidOid;
|
||||||
rnode.spcNode = InvalidOid;
|
rlocator.spcOid = InvalidOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OidIsValid(rnode.relNode))
|
if (!RelFileNumberIsValid(rlocator.relNumber))
|
||||||
{
|
{
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
@ -990,7 +990,7 @@ pg_relation_filepath(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
|
|
||||||
path = relpathbackend(rnode, backend, MAIN_FORKNUM);
|
path = relpathbackend(rlocator, backend, MAIN_FORKNUM);
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(cstring_to_text(path));
|
PG_RETURN_TEXT_P(cstring_to_text(path));
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* pg_upgrade_support.c
|
* pg_upgrade_support.c
|
||||||
*
|
*
|
||||||
* server-side functions to set backend global variables
|
* server-side functions to set backend global variables
|
||||||
* to control oid and relfilenode assignment, and do other special
|
* to control oid and relfilenumber assignment, and do other special
|
||||||
* hacks needed for pg_upgrade.
|
* hacks needed for pg_upgrade.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010-2022, PostgreSQL Global Development Group
|
* Copyright (c) 2010-2022, PostgreSQL Global Development Group
|
||||||
@ -98,10 +98,10 @@ binary_upgrade_set_next_heap_pg_class_oid(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
binary_upgrade_set_next_heap_relfilenode(PG_FUNCTION_ARGS)
|
binary_upgrade_set_next_heap_relfilenode(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
Oid nodeoid = PG_GETARG_OID(0);
|
RelFileNumber relfilenumber = PG_GETARG_OID(0);
|
||||||
|
|
||||||
CHECK_IS_BINARY_UPGRADE;
|
CHECK_IS_BINARY_UPGRADE;
|
||||||
binary_upgrade_next_heap_pg_class_relfilenode = nodeoid;
|
binary_upgrade_next_heap_pg_class_relfilenumber = relfilenumber;
|
||||||
|
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
@ -120,10 +120,10 @@ binary_upgrade_set_next_index_pg_class_oid(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
binary_upgrade_set_next_index_relfilenode(PG_FUNCTION_ARGS)
|
binary_upgrade_set_next_index_relfilenode(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
Oid nodeoid = PG_GETARG_OID(0);
|
RelFileNumber relfilenumber = PG_GETARG_OID(0);
|
||||||
|
|
||||||
CHECK_IS_BINARY_UPGRADE;
|
CHECK_IS_BINARY_UPGRADE;
|
||||||
binary_upgrade_next_index_pg_class_relfilenode = nodeoid;
|
binary_upgrade_next_index_pg_class_relfilenumber = relfilenumber;
|
||||||
|
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
@ -142,10 +142,10 @@ binary_upgrade_set_next_toast_pg_class_oid(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
binary_upgrade_set_next_toast_relfilenode(PG_FUNCTION_ARGS)
|
binary_upgrade_set_next_toast_relfilenode(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
Oid nodeoid = PG_GETARG_OID(0);
|
RelFileNumber relfilenumber = PG_GETARG_OID(0);
|
||||||
|
|
||||||
CHECK_IS_BINARY_UPGRADE;
|
CHECK_IS_BINARY_UPGRADE;
|
||||||
binary_upgrade_next_toast_pg_class_relfilenode = nodeoid;
|
binary_upgrade_next_toast_pg_class_relfilenumber = relfilenumber;
|
||||||
|
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
|
2
src/backend/utils/cache/Makefile
vendored
2
src/backend/utils/cache/Makefile
vendored
@ -21,7 +21,7 @@ OBJS = \
|
|||||||
partcache.o \
|
partcache.o \
|
||||||
plancache.o \
|
plancache.o \
|
||||||
relcache.o \
|
relcache.o \
|
||||||
relfilenodemap.o \
|
relfilenumbermap.o \
|
||||||
relmapper.o \
|
relmapper.o \
|
||||||
spccache.o \
|
spccache.o \
|
||||||
syscache.o \
|
syscache.o \
|
||||||
|
16
src/backend/utils/cache/inval.c
vendored
16
src/backend/utils/cache/inval.c
vendored
@ -661,11 +661,11 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
|
|||||||
* We could have smgr entries for relations of other databases, so no
|
* We could have smgr entries for relations of other databases, so no
|
||||||
* short-circuit test is possible here.
|
* short-circuit test is possible here.
|
||||||
*/
|
*/
|
||||||
RelFileNodeBackend rnode;
|
RelFileLocatorBackend rlocator;
|
||||||
|
|
||||||
rnode.node = msg->sm.rnode;
|
rlocator.locator = msg->sm.rlocator;
|
||||||
rnode.backend = (msg->sm.backend_hi << 16) | (int) msg->sm.backend_lo;
|
rlocator.backend = (msg->sm.backend_hi << 16) | (int) msg->sm.backend_lo;
|
||||||
smgrclosenode(rnode);
|
smgrcloserellocator(rlocator);
|
||||||
}
|
}
|
||||||
else if (msg->id == SHAREDINVALRELMAP_ID)
|
else if (msg->id == SHAREDINVALRELMAP_ID)
|
||||||
{
|
{
|
||||||
@ -1459,14 +1459,14 @@ CacheInvalidateRelcacheByRelid(Oid relid)
|
|||||||
* Thus, the maximum possible backend ID is 2^23-1.
|
* Thus, the maximum possible backend ID is 2^23-1.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CacheInvalidateSmgr(RelFileNodeBackend rnode)
|
CacheInvalidateSmgr(RelFileLocatorBackend rlocator)
|
||||||
{
|
{
|
||||||
SharedInvalidationMessage msg;
|
SharedInvalidationMessage msg;
|
||||||
|
|
||||||
msg.sm.id = SHAREDINVALSMGR_ID;
|
msg.sm.id = SHAREDINVALSMGR_ID;
|
||||||
msg.sm.backend_hi = rnode.backend >> 16;
|
msg.sm.backend_hi = rlocator.backend >> 16;
|
||||||
msg.sm.backend_lo = rnode.backend & 0xffff;
|
msg.sm.backend_lo = rlocator.backend & 0xffff;
|
||||||
msg.sm.rnode = rnode.node;
|
msg.sm.rlocator = rlocator.locator;
|
||||||
/* check AddCatcacheInvalidationMessage() for an explanation */
|
/* check AddCatcacheInvalidationMessage() for an explanation */
|
||||||
VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
|
VALGRIND_MAKE_MEM_DEFINED(&msg, sizeof(msg));
|
||||||
|
|
||||||
|
180
src/backend/utils/cache/relcache.c
vendored
180
src/backend/utils/cache/relcache.c
vendored
@ -369,7 +369,7 @@ ScanPgRelation(Oid targetRelId, bool indexOK, bool force_non_historic)
|
|||||||
/*
|
/*
|
||||||
* The caller might need a tuple that's newer than the one the historic
|
* The caller might need a tuple that's newer than the one the historic
|
||||||
* snapshot; currently the only case requiring to do so is looking up the
|
* snapshot; currently the only case requiring to do so is looking up the
|
||||||
* relfilenode of non mapped system relations during decoding. That
|
* relfilenumber of non mapped system relations during decoding. That
|
||||||
* snapshot can't change in the midst of a relcache build, so there's no
|
* snapshot can't change in the midst of a relcache build, so there's no
|
||||||
* need to register the snapshot.
|
* need to register the snapshot.
|
||||||
*/
|
*/
|
||||||
@ -1133,8 +1133,8 @@ retry:
|
|||||||
relation->rd_refcnt = 0;
|
relation->rd_refcnt = 0;
|
||||||
relation->rd_isnailed = false;
|
relation->rd_isnailed = false;
|
||||||
relation->rd_createSubid = InvalidSubTransactionId;
|
relation->rd_createSubid = InvalidSubTransactionId;
|
||||||
relation->rd_newRelfilenodeSubid = InvalidSubTransactionId;
|
relation->rd_newRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
relation->rd_firstRelfilenodeSubid = InvalidSubTransactionId;
|
relation->rd_firstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
relation->rd_droppedSubid = InvalidSubTransactionId;
|
relation->rd_droppedSubid = InvalidSubTransactionId;
|
||||||
switch (relation->rd_rel->relpersistence)
|
switch (relation->rd_rel->relpersistence)
|
||||||
{
|
{
|
||||||
@ -1300,7 +1300,7 @@ retry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the physical addressing info (RelFileNode) for a relcache entry
|
* Initialize the physical addressing info (RelFileLocator) for a relcache entry
|
||||||
*
|
*
|
||||||
* Note: at the physical level, relations in the pg_global tablespace must
|
* Note: at the physical level, relations in the pg_global tablespace must
|
||||||
* be treated as shared, even if relisshared isn't set. Hence we do not
|
* be treated as shared, even if relisshared isn't set. Hence we do not
|
||||||
@ -1309,20 +1309,20 @@ retry:
|
|||||||
static void
|
static void
|
||||||
RelationInitPhysicalAddr(Relation relation)
|
RelationInitPhysicalAddr(Relation relation)
|
||||||
{
|
{
|
||||||
Oid oldnode = relation->rd_node.relNode;
|
RelFileNumber oldnumber = relation->rd_locator.relNumber;
|
||||||
|
|
||||||
/* these relations kinds never have storage */
|
/* these relations kinds never have storage */
|
||||||
if (!RELKIND_HAS_STORAGE(relation->rd_rel->relkind))
|
if (!RELKIND_HAS_STORAGE(relation->rd_rel->relkind))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (relation->rd_rel->reltablespace)
|
if (relation->rd_rel->reltablespace)
|
||||||
relation->rd_node.spcNode = relation->rd_rel->reltablespace;
|
relation->rd_locator.spcOid = relation->rd_rel->reltablespace;
|
||||||
else
|
else
|
||||||
relation->rd_node.spcNode = MyDatabaseTableSpace;
|
relation->rd_locator.spcOid = MyDatabaseTableSpace;
|
||||||
if (relation->rd_node.spcNode == GLOBALTABLESPACE_OID)
|
if (relation->rd_locator.spcOid == GLOBALTABLESPACE_OID)
|
||||||
relation->rd_node.dbNode = InvalidOid;
|
relation->rd_locator.dbOid = InvalidOid;
|
||||||
else
|
else
|
||||||
relation->rd_node.dbNode = MyDatabaseId;
|
relation->rd_locator.dbOid = MyDatabaseId;
|
||||||
|
|
||||||
if (relation->rd_rel->relfilenode)
|
if (relation->rd_rel->relfilenode)
|
||||||
{
|
{
|
||||||
@ -1356,30 +1356,30 @@ RelationInitPhysicalAddr(Relation relation)
|
|||||||
heap_freetuple(phys_tuple);
|
heap_freetuple(phys_tuple);
|
||||||
}
|
}
|
||||||
|
|
||||||
relation->rd_node.relNode = relation->rd_rel->relfilenode;
|
relation->rd_locator.relNumber = relation->rd_rel->relfilenode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Consult the relation mapper */
|
/* Consult the relation mapper */
|
||||||
relation->rd_node.relNode =
|
relation->rd_locator.relNumber =
|
||||||
RelationMapOidToFilenode(relation->rd_id,
|
RelationMapOidToFilenumber(relation->rd_id,
|
||||||
relation->rd_rel->relisshared);
|
relation->rd_rel->relisshared);
|
||||||
if (!OidIsValid(relation->rd_node.relNode))
|
if (!RelFileNumberIsValid(relation->rd_locator.relNumber))
|
||||||
elog(ERROR, "could not find relation mapping for relation \"%s\", OID %u",
|
elog(ERROR, "could not find relation mapping for relation \"%s\", OID %u",
|
||||||
RelationGetRelationName(relation), relation->rd_id);
|
RelationGetRelationName(relation), relation->rd_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For RelationNeedsWAL() to answer correctly on parallel workers, restore
|
* For RelationNeedsWAL() to answer correctly on parallel workers, restore
|
||||||
* rd_firstRelfilenodeSubid. No subtransactions start or end while in
|
* rd_firstRelfilelocatorSubid. No subtransactions start or end while in
|
||||||
* parallel mode, so the specific SubTransactionId does not matter.
|
* parallel mode, so the specific SubTransactionId does not matter.
|
||||||
*/
|
*/
|
||||||
if (IsParallelWorker() && oldnode != relation->rd_node.relNode)
|
if (IsParallelWorker() && oldnumber != relation->rd_locator.relNumber)
|
||||||
{
|
{
|
||||||
if (RelFileNodeSkippingWAL(relation->rd_node))
|
if (RelFileLocatorSkippingWAL(relation->rd_locator))
|
||||||
relation->rd_firstRelfilenodeSubid = TopSubTransactionId;
|
relation->rd_firstRelfilelocatorSubid = TopSubTransactionId;
|
||||||
else
|
else
|
||||||
relation->rd_firstRelfilenodeSubid = InvalidSubTransactionId;
|
relation->rd_firstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1889,8 +1889,8 @@ formrdesc(const char *relationName, Oid relationReltype,
|
|||||||
*/
|
*/
|
||||||
relation->rd_isnailed = true;
|
relation->rd_isnailed = true;
|
||||||
relation->rd_createSubid = InvalidSubTransactionId;
|
relation->rd_createSubid = InvalidSubTransactionId;
|
||||||
relation->rd_newRelfilenodeSubid = InvalidSubTransactionId;
|
relation->rd_newRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
relation->rd_firstRelfilenodeSubid = InvalidSubTransactionId;
|
relation->rd_firstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
relation->rd_droppedSubid = InvalidSubTransactionId;
|
relation->rd_droppedSubid = InvalidSubTransactionId;
|
||||||
relation->rd_backend = InvalidBackendId;
|
relation->rd_backend = InvalidBackendId;
|
||||||
relation->rd_islocaltemp = false;
|
relation->rd_islocaltemp = false;
|
||||||
@ -1978,11 +1978,11 @@ formrdesc(const char *relationName, Oid relationReltype,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* All relations made with formrdesc are mapped. This is necessarily so
|
* All relations made with formrdesc are mapped. This is necessarily so
|
||||||
* because there is no other way to know what filenode they currently
|
* because there is no other way to know what filenumber they currently
|
||||||
* have. In bootstrap mode, add them to the initial relation mapper data,
|
* have. In bootstrap mode, add them to the initial relation mapper data,
|
||||||
* specifying that the initial filenode is the same as the OID.
|
* specifying that the initial filenumber is the same as the OID.
|
||||||
*/
|
*/
|
||||||
relation->rd_rel->relfilenode = InvalidOid;
|
relation->rd_rel->relfilenode = InvalidRelFileNumber;
|
||||||
if (IsBootstrapProcessingMode())
|
if (IsBootstrapProcessingMode())
|
||||||
RelationMapUpdateMap(RelationGetRelid(relation),
|
RelationMapUpdateMap(RelationGetRelid(relation),
|
||||||
RelationGetRelid(relation),
|
RelationGetRelid(relation),
|
||||||
@ -2180,7 +2180,7 @@ RelationClose(Relation relation)
|
|||||||
#ifdef RELCACHE_FORCE_RELEASE
|
#ifdef RELCACHE_FORCE_RELEASE
|
||||||
if (RelationHasReferenceCountZero(relation) &&
|
if (RelationHasReferenceCountZero(relation) &&
|
||||||
relation->rd_createSubid == InvalidSubTransactionId &&
|
relation->rd_createSubid == InvalidSubTransactionId &&
|
||||||
relation->rd_firstRelfilenodeSubid == InvalidSubTransactionId)
|
relation->rd_firstRelfilelocatorSubid == InvalidSubTransactionId)
|
||||||
RelationClearRelation(relation, false);
|
RelationClearRelation(relation, false);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -2352,7 +2352,7 @@ RelationReloadNailed(Relation relation)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If it's a nailed-but-not-mapped index, then we need to re-read the
|
* If it's a nailed-but-not-mapped index, then we need to re-read the
|
||||||
* pg_class row to see if its relfilenode changed.
|
* pg_class row to see if its relfilenumber changed.
|
||||||
*/
|
*/
|
||||||
RelationReloadIndexInfo(relation);
|
RelationReloadIndexInfo(relation);
|
||||||
}
|
}
|
||||||
@ -2700,8 +2700,8 @@ RelationClearRelation(Relation relation, bool rebuild)
|
|||||||
Assert(newrel->rd_isnailed == relation->rd_isnailed);
|
Assert(newrel->rd_isnailed == relation->rd_isnailed);
|
||||||
/* creation sub-XIDs must be preserved */
|
/* creation sub-XIDs must be preserved */
|
||||||
SWAPFIELD(SubTransactionId, rd_createSubid);
|
SWAPFIELD(SubTransactionId, rd_createSubid);
|
||||||
SWAPFIELD(SubTransactionId, rd_newRelfilenodeSubid);
|
SWAPFIELD(SubTransactionId, rd_newRelfilelocatorSubid);
|
||||||
SWAPFIELD(SubTransactionId, rd_firstRelfilenodeSubid);
|
SWAPFIELD(SubTransactionId, rd_firstRelfilelocatorSubid);
|
||||||
SWAPFIELD(SubTransactionId, rd_droppedSubid);
|
SWAPFIELD(SubTransactionId, rd_droppedSubid);
|
||||||
/* un-swap rd_rel pointers, swap contents instead */
|
/* un-swap rd_rel pointers, swap contents instead */
|
||||||
SWAPFIELD(Form_pg_class, rd_rel);
|
SWAPFIELD(Form_pg_class, rd_rel);
|
||||||
@ -2791,12 +2791,12 @@ static void
|
|||||||
RelationFlushRelation(Relation relation)
|
RelationFlushRelation(Relation relation)
|
||||||
{
|
{
|
||||||
if (relation->rd_createSubid != InvalidSubTransactionId ||
|
if (relation->rd_createSubid != InvalidSubTransactionId ||
|
||||||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId)
|
relation->rd_firstRelfilelocatorSubid != InvalidSubTransactionId)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* New relcache entries are always rebuilt, not flushed; else we'd
|
* New relcache entries are always rebuilt, not flushed; else we'd
|
||||||
* forget the "new" status of the relation. Ditto for the
|
* forget the "new" status of the relation. Ditto for the
|
||||||
* new-relfilenode status.
|
* new-relfilenumber status.
|
||||||
*
|
*
|
||||||
* The rel could have zero refcnt here, so temporarily increment the
|
* The rel could have zero refcnt here, so temporarily increment the
|
||||||
* refcnt to ensure it's safe to rebuild it. We can assume that the
|
* refcnt to ensure it's safe to rebuild it. We can assume that the
|
||||||
@ -2835,7 +2835,7 @@ RelationForgetRelation(Oid rid)
|
|||||||
|
|
||||||
Assert(relation->rd_droppedSubid == InvalidSubTransactionId);
|
Assert(relation->rd_droppedSubid == InvalidSubTransactionId);
|
||||||
if (relation->rd_createSubid != InvalidSubTransactionId ||
|
if (relation->rd_createSubid != InvalidSubTransactionId ||
|
||||||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId)
|
relation->rd_firstRelfilelocatorSubid != InvalidSubTransactionId)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* In the event of subtransaction rollback, we must not forget
|
* In the event of subtransaction rollback, we must not forget
|
||||||
@ -2894,7 +2894,7 @@ RelationCacheInvalidateEntry(Oid relationId)
|
|||||||
*
|
*
|
||||||
* Apart from debug_discard_caches, this is currently used only to recover
|
* Apart from debug_discard_caches, this is currently used only to recover
|
||||||
* from SI message buffer overflow, so we do not touch relations having
|
* from SI message buffer overflow, so we do not touch relations having
|
||||||
* new-in-transaction relfilenodes; they cannot be targets of cross-backend
|
* new-in-transaction relfilenumbers; they cannot be targets of cross-backend
|
||||||
* SI updates (and our own updates now go through a separate linked list
|
* SI updates (and our own updates now go through a separate linked list
|
||||||
* that isn't limited by the SI message buffer size).
|
* that isn't limited by the SI message buffer size).
|
||||||
*
|
*
|
||||||
@ -2909,7 +2909,7 @@ RelationCacheInvalidateEntry(Oid relationId)
|
|||||||
* so hash_seq_search will complete safely; (b) during the second pass we
|
* so hash_seq_search will complete safely; (b) during the second pass we
|
||||||
* only hold onto pointers to nondeletable entries.
|
* only hold onto pointers to nondeletable entries.
|
||||||
*
|
*
|
||||||
* The two-phase approach also makes it easy to update relfilenodes for
|
* The two-phase approach also makes it easy to update relfilenumbers for
|
||||||
* mapped relations before we do anything else, and to ensure that the
|
* mapped relations before we do anything else, and to ensure that the
|
||||||
* second pass processes nailed-in-cache items before other nondeletable
|
* second pass processes nailed-in-cache items before other nondeletable
|
||||||
* items. This should ensure that system catalogs are up to date before
|
* items. This should ensure that system catalogs are up to date before
|
||||||
@ -2948,12 +2948,12 @@ RelationCacheInvalidate(bool debug_discard)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Ignore new relations; no other backend will manipulate them before
|
* Ignore new relations; no other backend will manipulate them before
|
||||||
* we commit. Likewise, before replacing a relation's relfilenode, we
|
* we commit. Likewise, before replacing a relation's relfilelocator,
|
||||||
* shall have acquired AccessExclusiveLock and drained any applicable
|
* we shall have acquired AccessExclusiveLock and drained any
|
||||||
* pending invalidations.
|
* applicable pending invalidations.
|
||||||
*/
|
*/
|
||||||
if (relation->rd_createSubid != InvalidSubTransactionId ||
|
if (relation->rd_createSubid != InvalidSubTransactionId ||
|
||||||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId)
|
relation->rd_firstRelfilelocatorSubid != InvalidSubTransactionId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
relcacheInvalsReceived++;
|
relcacheInvalsReceived++;
|
||||||
@ -2967,8 +2967,8 @@ RelationCacheInvalidate(bool debug_discard)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If it's a mapped relation, immediately update its rd_node in
|
* If it's a mapped relation, immediately update its rd_locator in
|
||||||
* case its relfilenode changed. We must do this during phase 1
|
* case its relfilenumber changed. We must do this during phase 1
|
||||||
* in case the relation is consulted during rebuild of other
|
* in case the relation is consulted during rebuild of other
|
||||||
* relcache entries in phase 2. It's safe since consulting the
|
* relcache entries in phase 2. It's safe since consulting the
|
||||||
* map doesn't involve any access to relcache entries.
|
* map doesn't involve any access to relcache entries.
|
||||||
@ -3078,14 +3078,14 @@ AssertPendingSyncConsistency(Relation relation)
|
|||||||
RelationIsPermanent(relation) &&
|
RelationIsPermanent(relation) &&
|
||||||
((relation->rd_createSubid != InvalidSubTransactionId &&
|
((relation->rd_createSubid != InvalidSubTransactionId &&
|
||||||
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
|
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
|
||||||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
|
relation->rd_firstRelfilelocatorSubid != InvalidSubTransactionId);
|
||||||
|
|
||||||
Assert(relcache_verdict == RelFileNodeSkippingWAL(relation->rd_node));
|
Assert(relcache_verdict == RelFileLocatorSkippingWAL(relation->rd_locator));
|
||||||
|
|
||||||
if (relation->rd_droppedSubid != InvalidSubTransactionId)
|
if (relation->rd_droppedSubid != InvalidSubTransactionId)
|
||||||
Assert(!relation->rd_isvalid &&
|
Assert(!relation->rd_isvalid &&
|
||||||
(relation->rd_createSubid != InvalidSubTransactionId ||
|
(relation->rd_createSubid != InvalidSubTransactionId ||
|
||||||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId));
|
relation->rd_firstRelfilelocatorSubid != InvalidSubTransactionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3282,8 +3282,8 @@ AtEOXact_cleanup(Relation relation, bool isCommit)
|
|||||||
* also lets RelationClearRelation() drop the relcache entry.
|
* also lets RelationClearRelation() drop the relcache entry.
|
||||||
*/
|
*/
|
||||||
relation->rd_createSubid = InvalidSubTransactionId;
|
relation->rd_createSubid = InvalidSubTransactionId;
|
||||||
relation->rd_newRelfilenodeSubid = InvalidSubTransactionId;
|
relation->rd_newRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
relation->rd_firstRelfilenodeSubid = InvalidSubTransactionId;
|
relation->rd_firstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
relation->rd_droppedSubid = InvalidSubTransactionId;
|
relation->rd_droppedSubid = InvalidSubTransactionId;
|
||||||
|
|
||||||
if (clear_relcache)
|
if (clear_relcache)
|
||||||
@ -3397,8 +3397,8 @@ AtEOSubXact_cleanup(Relation relation, bool isCommit,
|
|||||||
{
|
{
|
||||||
/* allow the entry to be removed */
|
/* allow the entry to be removed */
|
||||||
relation->rd_createSubid = InvalidSubTransactionId;
|
relation->rd_createSubid = InvalidSubTransactionId;
|
||||||
relation->rd_newRelfilenodeSubid = InvalidSubTransactionId;
|
relation->rd_newRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
relation->rd_firstRelfilenodeSubid = InvalidSubTransactionId;
|
relation->rd_firstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
relation->rd_droppedSubid = InvalidSubTransactionId;
|
relation->rd_droppedSubid = InvalidSubTransactionId;
|
||||||
RelationClearRelation(relation, false);
|
RelationClearRelation(relation, false);
|
||||||
return;
|
return;
|
||||||
@ -3419,23 +3419,23 @@ AtEOSubXact_cleanup(Relation relation, bool isCommit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Likewise, update or drop any new-relfilenode-in-subtransaction record
|
* Likewise, update or drop any new-relfilenumber-in-subtransaction record
|
||||||
* or drop record.
|
* or drop record.
|
||||||
*/
|
*/
|
||||||
if (relation->rd_newRelfilenodeSubid == mySubid)
|
if (relation->rd_newRelfilelocatorSubid == mySubid)
|
||||||
{
|
{
|
||||||
if (isCommit)
|
if (isCommit)
|
||||||
relation->rd_newRelfilenodeSubid = parentSubid;
|
relation->rd_newRelfilelocatorSubid = parentSubid;
|
||||||
else
|
else
|
||||||
relation->rd_newRelfilenodeSubid = InvalidSubTransactionId;
|
relation->rd_newRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relation->rd_firstRelfilenodeSubid == mySubid)
|
if (relation->rd_firstRelfilelocatorSubid == mySubid)
|
||||||
{
|
{
|
||||||
if (isCommit)
|
if (isCommit)
|
||||||
relation->rd_firstRelfilenodeSubid = parentSubid;
|
relation->rd_firstRelfilelocatorSubid = parentSubid;
|
||||||
else
|
else
|
||||||
relation->rd_firstRelfilenodeSubid = InvalidSubTransactionId;
|
relation->rd_firstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relation->rd_droppedSubid == mySubid)
|
if (relation->rd_droppedSubid == mySubid)
|
||||||
@ -3459,7 +3459,7 @@ RelationBuildLocalRelation(const char *relname,
|
|||||||
TupleDesc tupDesc,
|
TupleDesc tupDesc,
|
||||||
Oid relid,
|
Oid relid,
|
||||||
Oid accessmtd,
|
Oid accessmtd,
|
||||||
Oid relfilenode,
|
RelFileNumber relfilenumber,
|
||||||
Oid reltablespace,
|
Oid reltablespace,
|
||||||
bool shared_relation,
|
bool shared_relation,
|
||||||
bool mapped_relation,
|
bool mapped_relation,
|
||||||
@ -3533,8 +3533,8 @@ RelationBuildLocalRelation(const char *relname,
|
|||||||
|
|
||||||
/* it's being created in this transaction */
|
/* it's being created in this transaction */
|
||||||
rel->rd_createSubid = GetCurrentSubTransactionId();
|
rel->rd_createSubid = GetCurrentSubTransactionId();
|
||||||
rel->rd_newRelfilenodeSubid = InvalidSubTransactionId;
|
rel->rd_newRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
rel->rd_firstRelfilenodeSubid = InvalidSubTransactionId;
|
rel->rd_firstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
rel->rd_droppedSubid = InvalidSubTransactionId;
|
rel->rd_droppedSubid = InvalidSubTransactionId;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3616,8 +3616,8 @@ RelationBuildLocalRelation(const char *relname,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert relation physical and logical identifiers (OIDs) into the right
|
* Insert relation physical and logical identifiers (OIDs) into the right
|
||||||
* places. For a mapped relation, we set relfilenode to zero and rely on
|
* places. For a mapped relation, we set relfilenumber to zero and rely
|
||||||
* RelationInitPhysicalAddr to consult the map.
|
* on RelationInitPhysicalAddr to consult the map.
|
||||||
*/
|
*/
|
||||||
rel->rd_rel->relisshared = shared_relation;
|
rel->rd_rel->relisshared = shared_relation;
|
||||||
|
|
||||||
@ -3630,12 +3630,12 @@ RelationBuildLocalRelation(const char *relname,
|
|||||||
|
|
||||||
if (mapped_relation)
|
if (mapped_relation)
|
||||||
{
|
{
|
||||||
rel->rd_rel->relfilenode = InvalidOid;
|
rel->rd_rel->relfilenode = InvalidRelFileNumber;
|
||||||
/* Add it to the active mapping information */
|
/* Add it to the active mapping information */
|
||||||
RelationMapUpdateMap(relid, relfilenode, shared_relation, true);
|
RelationMapUpdateMap(relid, relfilenumber, shared_relation, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rel->rd_rel->relfilenode = relfilenode;
|
rel->rd_rel->relfilenode = relfilenumber;
|
||||||
|
|
||||||
RelationInitLockInfo(rel); /* see lmgr.c */
|
RelationInitLockInfo(rel); /* see lmgr.c */
|
||||||
|
|
||||||
@ -3683,13 +3683,13 @@ RelationBuildLocalRelation(const char *relname,
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RelationSetNewRelfilenode
|
* RelationSetNewRelfilenumber
|
||||||
*
|
*
|
||||||
* Assign a new relfilenode (physical file name), and possibly a new
|
* Assign a new relfilenumber (physical file name), and possibly a new
|
||||||
* persistence setting, to the relation.
|
* persistence setting, to the relation.
|
||||||
*
|
*
|
||||||
* This allows a full rewrite of the relation to be done with transactional
|
* This allows a full rewrite of the relation to be done with transactional
|
||||||
* safety (since the filenode assignment can be rolled back). Note however
|
* safety (since the filenumber assignment can be rolled back). Note however
|
||||||
* that there is no simple way to access the relation's old data for the
|
* that there is no simple way to access the relation's old data for the
|
||||||
* remainder of the current transaction. This limits the usefulness to cases
|
* remainder of the current transaction. This limits the usefulness to cases
|
||||||
* such as TRUNCATE or rebuilding an index from scratch.
|
* such as TRUNCATE or rebuilding an index from scratch.
|
||||||
@ -3697,19 +3697,19 @@ RelationBuildLocalRelation(const char *relname,
|
|||||||
* Caller must already hold exclusive lock on the relation.
|
* Caller must already hold exclusive lock on the relation.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
RelationSetNewRelfilenode(Relation relation, char persistence)
|
RelationSetNewRelfilenumber(Relation relation, char persistence)
|
||||||
{
|
{
|
||||||
Oid newrelfilenode;
|
RelFileNumber newrelfilenumber;
|
||||||
Relation pg_class;
|
Relation pg_class;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Form_pg_class classform;
|
Form_pg_class classform;
|
||||||
MultiXactId minmulti = InvalidMultiXactId;
|
MultiXactId minmulti = InvalidMultiXactId;
|
||||||
TransactionId freezeXid = InvalidTransactionId;
|
TransactionId freezeXid = InvalidTransactionId;
|
||||||
RelFileNode newrnode;
|
RelFileLocator newrlocator;
|
||||||
|
|
||||||
/* Allocate a new relfilenode */
|
/* Allocate a new relfilenumber */
|
||||||
newrelfilenode = GetNewRelFileNode(relation->rd_rel->reltablespace, NULL,
|
newrelfilenumber = GetNewRelFileNumber(relation->rd_rel->reltablespace,
|
||||||
persistence);
|
NULL, persistence);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get a writable copy of the pg_class tuple for the given relation.
|
* Get a writable copy of the pg_class tuple for the given relation.
|
||||||
@ -3729,19 +3729,19 @@ RelationSetNewRelfilenode(Relation relation, char persistence)
|
|||||||
RelationDropStorage(relation);
|
RelationDropStorage(relation);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create storage for the main fork of the new relfilenode. If it's a
|
* Create storage for the main fork of the new relfilenumber. If it's a
|
||||||
* table-like object, call into the table AM to do so, which'll also
|
* table-like object, call into the table AM to do so, which'll also
|
||||||
* create the table's init fork if needed.
|
* create the table's init fork if needed.
|
||||||
*
|
*
|
||||||
* NOTE: If relevant for the AM, any conflict in relfilenode value will be
|
* NOTE: If relevant for the AM, any conflict in relfilenumber value will
|
||||||
* caught here, if GetNewRelFileNode messes up for any reason.
|
* be caught here, if GetNewRelFileNumber messes up for any reason.
|
||||||
*/
|
*/
|
||||||
newrnode = relation->rd_node;
|
newrlocator = relation->rd_locator;
|
||||||
newrnode.relNode = newrelfilenode;
|
newrlocator.relNumber = newrelfilenumber;
|
||||||
|
|
||||||
if (RELKIND_HAS_TABLE_AM(relation->rd_rel->relkind))
|
if (RELKIND_HAS_TABLE_AM(relation->rd_rel->relkind))
|
||||||
{
|
{
|
||||||
table_relation_set_new_filenode(relation, &newrnode,
|
table_relation_set_new_filelocator(relation, &newrlocator,
|
||||||
persistence,
|
persistence,
|
||||||
&freezeXid, &minmulti);
|
&freezeXid, &minmulti);
|
||||||
}
|
}
|
||||||
@ -3750,7 +3750,7 @@ RelationSetNewRelfilenode(Relation relation, char persistence)
|
|||||||
/* handle these directly, at least for now */
|
/* handle these directly, at least for now */
|
||||||
SMgrRelation srel;
|
SMgrRelation srel;
|
||||||
|
|
||||||
srel = RelationCreateStorage(newrnode, persistence, true);
|
srel = RelationCreateStorage(newrlocator, persistence, true);
|
||||||
smgrclose(srel);
|
smgrclose(srel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3789,7 +3789,7 @@ RelationSetNewRelfilenode(Relation relation, char persistence)
|
|||||||
|
|
||||||
/* Do the deed */
|
/* Do the deed */
|
||||||
RelationMapUpdateMap(RelationGetRelid(relation),
|
RelationMapUpdateMap(RelationGetRelid(relation),
|
||||||
newrelfilenode,
|
newrelfilenumber,
|
||||||
relation->rd_rel->relisshared,
|
relation->rd_rel->relisshared,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
@ -3799,7 +3799,7 @@ RelationSetNewRelfilenode(Relation relation, char persistence)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Normal case, update the pg_class entry */
|
/* Normal case, update the pg_class entry */
|
||||||
classform->relfilenode = newrelfilenode;
|
classform->relfilenode = newrelfilenumber;
|
||||||
|
|
||||||
/* relpages etc. never change for sequences */
|
/* relpages etc. never change for sequences */
|
||||||
if (relation->rd_rel->relkind != RELKIND_SEQUENCE)
|
if (relation->rd_rel->relkind != RELKIND_SEQUENCE)
|
||||||
@ -3825,27 +3825,27 @@ RelationSetNewRelfilenode(Relation relation, char persistence)
|
|||||||
*/
|
*/
|
||||||
CommandCounterIncrement();
|
CommandCounterIncrement();
|
||||||
|
|
||||||
RelationAssumeNewRelfilenode(relation);
|
RelationAssumeNewRelfilelocator(relation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RelationAssumeNewRelfilenode
|
* RelationAssumeNewRelfilelocator
|
||||||
*
|
*
|
||||||
* Code that modifies pg_class.reltablespace or pg_class.relfilenode must call
|
* Code that modifies pg_class.reltablespace or pg_class.relfilenode must call
|
||||||
* this. The call shall precede any code that might insert WAL records whose
|
* this. The call shall precede any code that might insert WAL records whose
|
||||||
* replay would modify bytes in the new RelFileNode, and the call shall follow
|
* replay would modify bytes in the new RelFileLocator, and the call shall follow
|
||||||
* any WAL modifying bytes in the prior RelFileNode. See struct RelationData.
|
* any WAL modifying bytes in the prior RelFileLocator. See struct RelationData.
|
||||||
* Ideally, call this as near as possible to the CommandCounterIncrement()
|
* Ideally, call this as near as possible to the CommandCounterIncrement()
|
||||||
* that makes the pg_class change visible (before it or after it); that
|
* that makes the pg_class change visible (before it or after it); that
|
||||||
* minimizes the chance of future development adding a forbidden WAL insertion
|
* minimizes the chance of future development adding a forbidden WAL insertion
|
||||||
* between RelationAssumeNewRelfilenode() and CommandCounterIncrement().
|
* between RelationAssumeNewRelfilelocator() and CommandCounterIncrement().
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
RelationAssumeNewRelfilenode(Relation relation)
|
RelationAssumeNewRelfilelocator(Relation relation)
|
||||||
{
|
{
|
||||||
relation->rd_newRelfilenodeSubid = GetCurrentSubTransactionId();
|
relation->rd_newRelfilelocatorSubid = GetCurrentSubTransactionId();
|
||||||
if (relation->rd_firstRelfilenodeSubid == InvalidSubTransactionId)
|
if (relation->rd_firstRelfilelocatorSubid == InvalidSubTransactionId)
|
||||||
relation->rd_firstRelfilenodeSubid = relation->rd_newRelfilenodeSubid;
|
relation->rd_firstRelfilelocatorSubid = relation->rd_newRelfilelocatorSubid;
|
||||||
|
|
||||||
/* Flag relation as needing eoxact cleanup (to clear these fields) */
|
/* Flag relation as needing eoxact cleanup (to clear these fields) */
|
||||||
EOXactListAdd(relation);
|
EOXactListAdd(relation);
|
||||||
@ -6254,8 +6254,8 @@ load_relcache_init_file(bool shared)
|
|||||||
rel->rd_fkeyvalid = false;
|
rel->rd_fkeyvalid = false;
|
||||||
rel->rd_fkeylist = NIL;
|
rel->rd_fkeylist = NIL;
|
||||||
rel->rd_createSubid = InvalidSubTransactionId;
|
rel->rd_createSubid = InvalidSubTransactionId;
|
||||||
rel->rd_newRelfilenodeSubid = InvalidSubTransactionId;
|
rel->rd_newRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
rel->rd_firstRelfilenodeSubid = InvalidSubTransactionId;
|
rel->rd_firstRelfilelocatorSubid = InvalidSubTransactionId;
|
||||||
rel->rd_droppedSubid = InvalidSubTransactionId;
|
rel->rd_droppedSubid = InvalidSubTransactionId;
|
||||||
rel->rd_amcache = NULL;
|
rel->rd_amcache = NULL;
|
||||||
rel->pgstat_info = NULL;
|
rel->pgstat_info = NULL;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* relfilenodemap.c
|
* relfilenumbermap.c
|
||||||
* relfilenode to oid mapping cache.
|
* relfilenumber to oid mapping cache.
|
||||||
*
|
*
|
||||||
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* src/backend/utils/cache/relfilenodemap.c
|
* src/backend/utils/cache/relfilenumbermap.c
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -25,42 +25,42 @@
|
|||||||
#include "utils/hsearch.h"
|
#include "utils/hsearch.h"
|
||||||
#include "utils/inval.h"
|
#include "utils/inval.h"
|
||||||
#include "utils/rel.h"
|
#include "utils/rel.h"
|
||||||
#include "utils/relfilenodemap.h"
|
#include "utils/relfilenumbermap.h"
|
||||||
#include "utils/relmapper.h"
|
#include "utils/relmapper.h"
|
||||||
|
|
||||||
/* Hash table for information about each relfilenode <-> oid pair */
|
/* Hash table for information about each relfilenumber <-> oid pair */
|
||||||
static HTAB *RelfilenodeMapHash = NULL;
|
static HTAB *RelfilenumberMapHash = NULL;
|
||||||
|
|
||||||
/* built first time through in InitializeRelfilenodeMap */
|
/* built first time through in InitializeRelfilenumberMap */
|
||||||
static ScanKeyData relfilenode_skey[2];
|
static ScanKeyData relfilenumber_skey[2];
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Oid reltablespace;
|
Oid reltablespace;
|
||||||
Oid relfilenode;
|
RelFileNumber relfilenumber;
|
||||||
} RelfilenodeMapKey;
|
} RelfilenumberMapKey;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
RelfilenodeMapKey key; /* lookup key - must be first */
|
RelfilenumberMapKey key; /* lookup key - must be first */
|
||||||
Oid relid; /* pg_class.oid */
|
Oid relid; /* pg_class.oid */
|
||||||
} RelfilenodeMapEntry;
|
} RelfilenumberMapEntry;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RelfilenodeMapInvalidateCallback
|
* RelfilenumberMapInvalidateCallback
|
||||||
* Flush mapping entries when pg_class is updated in a relevant fashion.
|
* Flush mapping entries when pg_class is updated in a relevant fashion.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
RelfilenodeMapInvalidateCallback(Datum arg, Oid relid)
|
RelfilenumberMapInvalidateCallback(Datum arg, Oid relid)
|
||||||
{
|
{
|
||||||
HASH_SEQ_STATUS status;
|
HASH_SEQ_STATUS status;
|
||||||
RelfilenodeMapEntry *entry;
|
RelfilenumberMapEntry *entry;
|
||||||
|
|
||||||
/* callback only gets registered after creating the hash */
|
/* callback only gets registered after creating the hash */
|
||||||
Assert(RelfilenodeMapHash != NULL);
|
Assert(RelfilenumberMapHash != NULL);
|
||||||
|
|
||||||
hash_seq_init(&status, RelfilenodeMapHash);
|
hash_seq_init(&status, RelfilenumberMapHash);
|
||||||
while ((entry = (RelfilenodeMapEntry *) hash_seq_search(&status)) != NULL)
|
while ((entry = (RelfilenumberMapEntry *) hash_seq_search(&status)) != NULL)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If relid is InvalidOid, signaling a complete reset, we must remove
|
* If relid is InvalidOid, signaling a complete reset, we must remove
|
||||||
@ -71,7 +71,7 @@ RelfilenodeMapInvalidateCallback(Datum arg, Oid relid)
|
|||||||
entry->relid == InvalidOid || /* negative cache entry */
|
entry->relid == InvalidOid || /* negative cache entry */
|
||||||
entry->relid == relid) /* individual flushed relation */
|
entry->relid == relid) /* individual flushed relation */
|
||||||
{
|
{
|
||||||
if (hash_search(RelfilenodeMapHash,
|
if (hash_search(RelfilenumberMapHash,
|
||||||
(void *) &entry->key,
|
(void *) &entry->key,
|
||||||
HASH_REMOVE,
|
HASH_REMOVE,
|
||||||
NULL) == NULL)
|
NULL) == NULL)
|
||||||
@ -81,11 +81,11 @@ RelfilenodeMapInvalidateCallback(Datum arg, Oid relid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* InitializeRelfilenodeMap
|
* InitializeRelfilenumberMap
|
||||||
* Initialize cache, either on first use or after a reset.
|
* Initialize cache, either on first use or after a reset.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
InitializeRelfilenodeMap(void)
|
InitializeRelfilenumberMap(void)
|
||||||
{
|
{
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
int i;
|
int i;
|
||||||
@ -95,50 +95,50 @@ InitializeRelfilenodeMap(void)
|
|||||||
CreateCacheMemoryContext();
|
CreateCacheMemoryContext();
|
||||||
|
|
||||||
/* build skey */
|
/* build skey */
|
||||||
MemSet(&relfilenode_skey, 0, sizeof(relfilenode_skey));
|
MemSet(&relfilenumber_skey, 0, sizeof(relfilenumber_skey));
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
fmgr_info_cxt(F_OIDEQ,
|
fmgr_info_cxt(F_OIDEQ,
|
||||||
&relfilenode_skey[i].sk_func,
|
&relfilenumber_skey[i].sk_func,
|
||||||
CacheMemoryContext);
|
CacheMemoryContext);
|
||||||
relfilenode_skey[i].sk_strategy = BTEqualStrategyNumber;
|
relfilenumber_skey[i].sk_strategy = BTEqualStrategyNumber;
|
||||||
relfilenode_skey[i].sk_subtype = InvalidOid;
|
relfilenumber_skey[i].sk_subtype = InvalidOid;
|
||||||
relfilenode_skey[i].sk_collation = InvalidOid;
|
relfilenumber_skey[i].sk_collation = InvalidOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
relfilenode_skey[0].sk_attno = Anum_pg_class_reltablespace;
|
relfilenumber_skey[0].sk_attno = Anum_pg_class_reltablespace;
|
||||||
relfilenode_skey[1].sk_attno = Anum_pg_class_relfilenode;
|
relfilenumber_skey[1].sk_attno = Anum_pg_class_relfilenode;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only create the RelfilenodeMapHash now, so we don't end up partially
|
* Only create the RelfilenumberMapHash now, so we don't end up partially
|
||||||
* initialized when fmgr_info_cxt() above ERRORs out with an out of memory
|
* initialized when fmgr_info_cxt() above ERRORs out with an out of memory
|
||||||
* error.
|
* error.
|
||||||
*/
|
*/
|
||||||
ctl.keysize = sizeof(RelfilenodeMapKey);
|
ctl.keysize = sizeof(RelfilenumberMapKey);
|
||||||
ctl.entrysize = sizeof(RelfilenodeMapEntry);
|
ctl.entrysize = sizeof(RelfilenumberMapEntry);
|
||||||
ctl.hcxt = CacheMemoryContext;
|
ctl.hcxt = CacheMemoryContext;
|
||||||
|
|
||||||
RelfilenodeMapHash =
|
RelfilenumberMapHash =
|
||||||
hash_create("RelfilenodeMap cache", 64, &ctl,
|
hash_create("RelfilenumberMap cache", 64, &ctl,
|
||||||
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
|
HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
|
||||||
|
|
||||||
/* Watch for invalidation events. */
|
/* Watch for invalidation events. */
|
||||||
CacheRegisterRelcacheCallback(RelfilenodeMapInvalidateCallback,
|
CacheRegisterRelcacheCallback(RelfilenumberMapInvalidateCallback,
|
||||||
(Datum) 0);
|
(Datum) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map a relation's (tablespace, filenode) to a relation's oid and cache the
|
* Map a relation's (tablespace, relfilenumber) to a relation's oid and cache
|
||||||
* result.
|
* the result.
|
||||||
*
|
*
|
||||||
* Returns InvalidOid if no relation matching the criteria could be found.
|
* Returns InvalidOid if no relation matching the criteria could be found.
|
||||||
*/
|
*/
|
||||||
Oid
|
Oid
|
||||||
RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
|
RelidByRelfilenumber(Oid reltablespace, RelFileNumber relfilenumber)
|
||||||
{
|
{
|
||||||
RelfilenodeMapKey key;
|
RelfilenumberMapKey key;
|
||||||
RelfilenodeMapEntry *entry;
|
RelfilenumberMapEntry *entry;
|
||||||
bool found;
|
bool found;
|
||||||
SysScanDesc scandesc;
|
SysScanDesc scandesc;
|
||||||
Relation relation;
|
Relation relation;
|
||||||
@ -146,8 +146,8 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
|
|||||||
ScanKeyData skey[2];
|
ScanKeyData skey[2];
|
||||||
Oid relid;
|
Oid relid;
|
||||||
|
|
||||||
if (RelfilenodeMapHash == NULL)
|
if (RelfilenumberMapHash == NULL)
|
||||||
InitializeRelfilenodeMap();
|
InitializeRelfilenumberMap();
|
||||||
|
|
||||||
/* pg_class will show 0 when the value is actually MyDatabaseTableSpace */
|
/* pg_class will show 0 when the value is actually MyDatabaseTableSpace */
|
||||||
if (reltablespace == MyDatabaseTableSpace)
|
if (reltablespace == MyDatabaseTableSpace)
|
||||||
@ -155,7 +155,7 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
|
|||||||
|
|
||||||
MemSet(&key, 0, sizeof(key));
|
MemSet(&key, 0, sizeof(key));
|
||||||
key.reltablespace = reltablespace;
|
key.reltablespace = reltablespace;
|
||||||
key.relfilenode = relfilenode;
|
key.relfilenumber = relfilenumber;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check cache and return entry if one is found. Even if no target
|
* Check cache and return entry if one is found. Even if no target
|
||||||
@ -164,7 +164,7 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
|
|||||||
* since querying invalid values isn't supposed to be a frequent thing,
|
* since querying invalid values isn't supposed to be a frequent thing,
|
||||||
* but it's basically free.
|
* but it's basically free.
|
||||||
*/
|
*/
|
||||||
entry = hash_search(RelfilenodeMapHash, (void *) &key, HASH_FIND, &found);
|
entry = hash_search(RelfilenumberMapHash, (void *) &key, HASH_FIND, &found);
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
return entry->relid;
|
return entry->relid;
|
||||||
@ -179,7 +179,7 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
|
|||||||
/*
|
/*
|
||||||
* Ok, shared table, check relmapper.
|
* Ok, shared table, check relmapper.
|
||||||
*/
|
*/
|
||||||
relid = RelationMapFilenodeToOid(relfilenode, true);
|
relid = RelationMapFilenumberToOid(relfilenumber, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -192,11 +192,11 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
|
|||||||
relation = table_open(RelationRelationId, AccessShareLock);
|
relation = table_open(RelationRelationId, AccessShareLock);
|
||||||
|
|
||||||
/* copy scankey to local copy, it will be modified during the scan */
|
/* copy scankey to local copy, it will be modified during the scan */
|
||||||
memcpy(skey, relfilenode_skey, sizeof(skey));
|
memcpy(skey, relfilenumber_skey, sizeof(skey));
|
||||||
|
|
||||||
/* set scan arguments */
|
/* set scan arguments */
|
||||||
skey[0].sk_argument = ObjectIdGetDatum(reltablespace);
|
skey[0].sk_argument = ObjectIdGetDatum(reltablespace);
|
||||||
skey[1].sk_argument = ObjectIdGetDatum(relfilenode);
|
skey[1].sk_argument = ObjectIdGetDatum(relfilenumber);
|
||||||
|
|
||||||
scandesc = systable_beginscan(relation,
|
scandesc = systable_beginscan(relation,
|
||||||
ClassTblspcRelfilenodeIndexId,
|
ClassTblspcRelfilenodeIndexId,
|
||||||
@ -213,12 +213,12 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
|
|||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
elog(ERROR,
|
elog(ERROR,
|
||||||
"unexpected duplicate for tablespace %u, relfilenode %u",
|
"unexpected duplicate for tablespace %u, relfilenumber %u",
|
||||||
reltablespace, relfilenode);
|
reltablespace, relfilenumber);
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
Assert(classform->reltablespace == reltablespace);
|
Assert(classform->reltablespace == reltablespace);
|
||||||
Assert(classform->relfilenode == relfilenode);
|
Assert(classform->relfilenode == relfilenumber);
|
||||||
relid = classform->oid;
|
relid = classform->oid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
|
|||||||
|
|
||||||
/* check for tables that are mapped but not shared */
|
/* check for tables that are mapped but not shared */
|
||||||
if (!found)
|
if (!found)
|
||||||
relid = RelationMapFilenodeToOid(relfilenode, false);
|
relid = RelationMapFilenumberToOid(relfilenumber, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -235,7 +235,7 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
|
|||||||
* caused cache invalidations to be executed which would have deleted a
|
* caused cache invalidations to be executed which would have deleted a
|
||||||
* new entry if we had entered it above.
|
* new entry if we had entered it above.
|
||||||
*/
|
*/
|
||||||
entry = hash_search(RelfilenodeMapHash, (void *) &key, HASH_ENTER, &found);
|
entry = hash_search(RelfilenumberMapHash, (void *) &key, HASH_ENTER, &found);
|
||||||
if (found)
|
if (found)
|
||||||
elog(ERROR, "corrupted hashtable");
|
elog(ERROR, "corrupted hashtable");
|
||||||
entry->relid = relid;
|
entry->relid = relid;
|
88
src/backend/utils/cache/relmapper.c
vendored
88
src/backend/utils/cache/relmapper.c
vendored
@ -1,7 +1,7 @@
|
|||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* relmapper.c
|
* relmapper.c
|
||||||
* Catalog-to-filenode mapping
|
* Catalog-to-filenumber mapping
|
||||||
*
|
*
|
||||||
* For most tables, the physical file underlying the table is specified by
|
* For most tables, the physical file underlying the table is specified by
|
||||||
* pg_class.relfilenode. However, that obviously won't work for pg_class
|
* pg_class.relfilenode. However, that obviously won't work for pg_class
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* update other databases' pg_class entries when relocating a shared catalog.
|
* update other databases' pg_class entries when relocating a shared catalog.
|
||||||
* Therefore, for these special catalogs (henceforth referred to as "mapped
|
* Therefore, for these special catalogs (henceforth referred to as "mapped
|
||||||
* catalogs") we rely on a separately maintained file that shows the mapping
|
* catalogs") we rely on a separately maintained file that shows the mapping
|
||||||
* from catalog OIDs to filenode numbers. Each database has a map file for
|
* from catalog OIDs to filenumbers. Each database has a map file for
|
||||||
* its local mapped catalogs, and there is a separate map file for shared
|
* its local mapped catalogs, and there is a separate map file for shared
|
||||||
* catalogs. Mapped catalogs have zero in their pg_class.relfilenode entries.
|
* catalogs. Mapped catalogs have zero in their pg_class.relfilenode entries.
|
||||||
*
|
*
|
||||||
@ -79,7 +79,7 @@
|
|||||||
typedef struct RelMapping
|
typedef struct RelMapping
|
||||||
{
|
{
|
||||||
Oid mapoid; /* OID of a catalog */
|
Oid mapoid; /* OID of a catalog */
|
||||||
Oid mapfilenode; /* its filenode number */
|
RelFileNumber mapfilenumber; /* its rel file number */
|
||||||
} RelMapping;
|
} RelMapping;
|
||||||
|
|
||||||
typedef struct RelMapFile
|
typedef struct RelMapFile
|
||||||
@ -116,7 +116,7 @@ static RelMapFile local_map;
|
|||||||
* subtransactions, so one set of transaction-level changes is sufficient.
|
* subtransactions, so one set of transaction-level changes is sufficient.
|
||||||
*
|
*
|
||||||
* The active_xxx variables contain updates that are valid in our transaction
|
* The active_xxx variables contain updates that are valid in our transaction
|
||||||
* and should be honored by RelationMapOidToFilenode. The pending_xxx
|
* and should be honored by RelationMapOidToFilenumber. The pending_xxx
|
||||||
* variables contain updates we have been told about that aren't active yet;
|
* variables contain updates we have been told about that aren't active yet;
|
||||||
* they will become active at the next CommandCounterIncrement. This setup
|
* they will become active at the next CommandCounterIncrement. This setup
|
||||||
* lets map updates act similarly to updates of pg_class rows, ie, they
|
* lets map updates act similarly to updates of pg_class rows, ie, they
|
||||||
@ -132,8 +132,8 @@ static RelMapFile pending_local_updates;
|
|||||||
|
|
||||||
|
|
||||||
/* non-export function prototypes */
|
/* non-export function prototypes */
|
||||||
static void apply_map_update(RelMapFile *map, Oid relationId, Oid fileNode,
|
static void apply_map_update(RelMapFile *map, Oid relationId,
|
||||||
bool add_okay);
|
RelFileNumber filenumber, bool add_okay);
|
||||||
static void merge_map_updates(RelMapFile *map, const RelMapFile *updates,
|
static void merge_map_updates(RelMapFile *map, const RelMapFile *updates,
|
||||||
bool add_okay);
|
bool add_okay);
|
||||||
static void load_relmap_file(bool shared, bool lock_held);
|
static void load_relmap_file(bool shared, bool lock_held);
|
||||||
@ -146,19 +146,20 @@ static void perform_relmap_update(bool shared, const RelMapFile *updates);
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RelationMapOidToFilenode
|
* RelationMapOidToFilenumber
|
||||||
*
|
*
|
||||||
* The raison d' etre ... given a relation OID, look up its filenode.
|
* The raison d' etre ... given a relation OID, look up its filenumber.
|
||||||
*
|
*
|
||||||
* Although shared and local relation OIDs should never overlap, the caller
|
* Although shared and local relation OIDs should never overlap, the caller
|
||||||
* always knows which we need --- so pass that information to avoid useless
|
* always knows which we need --- so pass that information to avoid useless
|
||||||
* searching.
|
* searching.
|
||||||
*
|
*
|
||||||
* Returns InvalidOid if the OID is not known (which should never happen,
|
* Returns InvalidRelFileNumber if the OID is not known (which should never
|
||||||
* but the caller is in a better position to report a meaningful error).
|
* happen, but the caller is in a better position to report a meaningful
|
||||||
|
* error).
|
||||||
*/
|
*/
|
||||||
Oid
|
RelFileNumber
|
||||||
RelationMapOidToFilenode(Oid relationId, bool shared)
|
RelationMapOidToFilenumber(Oid relationId, bool shared)
|
||||||
{
|
{
|
||||||
const RelMapFile *map;
|
const RelMapFile *map;
|
||||||
int32 i;
|
int32 i;
|
||||||
@ -170,13 +171,13 @@ RelationMapOidToFilenode(Oid relationId, bool shared)
|
|||||||
for (i = 0; i < map->num_mappings; i++)
|
for (i = 0; i < map->num_mappings; i++)
|
||||||
{
|
{
|
||||||
if (relationId == map->mappings[i].mapoid)
|
if (relationId == map->mappings[i].mapoid)
|
||||||
return map->mappings[i].mapfilenode;
|
return map->mappings[i].mapfilenumber;
|
||||||
}
|
}
|
||||||
map = &shared_map;
|
map = &shared_map;
|
||||||
for (i = 0; i < map->num_mappings; i++)
|
for (i = 0; i < map->num_mappings; i++)
|
||||||
{
|
{
|
||||||
if (relationId == map->mappings[i].mapoid)
|
if (relationId == map->mappings[i].mapoid)
|
||||||
return map->mappings[i].mapfilenode;
|
return map->mappings[i].mapfilenumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -185,33 +186,33 @@ RelationMapOidToFilenode(Oid relationId, bool shared)
|
|||||||
for (i = 0; i < map->num_mappings; i++)
|
for (i = 0; i < map->num_mappings; i++)
|
||||||
{
|
{
|
||||||
if (relationId == map->mappings[i].mapoid)
|
if (relationId == map->mappings[i].mapoid)
|
||||||
return map->mappings[i].mapfilenode;
|
return map->mappings[i].mapfilenumber;
|
||||||
}
|
}
|
||||||
map = &local_map;
|
map = &local_map;
|
||||||
for (i = 0; i < map->num_mappings; i++)
|
for (i = 0; i < map->num_mappings; i++)
|
||||||
{
|
{
|
||||||
if (relationId == map->mappings[i].mapoid)
|
if (relationId == map->mappings[i].mapoid)
|
||||||
return map->mappings[i].mapfilenode;
|
return map->mappings[i].mapfilenumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return InvalidOid;
|
return InvalidRelFileNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RelationMapFilenodeToOid
|
* RelationMapFilenumberToOid
|
||||||
*
|
*
|
||||||
* Do the reverse of the normal direction of mapping done in
|
* Do the reverse of the normal direction of mapping done in
|
||||||
* RelationMapOidToFilenode.
|
* RelationMapOidToFilenumber.
|
||||||
*
|
*
|
||||||
* This is not supposed to be used during normal running but rather for
|
* This is not supposed to be used during normal running but rather for
|
||||||
* information purposes when looking at the filesystem or xlog.
|
* information purposes when looking at the filesystem or xlog.
|
||||||
*
|
*
|
||||||
* Returns InvalidOid if the OID is not known; this can easily happen if the
|
* Returns InvalidOid if the OID is not known; this can easily happen if the
|
||||||
* relfilenode doesn't pertain to a mapped relation.
|
* relfilenumber doesn't pertain to a mapped relation.
|
||||||
*/
|
*/
|
||||||
Oid
|
Oid
|
||||||
RelationMapFilenodeToOid(Oid filenode, bool shared)
|
RelationMapFilenumberToOid(RelFileNumber filenumber, bool shared)
|
||||||
{
|
{
|
||||||
const RelMapFile *map;
|
const RelMapFile *map;
|
||||||
int32 i;
|
int32 i;
|
||||||
@ -222,13 +223,13 @@ RelationMapFilenodeToOid(Oid filenode, bool shared)
|
|||||||
map = &active_shared_updates;
|
map = &active_shared_updates;
|
||||||
for (i = 0; i < map->num_mappings; i++)
|
for (i = 0; i < map->num_mappings; i++)
|
||||||
{
|
{
|
||||||
if (filenode == map->mappings[i].mapfilenode)
|
if (filenumber == map->mappings[i].mapfilenumber)
|
||||||
return map->mappings[i].mapoid;
|
return map->mappings[i].mapoid;
|
||||||
}
|
}
|
||||||
map = &shared_map;
|
map = &shared_map;
|
||||||
for (i = 0; i < map->num_mappings; i++)
|
for (i = 0; i < map->num_mappings; i++)
|
||||||
{
|
{
|
||||||
if (filenode == map->mappings[i].mapfilenode)
|
if (filenumber == map->mappings[i].mapfilenumber)
|
||||||
return map->mappings[i].mapoid;
|
return map->mappings[i].mapoid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,13 +238,13 @@ RelationMapFilenodeToOid(Oid filenode, bool shared)
|
|||||||
map = &active_local_updates;
|
map = &active_local_updates;
|
||||||
for (i = 0; i < map->num_mappings; i++)
|
for (i = 0; i < map->num_mappings; i++)
|
||||||
{
|
{
|
||||||
if (filenode == map->mappings[i].mapfilenode)
|
if (filenumber == map->mappings[i].mapfilenumber)
|
||||||
return map->mappings[i].mapoid;
|
return map->mappings[i].mapoid;
|
||||||
}
|
}
|
||||||
map = &local_map;
|
map = &local_map;
|
||||||
for (i = 0; i < map->num_mappings; i++)
|
for (i = 0; i < map->num_mappings; i++)
|
||||||
{
|
{
|
||||||
if (filenode == map->mappings[i].mapfilenode)
|
if (filenumber == map->mappings[i].mapfilenumber)
|
||||||
return map->mappings[i].mapoid;
|
return map->mappings[i].mapoid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,13 +253,13 @@ RelationMapFilenodeToOid(Oid filenode, bool shared)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RelationMapOidToFilenodeForDatabase
|
* RelationMapOidToFilenumberForDatabase
|
||||||
*
|
*
|
||||||
* Like RelationMapOidToFilenode, but reads the mapping from the indicated
|
* Like RelationMapOidToFilenumber, but reads the mapping from the indicated
|
||||||
* path instead of using the one for the current database.
|
* path instead of using the one for the current database.
|
||||||
*/
|
*/
|
||||||
Oid
|
RelFileNumber
|
||||||
RelationMapOidToFilenodeForDatabase(char *dbpath, Oid relationId)
|
RelationMapOidToFilenumberForDatabase(char *dbpath, Oid relationId)
|
||||||
{
|
{
|
||||||
RelMapFile map;
|
RelMapFile map;
|
||||||
int i;
|
int i;
|
||||||
@ -270,10 +271,10 @@ RelationMapOidToFilenodeForDatabase(char *dbpath, Oid relationId)
|
|||||||
for (i = 0; i < map.num_mappings; i++)
|
for (i = 0; i < map.num_mappings; i++)
|
||||||
{
|
{
|
||||||
if (relationId == map.mappings[i].mapoid)
|
if (relationId == map.mappings[i].mapoid)
|
||||||
return map.mappings[i].mapfilenode;
|
return map.mappings[i].mapfilenumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
return InvalidOid;
|
return InvalidRelFileNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -311,13 +312,13 @@ RelationMapCopy(Oid dbid, Oid tsid, char *srcdbpath, char *dstdbpath)
|
|||||||
/*
|
/*
|
||||||
* RelationMapUpdateMap
|
* RelationMapUpdateMap
|
||||||
*
|
*
|
||||||
* Install a new relfilenode mapping for the specified relation.
|
* Install a new relfilenumber mapping for the specified relation.
|
||||||
*
|
*
|
||||||
* If immediate is true (or we're bootstrapping), the mapping is activated
|
* If immediate is true (or we're bootstrapping), the mapping is activated
|
||||||
* immediately. Otherwise it is made pending until CommandCounterIncrement.
|
* immediately. Otherwise it is made pending until CommandCounterIncrement.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
RelationMapUpdateMap(Oid relationId, Oid fileNode, bool shared,
|
RelationMapUpdateMap(Oid relationId, RelFileNumber fileNumber, bool shared,
|
||||||
bool immediate)
|
bool immediate)
|
||||||
{
|
{
|
||||||
RelMapFile *map;
|
RelMapFile *map;
|
||||||
@ -362,7 +363,7 @@ RelationMapUpdateMap(Oid relationId, Oid fileNode, bool shared,
|
|||||||
map = &pending_local_updates;
|
map = &pending_local_updates;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply_map_update(map, relationId, fileNode, true);
|
apply_map_update(map, relationId, fileNumber, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -375,7 +376,8 @@ RelationMapUpdateMap(Oid relationId, Oid fileNode, bool shared,
|
|||||||
* add_okay = false to draw an error if not.
|
* add_okay = false to draw an error if not.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
apply_map_update(RelMapFile *map, Oid relationId, Oid fileNode, bool add_okay)
|
apply_map_update(RelMapFile *map, Oid relationId, RelFileNumber fileNumber,
|
||||||
|
bool add_okay)
|
||||||
{
|
{
|
||||||
int32 i;
|
int32 i;
|
||||||
|
|
||||||
@ -384,7 +386,7 @@ apply_map_update(RelMapFile *map, Oid relationId, Oid fileNode, bool add_okay)
|
|||||||
{
|
{
|
||||||
if (relationId == map->mappings[i].mapoid)
|
if (relationId == map->mappings[i].mapoid)
|
||||||
{
|
{
|
||||||
map->mappings[i].mapfilenode = fileNode;
|
map->mappings[i].mapfilenumber = fileNumber;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,7 +398,7 @@ apply_map_update(RelMapFile *map, Oid relationId, Oid fileNode, bool add_okay)
|
|||||||
if (map->num_mappings >= MAX_MAPPINGS)
|
if (map->num_mappings >= MAX_MAPPINGS)
|
||||||
elog(ERROR, "ran out of space in relation map");
|
elog(ERROR, "ran out of space in relation map");
|
||||||
map->mappings[map->num_mappings].mapoid = relationId;
|
map->mappings[map->num_mappings].mapoid = relationId;
|
||||||
map->mappings[map->num_mappings].mapfilenode = fileNode;
|
map->mappings[map->num_mappings].mapfilenumber = fileNumber;
|
||||||
map->num_mappings++;
|
map->num_mappings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,7 +417,7 @@ merge_map_updates(RelMapFile *map, const RelMapFile *updates, bool add_okay)
|
|||||||
{
|
{
|
||||||
apply_map_update(map,
|
apply_map_update(map,
|
||||||
updates->mappings[i].mapoid,
|
updates->mappings[i].mapoid,
|
||||||
updates->mappings[i].mapfilenode,
|
updates->mappings[i].mapfilenumber,
|
||||||
add_okay);
|
add_okay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -983,12 +985,12 @@ write_relmap_file(RelMapFile *newmap, bool write_wal, bool send_sinval,
|
|||||||
|
|
||||||
for (i = 0; i < newmap->num_mappings; i++)
|
for (i = 0; i < newmap->num_mappings; i++)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
|
|
||||||
rnode.spcNode = tsid;
|
rlocator.spcOid = tsid;
|
||||||
rnode.dbNode = dbid;
|
rlocator.dbOid = dbid;
|
||||||
rnode.relNode = newmap->mappings[i].mapfilenode;
|
rlocator.relNumber = newmap->mappings[i].mapfilenumber;
|
||||||
RelationPreserveStorage(rnode, false);
|
RelationPreserveStorage(rlocator, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4804,15 +4804,15 @@ binary_upgrade_set_pg_class_oids(Archive *fout,
|
|||||||
{
|
{
|
||||||
PQExpBuffer upgrade_query = createPQExpBuffer();
|
PQExpBuffer upgrade_query = createPQExpBuffer();
|
||||||
PGresult *upgrade_res;
|
PGresult *upgrade_res;
|
||||||
Oid relfilenode;
|
RelFileNumber relfilenumber;
|
||||||
Oid toast_oid;
|
Oid toast_oid;
|
||||||
Oid toast_relfilenode;
|
RelFileNumber toast_relfilenumber;
|
||||||
char relkind;
|
char relkind;
|
||||||
Oid toast_index_oid;
|
Oid toast_index_oid;
|
||||||
Oid toast_index_relfilenode;
|
RelFileNumber toast_index_relfilenumber;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Preserve the OID and relfilenode of the table, table's index, table's
|
* Preserve the OID and relfilenumber of the table, table's index, table's
|
||||||
* toast table and toast table's index if any.
|
* toast table and toast table's index if any.
|
||||||
*
|
*
|
||||||
* One complexity is that the current table definition might not require
|
* One complexity is that the current table definition might not require
|
||||||
@ -4835,15 +4835,15 @@ binary_upgrade_set_pg_class_oids(Archive *fout,
|
|||||||
|
|
||||||
relkind = *PQgetvalue(upgrade_res, 0, PQfnumber(upgrade_res, "relkind"));
|
relkind = *PQgetvalue(upgrade_res, 0, PQfnumber(upgrade_res, "relkind"));
|
||||||
|
|
||||||
relfilenode = atooid(PQgetvalue(upgrade_res, 0,
|
relfilenumber = atooid(PQgetvalue(upgrade_res, 0,
|
||||||
PQfnumber(upgrade_res, "relfilenode")));
|
PQfnumber(upgrade_res, "relfilenode")));
|
||||||
toast_oid = atooid(PQgetvalue(upgrade_res, 0,
|
toast_oid = atooid(PQgetvalue(upgrade_res, 0,
|
||||||
PQfnumber(upgrade_res, "reltoastrelid")));
|
PQfnumber(upgrade_res, "reltoastrelid")));
|
||||||
toast_relfilenode = atooid(PQgetvalue(upgrade_res, 0,
|
toast_relfilenumber = atooid(PQgetvalue(upgrade_res, 0,
|
||||||
PQfnumber(upgrade_res, "toast_relfilenode")));
|
PQfnumber(upgrade_res, "toast_relfilenode")));
|
||||||
toast_index_oid = atooid(PQgetvalue(upgrade_res, 0,
|
toast_index_oid = atooid(PQgetvalue(upgrade_res, 0,
|
||||||
PQfnumber(upgrade_res, "indexrelid")));
|
PQfnumber(upgrade_res, "indexrelid")));
|
||||||
toast_index_relfilenode = atooid(PQgetvalue(upgrade_res, 0,
|
toast_index_relfilenumber = atooid(PQgetvalue(upgrade_res, 0,
|
||||||
PQfnumber(upgrade_res, "toast_index_relfilenode")));
|
PQfnumber(upgrade_res, "toast_index_relfilenode")));
|
||||||
|
|
||||||
appendPQExpBufferStr(upgrade_buffer,
|
appendPQExpBufferStr(upgrade_buffer,
|
||||||
@ -4857,13 +4857,13 @@ binary_upgrade_set_pg_class_oids(Archive *fout,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Not every relation has storage. Also, in a pre-v12 database,
|
* Not every relation has storage. Also, in a pre-v12 database,
|
||||||
* partitioned tables have a relfilenode, which should not be
|
* partitioned tables have a relfilenumber, which should not be
|
||||||
* preserved when upgrading.
|
* preserved when upgrading.
|
||||||
*/
|
*/
|
||||||
if (OidIsValid(relfilenode) && relkind != RELKIND_PARTITIONED_TABLE)
|
if (RelFileNumberIsValid(relfilenumber) && relkind != RELKIND_PARTITIONED_TABLE)
|
||||||
appendPQExpBuffer(upgrade_buffer,
|
appendPQExpBuffer(upgrade_buffer,
|
||||||
"SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
|
"SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
|
||||||
relfilenode);
|
relfilenumber);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In a pre-v12 database, partitioned tables might be marked as having
|
* In a pre-v12 database, partitioned tables might be marked as having
|
||||||
@ -4877,7 +4877,7 @@ binary_upgrade_set_pg_class_oids(Archive *fout,
|
|||||||
toast_oid);
|
toast_oid);
|
||||||
appendPQExpBuffer(upgrade_buffer,
|
appendPQExpBuffer(upgrade_buffer,
|
||||||
"SELECT pg_catalog.binary_upgrade_set_next_toast_relfilenode('%u'::pg_catalog.oid);\n",
|
"SELECT pg_catalog.binary_upgrade_set_next_toast_relfilenode('%u'::pg_catalog.oid);\n",
|
||||||
toast_relfilenode);
|
toast_relfilenumber);
|
||||||
|
|
||||||
/* every toast table has an index */
|
/* every toast table has an index */
|
||||||
appendPQExpBuffer(upgrade_buffer,
|
appendPQExpBuffer(upgrade_buffer,
|
||||||
@ -4885,20 +4885,20 @@ binary_upgrade_set_pg_class_oids(Archive *fout,
|
|||||||
toast_index_oid);
|
toast_index_oid);
|
||||||
appendPQExpBuffer(upgrade_buffer,
|
appendPQExpBuffer(upgrade_buffer,
|
||||||
"SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
|
"SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
|
||||||
toast_index_relfilenode);
|
toast_index_relfilenumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(upgrade_res);
|
PQclear(upgrade_res);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Preserve the OID and relfilenode of the index */
|
/* Preserve the OID and relfilenumber of the index */
|
||||||
appendPQExpBuffer(upgrade_buffer,
|
appendPQExpBuffer(upgrade_buffer,
|
||||||
"SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
|
"SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
|
||||||
pg_class_oid);
|
pg_class_oid);
|
||||||
appendPQExpBuffer(upgrade_buffer,
|
appendPQExpBuffer(upgrade_buffer,
|
||||||
"SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
|
"SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
|
||||||
relfilenode);
|
relfilenumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferChar(upgrade_buffer, '\n');
|
appendPQExpBufferChar(upgrade_buffer, '\n');
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#define DATAPAGEMAP_H
|
#define DATAPAGEMAP_H
|
||||||
|
|
||||||
#include "storage/block.h"
|
#include "storage/block.h"
|
||||||
#include "storage/relfilenode.h"
|
#include "storage/relfilelocator.h"
|
||||||
|
|
||||||
struct datapagemap
|
struct datapagemap
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ static uint32 hash_string_pointer(const char *s);
|
|||||||
static filehash_hash *filehash;
|
static filehash_hash *filehash;
|
||||||
|
|
||||||
static bool isRelDataFile(const char *path);
|
static bool isRelDataFile(const char *path);
|
||||||
static char *datasegpath(RelFileNode rnode, ForkNumber forknum,
|
static char *datasegpath(RelFileLocator rlocator, ForkNumber forknum,
|
||||||
BlockNumber segno);
|
BlockNumber segno);
|
||||||
|
|
||||||
static file_entry_t *insert_filehash_entry(const char *path);
|
static file_entry_t *insert_filehash_entry(const char *path);
|
||||||
@ -288,7 +288,7 @@ process_target_file(const char *path, file_type_t type, size_t size,
|
|||||||
* hash table!
|
* hash table!
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
process_target_wal_block_change(ForkNumber forknum, RelFileNode rnode,
|
process_target_wal_block_change(ForkNumber forknum, RelFileLocator rlocator,
|
||||||
BlockNumber blkno)
|
BlockNumber blkno)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
@ -299,7 +299,7 @@ process_target_wal_block_change(ForkNumber forknum, RelFileNode rnode,
|
|||||||
segno = blkno / RELSEG_SIZE;
|
segno = blkno / RELSEG_SIZE;
|
||||||
blkno_inseg = blkno % RELSEG_SIZE;
|
blkno_inseg = blkno % RELSEG_SIZE;
|
||||||
|
|
||||||
path = datasegpath(rnode, forknum, segno);
|
path = datasegpath(rlocator, forknum, segno);
|
||||||
entry = lookup_filehash_entry(path);
|
entry = lookup_filehash_entry(path);
|
||||||
pfree(path);
|
pfree(path);
|
||||||
|
|
||||||
@ -508,7 +508,7 @@ print_filemap(filemap_t *filemap)
|
|||||||
static bool
|
static bool
|
||||||
isRelDataFile(const char *path)
|
isRelDataFile(const char *path)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
unsigned int segNo;
|
unsigned int segNo;
|
||||||
int nmatch;
|
int nmatch;
|
||||||
bool matched;
|
bool matched;
|
||||||
@ -532,32 +532,32 @@ isRelDataFile(const char *path)
|
|||||||
*
|
*
|
||||||
*----
|
*----
|
||||||
*/
|
*/
|
||||||
rnode.spcNode = InvalidOid;
|
rlocator.spcOid = InvalidOid;
|
||||||
rnode.dbNode = InvalidOid;
|
rlocator.dbOid = InvalidOid;
|
||||||
rnode.relNode = InvalidOid;
|
rlocator.relNumber = InvalidRelFileNumber;
|
||||||
segNo = 0;
|
segNo = 0;
|
||||||
matched = false;
|
matched = false;
|
||||||
|
|
||||||
nmatch = sscanf(path, "global/%u.%u", &rnode.relNode, &segNo);
|
nmatch = sscanf(path, "global/%u.%u", &rlocator.relNumber, &segNo);
|
||||||
if (nmatch == 1 || nmatch == 2)
|
if (nmatch == 1 || nmatch == 2)
|
||||||
{
|
{
|
||||||
rnode.spcNode = GLOBALTABLESPACE_OID;
|
rlocator.spcOid = GLOBALTABLESPACE_OID;
|
||||||
rnode.dbNode = 0;
|
rlocator.dbOid = 0;
|
||||||
matched = true;
|
matched = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nmatch = sscanf(path, "base/%u/%u.%u",
|
nmatch = sscanf(path, "base/%u/%u.%u",
|
||||||
&rnode.dbNode, &rnode.relNode, &segNo);
|
&rlocator.dbOid, &rlocator.relNumber, &segNo);
|
||||||
if (nmatch == 2 || nmatch == 3)
|
if (nmatch == 2 || nmatch == 3)
|
||||||
{
|
{
|
||||||
rnode.spcNode = DEFAULTTABLESPACE_OID;
|
rlocator.spcOid = DEFAULTTABLESPACE_OID;
|
||||||
matched = true;
|
matched = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nmatch = sscanf(path, "pg_tblspc/%u/" TABLESPACE_VERSION_DIRECTORY "/%u/%u.%u",
|
nmatch = sscanf(path, "pg_tblspc/%u/" TABLESPACE_VERSION_DIRECTORY "/%u/%u.%u",
|
||||||
&rnode.spcNode, &rnode.dbNode, &rnode.relNode,
|
&rlocator.spcOid, &rlocator.dbOid, &rlocator.relNumber,
|
||||||
&segNo);
|
&segNo);
|
||||||
if (nmatch == 3 || nmatch == 4)
|
if (nmatch == 3 || nmatch == 4)
|
||||||
matched = true;
|
matched = true;
|
||||||
@ -567,12 +567,12 @@ isRelDataFile(const char *path)
|
|||||||
/*
|
/*
|
||||||
* The sscanf tests above can match files that have extra characters at
|
* The sscanf tests above can match files that have extra characters at
|
||||||
* the end. To eliminate such cases, cross-check that GetRelationPath
|
* the end. To eliminate such cases, cross-check that GetRelationPath
|
||||||
* creates the exact same filename, when passed the RelFileNode
|
* creates the exact same filename, when passed the RelFileLocator
|
||||||
* information we extracted from the filename.
|
* information we extracted from the filename.
|
||||||
*/
|
*/
|
||||||
if (matched)
|
if (matched)
|
||||||
{
|
{
|
||||||
char *check_path = datasegpath(rnode, MAIN_FORKNUM, segNo);
|
char *check_path = datasegpath(rlocator, MAIN_FORKNUM, segNo);
|
||||||
|
|
||||||
if (strcmp(check_path, path) != 0)
|
if (strcmp(check_path, path) != 0)
|
||||||
matched = false;
|
matched = false;
|
||||||
@ -589,12 +589,12 @@ isRelDataFile(const char *path)
|
|||||||
* The returned path is palloc'd
|
* The returned path is palloc'd
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
datasegpath(RelFileNode rnode, ForkNumber forknum, BlockNumber segno)
|
datasegpath(RelFileLocator rlocator, ForkNumber forknum, BlockNumber segno)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
char *segpath;
|
char *segpath;
|
||||||
|
|
||||||
path = relpathperm(rnode, forknum);
|
path = relpathperm(rlocator, forknum);
|
||||||
if (segno > 0)
|
if (segno > 0)
|
||||||
{
|
{
|
||||||
segpath = psprintf("%s.%u", path, segno);
|
segpath = psprintf("%s.%u", path, segno);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "datapagemap.h"
|
#include "datapagemap.h"
|
||||||
#include "storage/block.h"
|
#include "storage/block.h"
|
||||||
#include "storage/relfilenode.h"
|
#include "storage/relfilelocator.h"
|
||||||
|
|
||||||
/* these enum values are sorted in the order we want actions to be processed */
|
/* these enum values are sorted in the order we want actions to be processed */
|
||||||
typedef enum
|
typedef enum
|
||||||
@ -103,7 +103,7 @@ extern void process_source_file(const char *path, file_type_t type,
|
|||||||
extern void process_target_file(const char *path, file_type_t type,
|
extern void process_target_file(const char *path, file_type_t type,
|
||||||
size_t size, const char *link_target);
|
size_t size, const char *link_target);
|
||||||
extern void process_target_wal_block_change(ForkNumber forknum,
|
extern void process_target_wal_block_change(ForkNumber forknum,
|
||||||
RelFileNode rnode,
|
RelFileLocator rlocator,
|
||||||
BlockNumber blkno);
|
BlockNumber blkno);
|
||||||
|
|
||||||
extern filemap_t *decide_file_actions(void);
|
extern filemap_t *decide_file_actions(void);
|
||||||
|
@ -445,18 +445,18 @@ extractPageInfo(XLogReaderState *record)
|
|||||||
|
|
||||||
for (block_id = 0; block_id <= XLogRecMaxBlockId(record); block_id++)
|
for (block_id = 0; block_id <= XLogRecMaxBlockId(record); block_id++)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
|
|
||||||
if (!XLogRecGetBlockTagExtended(record, block_id,
|
if (!XLogRecGetBlockTagExtended(record, block_id,
|
||||||
&rnode, &forknum, &blkno, NULL))
|
&rlocator, &forknum, &blkno, NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* We only care about the main fork; others are copied in toto */
|
/* We only care about the main fork; others are copied in toto */
|
||||||
if (forknum != MAIN_FORKNUM)
|
if (forknum != MAIN_FORKNUM)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
process_target_wal_block_change(forknum, rnode, blkno);
|
process_target_wal_block_change(forknum, rlocator, blkno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "datapagemap.h"
|
#include "datapagemap.h"
|
||||||
#include "libpq-fe.h"
|
#include "libpq-fe.h"
|
||||||
#include "storage/block.h"
|
#include "storage/block.h"
|
||||||
#include "storage/relfilenode.h"
|
#include "storage/relfilelocator.h"
|
||||||
|
|
||||||
/* Configuration options */
|
/* Configuration options */
|
||||||
extern char *datadir_target;
|
extern char *datadir_target;
|
||||||
|
@ -19,7 +19,7 @@ OBJS = \
|
|||||||
option.o \
|
option.o \
|
||||||
parallel.o \
|
parallel.o \
|
||||||
pg_upgrade.o \
|
pg_upgrade.o \
|
||||||
relfilenode.o \
|
relfilenumber.o \
|
||||||
server.o \
|
server.o \
|
||||||
tablespace.o \
|
tablespace.o \
|
||||||
util.o \
|
util.o \
|
||||||
|
@ -190,9 +190,9 @@ create_rel_filename_map(const char *old_data, const char *new_data,
|
|||||||
map->new_tablespace_suffix = new_cluster.tablespace_suffix;
|
map->new_tablespace_suffix = new_cluster.tablespace_suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DB oid and relfilenodes are preserved between old and new cluster */
|
/* DB oid and relfilenumbers are preserved between old and new cluster */
|
||||||
map->db_oid = old_db->db_oid;
|
map->db_oid = old_db->db_oid;
|
||||||
map->relfilenode = old_rel->relfilenode;
|
map->relfilenumber = old_rel->relfilenumber;
|
||||||
|
|
||||||
/* used only for logging and error reporting, old/new are identical */
|
/* used only for logging and error reporting, old/new are identical */
|
||||||
map->nspname = old_rel->nspname;
|
map->nspname = old_rel->nspname;
|
||||||
@ -399,7 +399,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
|
|||||||
i_reloid,
|
i_reloid,
|
||||||
i_indtable,
|
i_indtable,
|
||||||
i_toastheap,
|
i_toastheap,
|
||||||
i_relfilenode,
|
i_relfilenumber,
|
||||||
i_reltablespace;
|
i_reltablespace;
|
||||||
char query[QUERY_ALLOC];
|
char query[QUERY_ALLOC];
|
||||||
char *last_namespace = NULL,
|
char *last_namespace = NULL,
|
||||||
@ -495,7 +495,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
|
|||||||
i_toastheap = PQfnumber(res, "toastheap");
|
i_toastheap = PQfnumber(res, "toastheap");
|
||||||
i_nspname = PQfnumber(res, "nspname");
|
i_nspname = PQfnumber(res, "nspname");
|
||||||
i_relname = PQfnumber(res, "relname");
|
i_relname = PQfnumber(res, "relname");
|
||||||
i_relfilenode = PQfnumber(res, "relfilenode");
|
i_relfilenumber = PQfnumber(res, "relfilenode");
|
||||||
i_reltablespace = PQfnumber(res, "reltablespace");
|
i_reltablespace = PQfnumber(res, "reltablespace");
|
||||||
i_spclocation = PQfnumber(res, "spclocation");
|
i_spclocation = PQfnumber(res, "spclocation");
|
||||||
|
|
||||||
@ -527,7 +527,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
|
|||||||
relname = PQgetvalue(res, relnum, i_relname);
|
relname = PQgetvalue(res, relnum, i_relname);
|
||||||
curr->relname = pg_strdup(relname);
|
curr->relname = pg_strdup(relname);
|
||||||
|
|
||||||
curr->relfilenode = atooid(PQgetvalue(res, relnum, i_relfilenode));
|
curr->relfilenumber = atooid(PQgetvalue(res, relnum, i_relfilenumber));
|
||||||
curr->tblsp_alloc = false;
|
curr->tblsp_alloc = false;
|
||||||
|
|
||||||
/* Is the tablespace oid non-default? */
|
/* Is the tablespace oid non-default? */
|
||||||
|
@ -135,7 +135,7 @@ typedef struct
|
|||||||
char *nspname; /* namespace name */
|
char *nspname; /* namespace name */
|
||||||
char *relname; /* relation name */
|
char *relname; /* relation name */
|
||||||
Oid reloid; /* relation OID */
|
Oid reloid; /* relation OID */
|
||||||
Oid relfilenode; /* relation file node */
|
RelFileNumber relfilenumber; /* relation file number */
|
||||||
Oid indtable; /* if index, OID of its table, else 0 */
|
Oid indtable; /* if index, OID of its table, else 0 */
|
||||||
Oid toastheap; /* if toast table, OID of base table, else 0 */
|
Oid toastheap; /* if toast table, OID of base table, else 0 */
|
||||||
char *tablespace; /* tablespace path; "" for cluster default */
|
char *tablespace; /* tablespace path; "" for cluster default */
|
||||||
@ -159,7 +159,7 @@ typedef struct
|
|||||||
const char *old_tablespace_suffix;
|
const char *old_tablespace_suffix;
|
||||||
const char *new_tablespace_suffix;
|
const char *new_tablespace_suffix;
|
||||||
Oid db_oid;
|
Oid db_oid;
|
||||||
Oid relfilenode;
|
RelFileNumber relfilenumber;
|
||||||
/* the rest are used only for logging and error reporting */
|
/* the rest are used only for logging and error reporting */
|
||||||
char *nspname; /* namespaces */
|
char *nspname; /* namespaces */
|
||||||
char *relname;
|
char *relname;
|
||||||
@ -400,7 +400,7 @@ void parseCommandLine(int argc, char *argv[]);
|
|||||||
void adjust_data_dir(ClusterInfo *cluster);
|
void adjust_data_dir(ClusterInfo *cluster);
|
||||||
void get_sock_dir(ClusterInfo *cluster, bool live_check);
|
void get_sock_dir(ClusterInfo *cluster, bool live_check);
|
||||||
|
|
||||||
/* relfilenode.c */
|
/* relfilenumber.c */
|
||||||
|
|
||||||
void transfer_all_new_tablespaces(DbInfoArr *old_db_arr,
|
void transfer_all_new_tablespaces(DbInfoArr *old_db_arr,
|
||||||
DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata);
|
DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* relfilenode.c
|
* relfilenumber.c
|
||||||
*
|
*
|
||||||
* relfilenode functions
|
* relfilenumber functions
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010-2022, PostgreSQL Global Development Group
|
* Copyright (c) 2010-2022, PostgreSQL Global Development Group
|
||||||
* src/bin/pg_upgrade/relfilenode.c
|
* src/bin/pg_upgrade/relfilenumber.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -181,7 +181,7 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
|
|||||||
/*
|
/*
|
||||||
* Now copy/link any related segments as well. Remember, PG breaks large
|
* Now copy/link any related segments as well. Remember, PG breaks large
|
||||||
* files into 1GB segments, the first segment has no extension, subsequent
|
* files into 1GB segments, the first segment has no extension, subsequent
|
||||||
* segments are named relfilenode.1, relfilenode.2, relfilenode.3.
|
* segments are named relfilenumber.1, relfilenumber.2, relfilenumber.3.
|
||||||
*/
|
*/
|
||||||
for (segno = 0;; segno++)
|
for (segno = 0;; segno++)
|
||||||
{
|
{
|
||||||
@ -194,14 +194,14 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
|
|||||||
map->old_tablespace,
|
map->old_tablespace,
|
||||||
map->old_tablespace_suffix,
|
map->old_tablespace_suffix,
|
||||||
map->db_oid,
|
map->db_oid,
|
||||||
map->relfilenode,
|
map->relfilenumber,
|
||||||
type_suffix,
|
type_suffix,
|
||||||
extent_suffix);
|
extent_suffix);
|
||||||
snprintf(new_file, sizeof(new_file), "%s%s/%u/%u%s%s",
|
snprintf(new_file, sizeof(new_file), "%s%s/%u/%u%s%s",
|
||||||
map->new_tablespace,
|
map->new_tablespace,
|
||||||
map->new_tablespace_suffix,
|
map->new_tablespace_suffix,
|
||||||
map->db_oid,
|
map->db_oid,
|
||||||
map->relfilenode,
|
map->relfilenumber,
|
||||||
type_suffix,
|
type_suffix,
|
||||||
extent_suffix);
|
extent_suffix);
|
||||||
|
|
@ -37,7 +37,7 @@ static const char *progname;
|
|||||||
static int WalSegSz;
|
static int WalSegSz;
|
||||||
static volatile sig_atomic_t time_to_stop = false;
|
static volatile sig_atomic_t time_to_stop = false;
|
||||||
|
|
||||||
static const RelFileNode emptyRelFileNode = {0, 0, 0};
|
static const RelFileLocator emptyRelFileLocator = {0, 0, 0};
|
||||||
|
|
||||||
typedef struct XLogDumpPrivate
|
typedef struct XLogDumpPrivate
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ typedef struct XLogDumpConfig
|
|||||||
bool filter_by_rmgr_enabled;
|
bool filter_by_rmgr_enabled;
|
||||||
TransactionId filter_by_xid;
|
TransactionId filter_by_xid;
|
||||||
bool filter_by_xid_enabled;
|
bool filter_by_xid_enabled;
|
||||||
RelFileNode filter_by_relation;
|
RelFileLocator filter_by_relation;
|
||||||
bool filter_by_extended;
|
bool filter_by_extended;
|
||||||
bool filter_by_relation_enabled;
|
bool filter_by_relation_enabled;
|
||||||
BlockNumber filter_by_relation_block;
|
BlockNumber filter_by_relation_block;
|
||||||
@ -393,7 +393,7 @@ WALDumpReadPage(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen,
|
|||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
XLogRecordMatchesRelationBlock(XLogReaderState *record,
|
XLogRecordMatchesRelationBlock(XLogReaderState *record,
|
||||||
RelFileNode matchRnode,
|
RelFileLocator matchRlocator,
|
||||||
BlockNumber matchBlock,
|
BlockNumber matchBlock,
|
||||||
ForkNumber matchFork)
|
ForkNumber matchFork)
|
||||||
{
|
{
|
||||||
@ -401,17 +401,17 @@ XLogRecordMatchesRelationBlock(XLogReaderState *record,
|
|||||||
|
|
||||||
for (block_id = 0; block_id <= XLogRecMaxBlockId(record); block_id++)
|
for (block_id = 0; block_id <= XLogRecMaxBlockId(record); block_id++)
|
||||||
{
|
{
|
||||||
RelFileNode rnode;
|
RelFileLocator rlocator;
|
||||||
ForkNumber forknum;
|
ForkNumber forknum;
|
||||||
BlockNumber blk;
|
BlockNumber blk;
|
||||||
|
|
||||||
if (!XLogRecGetBlockTagExtended(record, block_id,
|
if (!XLogRecGetBlockTagExtended(record, block_id,
|
||||||
&rnode, &forknum, &blk, NULL))
|
&rlocator, &forknum, &blk, NULL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((matchFork == InvalidForkNumber || matchFork == forknum) &&
|
if ((matchFork == InvalidForkNumber || matchFork == forknum) &&
|
||||||
(RelFileNodeEquals(matchRnode, emptyRelFileNode) ||
|
(RelFileLocatorEquals(matchRlocator, emptyRelFileLocator) ||
|
||||||
RelFileNodeEquals(matchRnode, rnode)) &&
|
RelFileLocatorEquals(matchRlocator, rlocator)) &&
|
||||||
(matchBlock == InvalidBlockNumber || matchBlock == blk))
|
(matchBlock == InvalidBlockNumber || matchBlock == blk))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -885,11 +885,11 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
if (sscanf(optarg, "%u/%u/%u",
|
if (sscanf(optarg, "%u/%u/%u",
|
||||||
&config.filter_by_relation.spcNode,
|
&config.filter_by_relation.spcOid,
|
||||||
&config.filter_by_relation.dbNode,
|
&config.filter_by_relation.dbOid,
|
||||||
&config.filter_by_relation.relNode) != 3 ||
|
&config.filter_by_relation.relNumber) != 3 ||
|
||||||
!OidIsValid(config.filter_by_relation.spcNode) ||
|
!OidIsValid(config.filter_by_relation.spcOid) ||
|
||||||
!OidIsValid(config.filter_by_relation.relNode))
|
!RelFileNumberIsValid(config.filter_by_relation.relNumber))
|
||||||
{
|
{
|
||||||
pg_log_error("invalid relation specification: \"%s\"", optarg);
|
pg_log_error("invalid relation specification: \"%s\"", optarg);
|
||||||
pg_log_error_detail("Expecting \"tablespace OID/database OID/relation filenode\".");
|
pg_log_error_detail("Expecting \"tablespace OID/database OID/relation filenode\".");
|
||||||
@ -1132,7 +1132,7 @@ main(int argc, char **argv)
|
|||||||
!XLogRecordMatchesRelationBlock(xlogreader_state,
|
!XLogRecordMatchesRelationBlock(xlogreader_state,
|
||||||
config.filter_by_relation_enabled ?
|
config.filter_by_relation_enabled ?
|
||||||
config.filter_by_relation :
|
config.filter_by_relation :
|
||||||
emptyRelFileNode,
|
emptyRelFileLocator,
|
||||||
config.filter_by_relation_block_enabled ?
|
config.filter_by_relation_block_enabled ?
|
||||||
config.filter_by_relation_block :
|
config.filter_by_relation_block :
|
||||||
InvalidBlockNumber,
|
InvalidBlockNumber,
|
||||||
|
@ -107,24 +107,24 @@ forkname_chars(const char *str, ForkNumber *fork)
|
|||||||
* XXX this must agree with GetRelationPath()!
|
* XXX this must agree with GetRelationPath()!
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
GetDatabasePath(Oid dbNode, Oid spcNode)
|
GetDatabasePath(Oid dbOid, Oid spcOid)
|
||||||
{
|
{
|
||||||
if (spcNode == GLOBALTABLESPACE_OID)
|
if (spcOid == GLOBALTABLESPACE_OID)
|
||||||
{
|
{
|
||||||
/* Shared system relations live in {datadir}/global */
|
/* Shared system relations live in {datadir}/global */
|
||||||
Assert(dbNode == 0);
|
Assert(dbOid == 0);
|
||||||
return pstrdup("global");
|
return pstrdup("global");
|
||||||
}
|
}
|
||||||
else if (spcNode == DEFAULTTABLESPACE_OID)
|
else if (spcOid == DEFAULTTABLESPACE_OID)
|
||||||
{
|
{
|
||||||
/* The default tablespace is {datadir}/base */
|
/* The default tablespace is {datadir}/base */
|
||||||
return psprintf("base/%u", dbNode);
|
return psprintf("base/%u", dbOid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* All other tablespaces are accessed via symlinks */
|
/* All other tablespaces are accessed via symlinks */
|
||||||
return psprintf("pg_tblspc/%u/%s/%u",
|
return psprintf("pg_tblspc/%u/%s/%u",
|
||||||
spcNode, TABLESPACE_VERSION_DIRECTORY, dbNode);
|
spcOid, TABLESPACE_VERSION_DIRECTORY, dbOid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,44 +138,44 @@ GetDatabasePath(Oid dbNode, Oid spcNode)
|
|||||||
* the trouble considering BackendId is just int anyway.
|
* the trouble considering BackendId is just int anyway.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
GetRelationPath(Oid dbNode, Oid spcNode, Oid relNode,
|
GetRelationPath(Oid dbOid, Oid spcOid, RelFileNumber relNumber,
|
||||||
int backendId, ForkNumber forkNumber)
|
int backendId, ForkNumber forkNumber)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
if (spcNode == GLOBALTABLESPACE_OID)
|
if (spcOid == GLOBALTABLESPACE_OID)
|
||||||
{
|
{
|
||||||
/* Shared system relations live in {datadir}/global */
|
/* Shared system relations live in {datadir}/global */
|
||||||
Assert(dbNode == 0);
|
Assert(dbOid == 0);
|
||||||
Assert(backendId == InvalidBackendId);
|
Assert(backendId == InvalidBackendId);
|
||||||
if (forkNumber != MAIN_FORKNUM)
|
if (forkNumber != MAIN_FORKNUM)
|
||||||
path = psprintf("global/%u_%s",
|
path = psprintf("global/%u_%s",
|
||||||
relNode, forkNames[forkNumber]);
|
relNumber, forkNames[forkNumber]);
|
||||||
else
|
else
|
||||||
path = psprintf("global/%u", relNode);
|
path = psprintf("global/%u", relNumber);
|
||||||
}
|
}
|
||||||
else if (spcNode == DEFAULTTABLESPACE_OID)
|
else if (spcOid == DEFAULTTABLESPACE_OID)
|
||||||
{
|
{
|
||||||
/* The default tablespace is {datadir}/base */
|
/* The default tablespace is {datadir}/base */
|
||||||
if (backendId == InvalidBackendId)
|
if (backendId == InvalidBackendId)
|
||||||
{
|
{
|
||||||
if (forkNumber != MAIN_FORKNUM)
|
if (forkNumber != MAIN_FORKNUM)
|
||||||
path = psprintf("base/%u/%u_%s",
|
path = psprintf("base/%u/%u_%s",
|
||||||
dbNode, relNode,
|
dbOid, relNumber,
|
||||||
forkNames[forkNumber]);
|
forkNames[forkNumber]);
|
||||||
else
|
else
|
||||||
path = psprintf("base/%u/%u",
|
path = psprintf("base/%u/%u",
|
||||||
dbNode, relNode);
|
dbOid, relNumber);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (forkNumber != MAIN_FORKNUM)
|
if (forkNumber != MAIN_FORKNUM)
|
||||||
path = psprintf("base/%u/t%d_%u_%s",
|
path = psprintf("base/%u/t%d_%u_%s",
|
||||||
dbNode, backendId, relNode,
|
dbOid, backendId, relNumber,
|
||||||
forkNames[forkNumber]);
|
forkNames[forkNumber]);
|
||||||
else
|
else
|
||||||
path = psprintf("base/%u/t%d_%u",
|
path = psprintf("base/%u/t%d_%u",
|
||||||
dbNode, backendId, relNode);
|
dbOid, backendId, relNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -185,25 +185,25 @@ GetRelationPath(Oid dbNode, Oid spcNode, Oid relNode,
|
|||||||
{
|
{
|
||||||
if (forkNumber != MAIN_FORKNUM)
|
if (forkNumber != MAIN_FORKNUM)
|
||||||
path = psprintf("pg_tblspc/%u/%s/%u/%u_%s",
|
path = psprintf("pg_tblspc/%u/%s/%u/%u_%s",
|
||||||
spcNode, TABLESPACE_VERSION_DIRECTORY,
|
spcOid, TABLESPACE_VERSION_DIRECTORY,
|
||||||
dbNode, relNode,
|
dbOid, relNumber,
|
||||||
forkNames[forkNumber]);
|
forkNames[forkNumber]);
|
||||||
else
|
else
|
||||||
path = psprintf("pg_tblspc/%u/%s/%u/%u",
|
path = psprintf("pg_tblspc/%u/%s/%u/%u",
|
||||||
spcNode, TABLESPACE_VERSION_DIRECTORY,
|
spcOid, TABLESPACE_VERSION_DIRECTORY,
|
||||||
dbNode, relNode);
|
dbOid, relNumber);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (forkNumber != MAIN_FORKNUM)
|
if (forkNumber != MAIN_FORKNUM)
|
||||||
path = psprintf("pg_tblspc/%u/%s/%u/t%d_%u_%s",
|
path = psprintf("pg_tblspc/%u/%s/%u/t%d_%u_%s",
|
||||||
spcNode, TABLESPACE_VERSION_DIRECTORY,
|
spcOid, TABLESPACE_VERSION_DIRECTORY,
|
||||||
dbNode, backendId, relNode,
|
dbOid, backendId, relNumber,
|
||||||
forkNames[forkNumber]);
|
forkNames[forkNumber]);
|
||||||
else
|
else
|
||||||
path = psprintf("pg_tblspc/%u/%s/%u/t%d_%u",
|
path = psprintf("pg_tblspc/%u/%s/%u/t%d_%u",
|
||||||
spcNode, TABLESPACE_VERSION_DIRECTORY,
|
spcOid, TABLESPACE_VERSION_DIRECTORY,
|
||||||
dbNode, backendId, relNode);
|
dbOid, backendId, relNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
#include "storage/bufpage.h"
|
#include "storage/bufpage.h"
|
||||||
#include "storage/itemptr.h"
|
#include "storage/itemptr.h"
|
||||||
#include "storage/relfilenode.h"
|
#include "storage/relfilelocator.h"
|
||||||
#include "utils/relcache.h"
|
#include "utils/relcache.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ typedef struct
|
|||||||
|
|
||||||
typedef struct ginxlogSplit
|
typedef struct ginxlogSplit
|
||||||
{
|
{
|
||||||
RelFileNode node;
|
RelFileLocator locator;
|
||||||
BlockNumber rrlink; /* right link, or root's blocknumber if root
|
BlockNumber rrlink; /* right link, or root's blocknumber if root
|
||||||
* split */
|
* split */
|
||||||
BlockNumber leftChildBlkno; /* valid on a non-leaf split */
|
BlockNumber leftChildBlkno; /* valid on a non-leaf split */
|
||||||
@ -167,7 +167,7 @@ typedef struct ginxlogDeletePage
|
|||||||
*/
|
*/
|
||||||
typedef struct ginxlogUpdateMeta
|
typedef struct ginxlogUpdateMeta
|
||||||
{
|
{
|
||||||
RelFileNode node;
|
RelFileLocator locator;
|
||||||
GinMetaPageData metadata;
|
GinMetaPageData metadata;
|
||||||
BlockNumber prevTail;
|
BlockNumber prevTail;
|
||||||
BlockNumber newRightlink;
|
BlockNumber newRightlink;
|
||||||
|
@ -97,7 +97,7 @@ typedef struct gistxlogPageDelete
|
|||||||
*/
|
*/
|
||||||
typedef struct gistxlogPageReuse
|
typedef struct gistxlogPageReuse
|
||||||
{
|
{
|
||||||
RelFileNode node;
|
RelFileLocator locator;
|
||||||
BlockNumber block;
|
BlockNumber block;
|
||||||
FullTransactionId latestRemovedFullXid;
|
FullTransactionId latestRemovedFullXid;
|
||||||
} gistxlogPageReuse;
|
} gistxlogPageReuse;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
#include "storage/buf.h"
|
#include "storage/buf.h"
|
||||||
#include "storage/bufpage.h"
|
#include "storage/bufpage.h"
|
||||||
#include "storage/relfilenode.h"
|
#include "storage/relfilelocator.h"
|
||||||
#include "utils/relcache.h"
|
#include "utils/relcache.h"
|
||||||
|
|
||||||
|
|
||||||
@ -370,9 +370,9 @@ typedef struct xl_heap_new_cid
|
|||||||
CommandId combocid; /* just for debugging */
|
CommandId combocid; /* just for debugging */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Store the relfilenode/ctid pair to facilitate lookups.
|
* Store the relfilelocator/ctid pair to facilitate lookups.
|
||||||
*/
|
*/
|
||||||
RelFileNode target_node;
|
RelFileLocator target_locator;
|
||||||
ItemPointerData target_tid;
|
ItemPointerData target_tid;
|
||||||
} xl_heap_new_cid;
|
} xl_heap_new_cid;
|
||||||
|
|
||||||
@ -415,7 +415,7 @@ extern bool heap_prepare_freeze_tuple(HeapTupleHeader tuple,
|
|||||||
MultiXactId *relminmxid_out);
|
MultiXactId *relminmxid_out);
|
||||||
extern void heap_execute_freeze_tuple(HeapTupleHeader tuple,
|
extern void heap_execute_freeze_tuple(HeapTupleHeader tuple,
|
||||||
xl_heap_freeze_tuple *xlrec_tp);
|
xl_heap_freeze_tuple *xlrec_tp);
|
||||||
extern XLogRecPtr log_heap_visible(RelFileNode rnode, Buffer heap_buffer,
|
extern XLogRecPtr log_heap_visible(RelFileLocator rlocator, Buffer heap_buffer,
|
||||||
Buffer vm_buffer, TransactionId cutoff_xid, uint8 flags);
|
Buffer vm_buffer, TransactionId cutoff_xid, uint8 flags);
|
||||||
|
|
||||||
#endif /* HEAPAM_XLOG_H */
|
#endif /* HEAPAM_XLOG_H */
|
||||||
|
@ -180,12 +180,12 @@ typedef struct xl_btree_dedup
|
|||||||
* This is what we need to know about page reuse within btree. This record
|
* This is what we need to know about page reuse within btree. This record
|
||||||
* only exists to generate a conflict point for Hot Standby.
|
* only exists to generate a conflict point for Hot Standby.
|
||||||
*
|
*
|
||||||
* Note that we must include a RelFileNode in the record because we don't
|
* Note that we must include a RelFileLocator in the record because we don't
|
||||||
* actually register the buffer with the record.
|
* actually register the buffer with the record.
|
||||||
*/
|
*/
|
||||||
typedef struct xl_btree_reuse_page
|
typedef struct xl_btree_reuse_page
|
||||||
{
|
{
|
||||||
RelFileNode node;
|
RelFileLocator locator;
|
||||||
BlockNumber block;
|
BlockNumber block;
|
||||||
FullTransactionId latestRemovedFullXid;
|
FullTransactionId latestRemovedFullXid;
|
||||||
} xl_btree_reuse_page;
|
} xl_btree_reuse_page;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "access/htup.h"
|
#include "access/htup.h"
|
||||||
#include "storage/itemptr.h"
|
#include "storage/itemptr.h"
|
||||||
#include "storage/relfilenode.h"
|
#include "storage/relfilelocator.h"
|
||||||
#include "utils/relcache.h"
|
#include "utils/relcache.h"
|
||||||
|
|
||||||
/* struct definition is private to rewriteheap.c */
|
/* struct definition is private to rewriteheap.c */
|
||||||
@ -34,8 +34,8 @@ extern bool rewrite_heap_dead_tuple(RewriteState state, HeapTuple oldTuple);
|
|||||||
*/
|
*/
|
||||||
typedef struct LogicalRewriteMappingData
|
typedef struct LogicalRewriteMappingData
|
||||||
{
|
{
|
||||||
RelFileNode old_node;
|
RelFileLocator old_locator;
|
||||||
RelFileNode new_node;
|
RelFileLocator new_locator;
|
||||||
ItemPointerData old_tid;
|
ItemPointerData old_tid;
|
||||||
ItemPointerData new_tid;
|
ItemPointerData new_tid;
|
||||||
} LogicalRewriteMappingData;
|
} LogicalRewriteMappingData;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user