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)
const char *dummy_params[1] = {"1"};
Oid dummy_param_oids[1] = {INT4OID};
int i;
+ int gotrows;
bool goterror;
fprintf(stderr, "aborted pipeline... ");
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)
}
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));
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;
}
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;
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);
$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 = ();
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;
$result = slurp_file_eval($traceout);
next unless $result ne "";
- is($expected, $result, "$testname trace match");
+ is($result, $expected, "$testname trace match");
}
}
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
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