Исходный код СУБД 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
/*-------------------------------------------------------------------------
 *
 * basebackup_incremental.h
 *    API for incremental backup support
 *
 * Portions Copyright (c) 2010-2026, PostgreSQL Global Development Group
 *
 * src/include/backup/basebackup_incremental.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef BASEBACKUP_INCREMENTAL_H
#define BASEBACKUP_INCREMENTAL_H
 
#include "access/xlogbackup.h"
#include "common/relpath.h"
#include "storage/block.h"
#include "utils/palloc.h"
 
#define INCREMENTAL_MAGIC           0xd3ae1f0d
 
/* [PG_CUSTOM: CFS]
 * Fork extension: incremental files for CFS .cfp sidecar files use this
 * alternate magic and carry an extra uint64 "exact size" field after the
 * truncation block length.  Unlike relation files, whose length is always
 * a multiple of BLCKSZ, a .cfp file has an arbitrary byte length that the
 * block-granular reconstruction could not otherwise reproduce.
 */
#ifdef USE_CFS
#define INCREMENTAL_CFS_MAGIC       0xcb51f0da
#endif
 
typedef enum
{
    BACK_UP_FILE_FULLY,
    BACK_UP_FILE_INCREMENTALLY
} FileBackupMethod;
 
struct IncrementalBackupInfo;
typedef struct IncrementalBackupInfo IncrementalBackupInfo;
 
extern IncrementalBackupInfo *CreateIncrementalBackupInfo(MemoryContext);
 
extern void AppendIncrementalManifestData(IncrementalBackupInfo *ib,
                                          const char *data,
                                          int len);
extern void FinalizeIncrementalManifest(IncrementalBackupInfo *ib);
 
extern void PrepareForIncrementalBackup(IncrementalBackupInfo *ib,
                                        BackupState *backup_state);
 
extern char *GetIncrementalFilePath(Oid dboid, Oid spcoid,
                                    RelFileNumber relfilenumber,
                                    ForkNumber forknum, unsigned segno);
extern FileBackupMethod GetFileBackupMethod(IncrementalBackupInfo *ib,
                                            const char *path,
                                            Oid dboid, Oid spcoid,
                                            RelFileNumber relfilenumber,
                                            ForkNumber forknum,
                                            unsigned segno, size_t size,
                                            unsigned *num_blocks_required,
                                            BlockNumber *relative_block_numbers,
                                            unsigned *truncation_block_length);
extern size_t GetIncrementalFileSize(unsigned num_blocks_required);
extern size_t GetIncrementalHeaderSize(unsigned num_blocks_required);
 
/* [PG_CUSTOM: CFS] */
#ifdef USE_CFS
extern char *GetIncrementalSidecarPath(const char *path);
extern FileBackupMethod GetCfsSidecarBackupMethod(IncrementalBackupInfo *ib,
                                                  const char *path,
                                                  size_t size,
                                                  uint64 cfp_epoch,
                                                  unsigned *num_blocks_required,
                                                  BlockNumber *relative_block_numbers,
                                                  unsigned *truncation_block_length);
extern size_t GetIncrementalCfsFileSize(unsigned num_blocks_required);
extern size_t GetIncrementalCfsHeaderSize(unsigned num_blocks_required);
#endif
 
#endif