summaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
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/backend/tcop/postgres.c
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/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c6
1 files changed, 2 insertions, 4 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)