Skip to content

Commit b6e0c37

Browse files
MMeenttristan957
authored andcommitted
Pull 99% of walproposer code into extension. (#188)
* Pull 99% of walproposer code into extension. * Annotate nbytes to show it's used for asserts only, fixing one more warning. * Fix makefiles: - Include neon extensions into contrib Makefile - Configure libpqwalproposer more like other extensions * Add comment about lack of PG timelines, and make StartReplication static again. * Fix some compiler warnings in vendor/postgres, and pull libpqwalproposer into vendor/neon * Fix issue with makefile that didn't get caught in the normal test envs.
1 parent 56801f6 commit b6e0c37

File tree

27 files changed

+1559
-803
lines changed

27 files changed

+1559
-803
lines changed

contrib/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ SUBDIRS = \
2626
isn \
2727
lo \
2828
ltree \
29+
neon \
30+
neon_test_utils \
2931
oid2name \
3032
old_snapshot \
3133
pageinspect \

contrib/neon/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
MODULE_big = neon
55
OBJS = \
66
$(WIN32RES) \
7-
inmem_smgr.o libpagestore.o pagestore_smgr.o relsize_cache.o neon.o
7+
inmem_smgr.o \
8+
libpagestore.o \
9+
libpqwalproposer.o \
10+
pagestore_smgr.o \
11+
relsize_cache.o \
12+
neon.o \
13+
walproposer.o \
14+
walproposer_utils.o
815

916
PG_CPPFLAGS = -I$(libpq_srcdir)
1017
SHLIB_LINK_INTERNAL = $(libpq)
@@ -13,6 +20,7 @@ EXTENSION = neon
1320
DATA = neon--1.0.sql
1421
PGFILEDESC = "neon - cloud storage for PostgreSQL"
1522

23+
1624
ifdef USE_PGXS
1725
PG_CONFIG = pg_config
1826
PGXS := $(shell $(PG_CONFIG) --pgxs)

contrib/neon/libpagestore.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
#include "pgstat.h"
2727
#include "utils/guc.h"
2828

29-
#include "replication/walproposer.h"
29+
#include "neon.h"
30+
#include "walproposer.h"
31+
#include "walproposer_utils.h"
3032

31-
PG_MODULE_MAGIC;
32-
33-
void _PG_init(void);
3433

3534
#define PageStoreTrace DEBUG5
3635

@@ -355,7 +354,7 @@ substitute_pageserver_password(const char *page_server_connstring_raw)
355354
* Module initialization function
356355
*/
357356
void
358-
_PG_init(void)
357+
pg_init_libpagestore(void)
359358
{
360359
DefineCustomStringVariable("neon.pageserver_connstring",
361360
"connection string to the page server",

src/backend/replication/libpqwalproposer/libpqwalproposer.c renamed to contrib/neon/libpqwalproposer.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#include "postgres.h"
22

3-
#include "replication/walproposer.h"
43
#include "libpq-fe.h"
5-
6-
/* Required for anything that's dynamically loaded */
7-
PG_MODULE_MAGIC;
8-
void _PG_init(void);
4+
#include "neon.h"
5+
#include "walproposer.h"
96

107
/* Header in walproposer.h -- Wrapper struct to abstract away the libpq connection */
118
struct WalProposerConn
@@ -46,7 +43,7 @@ static WalProposerFunctionsType PQWalProposerFunctions = {
4643

4744
/* Module initialization */
4845
void
49-
_PG_init(void)
46+
pg_init_libpqwalproposer(void)
5047
{
5148
if (WalProposerFunctions != NULL)
5249
elog(ERROR, "libpqwalproposer already loaded");

contrib/neon/neon.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,24 @@
1717
#include "storage/bufmgr.h"
1818
#include "catalog/pg_type.h"
1919
#include "replication/walsender.h"
20-
#include "replication/walproposer.h"
2120
#include "funcapi.h"
2221
#include "access/htup_details.h"
2322
#include "utils/pg_lsn.h"
2423

24+
#include "neon.h"
25+
#include "walproposer.h"
26+
27+
PG_MODULE_MAGIC;
28+
void _PG_init(void);
29+
30+
31+
void _PG_init(void)
32+
{
33+
pg_init_libpagestore();
34+
pg_init_libpqwalproposer();
35+
pg_init_walproposer();
36+
}
37+
2538
PG_FUNCTION_INFO_V1(pg_cluster_size);
2639
PG_FUNCTION_INFO_V1(backpressure_lsns);
2740

contrib/neon/neon.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* neon.h
4+
* Functions used in the initialization of this extension.
5+
*
6+
* IDENTIFICATION
7+
* contrib/neon/neon.h
8+
*
9+
*-------------------------------------------------------------------------
10+
*/
11+
12+
#ifndef NEON_H
13+
#define NEON_H
14+
15+
extern void pg_init_libpagestore(void);
16+
extern void pg_init_libpqwalproposer(void);
17+
extern void pg_init_walproposer(void);
18+
19+
#endif /* NEON_H */

contrib/neon/pagestore_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ extern void zenith_write(SMgrRelation reln, ForkNumber forknum,
182182
extern void zenith_writeback(SMgrRelation reln, ForkNumber forknum,
183183
BlockNumber blocknum, BlockNumber nblocks);
184184
extern BlockNumber zenith_nblocks(SMgrRelation reln, ForkNumber forknum);
185-
extern int64 zenith_dbsize(Oid dbNode);
185+
extern const int64 zenith_dbsize(Oid dbNode);
186186
extern void zenith_truncate(SMgrRelation reln, ForkNumber forknum,
187187
BlockNumber nblocks);
188188
extern void zenith_immedsync(SMgrRelation reln, ForkNumber forknum);

contrib/neon/pagestore_smgr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ zenith_nblocks(SMgrRelation reln, ForkNumber forknum)
13361336
/*
13371337
* zenith_db_size() -- Get the size of the database in bytes.
13381338
*/
1339-
int64
1339+
const int64
13401340
zenith_dbsize(Oid dbNode)
13411341
{
13421342
ZenithResponse *resp;

0 commit comments

Comments
 (0)