diff --git a/src/test/modules/libpq_pipeline/libpq_pipeline.c b/src/test/modules/libpq_pipeline/libpq_pipeline.c index 1979f178af..92af8698d6 100644 --- a/src/test/modules/libpq_pipeline/libpq_pipeline.c +++ b/src/test/modules/libpq_pipeline/libpq_pipeline.c @@ -45,12 +45,16 @@ char *tracefile = NULL; /* path to PQtrace() file */ static const char *const drop_table_sql = "DROP TABLE IF EXISTS pq_pipeline_demo"; static const char *const create_table_sql = -"CREATE UNLOGGED TABLE pq_pipeline_demo(id serial primary key, itemno integer);"; +"CREATE UNLOGGED TABLE pq_pipeline_demo(id serial primary key, itemno integer," +"int8filler int8);"; static const char *const insert_sql = -"INSERT INTO pq_pipeline_demo(itemno) VALUES ($1);"; +"INSERT INTO pq_pipeline_demo(itemno) VALUES ($1)"; +static const char *const insert_sql2 = +"INSERT INTO pq_pipeline_demo(itemno,int8filler) VALUES ($1, $2)"; -/* max char length of an int32, plus sign and null terminator */ +/* max char length of an int32/64, plus sign and null terminator */ #define MAXINTLEN 12 +#define MAXINT8LEN 20 static void exit_nicely(PGconn *conn) @@ -243,6 +247,7 @@ test_pipeline_abort(PGconn *conn) const char *dummy_params[1] = {"1"}; Oid dummy_param_oids[1] = {INT4OID}; int i; + int gotrows; bool goterror; fprintf(stderr, "aborted pipeline... "); @@ -441,12 +446,14 @@ test_pipeline_abort(PGconn *conn) pg_fatal("pipeline sync failed: %s", PQerrorMessage(conn)); PQsetSingleRowMode(conn); goterror = false; + gotrows = 0; while ((res = PQgetResult(conn)) != NULL) { switch (PQresultStatus(res)) { case PGRES_SINGLE_TUPLE: printf("got row: %s\n", PQgetvalue(res, 0, 0)); + gotrows++; break; case PGRES_FATAL_ERROR: if (strcmp(PQresultErrorField(res, PG_DIAG_SQLSTATE), "22012") != 0) @@ -463,6 +470,8 @@ test_pipeline_abort(PGconn *conn) } if (!goterror) pg_fatal("did not get division-by-zero error"); + if (gotrows != 3) + pg_fatal("did not get three rows"); /* the third pipeline sync */ if ((res = PQgetResult(conn)) == NULL) pg_fatal("Unexpected NULL result: %s", PQerrorMessage(conn)); @@ -534,15 +543,17 @@ enum PipelineInsertStep static void test_pipelined_insert(PGconn *conn, int n_rows) { - const char *insert_params[1]; - Oid insert_param_oids[1] = {INT4OID}; + Oid insert_param_oids[2] = {INT4OID, INT8OID}; + const char *insert_params[2]; char insert_param_0[MAXINTLEN]; + char insert_param_1[MAXINT8LEN]; enum PipelineInsertStep send_step = BI_BEGIN_TX, recv_step = BI_BEGIN_TX; int rows_to_send, rows_to_receive; - insert_params[0] = &insert_param_0[0]; + insert_params[0] = insert_param_0; + insert_params[1] = insert_param_1; rows_to_send = rows_to_receive = n_rows; @@ -585,8 +596,8 @@ test_pipelined_insert(PGconn *conn, int n_rows) } Assert(send_step == BI_PREPARE); - pg_debug("sending: %s\n", insert_sql); - if (PQsendPrepare(conn, "my_insert", insert_sql, 1, insert_param_oids) != 1) + pg_debug("sending: %s\n", insert_sql2); + if (PQsendPrepare(conn, "my_insert", insert_sql2, 2, insert_param_oids) != 1) pg_fatal("dispatching PREPARE failed: %s", PQerrorMessage(conn)); send_step = BI_INSERT_ROWS; @@ -712,10 +723,12 @@ test_pipelined_insert(PGconn *conn, int n_rows) if (send_step == BI_INSERT_ROWS) { - snprintf(&insert_param_0[0], MAXINTLEN, "%d", rows_to_send); + snprintf(insert_param_0, MAXINTLEN, "%d", rows_to_send); + snprintf(insert_param_1, MAXINT8LEN, "%lld", + (long long) rows_to_send); if (PQsendQueryPrepared(conn, "my_insert", - 1, insert_params, NULL, NULL, 0) == 1) + 2, insert_params, NULL, NULL, 0) == 1) { pg_debug("sent row %d\n", rows_to_send); diff --git a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl index f20a6a29bd..f8e39b5813 100644 --- a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl +++ b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl @@ -11,13 +11,15 @@ my $node = get_new_node('main'); $node->init; $node->start; -my $numrows = 10000; +my $numrows = 700; $ENV{PATH} = "$ENV{PATH}:" . getcwd(); my ($out, $err) = run_command([ 'libpq_pipeline', 'tests' ]); die "oops: $err" unless $err eq ''; my @tests = split(/\s+/, $out); +mkdir "$TestLib::tmp_check/traces"; + for my $testname (@tests) { my @extraargs = (); @@ -26,7 +28,7 @@ for my $testname (@tests) pipeline_abort transaction disallowed_in_pipeline)) > 0; # For a bunch of tests, generate a libpq trace file too. - my $traceout = "$TestLib::log_path/$testname.trace"; + my $traceout = "$TestLib::tmp_check/traces/$testname.trace"; if ($cmptrace) { push @extraargs, "-t", $traceout; @@ -52,7 +54,7 @@ for my $testname (@tests) $result = slurp_file_eval($traceout); next unless $result ne ""; - is($expected, $result, "$testname trace match"); + is($result, $expected, "$testname trace match"); } } diff --git a/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace b/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace index 2967b70b75..6aacca03bf 100644 --- a/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace +++ b/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace @@ -5,10 +5,10 @@ F 42 Query "DROP TABLE IF EXISTS pq_pipeline_demo" B 123 NoticeResponse S "NOTICE" V "NOTICE" C "00000" M "table "pq_pipeline_demo" does not exist, skipping" F "SSSS" L "SSSS" R "SSSS" \x00 B 15 CommandComplete "DROP TABLE" B 5 ReadyForQuery I -F 83 Query "CREATE UNLOGGED TABLE pq_pipeline_demo(id serial primary key, itemno integer);" +F 99 Query "CREATE UNLOGGED TABLE pq_pipeline_demo(id serial primary key, itemno integer,int8filler int8);" B 17 CommandComplete "CREATE TABLE" B 5 ReadyForQuery I -F 61 Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1);" 1 NNNN +F 60 Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1)" 1 NNNN F 19 Bind "" "" 0 1 1 '1' 1 0 F 6 Describe P "" F 9 Execute "" 0 @@ -16,12 +16,12 @@ F 39 Parse "" "SELECT no_such_function($1)" 1 NNNN F 19 Bind "" "" 0 1 1 '1' 1 0 F 6 Describe P "" F 9 Execute "" 0 -F 61 Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1);" 1 NNNN +F 60 Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1)" 1 NNNN F 19 Bind "" "" 0 1 1 '2' 1 0 F 6 Describe P "" F 9 Execute "" 0 F 4 Sync -F 61 Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1);" 1 NNNN +F 60 Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1)" 1 NNNN F 19 Bind "" "" 0 1 1 '3' 1 0 F 6 Describe P "" F 9 Execute "" 0