Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*-------------------------------------------------------------------------
 *
 * storage_xlog.h
 *    prototypes for XLog support for backend/catalog/storage.c
 *
 *
 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * src/include/catalog/storage_xlog.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef STORAGE_XLOG_H
#define STORAGE_XLOG_H
 
#include "access/xlogreader.h"
#include "lib/stringinfo.h"
#include "storage/block.h"
#include "storage/relfilelocator.h"
 
/*
 * Declarations for smgr-related XLOG records
 *
 * Note: we log file creation and truncation here, but logging of deletion
 * actions is handled by xact.c, because it is part of transaction commit.
 */
 
/* XLOG gives us high 4 bits */
#define XLOG_SMGR_CREATE    0x10
#define XLOG_SMGR_TRUNCATE  0x20
/* [PG_CUSTOM: CFS] */
#define XLOG_SMGR_CFS_POLICY    0x30
 
typedef struct xl_smgr_create
{
    RelFileLocator rlocator;
    ForkNumber  forkNum;
} xl_smgr_create;
 
/* [PG_CUSTOM: CFS]
 * xl_smgr_cfs_policy
 *      Effective CFS policy of a freshly created relation.  Emitted right
 *      after the relation's XLOG_SMGR_CREATE record whenever a permanent
 *      relation is created with CFS reloptions, so that WAL redo on a
 *      standby / during crash recovery — where no relcache entry exists —
 *      learns that the relation is compressed before any data-bearing
 *      record for it replays.
 *
 *      The payload mirrors the catalog contract: algorithm plus only the
 *      explicitly stored level / min_gain_bytes with their set-flags.  A
 *      value resolved from a session GUC never enters the record — redo
 *      publishes the flags as-is and the standby's writers resolve unset
 *      fields from their own GUCs, so nothing of the writing session's
 *      configuration sticks to the replica.  is_cfs is implied (the record
 *      is only written for CFS relations).
 *
 *      The type is declared unconditionally so that headers included by
 *      always-compiled translation units (cfs_sql.c) stay valid without
 *      USE_CFS; the record is only ever emitted and replayed when the
 *      feature is built in.
 */
typedef struct xl_smgr_cfs_policy
{
    RelFileLocator rlocator;
    int32       level;          /* explicit compression level (0 = unset) */
    int32       min_gain_bytes; /* explicit min gain (0 = unset) */
    uint8       algorithm;      /* CfsAlgorithm */
    uint8       level_set;      /* level stored explicitly in the catalog */
    uint8       min_gain_bytes_set; /* min_gain_bytes stored explicitly */
} xl_smgr_cfs_policy;
 
/* flags for xl_smgr_truncate */
#define SMGR_TRUNCATE_HEAP      0x0001
#define SMGR_TRUNCATE_VM        0x0002
#define SMGR_TRUNCATE_FSM       0x0004
#define SMGR_TRUNCATE_ALL       \
    (SMGR_TRUNCATE_HEAP|SMGR_TRUNCATE_VM|SMGR_TRUNCATE_FSM)
 
typedef struct xl_smgr_truncate
{
    BlockNumber blkno;
    RelFileLocator rlocator;
    int         flags;
} xl_smgr_truncate;
 
extern void log_smgrcreate(const RelFileLocator *rlocator, ForkNumber forkNum);
 
extern void smgr_redo(XLogReaderState *record);
extern void smgr_desc(StringInfo buf, XLogReaderState *record);
extern const char *smgr_identify(uint8 info);
 
#endif                          /* STORAGE_XLOG_H */