forked from ClickHouse/walshadow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwalshadow.h
More file actions
76 lines (64 loc) · 2.14 KB
/
Copy pathwalshadow.h
File metadata and controls
76 lines (64 loc) · 2.14 KB
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
/*
* walshadow — shared declarations for the shadow-side module.
*
* One entry point: a background worker reached via
* shared_preload_libraries. Needs no catalog row, which is the whole point —
* a shadow standby's catalog is a read-only physical copy of source's, so
* anything requiring a pg_proc row is unreachable there.
*
* Wire encoding is network byte order throughout (pqformat's pq_send*),
* matching PG's own convention rather than the daemon's native LE.
*/
#ifndef WALSHADOW_H
#define WALSHADOW_H
#include "postgres.h"
#include "lib/stringinfo.h"
/* Bumped when a request or response layout changes, or when an op's reading
* of an unchanged layout changes */
#define WS_PROTO_VERSION 1
/* Bumped when any catalog projection changes shape */
#define WS_PROJECTION_VERSION 1
/* request opcodes */
#define WS_OP_HELLO 0x01
#define WS_OP_DECODE 0x02
#define WS_OP_SCAN 0x03
#define WS_OP_REPLAY_LSN 0x04
/* response status byte */
#define WS_STATUS_OK 0x00
#define WS_STATUS_ERROR 0x01
/* per-item kind in a DECODE response */
#define WS_ITEM_TEXT 0x00
#define WS_ITEM_ERROR 0x01
/*
* Catalogs the overlay scan covers. Ids are wire values; never renumber.
*/
typedef enum WsCatalog
{
WS_CAT_CLASS = 1,
WS_CAT_ATTRIBUTE = 2,
WS_CAT_INDEX = 3,
WS_CAT_NAMESPACE = 4,
WS_CAT_TYPE = 5,
} WsCatalog;
/* decode.c */
extern char *ws_decode_datum_text(Oid typoid, bytea *raw);
/* overlay.c */
typedef struct WsScanStats
{
uint32 scanned;
uint32 emitted;
/* writers that did not resolve to the requested top xid: provably foreign,
* or (rel-scoped only) unresolvable and trusted ours by the lock argument.
* Whole-catalog scans error on an unresolvable writer instead. A committed
* read owns no transaction, so nothing lands here */
uint32 subtrans_mismatch;
} WsScanStats;
extern int ws_overlay_ncols(WsCatalog cat);
/*
* `top` invalid reads the committed view; an empty `oids` reads the whole
* catalog, which is the only mode pg_namespace and pg_type have.
*/
extern void ws_overlay_scan(WsCatalog cat, TransactionId top,
const Oid *oids, int noids,
StringInfo out, WsScanStats *stats);
#endif /* WALSHADOW_H */