Skip to content

Commit ff44835

Browse files
committed
CI test
1 parent 23a9e2c commit ff44835

File tree

6 files changed

+220
-16
lines changed

6 files changed

+220
-16
lines changed

extra/pg_uuidv7.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
. wasm-build/extension.sh
4+
5+
pushd $PG_EXTRA
6+
if [ -d pg_uuiv7 ]
7+
then
8+
echo using local pg_uuiv7
9+
else
10+
wget https://github.com/fboulnois/pg_uuidv7/archive/refs/tags/v1.6.0.tar.gz -O-|tar xfz -
11+
mv pg_uuidv7-*.*.* pg_uuiv7
12+
if $WASI
13+
then
14+
echo "no patching"
15+
else
16+
echo "PATCH?"
17+
18+
fi
19+
fi
20+
popd
21+
22+
pushd $PG_EXTRA/pg_uuiv7
23+
PG_CONFIG=${PGROOT}/bin/pg_config emmake make OPTFLAGS="" install || exit 25
24+
popd
25+
26+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--- REL_17_5_WASM/src/bin/pg_dump/pg_dump.c
2+
+++ pglite-REL_17_5_WASM/src/bin/pg_dump/pg_dump.c
3+
@@ -843,12 +843,12 @@
4+
* Open the database using the Archiver, so it knows about it. Errors mean
5+
* death.
6+
*/
7+
-puts("# 813 : " __FILE__);
8+
+puts("# 813 : " __FILE__ "\r\n");
9+
//setup();
10+
ConnectDatabase(fout, &dopt.cparams, false);
11+
-puts("# 815 : " __FILE__);
12+
+puts("# 815 : " __FILE__ "\r\n");
13+
setup_connection(fout, dumpencoding, dumpsnapshot, use_role);
14+
-puts("# 817 : " __FILE__);
15+
+puts("# 817 : " __FILE__ "\r\n");
16+
/*
17+
* On hot standbys, never try to dump unlogged table data, since it will
18+
* just throw an error.
19+
@@ -1295,7 +1295,7 @@
20+
* Quote all identifiers, if requested.
21+
*/
22+
if (fe_utils_quote_all_identifiers)
23+
- ExecuteSqlStatement(AH, "SET fe_utils_quote_all_identifiers = true");
24+
+ ExecuteSqlStatement(AH, "SET quote_all_identifiers = true");
25+
26+
/*
27+
* Adjust row-security mode, if supported.
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
--- REL_17_5_WASM/src/interfaces/libpq/fe-connect.c
2+
+++ pglite-REL_17_5_WASM/src/interfaces/libpq/fe-connect.c
3+
@@ -2480,7 +2480,7 @@
4+
int timeout = 0;
5+
int last_whichhost = -2; /* certainly different from whichhost */
6+
int last_whichaddr = -2; /* certainly different from whichaddr */
7+
-PDEBUG("# 2420: connectDBComplete Begin " __FILE__ );
8+
+PDEBUG("# 2483: connectDBComplete Begin " __FILE__ "\r\n");
9+
if (conn == NULL || conn->status == CONNECTION_BAD)
10+
return 0;
11+
12+
@@ -2492,6 +2492,7 @@
13+
if (!pqParseIntParam(conn->connect_timeout, &timeout, conn,
14+
"connect_timeout"))
15+
{
16+
+PDEBUG("# 2495: CONNECTION_BAD\r\n");
17+
/* mark the connection as bad to report the parsing failure */
18+
conn->status = CONNECTION_BAD;
19+
return 0;
20+
@@ -2516,7 +2517,7 @@
21+
last_whichhost = conn->whichhost;
22+
last_whichaddr = conn->whichaddr;
23+
}
24+
-printf("# 2476: switch (%d) PGRES_POLLING_OK=%d PGRES_POLLING_READING=%d PGRES_POLLING_WRITING=%d\n", flag, PGRES_POLLING_OK, PGRES_POLLING_READING,PGRES_POLLING_WRITING);
25+
+printf("# 2519: switch (%d) PGRES_POLLING_OK=%d PGRES_POLLING_READING=%d PGRES_POLLING_WRITING=%d\r\n", flag, PGRES_POLLING_OK, PGRES_POLLING_READING,PGRES_POLLING_WRITING);
26+
if(!flag) abort();
27+
/*
28+
* Wait, if necessary. Note that the initial state (just after
29+
@@ -2528,7 +2529,7 @@
30+
return 1; /* success! */
31+
32+
case PGRES_POLLING_READING:
33+
-#if !defined(__wasi__)
34+
+#if !defined(__wasi__) && !defined(__EMSCRIPTEN__)
35+
ret = pqWaitTimed(1, 0, conn, end_time);
36+
if (ret == -1)
37+
{
38+
@@ -2550,7 +2551,11 @@
39+
break;
40+
41+
default:
42+
-PDEBUG("# 2508: CONNECTION_BAD");
43+
+PDEBUG("# 2553: CONNECTION_BAD\r\n");
44+
+#if defined(__EMSCRIPTEN__)
45+
+conn->status = CONNECTION_CHECK_TARGET;
46+
+return 1;
47+
+#endif
48+
/* Just in case we failed to set it in PQconnectPoll */
49+
conn->status = CONNECTION_BAD;
50+
return 0;
51+
@@ -2558,12 +2563,17 @@
52+
53+
if (ret == 1) /* connect_timeout elapsed */
54+
{
55+
-PDEBUG("# 2535: timeout !");
56+
+PDEBUG("# 2561: timeout !\r\n");
57+
/*
58+
* Give up on current server/address, try the next one.
59+
*/
60+
+#if defined(__EMSCRIPTEN__)
61+
+PDEBUG("# 2566: FATAL !\r\n");
62+
+ return 0;
63+
+#else
64+
conn->try_next_addr = true;
65+
conn->status = CONNECTION_NEEDED;
66+
+#endif
67+
}
68+
69+
/*
70+
@@ -2618,13 +2628,13 @@
71+
/* Get the new data */
72+
switch (conn->status)
73+
{
74+
-printf("# 2577: conn->status(%d)\n", conn->status );
75+
+printf("# 2626: conn->status(%d)\r\n", conn->status );
76+
/*
77+
* We really shouldn't have been polled in these two cases, but we
78+
* can handle it.
79+
*/
80+
case CONNECTION_BAD:
81+
-PDEBUG("# FSM2580: CONNECTION_BAD");
82+
+PDEBUG("# FSM2580: CONNECTION_BAD\r\n");
83+
return PGRES_POLLING_FAILED;
84+
case CONNECTION_OK:
85+
return PGRES_POLLING_OK;
86+
@@ -2638,14 +2648,14 @@
87+
{
88+
/* Load waiting data */
89+
#if defined(__wasi__)
90+
- puts("# 2597: CONNECTION_CHECK_STANDBY -> ?????");
91+
+ puts("# 2646: CONNECTION_CHECK_STANDBY -> ?????\r\n");
92+
int n = pqReadData(conn);
93+
if (!n) {
94+
puts("YIELD!");
95+
sched_yield();
96+
}
97+
98+
- printf("# 2604: pqReadData-> %d\n", n);
99+
+ printf("# 2653: pqReadData-> %d\r\n", n);
100+
#else
101+
int n = pqReadData(conn);
102+
#endif
103+
@@ -2677,11 +2687,11 @@
104+
105+
keep_going: /* We will come back to here until there is
106+
* nothing left to do. */
107+
-PDEBUG("# 2615: keep_going");
108+
+PDEBUG("# 2685: keep_going\r\n");
109+
/* Time to advance to next address, or next host if no more addresses? */
110+
if (conn->try_next_addr)
111+
{
112+
-PDEBUG("# 2615: keep_going -> try_next_addr ");
113+
+PDEBUG("# 2689: keep_going -> try_next_addr\r\n");
114+
if (conn->whichaddr < conn->naddr)
115+
{
116+
conn->whichaddr++;
117+
@@ -2696,7 +2706,7 @@
118+
/* Time to advance to next connhost[] entry? */
119+
if (conn->try_next_host)
120+
{
121+
-PDEBUG("# 2615: keep_going -> try_next_host ");
122+
+PDEBUG("# 2704: keep_going -> try_next_host\r\n");
123+
pg_conn_host *ch;
124+
struct addrinfo hint;
125+
struct addrinfo *addrlist;
126+
@@ -3233,7 +3243,7 @@
127+
128+
case CONNECTION_STARTED:
129+
{
130+
-puts("# 3168: CONNECTION_STARTED");
131+
+puts("# 3241: CONNECTION_STARTED\r\n");
132+
socklen_t optlen = sizeof(optval);
133+
134+
/*
135+
@@ -3245,7 +3255,7 @@
136+
* Now check (using getsockopt) that there is not an error
137+
* state waiting for us on the socket.
138+
*/
139+
-#if !defined(__wasi__)
140+
+#if !defined(__wasi__) && !defined(__EMSCRIPTEN__)
141+
if (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,
142+
(char *) &optval, &optlen) == -1)
143+
{

pglite-REL_17_4_WASM/build.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,19 @@ ________________________________________________________
236236
LINK_ICU=""
237237
fi
238238

239+
239240
if ${CC} ${CC_PGLITE} ${PGINC} -o ${BUILD_PATH}/pglite.o -c ${WORKSPACE}/pglite-${PG_BRANCH}/pg_main.c \
240241
-Wno-incompatible-pointer-types-discards-qualifiers
241242
then
242243
echo " * linking node raw version of pglite ${PG_BRANCH} (with all symbols)"
243244

245+
# wgpu ???
246+
export EMCC_FORCE_STDLIBS=1
247+
244248
if COPTS="-O2 -g3 --no-wasm-opt" ${CC} ${CC_PGLITE} ${PGINC} -o ${PGL_DIST_JS}/pglite-js.js \
245249
-sGLOBAL_BASE=${CMA_MB}MB -ferror-limit=1 \
246250
-sFORCE_FILESYSTEM=1 $EMCC_NODE -sMAIN_MODULE=1 -sEXPORT_ALL -sASSERTIONS=0 \
247-
-sALLOW_TABLE_GROWTH -sALLOW_MEMORY_GROWTH -sERROR_ON_UNDEFINED_SYMBOLS \
251+
-sALLOW_TABLE_GROWTH -sALLOW_MEMORY_GROWTH -sERROR_ON_UNDEFINED_SYMBOLS=0 \
248252
-sEXPORTED_RUNTIME_METHODS=${EXPORTED_RUNTIME_METHODS} \
249253
${BUILD_PATH}/pglite.o \
250254
$LIBPGCORE \
@@ -259,6 +263,10 @@ ________________________________________________________
259263

260264
fi
261265

266+
if $DEBUG
267+
then
268+
unset EMCC_FORCE_STDLIBS
269+
fi
262270

263271
echo "
264272

pglite-REL_17_4_WASM/repl.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,15 +827,15 @@
827827
FS.rename(pg_lck, pg_in)
828828
console.log("send_to_pglite(sf):", count)
829829
Module._interactive_one()
830-
try {
830+
if (os.FS.analyzePath(pg_in).exists) {
831831
const fstat = FS.stat(pg_out)
832832
console.log("pgreply", fstat.size)
833833
var stream = FS.open(pg_out, 'r');
834834
buf = new Uint8Array(fstat.size);
835835
FS.read(stream, buf, 0, fstat.size, 0);
836836
FS.close(stream);
837837
FS.unlink(pg_out)
838-
} catch (x) {
838+
} else {
839839
console.log("REPL: no reply, see stdout", x)
840840
}
841841
} else {

wasm-build/sdk_port-wasi/sdk_port-wasi.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -392,18 +392,18 @@ volatile FILE *fd_FILE = NULL;
392392
// default fd is stderr
393393
int socket(int domain, int type, int protocol) {
394394
#if 0
395-
printf("# 404 : domain =%d type=%d proto=%d -> FORCE FD to 3 \n", domain , type, protocol);
395+
printf("# 395 : domain =%d type=%d proto=%d -> FORCE FD to 3 \n", domain , type, protocol);
396396
return 3;
397397
#else
398-
printf("# 408 : domain =%d type=%d proto=%d\n", domain , type, protocol);
398+
printf("# 398 : domain =%d type=%d proto=%d\n", domain , type, protocol);
399399
#endif
400400
if (domain|AF_UNIX) {
401401
fd_FILE = fopen(PGS_ILOCK, "w");
402402
if (fd_FILE) {
403403
fd_out = fileno(fd_FILE);
404-
printf("# 414: AF_UNIX sock=%d (fd_sock write) FILE=%s\n", fd_out, PGS_ILOCK);
404+
printf("# 404: AF_UNIX sock=%d (fd_sock write) FILE=%s\n", fd_out, PGS_ILOCK);
405405
} else {
406-
printf("# 416: AF_UNIX ERROR OPEN (w/w+) FILE=%s\n", PGS_ILOCK);
406+
printf("# 406: AF_UNIX ERROR OPEN (w/w+) FILE=%s\n", PGS_ILOCK);
407407
abort();
408408
}
409409
}
@@ -412,11 +412,11 @@ int socket(int domain, int type, int protocol) {
412412

413413
int connect(int socket, void *address, socklen_t address_len) {
414414
#if 1
415-
puts("# 425: connect STUB");
415+
puts("# 415: connect STUB");
416416
//fd_out = 3;
417417
return 0;
418418
#else
419-
puts("# 429: connect EINPROGRESS");
419+
puts("# 419: connect EINPROGRESS");
420420
errno = EINPROGRESS;
421421
return -1;
422422
#endif
@@ -425,7 +425,7 @@ int connect(int socket, void *address, socklen_t address_len) {
425425
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, void *dest_addr, socklen_t addrlen) {
426426
int sent = write( fd_out, buf, len);
427427

428-
printf("# 438: send/sendto(%d ?= %ld )/%zu sockfd=%d fno=%d fd_out=%d)\n", sent, ftell(fd_FILE), len, sockfd, fileno(fd_FILE), fd_out);
428+
printf("# 428: send/sendto(%d ?= %ld )/%zu sockfd=%d fno=%d fd_out=%d)\n", sent, ftell(fd_FILE), len, sockfd, fileno(fd_FILE), fd_out);
429429
fd_queue+=sent;
430430
return sent;
431431
}
@@ -438,32 +438,32 @@ volatile bool web_warned = false;
438438

439439
void sock_flush() {
440440
if (fd_queue) {
441-
printf(" -- 451 sockflush : AIO YIELD, expecting %s filled on return --\n", PGS_OUT);
441+
printf(" -- 441 sockflush : AIO YIELD, expecting %s filled on return --\n", PGS_OUT);
442442
if (!fd_FILE) {
443443
if (!web_warned) {
444-
puts("# 454: WARNING: fd_FILE not set but queue not empty, assuming web");
444+
puts("# 444: WARNING: fd_FILE not set but queue not empty, assuming web");
445445
web_warned = true;
446446
}
447447

448448
} else {
449-
printf("# 459: SENT=%ld/%d fd_out=%d fno=%d\n", ftell(fd_FILE), fd_queue, fd_out, fileno(fd_FILE));
449+
printf("# 449: SENT=%ld/%d fd_out=%d fno=%d\n", ftell(fd_FILE), fd_queue, fd_out, fileno(fd_FILE));
450450
fclose(fd_FILE);
451451
rename(PGS_ILOCK, PGS_IN);
452452
//freopen(PGS_ILOCK, "w+", fd_FILE);
453453
fd_FILE = fopen(PGS_ILOCK, "w");
454454
fd_out = fileno(fd_FILE);
455-
printf("# 465: fd_out=%d fno=%d\n", fd_out, fileno(fd_FILE));
455+
printf("# 455: fd_out=%d fno=%d\n", fd_out, fileno(fd_FILE));
456456
}
457457
fd_queue = 0;
458458
sched_yield();
459459
return;
460460
}
461461

462-
printf(" -- 472 sockflush[%d] : NO YIELD --\n",stage);
462+
printf(" -- 462 sockflush[%d] : NO YIELD --\n",stage);
463463

464464
// limit inf loops
465465
if (stage++ > 1024) {
466-
puts("# 476 sock_flush : busy looping ?");
466+
puts("# 466 sock_flush : busy looping ?");
467467
abort();
468468
}
469469
}

0 commit comments

Comments
 (0)