Skip to content

Commit 67a8545

Browse files
committed
PGCRYPTO env bool
1 parent 5a5af79 commit 67a8545

24 files changed

+211
-202
lines changed

ci-alpine-proot.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export WORKSPACE=$(pwd)
1616

1717
export WASI=${WASI:-false}
1818

19+
export PGCRYPTO=${PGCRYPTO:-false}
1920

2021
if $WASI
2122
then
@@ -64,7 +65,7 @@ fi
6465

6566
mkdir -p $CONTAINER_PATH/tmp
6667

67-
#TODO: pglite has .buildconfig in postgres source dir instead.
68+
#TODO: pglite has .buildconfig in postgres-pglite source dir instead.
6869
cat > $CONTAINER_PATH/tmp/portable.opts <<END
6970
export PG_VERSION=${PG_VERSION}
7071
export PG_BRANCH=${PG_BRANCH}
@@ -78,6 +79,7 @@ export WASI=${WASI}
7879
export NATIVE=${NATIVE}
7980
8081
export PGROOT=/tmp/pglite
82+
export PGCRYPTO=${PGCRYPTO}
8183
export USE_ICU=${USE_ICU}
8284
export GETZIC=${GETZIC}
8385
export ZIC=${ZIC}

patches-REL_17_5_WASM/postgresql-emscripten/src-Makefile.shlib.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--- REL_17_5_WASM/src/Makefile.shlib
2-
+++ pglite-REL_17_5_WASM/src/Makefile.shlib
2+
+++ REL_17_5_WASM-pglite/src/Makefile.shlib
33
@@ -224,6 +224,33 @@
44
override CXXFLAGS += $(CXXFLAGS_SL_MODULE)
55
endif

patches-REL_17_5_WASM/postgresql-emscripten/src-backend-commands-async.c.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--- REL_17_5_WASM/src/backend/commands/async.c
2-
+++ pglite-REL_17_5_WASM/src/backend/commands/async.c
2+
+++ REL_17_5_WASM-pglite/src/backend/commands/async.c
33
@@ -1651,8 +1651,12 @@
44
* NotifyQueueLock; which is unlikely but certainly possible. So we
55
* just log a low-level debug message if it happens.

patches-REL_17_5_WASM/postgresql-emscripten/src-backend-storage-ipc-sinvaladt.c.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--- REL_17_5_WASM/src/backend/storage/ipc/sinvaladt.c
2-
+++ pglite-REL_17_5_WASM/src/backend/storage/ipc/sinvaladt.c
2+
+++ REL_17_5_WASM-pglite/src/backend/storage/ipc/sinvaladt.c
33
@@ -289,6 +289,7 @@
44
*/
55
LWLockAcquire(SInvalWriteLock, LW_EXCLUSIVE);

patches-REL_17_5_WASM/postgresql-pglite/src-backend-libpq-pqcomm.c.diff

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--- REL_17_5_WASM/src/backend/libpq/pqcomm.c
2-
+++ pglite-REL_17_5_WASM/src/backend/libpq/pqcomm.c
2+
+++ REL_17_5_WASM-pglite/src/backend/libpq/pqcomm.c
33
@@ -131,8 +131,15 @@
44
static char *PqRecvBuffer;
55
static int PqRecvPointer;
@@ -16,15 +16,6 @@
1616
/*
1717
* Message status
1818
*/
19-
@@ -282,7 +289,7 @@
20-
(void) pq_settcpusertimeout(tcp_user_timeout, port);
21-
}
22-
#endif /* WASM */
23-
-PDEBUG("# 285:" __FILE__);
24-
+PDEBUG("# 287:" __FILE__);
25-
/* initialize state variables */
26-
PqSendBufferSize = PQ_SEND_BUFFER_SIZE;
27-
PqSendBuffer = MemoryContextAlloc(TopMemoryContext, PqSendBufferSize);
2819
@@ -320,9 +327,7 @@
2920
AddWaitEventToSet(FeBeWaitSet, WL_POSTMASTER_DEATH, PGINVALID_SOCKET,
3021
NULL, NULL);
Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,61 @@
11
--- REL_17_5_WASM/src/backend/utils/error/elog.c
2-
+++ pglite-REL_17_5_WASM/src/backend/utils/error/elog.c
3-
@@ -543,13 +543,8 @@
2+
+++ REL_17_5_WASM-pglite/src/backend/utils/error/elog.c
3+
@@ -348,12 +348,16 @@
4+
ErrorData *edata;
5+
bool output_to_server;
6+
bool output_to_client = false;
7+
+#if defined(__EMSCRIPTEN__) || defined(__wasi__)
8+
+# warning "FIXME: error levels"
9+
+#else
10+
int i;
11+
12+
/*
13+
* Check some cases in which we want to promote an error into a more
14+
* severe error. None of this logic applies for non-error messages.
15+
*/
16+
+
17+
if (elevel >= ERROR)
18+
{
19+
/*
20+
@@ -394,7 +398,7 @@
21+
for (i = 0; i <= errordata_stack_depth; i++)
22+
elevel = Max(elevel, errordata[i].elevel);
23+
}
24+
-
25+
+#endif
26+
/*
27+
* Now decide whether we need to process this report at all; if it's
28+
* warning or less and not enabled for logging, just return false without
29+
@@ -539,7 +543,12 @@
430
*/
531

632
recursion_depth--;
7-
-#if 0 //defined(__EMSCRIPTEN__) || defined(__wasi__)
8-
- fprintf(stderr, "# 547: PG_RE_THROW(ERROR : %d) ignored\n", recursion_depth);
9-
- trap();
10-
-#else
11-
fprintf(stderr, "# 549: PG_RE_THROW(ERROR : %d)\n", recursion_depth);
33+
+#if defined(__wasi__)
34+
+ fprintf(stderr, "# 547: PG_RE_THROW(ERROR : %d) ignored\r\n", recursion_depth);
35+
+ abort();
36+
+#else
1237
PG_RE_THROW();
13-
-#endif
38+
+#endif
1439
}
1540

1641
/* Emit the message to the right places */
42+
@@ -587,7 +596,11 @@
43+
* FATAL termination. The postmaster may or may not consider this
44+
* worthy of panic, depending on which subprocess returns it.
45+
*/
46+
+#if defined(__EMSCRIPTEN__) || defined(__wasi__)
47+
+ puts("# 600: proc_exit(FATAL) ignored\r\n");
48+
+#else
49+
proc_exit(1);
50+
+#endif
51+
}
52+
53+
if (elevel >= PANIC)
54+
@@ -697,6 +710,7 @@
55+
*/
56+
if (edata->elevel >= ERROR)
57+
{
58+
+puts("#712");
59+
errfinish(filename, lineno, funcname);
60+
pg_unreachable();
61+
}

patches-REL_17_5_WASM/postgresql-pglite/src-bin-initdb-initdb.c.diff

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--- REL_17_5_WASM/src/bin/initdb/initdb.c
2-
+++ pglite-REL_17_5_WASM/src/bin/initdb/initdb.c
2+
+++ REL_17_5_WASM-pglite/src/bin/initdb/initdb.c
33
@@ -171,7 +171,11 @@
44

55

@@ -41,7 +41,7 @@
4141
#if defined(HAVE_SHM_OPEN) && !defined(__sun__)
4242
int ntries = 10;
4343
pg_prng_state prng_state;
44-
@@ -1608,10 +1620,9 @@
44+
@@ -1608,10 +1620,8 @@
4545
}
4646

4747
PG_CMD_CLOSE();
@@ -50,11 +50,10 @@
5050
+ termPQExpBuffer(&cmd);
5151
free(bki_lines);
5252
-
53-
+PDEBUG("# 1624: BOOT pipe complete");
5453
check_ok();
5554
}
5655

57-
@@ -1711,16 +1722,16 @@
56+
@@ -1711,16 +1721,16 @@
5857
setup_run_file(FILE *cmdfd, const char *filename)
5958
{
6059
char **lines;
@@ -74,7 +73,7 @@
7473

7574
free(lines);
7675
}
77-
@@ -2636,8 +2647,13 @@
76+
@@ -2636,8 +2646,13 @@
7877
strlcpy(full_path, progname, sizeof(full_path));
7978

8079
if (ret == -1)
@@ -88,21 +87,7 @@
8887
else
8988
pg_fatal("program \"%s\" was found by \"%s\" but was not the same version as %s",
9089
"postgres", full_path, progname);
91-
@@ -3096,7 +3112,7 @@
92-
initPQExpBuffer(&cmd);
93-
printfPQExpBuffer(&cmd, "\"%s\" %s %s template1 >%s",
94-
backend_exec, backend_options, extra_options, DEVNULL);
95-
-
96-
+PDEBUG("# 3115: post-bootstrap sql begin");
97-
PG_CMD_OPEN(cmd.data);
98-
99-
setup_auth(cmdfd);
100-
@@ -3134,14 +3150,53 @@
101-
102-
PG_CMD_CLOSE();
103-
termPQExpBuffer(&cmd);
104-
-
105-
+PDEBUG("# 3115: post-bootstrap sql end");
90+
@@ -3138,10 +3153,49 @@
10691
check_ok();
10792
}
10893

@@ -154,7 +139,7 @@
154139
static struct option long_options[] = {
155140
{"pgdata", required_argument, NULL, 'D'},
156141
{"encoding", required_argument, NULL, 'E'},
157-
@@ -3201,9 +3256,15 @@
142+
@@ -3201,9 +3255,15 @@
158143
* POSIX says we must do this before any other usage of these files.
159144
*/
160145
setvbuf(stdout, NULL, PG_IOLBF, 0);
@@ -171,32 +156,28 @@
171156
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("initdb"));
172157

173158
if (argc > 1)
174-
@@ -3409,7 +3470,7 @@
159+
@@ -3409,7 +3469,10 @@
175160
if (icu_rules && locale_provider != COLLPROVIDER_ICU)
176161
pg_fatal("%s cannot be specified unless locale provider \"%s\" is chosen",
177162
"--icu-rules", "icu");
178163
-
179-
+PDEBUG("# 3463:"__FILE__ " TODO: atexit(cleanup_directories_atexit)");
164+
+#if defined(__wasi__) || defined(__EMSCRIPTEN__)
165+
+#pragma message "#TODO: atexit(cleanup_directories_atexit)"
166+
+PDEBUG("# 3472:"__FILE__ "#TODO: atexit(cleanup_directories_atexit)");
167+
+#endif
180168
atexit(cleanup_directories_atexit);
181169

182170
/* If we only need to sync, just do it and exit */
183-
@@ -3445,13 +3506,13 @@
171+
@@ -3445,9 +3508,7 @@
184172
get_restricted_token();
185173

186174
setup_pgdata();
187175
-
188-
+PDEBUG("# 3493:pgl_initdb_main " __FILE__);
189176
setup_bin_paths(argv[0]);
190177
-
191-
+PDEBUG("# 3495:pgl_initdb_main " __FILE__);
192178
effective_user = get_id();
193179
if (!username)
194180
username = effective_user;
195-
-
196-
+PDEBUG("# 3514:pgl_initdb_main " __FILE__);
197-
if (strncmp(username, "pg_", 3) == 0)
198-
pg_fatal("superuser name \"%s\" is disallowed; role names cannot begin with \"pg_\"", username);
199-
200181
@@ -3479,7 +3540,7 @@
201182
get_su_pwd();
202183

@@ -206,12 +187,11 @@
206187
initialize_data_directory();
207188

208189
if (do_sync)
209-
@@ -3535,7 +3596,7 @@
190+
@@ -3535,7 +3596,6 @@
210191
destroyPQExpBuffer(start_db_cmd);
211192
}
212193

213194
-
214-
+PDEBUG("# 3583");
215195
success = true;
216196
return 0;
217197
}

patches-REL_17_5_WASM/postgresql-pglite/src-interfaces-libpq-fe-auth.c.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--- REL_17_5_WASM/src/interfaces/libpq/fe-auth.c
2-
+++ pglite-REL_17_5_WASM/src/interfaces/libpq/fe-auth.c
2+
+++ REL_17_5_WASM-pglite/src/interfaces/libpq/fe-auth.c
33
@@ -1169,6 +1169,7 @@
44
pg_fe_getusername(uid_t user_id, PQExpBuffer errorMessage)
55
{
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
--- REL_17_5_WASM/src/port/pqsignal.c
2-
+++ pglite-REL_17_5_WASM/src/port/pqsignal.c
3-
@@ -174,7 +174,13 @@
2+
+++ REL_17_5_WASM-pglite/src/port/pqsignal.c
3+
@@ -174,3 +174,13 @@
44
#endif
55
}
66

7-
-/* sneak stubs into libpgport */
8-
-#if defined(__wasi__)
9-
-# include "../../../patches/wasi_port.c"
107
+/* sneak emsdk or wasi wasm port support into libpgport */
118
+#if defined(SDK_PORT)
129
+# if defined(__wasi__)
@@ -15,5 +12,5 @@
1512
+# if defined(__EMSCRIPTEN__)
1613
+// # include "sdk_port-emscripten.c"
1714
+# endif
18-
#endif
15+
+#endif
1916
+
Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--- REL_17_5_WASM/src/bin/pg_dump/pg_dump.c
2-
+++ pglite-REL_17_5_WASM/src/bin/pg_dump/pg_dump.c
2+
+++ REL_17_5_WASM-pglite/src/bin/pg_dump/pg_dump.c
33
@@ -30,13 +30,6 @@
44
*-------------------------------------------------------------------------
55
*/
@@ -14,16 +14,47 @@
1414

1515
#include <unistd.h>
1616
#include <ctype.h>
17-
@@ -432,7 +425,7 @@
17+
@@ -76,6 +69,30 @@
18+
#include "pg_dump.h"
19+
#include "storage/block.h"
20+
21+
+#if !defined(__wasi__) && !defined(__EMSCRIPTEN__)
22+
+extern PGDLLIMPORT bool fe_utils_quote_all_identifiers;
23+
+#else
24+
+#if defined(WASM)
25+
+#ifdef errno
26+
+ #undef errno
27+
+ int errno;
28+
+#endif
29+
+
30+
+pid_t fork(void) {
31+
+ return -1;
32+
+}
33+
+
34+
+# include <wasi/api.h>
35+
+
36+
+__attribute__((export_name("sdk_fd_seek")))
37+
+int sdk_fd_seek(int fd, int offset,int whence, unsigned long long *retptr) {
38+
+ puts("sdk_fd_seek called !");
39+
+ return __wasi_fd_seek(fd, offset, whence, retptr);
40+
+}
41+
+
42+
+#endif
43+
+#endif
44+
+
45+
typedef struct
46+
{
47+
Oid roleoid; /* role's OID */
48+
@@ -432,7 +449,7 @@
1849
{"lock-wait-timeout", required_argument, NULL, 2},
1950
{"no-table-access-method", no_argument, &dopt.outputNoTableAm, 1},
2051
{"no-tablespaces", no_argument, &dopt.outputNoTablespaces, 1},
21-
- {"quote-all-identifiers", no_argument, &fe_utils_quote_all_identifiers, true},
22-
+ {"quote-all-identifiers", no_argument, &fe_utils_quote_all_identifiers, 1},
52+
- {"quote-all-identifiers", no_argument, (int *)(&fe_utils_quote_all_identifiers), true},
53+
+ {"quote-all-identifiers", no_argument, (int *)(&fe_utils_quote_all_identifiers), 1},
2354
{"load-via-partition-root", no_argument, &dopt.load_via_partition_root, 1},
2455
{"role", required_argument, NULL, 3},
2556
{"section", required_argument, NULL, 5},
26-
@@ -459,9 +452,7 @@
57+
@@ -459,9 +476,7 @@
2758

2859
{NULL, 0, NULL, 0}
2960
};
@@ -34,7 +65,7 @@
3465
pg_logging_init(argv[0]);
3566
pg_logging_set_level(PG_LOG_WARNING);
3667
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_dump"));
37-
@@ -838,17 +829,15 @@
68+
@@ -838,12 +853,13 @@
3869
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
3970

4071
fout->numWorkers = numWorkers;
@@ -44,26 +75,8 @@
4475
* Open the database using the Archiver, so it knows about it. Errors mean
4576
* death.
4677
*/
47-
-puts("# 813 : " __FILE__ "\r\n");
48-
- //setup();
4978
ConnectDatabase(fout, &dopt.cparams, false);
50-
-puts("# 815 : " __FILE__ "\r\n");
5179
+puts("# 838:" __FILE__ ": ConnectDatabase->setup_connection\r\n");
5280
setup_connection(fout, dumpencoding, dumpsnapshot, use_role);
53-
-puts("# 817 : " __FILE__ "\r\n");
54-
+
55-
/*
56-
* On hot standbys, never try to dump unlogged table data, since it will
57-
* just throw an error.
58-
@@ -1203,10 +1192,9 @@
59-
const char *dumpsnapshot, char *use_role)
60-
{
61-
DumpOptions *dopt = AH->dopt;
62-
-puts("# 1206 : get_connection : "__FILE__);
63-
PGconn *conn = GetConnection(AH);
64-
const char *std_strings;
65-
-puts("# 1209 : setup_connection");
66-
+
67-
PQclear(ExecuteSqlQueryForSingleRow(AH, ALWAYS_SECURE_SEARCH_PATH_SQL));
6881

6982
/*

0 commit comments

Comments
 (0)