mirror of
https://github.com/neondatabase/neon.git
synced 2026-06-02 04:50:38 +00:00
Compile walproposer
This commit is contained in:
6
Makefile
6
Makefile
@@ -136,6 +136,12 @@ neon-pg-ext-%: postgres-%
|
||||
-C $(POSTGRES_INSTALL_DIR)/build/neon-test-utils-$* \
|
||||
-f $(ROOT_PROJECT_DIR)/pgxn/neon_test_utils/Makefile install
|
||||
|
||||
.PHONY:
|
||||
neon-pg-ext-walproposer:
|
||||
$(MAKE) PG_CONFIG=$(POSTGRES_INSTALL_DIR)/v15/bin/pg_config CFLAGS='$(PG_CFLAGS) $(COPT)' \
|
||||
-C $(POSTGRES_INSTALL_DIR)/build/neon-v15 \
|
||||
-f $(ROOT_PROJECT_DIR)/pgxn/neon/Makefile install
|
||||
|
||||
.PHONY: neon-pg-ext-clean-%
|
||||
neon-pg-ext-clean-%:
|
||||
$(MAKE) PG_CONFIG=$(POSTGRES_INSTALL_DIR)/$*/bin/pg_config \
|
||||
|
||||
@@ -14,3 +14,5 @@
|
||||
|
||||
int TestFunc(int a, int b);
|
||||
void RunClientC(uint32_t serverId);
|
||||
|
||||
void WalProposerRust();
|
||||
@@ -24,7 +24,7 @@ fn main() -> anyhow::Result<()> {
|
||||
// println!("cargo:rustc-link-lib=pgcommon_srv");
|
||||
// println!("cargo:rustc-link-lib=pgport_srv");
|
||||
println!("cargo:rustc-link-arg=-Wl,--start-group");
|
||||
println!("cargo:rustc-link-arg=-lwalproposer");
|
||||
println!("cargo:rustc-link-arg=-lsim");
|
||||
println!("cargo:rustc-link-arg=-lpgport_srv");
|
||||
println!("cargo:rustc-link-arg=-lpostgres");
|
||||
println!("cargo:rustc-link-arg=-lpgcommon_srv");
|
||||
@@ -35,6 +35,7 @@ fn main() -> anyhow::Result<()> {
|
||||
println!("cargo:rustc-link-arg=-lrt");
|
||||
println!("cargo:rustc-link-arg=-ldl");
|
||||
println!("cargo:rustc-link-arg=-lm");
|
||||
println!("cargo:rustc-link-arg=-lwalproposer");
|
||||
println!("cargo:rustc-link-arg=-Wl,--end-group");
|
||||
// println!("cargo:rustc-flags=-C default-linker-libraries=y");
|
||||
|
||||
@@ -126,6 +127,7 @@ fn main() -> anyhow::Result<()> {
|
||||
.parse_callbacks(Box::new(CargoCallbacks))
|
||||
.allowlist_function("TestFunc")
|
||||
.allowlist_function("RunClientC")
|
||||
.allowlist_function("WalProposerRust")
|
||||
// .allowlist_function("WalProposerRust")
|
||||
// .clang_arg(format!("-I{inc_server_path}"))
|
||||
// .clang_arg(format!("-I{inc_pgxn_path}"))
|
||||
|
||||
@@ -3,15 +3,17 @@ set -e
|
||||
|
||||
# TODO: rewrite to Makefile
|
||||
|
||||
# make -C ../../ neon-pg-ext-v15 -s
|
||||
make -C ../../ neon-pg-ext-walproposer -s
|
||||
# make -C ../../pg_install/build/v15/src/backend postgres-lib -s
|
||||
cp ../../pg_install/build/v15/src/backend/libpostgres.a .
|
||||
cp ../../pg_install/build/v15/src/common/libpgcommon_srv.a .
|
||||
cp ../../pg_install/build/v15/src/port/libpgport_srv.a .
|
||||
|
||||
clang -g -c -o test.o test.c -ferror-limit=1 -I ../../pg_install/v15/include/postgresql/server
|
||||
rm -rf libwalproposer.a
|
||||
ar rcs libwalproposer.a test.o
|
||||
clang -g -c libpqwalproposer.c test.c -ferror-limit=1 -I ../../pg_install/v15/include/postgresql/server -I ../../pgxn/neon
|
||||
rm -rf libsim.a
|
||||
ar rcs libsim.a test.o libpqwalproposer.o
|
||||
|
||||
rm -rf libwalproposer2.a
|
||||
ar rcs libwalproposer2.a ../../pg_install/build/neon-v15/*.o
|
||||
rm -rf libwalproposer.a
|
||||
|
||||
PGXN_DIR=../../pg_install/build/neon-v15/
|
||||
ar rcs libwalproposer.a $PGXN_DIR/walproposer.o $PGXN_DIR/walproposer_utils.o $PGXN_DIR/neon.o
|
||||
|
||||
110
libs/walproposer/libpqwalproposer.c
Normal file
110
libs/walproposer/libpqwalproposer.c
Normal file
@@ -0,0 +1,110 @@
|
||||
#include "postgres.h"
|
||||
#include "neon.h"
|
||||
#include "walproposer.h"
|
||||
|
||||
/* Header in walproposer.h -- Wrapper struct to abstract away the libpq connection */
|
||||
struct WalProposerConn
|
||||
{
|
||||
};
|
||||
|
||||
/* Helper function */
|
||||
static bool
|
||||
ensure_nonblocking_status(WalProposerConn *conn, bool is_nonblocking)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Exported function definitions */
|
||||
char *
|
||||
walprop_error_message(WalProposerConn *conn)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WalProposerConnStatusType
|
||||
walprop_status(WalProposerConn *conn)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return WP_CONNECTION_OK;
|
||||
}
|
||||
|
||||
WalProposerConn *
|
||||
walprop_connect_start(char *conninfo)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WalProposerConnectPollStatusType
|
||||
walprop_connect_poll(WalProposerConn *conn)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return WP_CONN_POLLING_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
walprop_send_query(WalProposerConn *conn, char *query)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
WalProposerExecStatusType
|
||||
walprop_get_query_result(WalProposerConn *conn)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return WP_EXEC_SUCCESS_COPYBOTH;
|
||||
}
|
||||
|
||||
pgsocket
|
||||
walprop_socket(WalProposerConn *conn)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
walprop_flush(WalProposerConn *conn)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
walprop_finish(WalProposerConn *conn)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
}
|
||||
|
||||
/*
|
||||
* Receive a message from the safekeeper.
|
||||
*
|
||||
* On success, the data is placed in *buf. It is valid until the next call
|
||||
* to this function.
|
||||
*/
|
||||
PGAsyncReadResult
|
||||
walprop_async_read(WalProposerConn *conn, char **buf, int *amount)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return PG_ASYNC_READ_FAIL;
|
||||
}
|
||||
|
||||
PGAsyncWriteResult
|
||||
walprop_async_write(WalProposerConn *conn, void const *buf, size_t size)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return PG_ASYNC_WRITE_FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is very similar to walprop_async_write. For more
|
||||
* information, refer to the comments there.
|
||||
*/
|
||||
bool
|
||||
walprop_blocking_write(WalProposerConn *conn, void const *buf, size_t size)
|
||||
{
|
||||
elog(INFO, "not implemented");
|
||||
return false;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::bindings::{TestFunc, RunClientC};
|
||||
use crate::bindings::{TestFunc, RunClientC, WalProposerRust};
|
||||
|
||||
#[test]
|
||||
fn test_rust_c_calls() {
|
||||
@@ -8,5 +8,6 @@ fn test_rust_c_calls() {
|
||||
|
||||
#[test]
|
||||
fn test_sim_bindings() {
|
||||
unsafe { RunClientC(0); }
|
||||
// unsafe { RunClientC(0); }
|
||||
unsafe { WalProposerRust(); }
|
||||
}
|
||||
|
||||
@@ -318,6 +318,7 @@ nwp_shmem_startup_hook(void)
|
||||
|
||||
void WalProposerRust()
|
||||
{
|
||||
MemoryContextInit();
|
||||
elog(LOG, "WalProposerRust");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user