Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 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
/*-------------------------------------------------------------------------
 *
 * cfs_swap.h
 *    The compaction swap protocol shared by the compaction driver and
 *    the open/recovery path (see cfs_swap.c).
 *
 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
 * Portions Copyright (c) 2026, Diasoft
 *
 * src/include/storage/cfs/cfs_swap.h
 *
 *-------------------------------------------------------------------------
 */
 
#ifndef CFS_SWAP_H
#define CFS_SWAP_H
 
#include "postgres.h"
 
#define CFS_SWAP_MARKER_SUFFIX  ".cfsswap"
#define CFS_CANDIDATE_SUFFIX    ".new"
 
/*
 * Temp suffix of the compaction candidate .cfsmap.  Deliberately distinct
 * from the snapshot writer's ".tmp" (cfs_map_file_write_snapshot_path):
 * the two temp namespaces must never share a name, or a snapshot writer
 * running while the lock-free copy phase builds its candidate could
 * truncate and rename the candidate away (mixed .cfsmap on disk).  The
 * segment temps ("<...>.cfp[.N].tmp") keep the plain ".tmp": nothing
 * outside compaction ever creates them.
 */
#define CFS_MAP_CANDIDATE_TMP_SUFFIX    ".cfscand"
 
/* Rename src to dst only when src exists; otherwise a silent no-op. */
extern int  cfs_rename_if_exists(const char *src, const char *dst);
 
/* Unlink 'path', tolerating its absence (WARNING on a real failure). */
extern void cfs_unlink_if_exists(const char *path);
 
/* True when 'path' names an existing file. */
extern bool cfs_swap_path_exists(const char *path);
 
/* Drop the .cfsswap commit marker, tolerating its absence. */
extern void cfs_swap_unlink_marker(const char *marker);
 
/*
 * cfs_unlink_trailing_segments — remove every .cfp segment above
 * 'last_seg' of the chain rooted at 'cfp_path'.
 */
extern void cfs_unlink_trailing_segments(const char *cfp_path,
                                         uint32 last_seg);
 
/*
 * cfs_recover_compaction — finish (or abort) an interrupted compaction
 * swap so that the .cfp / .cfsmap pair on disk is self-consistent before
 * the caller opens them.  Must run before any backend reads the
 * sidecars.  Covers every segment of the .cfp chain.
 */
extern void cfs_recover_compaction(const char *cfp_path,
                                   const char *map_path,
                                   const char *jrn_path);
 
#endif                          /* CFS_SWAP_H */