Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion pglite-wasm/included.pglite.imports
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,59 @@ text_to_cstring
text_to_cstring_buffer
time
tolower
TupleDescGetAttInMetadata
TupleDescGetAttInMetadata
MemoryContextRegisterResetCallback
defGetStreamingMode
CacheRegisterRelcacheCallback
is_publishable_relation
RelationIdGetRelation
MakeTupleTableSlot
execute_attr_map_slot
logicalrep_write_insert
logicalrep_write_update
logicalrep_write_delete
RelationClose
logicalrep_write_truncate
logicalrep_write_message
OutputPluginUpdateProgress
logicalrep_write_commit
logicalrep_write_begin_prepare
replorigin_by_oid
logicalrep_write_origin
logicalrep_write_prepare
logicalrep_write_commit_prepared
logicalrep_write_rollback_prepared
hash_destroy
logicalrep_write_stream_start
logicalrep_write_stream_stop
logicalrep_write_stream_abort
logicalrep_write_stream_commit
logicalrep_write_stream_prepare
GetRelationPublications
GetSchemaPublications
get_rel_relispartition
GetPublicationByName
FreeTupleDesc
free_attrmap
get_partition_ancestors
GetTopMostAncestorInPublication
CreateTupleDescCopyConstr
build_attrmap_by_name_if_req
SearchSysCacheExists
SearchSysCache2
SysCacheGetAttr
addRTEPermissionInfo
ExecInitRangeTable
make_orclause
ExecPrepareExpr
pub_collist_to_bitmapset
bms_num_members
bms_equal
logicalrep_write_begin
list_member_xid
lappend_xid
logicalrep_write_typ
logicalrep_write_rel
CacheMemoryContext
CurrentMemoryContext
TTSOpsHeapTuple
47 changes: 43 additions & 4 deletions pglite-wasm/pgl_mains.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,49 @@
#include <setjmp.h>
#include <stdlib.h>
#include <string.h>

volatile int sf_connected = 0;
FILE * single_mode_feed = NULL;
volatile bool inloop = false;
volatile sigjmp_buf local_sigjmp_buf;
bool repl = false;

#define PGLITE_POSTGRES_CONFIG_ENV "PGLITE_POSTGRES_CONFIG"

static void
ApplyPostgresConfigFromEnv(void)
{
const char *raw = getenv(PGLITE_POSTGRES_CONFIG_ENV);
char *config_copy = NULL;
char *cursor = NULL;
char *entry = NULL;

if (raw == NULL || raw[0] == '\0')
return;

config_copy = strdup(raw);
if (config_copy == NULL)
return;

cursor = config_copy;
while ((entry = strsep(&cursor, ";")) != NULL)
{
char *eq = NULL;

if (entry[0] == '\0')
continue;

eq = strchr(entry, '=');
if (eq == NULL || eq == entry || eq[1] == '\0')
continue;

*eq = '\0';
SetConfigOption(entry, eq + 1, PGC_POSTMASTER, PGC_S_ARGV);
}

free(config_copy);
}

__attribute__((export_name("pgl_shutdown")))
void
pg_shutdown() {
Expand Down Expand Up @@ -141,8 +179,9 @@ printf("# 123: RePostgresSingleUserMain progname=%s for %s feed=%s\n", progname,
const char *dbname = NULL;


/* Parse command-line options. */
process_postgres_switches(single_argc, single_argv, PGC_POSTMASTER, &dbname);
/* Parse command-line options. */
process_postgres_switches(single_argc, single_argv, PGC_POSTMASTER, &dbname);
ApplyPostgresConfigFromEnv();
#if PGDEBUG
printf("# 134: dbname=%s\n", dbname);
#endif
Expand Down Expand Up @@ -269,7 +308,8 @@ PDEBUG("# 254:"__FILE__);
InitializeGUCOptions();
PDEBUG("# 257:"__FILE__);
// if (!async_restart) /* Parse command-line options. */
process_postgres_switches(argc, argv, PGC_POSTMASTER, &dbname);
process_postgres_switches(argc, argv, PGC_POSTMASTER, &dbname);
ApplyPostgresConfigFromEnv();


PDEBUG("# 260:"__FILE__);
Expand Down Expand Up @@ -435,4 +475,3 @@ PDEBUG("# 167");
MemoryContextSwitchTo(TopMemoryContext);
} // AsyncPostgresSingleUserMain