diff --git a/pglite-wasm/included.pglite.imports b/pglite-wasm/included.pglite.imports index ad348a8178828..98ba337128a01 100644 --- a/pglite-wasm/included.pglite.imports +++ b/pglite-wasm/included.pglite.imports @@ -93,4 +93,59 @@ text_to_cstring text_to_cstring_buffer time tolower -TupleDescGetAttInMetadata \ No newline at end of file +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 diff --git a/pglite-wasm/pgl_mains.c b/pglite-wasm/pgl_mains.c index ab20394e07dff..69aef92eddd65 100644 --- a/pglite-wasm/pgl_mains.c +++ b/pglite-wasm/pgl_mains.c @@ -1,4 +1,6 @@ #include +#include +#include volatile int sf_connected = 0; FILE * single_mode_feed = NULL; @@ -6,6 +8,42 @@ 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() { @@ -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 @@ -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__); @@ -435,4 +475,3 @@ PDEBUG("# 167"); MemoryContextSwitchTo(TopMemoryContext); } // AsyncPostgresSingleUserMain -