aboutsummaryrefslogtreecommitdiff
path: root/src/test/modules/worker_spi/worker_spi.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2019-06-02 00:29:49 -0400
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2019-06-02 00:29:49 -0400
commit4b3f1dd71b74f82dedbf37c331d0a444368c4009 (patch)
treee7e6a8cc0818a8dc243a37f0cd4c8299710ea923 /src/test/modules/worker_spi/worker_spi.c
parent0b8e0532c65c3a2d4b0e9c254efa022767bacceb (diff)
downloadpostgresql-4b3f1dd71b74f82dedbf37c331d0a444368c4009.tar.gz
postgresql-4b3f1dd71b74f82dedbf37c331d0a444368c4009.zip
Increase test coverage for worker_spi by ∞%
This test module was not getting invoked, other than at compile time, limiting its usefulness -- and keeping its coverage at 0%. Add a minimal regression test to ensure it runs on make check-world; this makes it 92% covered (line-wise), which seems sufficient. Author: Álvaro Herrera <alvherre@alvh.no-ip.org> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/20190529193256.GA17603@alvherre.pgsql
Diffstat (limited to 'src/test/modules/worker_spi/worker_spi.c')
-rw-r--r--src/test/modules/worker_spi/worker_spi.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/worker_spi/worker_spi.c
index c1878dd6946..bc9ef64a508 100644
--- a/src/test/modules/worker_spi/worker_spi.c
+++ b/src/test/modules/worker_spi/worker_spi.c
@@ -55,6 +55,7 @@ static volatile sig_atomic_t got_sigterm = false;
/* GUC variables */
static int worker_spi_naptime = 10;
static int worker_spi_total_workers = 2;
+static char *worker_spi_database = NULL;
typedef struct worktable
@@ -179,7 +180,7 @@ worker_spi_main(Datum main_arg)
BackgroundWorkerUnblockSignals();
/* Connect to our database */
- BackgroundWorkerInitializeConnection("postgres", NULL, 0);
+ BackgroundWorkerInitializeConnection(worker_spi_database, NULL, 0);
elog(LOG, "%s initialized with %s.%s",
MyBgworkerEntry->bgw_name, table->schema, table->name);
@@ -339,6 +340,15 @@ _PG_init(void)
NULL,
NULL);
+ DefineCustomStringVariable("worker_spi.database",
+ "Database to connect to.",
+ NULL,
+ &worker_spi_database,
+ "postgres",
+ PGC_POSTMASTER,
+ 0,
+ NULL, NULL, NULL);
+
/* set up common data for all our workers */
memset(&worker, 0, sizeof(worker));
worker.bgw_flags = BGWORKER_SHMEM_ACCESS |