Skip to content

Commit

Permalink
update patch
Browse files Browse the repository at this point in the history
  • Loading branch information
pmp-p committed Aug 26, 2024
1 parent 1b48978 commit d9a92a1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
59 changes: 34 additions & 25 deletions patches/postgresql-emscripten/src-include-port-emscripten.h.diff
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
--- postgresql/src/include/port/emscripten.h
+++ postgresql-wasm/src/include/port/emscripten.h
@@ -0,0 +1,334 @@
@@ -0,0 +1,343 @@
+/* src/include/port/emscripten.h */
+
+#ifndef I_EMSCRIPTEN
+#define I_EMSCRIPTEN
+#include "/tmp/pgdebug.h"
+
+/* --------------- how to configure those when installed ? ---------------- */
+
+// socket emulation via file, need to go in PGDATA for nodefs mount in web mode
+#define PGS_ILOCK "/tmp/pglite/base/.s.PGSQL.5432.lock.in"
+#define PGS_IN "/tmp/pglite/base/.s.PGSQL.5432.in"
+#define PGS_OLOCK "/tmp/pglite/base/.s.PGSQL.5432.lock.out"
+#define PGS_OUT "/tmp/pglite/base/.s.PGSQL.5432.out"
+
+// MEMFS ok files
+
+#define IDB_PIPE_FILE "/tmp/initdb.txt"
+#define IDB_PIPE_BOOT "/tmp/initdb.boot.txt"
+#define IDB_PIPE_SINGLE "/tmp/initdb.single.txt"
+#define PG_DEBUG_HEADER "pg_debug.h"
+
+
+#if defined(PREFIX)
+#define em_xstr(s) em_str(s)
+#define em_str(s) #s
+# define WASM_PREFIX em_xstr(PREFIX)
+# define PG_MAIN_INCLUDE em_xstr(PATCH_MAIN)
+# define PG_PLUGIN_INCLUDE em_xstr(PATCH_PLUGIN
+# undef PG_DEBUG_HEADER
+# define PG_DEBUG_HEADER em_xstr(PATCH_PG_DEBUG)
+#else
+# define WASM_PREFIX "/pgdata"
+# define PG_MAIN_INCLUDE "/pgdata/pg_main.c"
+# define PG_PLUGIN_INCLUDE "/pgdata/pg_plugin.h"
+#endif
+
+#include PG_DEBUG_HEADER
+
+#define PGDLLIMPORT
+
+// #define COPY_INTERNAL
Expand Down Expand Up @@ -61,29 +93,6 @@
+
+
+
+#if defined(PREFIX)
+#define em_xstr(s) em_str(s)
+#define em_str(s) #s
+# define WASM_PREFIX em_xstr(PREFIX)
+# define PG_MAIN_INCLUDE em_xstr(PATCH_MAIN)
+# define PG_PLUGIN_INCLUDE em_xstr(PATCH_PLUGIN)
+#else
+# define WASM_PREFIX "/pgdata"
+# define PG_MAIN_INCLUDE "/data/git/pg/pg_main.c"
+# define PG_PLUGIN_INCLUDE "/data/git/pg/pg_plugin.h"
+#endif
+
+// socket emulation via file, need to go in PGDATA for nodefs mount in web mode
+#define PGS_ILOCK "/tmp/pglite/base/.s.PGSQL.5432.lock.in"
+#define PGS_IN "/tmp/pglite/base/.s.PGSQL.5432.in"
+#define PGS_OLOCK "/tmp/pglite/base/.s.PGSQL.5432.lock.out"
+#define PGS_OUT "/tmp/pglite/base/.s.PGSQL.5432.out"
+
+// MEMFS ok files
+
+#define IDB_PIPE_FILE "/tmp/initdb.txt"
+#define IDB_PIPE_BOOT "/tmp/initdb.boot.txt"
+#define IDB_PIPE_SINGLE "/tmp/initdb.single.txt"
+
+
+#define PG_FORCE_DISABLE_INLINE
Expand Down
2 changes: 1 addition & 1 deletion patches/postgresql-wasm/src-backend-catalog-index.c.diff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- postgresql/src/backend/catalog/index.c
+++ postgresql-wasm/src/backend/catalog/index.c
@@ -2994,7 +2994,7 @@
@@ -2995,7 +2995,7 @@
indexInfo->ii_ParallelWorkers =
plan_create_index_workers(RelationGetRelid(heapRelation),
RelationGetRelid(indexRelation));
Expand Down
4 changes: 2 additions & 2 deletions patches/postgresql-wasm/src-backend-tcop-postgres.c.diff
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
--- postgresql/src/backend/tcop/postgres.c
+++ postgresql-wasm/src/backend/tcop/postgres.c
@@ -3988,7 +3988,11 @@
@@ -4052,7 +4052,11 @@
#endif
}

-
+#if defined(__EMSCRIPTEN__) || defined(__wasi__)
+#define PG_MAIN
Expand Down

0 comments on commit d9a92a1

Please sign in to comment.