Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdb973ff

Browse files
committed
Fix some libpq_pipeline test problems
Test pipeline_abort was not checking that it got the rows it expected inone mode; make it do so. This doesn't fix the actual problem (no ideawhat that is, yet) but at least it should make it more obvious ratherthan being visible only as a difference in the trace output.While at it, fix other infelicities in the test:* I reversed the order of result vs. expected in like().* The output traces from -t are being put in the log dir, which meansthe buildfarm script uselessly captures them. Put them in a separatedir tmp_check/traces instead, to avoid cluttering the buildfarm results.* Test pipelined_insert was using too large a row count. Reduce that atad and add a filler column to make each insert a little bulkier, whilestill keeping enough that a buffer is filled and we have to switch mode.
1 parentb12bd48 commitdb973ff

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

‎src/test/modules/libpq_pipeline/libpq_pipeline.c‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ char *tracefile = NULL;/* path to PQtrace() file */
4545
staticconstchar*constdrop_table_sql=
4646
"DROP TABLE IF EXISTS pq_pipeline_demo";
4747
staticconstchar*constcreate_table_sql=
48-
"CREATE UNLOGGED TABLE pq_pipeline_demo(id serial primary key, itemno integer);";
48+
"CREATE UNLOGGED TABLE pq_pipeline_demo(id serial primary key, itemno integer,"
49+
"int8filler int8);";
4950
staticconstchar*constinsert_sql=
50-
"INSERT INTO pq_pipeline_demo(itemno) VALUES ($1);";
51+
"INSERT INTO pq_pipeline_demo(itemno) VALUES ($1)";
52+
staticconstchar*constinsert_sql2=
53+
"INSERT INTO pq_pipeline_demo(itemno,int8filler) VALUES ($1, $2)";
5154

52-
/* max char length of an int32, plus sign and null terminator */
55+
/* max char length of an int32/64, plus sign and null terminator */
5356
#defineMAXINTLEN 12
57+
#defineMAXINT8LEN 20
5458

5559
staticvoid
5660
exit_nicely(PGconn*conn)
@@ -243,6 +247,7 @@ test_pipeline_abort(PGconn *conn)
243247
constchar*dummy_params[1]= {"1"};
244248
Oiddummy_param_oids[1]= {INT4OID};
245249
inti;
250+
intgotrows;
246251
boolgoterror;
247252

248253
fprintf(stderr,"aborted pipeline... ");
@@ -441,12 +446,14 @@ test_pipeline_abort(PGconn *conn)
441446
pg_fatal("pipeline sync failed: %s",PQerrorMessage(conn));
442447
PQsetSingleRowMode(conn);
443448
goterror= false;
449+
gotrows=0;
444450
while ((res=PQgetResult(conn))!=NULL)
445451
{
446452
switch (PQresultStatus(res))
447453
{
448454
casePGRES_SINGLE_TUPLE:
449455
printf("got row: %s\n",PQgetvalue(res,0,0));
456+
gotrows++;
450457
break;
451458
casePGRES_FATAL_ERROR:
452459
if (strcmp(PQresultErrorField(res,PG_DIAG_SQLSTATE),"22012")!=0)
@@ -463,6 +470,8 @@ test_pipeline_abort(PGconn *conn)
463470
}
464471
if (!goterror)
465472
pg_fatal("did not get division-by-zero error");
473+
if (gotrows!=3)
474+
pg_fatal("did not get three rows");
466475
/* the third pipeline sync */
467476
if ((res=PQgetResult(conn))==NULL)
468477
pg_fatal("Unexpected NULL result: %s",PQerrorMessage(conn));
@@ -534,15 +543,17 @@ enum PipelineInsertStep
534543
staticvoid
535544
test_pipelined_insert(PGconn*conn,intn_rows)
536545
{
537-
constchar*insert_params[1];
538-
Oidinsert_param_oids[1]= {INT4OID};
546+
Oidinsert_param_oids[2]= {INT4OID,INT8OID};
547+
constchar*insert_params[2];
539548
charinsert_param_0[MAXINTLEN];
549+
charinsert_param_1[MAXINT8LEN];
540550
enumPipelineInsertStepsend_step=BI_BEGIN_TX,
541551
recv_step=BI_BEGIN_TX;
542552
introws_to_send,
543553
rows_to_receive;
544554

545-
insert_params[0]=&insert_param_0[0];
555+
insert_params[0]=insert_param_0;
556+
insert_params[1]=insert_param_1;
546557

547558
rows_to_send=rows_to_receive=n_rows;
548559

@@ -585,8 +596,8 @@ test_pipelined_insert(PGconn *conn, int n_rows)
585596
}
586597

587598
Assert(send_step==BI_PREPARE);
588-
pg_debug("sending: %s\n",insert_sql);
589-
if (PQsendPrepare(conn,"my_insert",insert_sql,1,insert_param_oids)!=1)
599+
pg_debug("sending: %s\n",insert_sql2);
600+
if (PQsendPrepare(conn,"my_insert",insert_sql2,2,insert_param_oids)!=1)
590601
pg_fatal("dispatching PREPARE failed: %s",PQerrorMessage(conn));
591602
send_step=BI_INSERT_ROWS;
592603

@@ -712,10 +723,12 @@ test_pipelined_insert(PGconn *conn, int n_rows)
712723

713724
if (send_step==BI_INSERT_ROWS)
714725
{
715-
snprintf(&insert_param_0[0],MAXINTLEN,"%d",rows_to_send);
726+
snprintf(insert_param_0,MAXINTLEN,"%d",rows_to_send);
727+
snprintf(insert_param_1,MAXINT8LEN,"%lld",
728+
(long long)rows_to_send);
716729

717730
if (PQsendQueryPrepared(conn,"my_insert",
718-
1,insert_params,NULL,NULL,0)==1)
731+
2,insert_params,NULL,NULL,0)==1)
719732
{
720733
pg_debug("sent row %d\n",rows_to_send);
721734

‎src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
$node->init;
1212
$node->start;
1313

14-
my$numrows =10000;
14+
my$numrows =700;
1515
$ENV{PATH} ="$ENV{PATH}:" . getcwd();
1616

1717
my ($out,$err) = run_command(['libpq_pipeline','tests' ]);
1818
die"oops:$err"unless$erreq'';
1919
my@tests =split(/\s+/,$out);
2020

21+
mkdir"$TestLib::tmp_check/traces";
22+
2123
formy$testname (@tests)
2224
{
2325
my@extraargs = ();
@@ -26,7 +28,7 @@
2628
pipeline_abort transaction disallowed_in_pipeline)) > 0;
2729

2830
# For a bunch of tests, generate a libpq trace file too.
29-
my$traceout ="$TestLib::log_path/$testname.trace";
31+
my$traceout ="$TestLib::tmp_check/traces/$testname.trace";
3032
if ($cmptrace)
3133
{
3234
push@extraargs,"-t",$traceout;
@@ -52,7 +54,7 @@
5254
$result = slurp_file_eval($traceout);
5355
nextunless$resultne"";
5456

55-
is($expected,$result,"$testname trace match");
57+
is($result,$expected,"$testname trace match");
5658
}
5759
}
5860

‎src/test/modules/libpq_pipeline/traces/pipeline_abort.trace‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ F42Query "DROP TABLE IF EXISTS pq_pipeline_demo"
55
B123NoticeResponse S "NOTICE" V "NOTICE" C "00000" M "table "pq_pipeline_demo" does not exist, skipping" F "SSSS" L "SSSS" R "SSSS" \x00
66
B15CommandComplete "DROP TABLE"
77
B5ReadyForQuery I
8-
F83Query "CREATE UNLOGGED TABLE pq_pipeline_demo(id serial primary key, itemno integer);"
8+
F99Query "CREATE UNLOGGED TABLE pq_pipeline_demo(id serial primary key, itemno integer,int8filler int8);"
99
B17CommandComplete "CREATE TABLE"
1010
B5ReadyForQuery I
11-
F61Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1);" 1 NNNN
11+
F60Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1)" 1 NNNN
1212
F19Bind "" "" 0 1 1 '1' 1 0
1313
F6Describe P ""
1414
F9Execute "" 0
1515
F39Parse "" "SELECT no_such_function($1)" 1 NNNN
1616
F19Bind "" "" 0 1 1 '1' 1 0
1717
F6Describe P ""
1818
F9Execute "" 0
19-
F61Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1);" 1 NNNN
19+
F60Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1)" 1 NNNN
2020
F19Bind "" "" 0 1 1 '2' 1 0
2121
F6Describe P ""
2222
F9Execute "" 0
2323
F4Sync
24-
F61Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1);" 1 NNNN
24+
F60Parse "" "INSERT INTO pq_pipeline_demo(itemno) VALUES ($1)" 1 NNNN
2525
F19Bind "" "" 0 1 1 '3' 1 0
2626
F6Describe P ""
2727
F9Execute "" 0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp