diff options
author | Robert Haas <rhaas@postgresql.org> | 2022-07-06 11:39:09 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2022-07-06 11:39:09 -0400 |
commit | b0a55e43299c4ea2a9a8c757f9c26352407d0ccc (patch) | |
tree | 2c22c2965f9976ae4469595cd28df13db6b943c2 /src/backend/commands/sequence.c | |
parent | 7775c748db1257523ecbed1060dadb608bdff6de (diff) | |
download | postgresql-b0a55e43299c4ea2a9a8c757f9c26352407d0ccc.tar.gz postgresql-b0a55e43299c4ea2a9a8c757f9c26352407d0ccc.zip |
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
Diffstat (limited to 'src/backend/commands/sequence.c')
-rw-r--r-- | src/backend/commands/sequence.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index ddf219b21f5..48d9d43dac6 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -75,7 +75,7 @@ typedef struct sequence_magic typedef struct SeqTableData { 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 */ bool last_valid; /* do we have a valid "last" value? */ 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 * 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. * * 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. */ - 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 @@ -347,9 +347,9 @@ fill_seq_with_data(Relation rel, HeapTuple tuple) { SMgrRelation srel; - srel = smgropen(rel->rd_node, InvalidBackendId); + srel = smgropen(rel->rd_locator, InvalidBackendId); 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); FlushRelationBuffers(rel); smgrclose(srel); @@ -418,7 +418,7 @@ fill_seq_fork_with_data(Relation rel, HeapTuple tuple, ForkNumber forkNum) XLogBeginInsert(); 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 *) 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 * 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 @@ -557,7 +557,7 @@ SequenceChangePersistence(Oid relid, char newrelpersistence) GetTopTransactionId(); (void) read_seq_tuple(seqrel, &buf, &seqdatatuple); - RelationSetNewRelfilenode(seqrel, newrelpersistence); + RelationSetNewRelfilenumber(seqrel, newrelpersistence); fill_seq_with_data(seqrel, &seqdatatuple); UnlockReleaseBuffer(buf); @@ -836,7 +836,7 @@ nextval_internal(Oid relid, bool check_permissions) seq->is_called = true; seq->log_cnt = 0; - xlrec.node = seqrel->rd_node; + xlrec.locator = seqrel->rd_locator; XLogRegisterData((char *) &xlrec, sizeof(xl_seq_rec)); XLogRegisterData((char *) seqdatatuple.t_data, seqdatatuple.t_len); @@ -1023,7 +1023,7 @@ do_setval(Oid relid, int64 next, bool iscalled) XLogBeginInsert(); 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 *) seqdatatuple.t_data, seqdatatuple.t_len); @@ -1147,7 +1147,7 @@ init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel) if (!found) { /* relid already filled in */ - elm->filenode = InvalidOid; + elm->filenumber = InvalidRelFileNumber; elm->lxid = InvalidLocalTransactionId; elm->last_valid = false; 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() * 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; } @@ -1254,7 +1254,8 @@ read_seq_tuple(Relation rel, Buffer *buf, HeapTuple seqdatatuple) * changed. This allows ALTER SEQUENCE to behave transactionally. Currently, * 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 - * 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 init_params(ParseState *pstate, List *options, bool for_identity, |