-
Notifications
You must be signed in to change notification settings - Fork 15
/
spock_output_proto.c
49 lines (45 loc) · 1.41 KB
/
spock_output_proto.c
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
/*-------------------------------------------------------------------------
*
* spock_proto.c
* spock protocol functions
*
* Copyright (c) 2022-2023, pgEdge, Inc.
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, The Regents of the University of California
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "replication/reorderbuffer.h"
#include "spock_output_plugin.h"
#include "spock_output_proto.h"
#include "spock_proto_native.h"
#include "spock_proto_json.h"
SpockProtoAPI *
spock_init_api(SpockProtoType typ)
{
SpockProtoAPI *res = palloc0(sizeof(SpockProtoAPI));
if (typ == SpockProtoJson)
{
res->write_rel = NULL;
res->write_begin = spock_json_write_begin;
res->write_commit = spock_json_write_commit;
res->write_origin = NULL;
res->write_insert = spock_json_write_insert;
res->write_update = spock_json_write_update;
res->write_delete = spock_json_write_delete;
res->write_startup_message = json_write_startup_message;
}
else
{
res->write_rel = spock_write_rel;
res->write_begin = spock_write_begin;
res->write_commit = spock_write_commit;
res->write_origin = spock_write_origin;
res->write_insert = spock_write_insert;
res->write_update = spock_write_update;
res->write_delete = spock_write_delete;
res->write_startup_message = write_startup_message;
}
return res;
}