summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas2014-07-11 13:53:40 +0000
committerRobert Haas2014-12-03 17:58:28 +0000
commit0acea149197d8133eb9938410585832b0f981638 (patch)
treea8d0c88c109d882a81493e3b52ac76b11a3fc96e /src
parentb52cb4690e0752efea440173c4923d76d2126679 (diff)
pg_background: Run commands in a background worker, and get the results.pg_background
The currently-active GUC values from the user session will be copied to the background worker. If the command returns a result set, you can retrieve the result set; if not, you can retrieve the command tags. If the command fails with an error, the same error will be thrown in the launching process when the results are retrieved. Warnings and other messages generated by the background worker, and notifications received by it, are also propagated to the foreground process. Patch by me; review by Amit Kapila and Andres Freund. V2: Refactor to reduce differences with exec_simple_query; other cleanups per Amit. V3: Per Andres, fix whitespace damage and use NameData instead of char[NAMEDATALEN]. V4: dsm_(un)keep_mapping -> dsm_(un)pin_mapping. Error context: background worker, pid %d. Permissions check: user must have permission to read results. V5: Revoke permissions on pg_background functions from public. Add missing call to process_session_preload_libraries().
Diffstat (limited to 'src')
-rw-r--r--src/backend/tcop/postgres.c6
-rw-r--r--src/include/storage/proc.h2
-rw-r--r--src/include/tcop/tcopprot.h2
3 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index cc62b2cfe8..cfd385fc4c 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -190,8 +190,6 @@ static int errdetail_execute(List *raw_parsetree_list);
static int errdetail_params(ParamListInfo params);
static int errdetail_abort(void);
static int errdetail_recovery_conflict(void);
-static void start_xact_command(void);
-static void finish_xact_command(void);
static bool IsTransactionExitStmt(Node *parsetree);
static bool IsTransactionExitStmtList(List *parseTrees);
static bool IsTransactionStmtList(List *parseTrees);
@@ -2375,7 +2373,7 @@ exec_describe_portal_message(const char *portal_name)
/*
* Convenience routines for starting/committing a single command.
*/
-static void
+void
start_xact_command(void)
{
if (!xact_started)
@@ -2395,7 +2393,7 @@ start_xact_command(void)
}
}
-static void
+void
finish_xact_command(void)
{
if (xact_started)
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index c23f4da5b6..8e84ee71ef 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -224,7 +224,7 @@ extern PGPROC *PreparedXactProcs;
/* configurable options */
extern int DeadlockTimeout;
-extern int StatementTimeout;
+extern PGDLLIMPORT int StatementTimeout;
extern int LockTimeout;
extern bool log_lock_waits;
diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h
index 60f75325db..fd3df58af2 100644
--- a/src/include/tcop/tcopprot.h
+++ b/src/include/tcop/tcopprot.h
@@ -69,6 +69,8 @@ extern void RecoveryConflictInterrupt(ProcSignalReason reason); /* called from S
* handler */
extern void prepare_for_client_read(void);
extern void client_read_ended(void);
+extern void start_xact_command(void);
+extern void finish_xact_command(void);
extern void process_postgres_switches(int argc, char *argv[],
GucContext ctx, const char **dbname);
extern void PostgresMain(int argc, char *argv[],