Skip to content

Commit f6834d8

Browse files
author
tudor
committed
test adding pglite diffs
1 parent 2caa85f commit f6834d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1496
-173
lines changed

contrib/pgstattuple/pgstatindex.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,9 @@ pgstathashindex(PG_FUNCTION_ARGS)
656656
stats.unused_pages++;
657657
else if (PageGetSpecialSize(page) !=
658658
MAXALIGN(sizeof(HashPageOpaqueData)))
659-
ereport(ERROR,
659+
ereport(WARNING,
660660
(errcode(ERRCODE_INDEX_CORRUPTED),
661-
errmsg("index \"%s\" contains corrupted page at block %u",
661+
errmsg("# 661(FATAL block=%d): index \"%s\" contains corrupted page at block %u", blkno,
662662
RelationGetRelationName(rel),
663663
BufferGetBlockNumber(buf))));
664664
else

contrib/xml2/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ DATA = xml2--1.1.sql xml2--1.0--1.1.sql
1111
PGFILEDESC = "xml2 - XPath querying and XSLT"
1212

1313
REGRESS = xml2
14-
14+
PG_CFLAGS=$(shell xml2-config --cflags)
1515
SHLIB_LINK += $(filter -lxslt, $(LIBS)) -lxml2
1616

1717
ifdef USE_PGXS

src/Makefile.shlib

+31-1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,33 @@ ifeq ($(SHLIB_EXPORTS),)
233233
override CXXFLAGS += $(CXXFLAGS_SL_MODULE)
234234
endif
235235

236+
ifeq ($(PORTNAME), emscripten)
237+
LINK.shared = emsdk-shared
238+
ifdef soname
239+
# emscripten uses unversioned shared libraries
240+
shlib = $(shlib_bare)
241+
soname = $(shlib_bare)
242+
endif
243+
BUILD.exports = ( echo '{ global:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@
244+
exports_file = $(SHLIB_EXPORTS:%.txt=%.list)
245+
# ifneq (,$(exports_file))
246+
# LINK.shared += -Wl,--version-script=$(exports_file)
247+
# endif
248+
endif
249+
250+
ifeq ($(PORTNAME), wasi)
251+
LINK.shared = wasi-shared
252+
ifdef soname
253+
# emscripten uses unversioned shared libraries
254+
shlib = $(shlib_bare)
255+
soname = $(shlib_bare)
256+
endif
257+
BUILD.exports = ( echo '{ global:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@
258+
exports_file = $(SHLIB_EXPORTS:%.txt=%.list)
259+
# ifneq (,$(exports_file))
260+
# LINK.shared += -Wl,--version-script=$(exports_file)
261+
# endif
262+
endif
236263

237264
##
238265
## BUILD
@@ -248,8 +275,11 @@ all-lib: lib$(NAME).pc
248275
endif
249276

250277
all-static-lib: $(stlib)
251-
278+
ifdef wasi
279+
all-shared-lib: all-static-lib
280+
else
252281
all-shared-lib: $(shlib)
282+
endif
253283

254284
# In this rule, "touch $@" works around a problem on some platforms wherein
255285
# ar updates the library file's mod time with a value calculated to

src/backend/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ifneq ($(PORTNAME), win32)
6565
ifneq ($(PORTNAME), aix)
6666

6767
postgres: $(OBJS)
68-
$(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o $@
68+
$(CC) $(MAIN_MODULE) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o $@
6969

7070
endif
7171
endif

src/backend/access/nbtree/nbtutils.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2732,7 +2732,7 @@ _bt_allequalimage(Relation rel, bool debugmessage)
27322732
break;
27332733
}
27342734
}
2735-
2735+
#if !defined(__EMSCRIPTEN__)
27362736
if (debugmessage)
27372737
{
27382738
if (allequalimage)
@@ -2742,6 +2742,6 @@ _bt_allequalimage(Relation rel, bool debugmessage)
27422742
elog(DEBUG1, "index \"%s\" cannot use deduplication",
27432743
RelationGetRelationName(rel));
27442744
}
2745-
2745+
#endif
27462746
return allequalimage;
27472747
}

src/backend/access/transam/xact.c

+6
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,7 @@ RecordTransactionAbort(bool isSubXact)
17401740
if (TransactionIdDidCommit(xid))
17411741
elog(PANIC, "cannot abort transaction %u, it was already committed",
17421742
xid);
1743+
else elog(WARNING, "# 1743: aborting transaction %u", xid);
17431744

17441745
/*
17451746
* Are we using the replication origins feature? Or, in other words, are
@@ -2748,7 +2749,9 @@ AbortTransaction(void)
27482749
* handler. We do this fairly early in the sequence so that the timeout
27492750
* infrastructure will be functional if needed while aborting.
27502751
*/
2752+
#if !defined(__EMSCRIPTEN__) && !defined(__wasi__)
27512753
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
2754+
#endif
27522755

27532756
/*
27542757
* check the current transaction state
@@ -5107,7 +5110,10 @@ AbortSubTransaction(void)
51075110
* handler. We do this fairly early in the sequence so that the timeout
51085111
* infrastructure will be functional if needed while aborting.
51095112
*/
5113+
#if !defined(__EMSCRIPTEN__) && !defined(__wasi__)
51105114
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
5115+
#endif
5116+
51115117

51125118
/*
51135119
* check the current transaction state

src/backend/access/transam/xlogarchive.c

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#include "storage/ipc.h"
3434
#include "storage/lwlock.h"
3535

36+
#if defined(__wasi__)
37+
#define system(cmd) system_wasi(cmd)
38+
#endif
39+
3640
/*
3741
* Attempt to retrieve the specified file from off-line archival storage.
3842
* If successful, fill "path" with its complete path (note that this will be

src/backend/bootstrap/bootstrap.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ CheckerModeMain(void)
199199
* to shared memory sizing, options work (or at least do not cause an error
200200
* up to shared memory creation).
201201
*/
202+
#if !defined(__EMSCRIPTEN__) && !defined(__wasi__)
202203
void
204+
#else
205+
int
206+
#endif
203207
BootstrapModeMain(int argc, char *argv[], bool check_only)
204208
{
205209
int i;
@@ -353,7 +357,7 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
353357
*/
354358
if (pg_link_canary_is_frontend())
355359
elog(ERROR, "backend is incorrectly linked to frontend functions");
356-
360+
puts("# 360: InitPostgres(boot): " __FILE__ );
357361
InitPostgres(NULL, InvalidOid, NULL, InvalidOid, false, false, NULL);
358362

359363
/* Initialize stuff for bootstrap-file processing */
@@ -378,7 +382,12 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
378382

379383
/* Clean up and exit */
380384
cleanup();
385+
#if !defined(__EMSCRIPTEN__) && !defined(__wasi__)
381386
proc_exit(0);
387+
#else
388+
puts("# 338 cleanup(boot): " __FILE__);
389+
return 0;
390+
#endif
382391
}
383392

384393

src/backend/catalog/index.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2995,7 +2995,7 @@ index_build(Relation heapRelation,
29952995
indexInfo->ii_ParallelWorkers =
29962996
plan_create_index_workers(RelationGetRelid(heapRelation),
29972997
RelationGetRelid(indexRelation));
2998-
2998+
#if !defined(__EMSCRIPTEN__)
29992999
if (indexInfo->ii_ParallelWorkers == 0)
30003000
ereport(DEBUG1,
30013001
(errmsg_internal("building index \"%s\" on table \"%s\" serially",
@@ -3007,7 +3007,7 @@ index_build(Relation heapRelation,
30073007
RelationGetRelationName(indexRelation),
30083008
RelationGetRelationName(heapRelation),
30093009
indexInfo->ii_ParallelWorkers)));
3010-
3010+
#endif
30113011
/*
30123012
* Switch to the table owner's userid, so that any index functions are run
30133013
* as that user. Also lock down security-restricted operations and

src/backend/commands/async.c

+4
Original file line numberDiff line numberDiff line change
@@ -1700,8 +1700,12 @@ SignalBackends(void)
17001700
* NotifyQueueLock; which is unlikely but certainly possible. So we
17011701
* just log a low-level debug message if it happens.
17021702
*/
1703+
#if defined(__EMSCRIPTEN__)
1704+
HandleNotifyInterrupt();
1705+
#else
17031706
if (SendProcSignal(pid, PROCSIG_NOTIFY_INTERRUPT, ids[i]) < 0)
17041707
elog(DEBUG3, "could not signal backend with PID %d: %m", pid);
1708+
#endif
17051709
}
17061710

17071711
pfree(pids);

src/backend/commands/collationcmds.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -828,14 +828,14 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
828828
maxaliases = 100;
829829
aliases = (CollAliasData *) palloc(maxaliases * sizeof(CollAliasData));
830830
naliases = 0;
831-
832831
locale_a_handle = OpenPipeStream("locale -a", "r");
833-
if (locale_a_handle == NULL)
832+
if (locale_a_handle == NULL) {
833+
puts("======================== ERROR ================");
834834
ereport(ERROR,
835835
(errcode_for_file_access(),
836836
errmsg("could not execute command \"%s\": %m",
837837
"locale -a")));
838-
838+
}
839839
while (fgets(localebuf, sizeof(localebuf), locale_a_handle))
840840
{
841841
size_t len;

src/backend/commands/dbcommands.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1776,8 +1776,9 @@ dropdb(const char *dbname, bool missing_ok, bool force)
17761776
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT);
17771777

17781778
/* Close all smgr fds in all backends. */
1779+
#if !defined(__wasi__) && !defined(__EMSCRIPTEN__)
17791780
WaitForProcSignalBarrier(EmitProcSignalBarrier(PROCSIGNAL_BARRIER_SMGRRELEASE));
1780-
1781+
#endif
17811782
/*
17821783
* Remove all tablespace subdirs belonging to the database.
17831784
*/

src/backend/commands/event_trigger.c

+12
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,8 @@ EventTriggerDDLCommandStart(Node *parsetree)
642642
List *runlist;
643643
EventTriggerData trigdata;
644644

645+
#if defined(__EMSCRIPTEN__) || defined(__wasi__)
646+
#else
645647
/*
646648
* Event Triggers are completely disabled in standalone mode. There are
647649
* (at least) two reasons for this:
@@ -660,6 +662,7 @@ EventTriggerDDLCommandStart(Node *parsetree)
660662
*/
661663
if (!IsUnderPostmaster)
662664
return;
665+
#endif
663666

664667
runlist = EventTriggerCommonSetup(parsetree,
665668
EVT_DDLCommandStart,
@@ -690,12 +693,15 @@ EventTriggerDDLCommandEnd(Node *parsetree)
690693
List *runlist;
691694
EventTriggerData trigdata;
692695

696+
#if defined(__EMSCRIPTEN__) || defined(__wasi__)
697+
#else
693698
/*
694699
* See EventTriggerDDLCommandStart for a discussion about why event
695700
* triggers are disabled in single user mode.
696701
*/
697702
if (!IsUnderPostmaster)
698703
return;
704+
#endif
699705

700706
/*
701707
* Also do nothing if our state isn't set up, which it won't be if there
@@ -738,12 +744,15 @@ EventTriggerSQLDrop(Node *parsetree)
738744
List *runlist;
739745
EventTriggerData trigdata;
740746

747+
#if defined(__EMSCRIPTEN__) || defined(__wasi__)
748+
#else
741749
/*
742750
* See EventTriggerDDLCommandStart for a discussion about why event
743751
* triggers are disabled in single user mode.
744752
*/
745753
if (!IsUnderPostmaster)
746754
return;
755+
#endif
747756

748757
/*
749758
* Use current state to determine whether this event fires at all. If
@@ -809,12 +818,15 @@ EventTriggerTableRewrite(Node *parsetree, Oid tableOid, int reason)
809818
List *runlist;
810819
EventTriggerData trigdata;
811820

821+
#if defined(__EMSCRIPTEN__) || defined(__wasi__)
822+
#else
812823
/*
813824
* See EventTriggerDDLCommandStart for a discussion about why event
814825
* triggers are disabled in single user mode.
815826
*/
816827
if (!IsUnderPostmaster)
817828
return;
829+
#endif
818830

819831
/*
820832
* Also do nothing if our state isn't set up, which it won't be if there

src/backend/libpq/auth.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,7 @@ auth_peer(hbaPort *port)
18661866
return STATUS_ERROR;
18671867
}
18681868

1869-
#ifndef WIN32
1869+
#if !defined(WIN32) && !defined(__wasi__)
18701870
errno = 0; /* clear errno before call */
18711871
pw = getpwuid(uid);
18721872
if (!pw)

src/backend/libpq/be-fsstubs.c

+14-6
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,12 @@ be_lo_close(PG_FUNCTION_ARGS)
150150
*
151151
*****************************************************************************/
152152

153+
#if defined(__EMSCRIPTEN__) || defined(__wasi__)
154+
static int
155+
#else
153156
int
154-
lo_read(int fd, char *buf, int len)
157+
#endif
158+
lo_read3(int fd, char *buf, int len)
155159
{
156160
int status;
157161
LargeObjectDesc *lobj;
@@ -178,8 +182,12 @@ lo_read(int fd, char *buf, int len)
178182
return status;
179183
}
180184

185+
#if defined(__EMSCRIPTEN__) || defined(__wasi__)
186+
static int
187+
#else
181188
int
182-
lo_write(int fd, const char *buf, int len)
189+
#endif
190+
lo_write3(int fd, const char *buf, int len)
183191
{
184192
int status;
185193
LargeObjectDesc *lobj;
@@ -190,7 +198,7 @@ lo_write(int fd, const char *buf, int len)
190198
errmsg("invalid large-object descriptor: %d", fd)));
191199
lobj = cookies[fd];
192200

193-
/* see comment in lo_read() */
201+
/* see comment in lo_read3() */
194202
if ((lobj->flags & IFS_WRLOCK) == 0)
195203
ereport(ERROR,
196204
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
@@ -365,7 +373,7 @@ be_loread(PG_FUNCTION_ARGS)
365373
len = 0;
366374

367375
retval = (bytea *) palloc(VARHDRSZ + len);
368-
totalread = lo_read(fd, VARDATA(retval), len);
376+
totalread = lo_read3(fd, VARDATA(retval), len);
369377
SET_VARSIZE(retval, totalread + VARHDRSZ);
370378

371379
PG_RETURN_BYTEA_P(retval);
@@ -382,7 +390,7 @@ be_lowrite(PG_FUNCTION_ARGS)
382390
PreventCommandIfReadOnly("lowrite()");
383391

384392
bytestowrite = VARSIZE_ANY_EXHDR(wbuf);
385-
totalwritten = lo_write(fd, VARDATA_ANY(wbuf), bytestowrite);
393+
totalwritten = lo_write3(fd, VARDATA_ANY(wbuf), bytestowrite);
386394
PG_RETURN_INT32(totalwritten);
387395
}
388396

@@ -560,7 +568,7 @@ lo_truncate_internal(int32 fd, int64 len)
560568
errmsg("invalid large-object descriptor: %d", fd)));
561569
lobj = cookies[fd];
562570

563-
/* see comment in lo_read() */
571+
/* see comment in lo_read3() */
564572
if ((lobj->flags & IFS_WRLOCK) == 0)
565573
ereport(ERROR,
566574
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

0 commit comments

Comments
 (0)