pg_background: Run commands in a background worker, and get the results. pg_background
authorRobert Haas <[email protected]>
Fri, 11 Jul 2014 13:53:40 +0000 (09:53 -0400)
committerRobert Haas <[email protected]>
Wed, 3 Dec 2014 17:58:28 +0000 (12:58 -0500)
commit0acea149197d8133eb9938410585832b0f981638
treea8d0c88c109d882a81493e3b52ac76b11a3fc96e
parentb52cb4690e0752efea440173c4923d76d2126679
pg_background: Run commands in a background worker, and get the results.

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().
contrib/Makefile
contrib/pg_background/Makefile [new file with mode: 0644]
contrib/pg_background/pg_background--1.0.sql [new file with mode: 0644]
contrib/pg_background/pg_background.c [new file with mode: 0644]
contrib/pg_background/pg_background.control [new file with mode: 0644]
src/backend/tcop/postgres.c
src/include/storage/proc.h
src/include/tcop/tcopprot.h