From d25f519107bff602e1ebc81853fe592d020c118d Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Thu, 28 Mar 2019 20:01:14 -0700 Subject: tableam: relation creation, VACUUM FULL/CLUSTER, SET TABLESPACE. This moves the responsibility for: - creating the storage necessary for a relation, including creating a new relfilenode for a relation with existing storage - non-transactional truncation of a relation - VACUUM FULL / CLUSTER's rewrite of a table below tableam. This is fairly straight forward, with a bit of complexity smattered in to move the computation of xid / multixid horizons below the AM, as they don't make sense for every table AM. Author: Andres Freund Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de --- src/backend/commands/sequence.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/backend/commands/sequence.c') diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 574b46a2812..e9add1b9873 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -312,12 +312,17 @@ ResetSequence(Oid seq_relid) seq->log_cnt = 0; /* - * Create a new storage file for the sequence. We want to keep the - * sequence's relfrozenxid at 0, since it won't contain any unfrozen XIDs. - * Same with relminmxid, since a sequence will never contain multixacts. + * Create a new storage file for the sequence. */ - RelationSetNewRelfilenode(seq_rel, seq_rel->rd_rel->relpersistence, - InvalidTransactionId, InvalidMultiXactId); + RelationSetNewRelfilenode(seq_rel, seq_rel->rd_rel->relpersistence); + + /* + * Ensure sequence's relfrozenxid is at 0, since it won't contain any + * unfrozen XIDs. Same with relminmxid, since a sequence will never + * contain multixacts. + */ + Assert(seq_rel->rd_rel->relfrozenxid == InvalidTransactionId); + Assert(seq_rel->rd_rel->relminmxid == InvalidMultiXactId); /* * Insert the modified tuple into the new storage file. @@ -482,12 +487,17 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt) /* * Create a new storage file for the sequence, making the state - * changes transactional. We want to keep the sequence's relfrozenxid - * at 0, since it won't contain any unfrozen XIDs. Same with - * relminmxid, since a sequence will never contain multixacts. + * changes transactional. + */ + RelationSetNewRelfilenode(seqrel, seqrel->rd_rel->relpersistence); + + /* + * Ensure sequence's relfrozenxid is at 0, since it won't contain any + * unfrozen XIDs. Same with relminmxid, since a sequence will never + * contain multixacts. */ - RelationSetNewRelfilenode(seqrel, seqrel->rd_rel->relpersistence, - InvalidTransactionId, InvalidMultiXactId); + Assert(seqrel->rd_rel->relfrozenxid == InvalidTransactionId); + Assert(seqrel->rd_rel->relminmxid == InvalidMultiXactId); /* * Insert the modified tuple into the new storage file. -- cgit v1.2.3