mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Rationalize handling of VacuumParams
This commit refactors the vacuum routines that rely on VacuumParams, adding const markers where necessary to force a new policy in the code. This structure should not use a pointer as it may be used across multiple relations, and its contents should never be updated. vacuum_rel() stands as an exception as it touches the "index_cleanup" and "truncate" options. VacuumParams has been introduced in0d83138974, and661643dedahas fixed a bug impacting VACUUM operating on multiple relations. The changes done in tableam.h break ABI compatibility, so this commit can only happen on HEAD. Author: Shihao Zhong <zhong950419@gmail.com> Co-authored-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Junwang Zhao <zhjwpku@gmail.com> Discussion: https://postgr.es/m/CAGRkXqTo+aK=GTy5pSc-9cy8H2F2TJvcrZ-zXEiNJj93np1UUw@mail.gmail.com
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "access/skey.h"
|
||||
#include "access/table.h" /* for backward compatibility */
|
||||
#include "access/tableam.h"
|
||||
#include "commands/vacuum.h"
|
||||
#include "nodes/lockoptions.h"
|
||||
#include "nodes/primnodes.h"
|
||||
#include "storage/bufpage.h"
|
||||
@@ -396,9 +397,8 @@ extern void log_heap_prune_and_freeze(Relation relation, Buffer buffer,
|
||||
OffsetNumber *unused, int nunused);
|
||||
|
||||
/* in heap/vacuumlazy.c */
|
||||
struct VacuumParams;
|
||||
extern void heap_vacuum_rel(Relation rel,
|
||||
struct VacuumParams *params, BufferAccessStrategy bstrategy);
|
||||
const VacuumParams params, BufferAccessStrategy bstrategy);
|
||||
|
||||
/* in heap/heapam_visibility.c */
|
||||
extern bool HeapTupleSatisfiesVisibility(HeapTuple htup, Snapshot snapshot,
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "access/relscan.h"
|
||||
#include "access/sdir.h"
|
||||
#include "access/xact.h"
|
||||
#include "commands/vacuum.h"
|
||||
#include "executor/tuptable.h"
|
||||
#include "storage/read_stream.h"
|
||||
#include "utils/rel.h"
|
||||
@@ -36,7 +37,6 @@ extern PGDLLIMPORT bool synchronize_seqscans;
|
||||
struct BulkInsertStateData;
|
||||
struct IndexInfo;
|
||||
struct SampleScanState;
|
||||
struct VacuumParams;
|
||||
struct ValidateIndexState;
|
||||
|
||||
/*
|
||||
@@ -645,7 +645,7 @@ typedef struct TableAmRoutine
|
||||
* integrate with autovacuum's scheduling.
|
||||
*/
|
||||
void (*relation_vacuum) (Relation rel,
|
||||
struct VacuumParams *params,
|
||||
const VacuumParams params,
|
||||
BufferAccessStrategy bstrategy);
|
||||
|
||||
/*
|
||||
@@ -1664,7 +1664,7 @@ table_relation_copy_for_cluster(Relation OldTable, Relation NewTable,
|
||||
* routine, even if (for ANALYZE) it is part of the same VACUUM command.
|
||||
*/
|
||||
static inline void
|
||||
table_relation_vacuum(Relation rel, struct VacuumParams *params,
|
||||
table_relation_vacuum(Relation rel, const VacuumParams params,
|
||||
BufferAccessStrategy bstrategy)
|
||||
{
|
||||
rel->rd_tableam->relation_vacuum(rel, params, bstrategy);
|
||||
|
||||
Reference in New Issue
Block a user