From 020618033a11c7e6c92dc4bd00d6a78a216874f1 Mon Sep 17 00:00:00 2001 From: "okbob@github.com" Date: Mon, 28 Aug 2023 14:57:07 +0200 Subject: [PATCH 2/4] PQlinkParameterStatus, PQunlinkParameterStatus test based on libpq_pipeline test --- .../modules/libpq_pipeline/libpq_pipeline.c | 31 +++++++++++++++++++ .../libpq_pipeline/traces/reportguc.trace | 15 +++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/test/modules/libpq_pipeline/traces/reportguc.trace diff --git a/src/test/modules/libpq_pipeline/libpq_pipeline.c b/src/test/modules/libpq_pipeline/libpq_pipeline.c index 9907bc8600..ea5ef97b2d 100644 --- a/src/test/modules/libpq_pipeline/libpq_pipeline.c +++ b/src/test/modules/libpq_pipeline/libpq_pipeline.c @@ -1677,6 +1677,34 @@ test_uniqviol(PGconn *conn) fprintf(stderr, "ok\n"); } +/* + * Test of ReportGUC message + */ +static void +test_reportguc(PGconn *conn) +{ + PGresult *res; + + fprintf(stderr, "reportguc ..."); + + res = PQexec(conn, "SELECT pg_catalog.set_config('test.test', 'Hello', false)"); + if (PQresultStatus(res) != PGRES_TUPLES_OK) + pg_fatal("failed to create custom config variable: %s", PQerrorMessage(conn)); + PQclear(res); + + res = PQlinkParameterStatus(conn, "test.test"); + if (PQresultStatus(res) != PGRES_COMMAND_OK) + pg_fatal("failed to link custom variable: %s", PQerrorMessage(conn)); + PQclear(res); + + res = PQunlinkParameterStatus(conn, "test.test"); + if (PQresultStatus(res) != PGRES_COMMAND_OK) + pg_fatal("failed to unlink custom variable: %s", PQerrorMessage(conn)); + PQclear(res); + + fprintf(stderr, "ok\n"); +} + /* * Subroutine for test_uniqviol; given a PGresult, print it out and consume * the expected NULL that should follow it. @@ -1757,6 +1785,7 @@ print_test_list(void) printf("singlerow\n"); printf("transaction\n"); printf("uniqviol\n"); + printf("reportguc\n"); } int @@ -1869,6 +1898,8 @@ main(int argc, char **argv) test_transaction(conn); else if (strcmp(testname, "uniqviol") == 0) test_uniqviol(conn); + else if (strcmp(testname, "reportguc") == 0) + test_reportguc(conn); else { fprintf(stderr, "\"%s\" is not a recognized test name\n", testname); diff --git a/src/test/modules/libpq_pipeline/traces/reportguc.trace b/src/test/modules/libpq_pipeline/traces/reportguc.trace new file mode 100644 index 0000000000..b000dfe0be --- /dev/null +++ b/src/test/modules/libpq_pipeline/traces/reportguc.trace @@ -0,0 +1,15 @@ +F 62 Query "SELECT pg_catalog.set_config('test.test', 'Hello', false)" +B 35 RowDescription 1 "set_config" NNNN 0 NNNN 65535 -1 0 +B 15 DataRow 1 5 'Hello' +B 13 CommandComplete "SELECT 1" +B 5 ReadyForQuery I +F 15 ReportGUC t "test.test" +F 4 Sync +B 20 ParameterStatus "test.test" "Hello" +B 19 CommandComplete "SET REPORT_GUC" +B 5 ReadyForQuery I +F 15 ReportGUC f "test.test" +F 4 Sync +B 21 CommandComplete "UNSET REPORT_GUC" +B 5 ReadyForQuery I +F 4 Terminate -- 2.41.0