Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable dynamically loaded postgres extensions #13

Open
wants to merge 3 commits into
base: wasm
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion src/backend/access/transam/xlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -7590,7 +7590,7 @@ StartupXLOG(void)
* of postmaster. Log messages issued from
* postmaster.
*/
proc_exit(3);
pg_proc_exit(3);

case RECOVERY_TARGET_ACTION_PAUSE:
SetRecoveryPause(true);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/transam/xlogarchive.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ RestoreArchivedFile(char *path, const char *xlogfname,
* We treat hard shell errors such as "command not found" as fatal, too.
*/
if (wait_result_is_signal(rc, SIGTERM))
proc_exit(1);
pg_proc_exit(1);

ereport(wait_result_is_any_signal(rc, true) ? FATAL : DEBUG2,
(errmsg("could not restore file \"%s\" from archive: %s",
Expand Down
28 changes: 14 additions & 14 deletions src/backend/bootstrap/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,15 @@ AuxiliaryProcessMain(int argc, char *argv[])
default:
write_stderr("Try \"%s --help\" for more information.\n",
progname);
proc_exit(1);
pg_proc_exit(1);
break;
}
}

if (argc != optind)
{
write_stderr("%s: invalid command-line arguments\n", progname);
proc_exit(1);
pg_proc_exit(1);
}

switch (MyAuxProcType)
Expand Down Expand Up @@ -343,7 +343,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
if (!IsUnderPostmaster)
{
if (!SelectConfigFiles(userDoption, progname))
proc_exit(1);
pg_proc_exit(1);
}

checkDataDir();
Expand Down Expand Up @@ -431,7 +431,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
case CheckerProcess:
/* don't set signals, they're useless here */
CheckerModeMain();
proc_exit(1); /* should never return */
pg_proc_exit(1); /* should never return */

case BootstrapProcess:

Expand All @@ -444,36 +444,36 @@ AuxiliaryProcessMain(int argc, char *argv[])
bootstrap_signals();
BootStrapXLOG();
BootstrapModeMain();
proc_exit(1); /* should never return */
pg_proc_exit(1); /* should never return */

case StartupProcess:
StartupProcessMain();
proc_exit(1);
pg_proc_exit(1);

case ArchiverProcess:
PgArchiverMain();
proc_exit(1);
pg_proc_exit(1);

case BgWriterProcess:
BackgroundWriterMain();
proc_exit(1);
pg_proc_exit(1);

case CheckpointerProcess:
CheckpointerMain();
proc_exit(1);
pg_proc_exit(1);

case WalWriterProcess:
InitXLOGAccess();
WalWriterMain();
proc_exit(1);
pg_proc_exit(1);

case WalReceiverProcess:
WalReceiverMain();
proc_exit(1);
pg_proc_exit(1);

default:
elog(PANIC, "unrecognized process type: %d", (int) MyAuxProcType);
proc_exit(1);
pg_proc_exit(1);
}
}

Expand All @@ -486,7 +486,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
static void
CheckerModeMain(void)
{
proc_exit(0);
pg_proc_exit(0);
}

/*
Expand Down Expand Up @@ -561,7 +561,7 @@ BootstrapModeMain(void)

/* Clean up and exit */
cleanup();
proc_exit(0);
pg_proc_exit(0);
}


Expand Down
2 changes: 1 addition & 1 deletion src/backend/executor/execMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,7 @@ ExecutePlan(EState *estate,
* point.
*/
if (!(estate->es_top_eflags & EXEC_FLAG_BACKWARD))
(void) ExecShutdownNode(planstate);
ExecShutdownNode(planstate);

if (use_parallel_mode)
ExitParallelMode();
Expand Down
11 changes: 9 additions & 2 deletions src/backend/executor/execProcnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@

static TupleTableSlot *ExecProcNodeFirst(PlanState *node);
static TupleTableSlot *ExecProcNodeInstr(PlanState *node);
static bool ExecShutdownNode_walker(PlanState *node, void *context);


/* ------------------------------------------------------------------------
Expand Down Expand Up @@ -768,8 +769,14 @@ ExecEndNode(PlanState *node)
* Give execution nodes a chance to stop asynchronous resource consumption
* and release any resources still held.
*/
bool
void
ExecShutdownNode(PlanState *node)
{
(void) ExecShutdownNode_walker(node, NULL);
}

static bool
ExecShutdownNode_walker(PlanState *node, void *context)
{
if (node == NULL)
return false;
Expand All @@ -789,7 +796,7 @@ ExecShutdownNode(PlanState *node)
if (node->instrument && node->instrument->running)
InstrStartNode(node->instrument);

planstate_tree_walker(node, ExecShutdownNode, NULL);
planstate_tree_walker(node, ExecShutdownNode_walker, context);

switch (nodeTag(node))
{
Expand Down
2 changes: 1 addition & 1 deletion src/backend/libpq/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ auth_failed(Port *port, int status, char *logdetail)
* events.)
*/
if (status == STATUS_EOF)
proc_exit(0);
pg_proc_exit(0);

switch (port->hba->auth_method)
{
Expand Down
8 changes: 4 additions & 4 deletions src/backend/postmaster/autovacuum.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ AutoVacLauncherMain(int argc, char *argv[])
{
if (!ShutdownRequestPending)
do_start_worker();
proc_exit(0); /* done */
pg_proc_exit(0); /* done */
}

AutoVacuumShmem->av_launcherpid = MyProcPid;
Expand Down Expand Up @@ -851,7 +851,7 @@ AutoVacLauncherShutdown(void)
(errmsg_internal("autovacuum launcher shutting down")));
AutoVacuumShmem->av_launcherpid = 0;

proc_exit(0); /* done */
pg_proc_exit(0); /* done */
}

/*
Expand Down Expand Up @@ -1589,7 +1589,7 @@ AutoVacWorkerMain(int argc, char *argv[])
* callback was registered to do ProcKill, which will clean up
* necessary state.
*/
proc_exit(0);
pg_proc_exit(0);
}

/* We can now handle ereport(ERROR) */
Expand Down Expand Up @@ -1721,7 +1721,7 @@ AutoVacWorkerMain(int argc, char *argv[])
*/

/* All done, go away */
proc_exit(0);
pg_proc_exit(0);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions src/backend/postmaster/bgworker.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ StartBackgroundWorker(void)
*/

/* and go away */
proc_exit(1);
pg_proc_exit(1);
}

/* We can now handle ereport(ERROR) */
Expand Down Expand Up @@ -875,7 +875,7 @@ StartBackgroundWorker(void)
entrypt(worker->bgw_main_arg);

/* ... and if it returns, we're done */
proc_exit(0);
pg_proc_exit(0);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/backend/postmaster/checkpointer.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ HandleCheckpointerInterrupts(void)
pgstat_send_wal(true);

/* Normal exit from the checkpointer is here */
proc_exit(0); /* done */
pg_proc_exit(0); /* done */
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/backend/postmaster/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ HandleMainLoopInterrupts(void)
}

if (ShutdownRequestPending)
proc_exit(0);
pg_proc_exit(0);
}

/*
Expand Down Expand Up @@ -72,7 +72,7 @@ void
SignalHandlerForCrashExit(SIGNAL_ARGS)
{
/*
* We DO NOT want to run proc_exit() or atexit() callbacks -- we're here
* We DO NOT want to run pg_proc_exit() or atexit() callbacks -- we're here
* because shared memory may be corrupted, so we don't want to try to
* clean up our transaction. Just nail the windows shut and get out of
* town. The callbacks wouldn't be safe to run from a signal handler,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/postmaster/pgarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ PgArchiverMain(void)

pgarch_MainLoop();

proc_exit(0);
pg_proc_exit(0);
}

/*
Expand Down
6 changes: 3 additions & 3 deletions src/backend/postmaster/postmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -4462,7 +4462,7 @@ BackendInitialize(Port *port)
* already did any appropriate error reporting.
*/
if (status != STATUS_OK)
proc_exit(0);
pg_proc_exit(0);

/*
* Now that we have the user and database name, we can set the process
Expand Down Expand Up @@ -5132,7 +5132,7 @@ ExitPostmaster(int status)
* MUST -- vadim 05-10-1999
*/

proc_exit(status);
pg_proc_exit(status);
}

/*
Expand Down Expand Up @@ -5316,7 +5316,7 @@ sigusr1_handler(SIGNAL_ARGS)
/*
* SIGTERM while processing startup packet.
*
* Running proc_exit() from a signal handler would be quite unsafe.
* Running pg_proc_exit() from a signal handler would be quite unsafe.
* However, since we have not yet touched shared memory, we can just
* pull the plug and exit without running any atexit handlers.
*
Expand Down
8 changes: 4 additions & 4 deletions src/backend/postmaster/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ StartupProcShutdownHandler(SIGNAL_ARGS)
int save_errno = errno;

if (in_restore_command)
proc_exit(1);
pg_proc_exit(1);
else
shutdown_requested = true;
WakeupRecovery();
Expand Down Expand Up @@ -165,7 +165,7 @@ HandleStartupProcInterrupts(void)
* Check if we were requested to exit without finishing recovery.
*/
if (shutdown_requested)
proc_exit(1);
pg_proc_exit(1);

/*
* Emergency bailout if postmaster has died. This is to avoid the
Expand Down Expand Up @@ -247,7 +247,7 @@ StartupProcessMain(void)
* Exit normally. Exit code 0 tells postmaster that we completed recovery
* successfully.
*/
proc_exit(0);
pg_proc_exit(0);
}

void
Expand All @@ -261,7 +261,7 @@ PreRestoreCommand(void)
*/
in_restore_command = true;
if (shutdown_requested)
proc_exit(1);
pg_proc_exit(1);
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/backend/postmaster/syslogger.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ SysLoggerMain(int argc, char *argv[])
* inside proc_exit. Regular exit() will take care of flushing
* and closing stdio channels.
*/
proc_exit(0);
pg_proc_exit(0);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/postmaster/walwriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,6 @@ HandleWalWriterInterrupts(void)
*/
pgstat_send_wal(true);

proc_exit(0);
pg_proc_exit(0);
}
}
2 changes: 1 addition & 1 deletion src/backend/replication/logical/tablesync.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ finish_sync_worker(void)
logicalrep_worker_wakeup(MyLogicalRepWorker->subid, InvalidOid);

/* Stop gracefully */
proc_exit(0);
pg_proc_exit(0);
}

/*
Expand Down
Loading