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

Commitc63f309

Browse files
committed
Allow isolation tests to specify multiple setup blocks.
Each setup block is run as a single PQexec submission, and somestatements such as VACUUM cannot be combined with others in such ablock.Backpatch to 9.2.Kevin Grittner and Tom Lane
1 parent63f1ccd commitc63f309

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

‎src/test/isolation/README

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ subdirectory. A test specification consists of four parts, in this order:
4949
setup { <SQL> }
5050

5151
The given SQL block is executed once, in one session only, before running
52-
the test. Create any test tables or other required objects here. This
53-
part is optional.
52+
the test. Create any test tables or other required objects here. This
53+
part is optional. Multiple setup blocks are allowed if needed; each is
54+
run separately, in the given order. (The reason for allowing multiple
55+
setup blocks is that each block is run as a single PQexec submission,
56+
and some statements such as VACUUM cannot be combined with others in such
57+
a block.)
5458

5559
teardown { <SQL> }
5660

‎src/test/isolation/isolationtester.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
512512
printf("\n");
513513

514514
/* Perform setup */
515-
if (testspec->setupsql)
515+
for (i=0;i<testspec->nsetupsqls;i++)
516516
{
517-
res=PQexec(conns[0],testspec->setupsql);
517+
res=PQexec(conns[0],testspec->setupsqls[i]);
518518
if (PQresultStatus(res)!=PGRES_COMMAND_OK)
519519
{
520520
fprintf(stderr,"setup failed: %s",PQerrorMessage(conns[0]));

‎src/test/isolation/isolationtester.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ typedef struct
4242

4343
typedefstruct
4444
{
45-
char*setupsql;
45+
char**setupsqls;
46+
intnsetupsqls;
4647
char*teardownsql;
4748
Session**sessions;
4849
intnsessions;

‎src/test/isolation/specparse.y

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ TestSpecparseresult;/* result of parsing is left here */
3535
}ptr_list;
3636
}
3737

38+
%type<ptr_list>setup_list
3839
%type<str>opt_setupopt_teardown
40+
%type<str>setup
3941
%type<ptr_list>step_listsession_listpermutation_listopt_permutation_list
4042
%type<ptr_list>string_list
4143
%type<session>session
@@ -48,12 +50,13 @@ TestSpecparseresult;/* result of parsing is left here */
4850
%%
4951

5052
TestSpec:
51-
opt_setup
53+
setup_list
5254
opt_teardown
5355
session_list
5456
opt_permutation_list
5557
{
56-
parseresult.setupsql =$1;
58+
parseresult.setupsqls = (char **)$1.elements;
59+
parseresult.nsetupsqls =$1.nelements;
5760
parseresult.teardownsql =$2;
5861
parseresult.sessions = (Session **)$3.elements;
5962
parseresult.nsessions =$3.nelements;
@@ -62,9 +65,28 @@ TestSpec:
6265
}
6366
;
6467

68+
setup_list:
69+
/* EMPTY*/
70+
{
71+
$$.elements =NULL;
72+
$$.nelements =0;
73+
}
74+
|setup_listsetup
75+
{
76+
$$.elements = realloc($1.elements,
77+
($1.nelements +1) *sizeof(void *));
78+
$$.elements[$1.nelements] =$2;
79+
$$.nelements =$1.nelements +1;
80+
}
81+
;
82+
6583
opt_setup:
6684
/* EMPTY*/{$$ =NULL; }
67-
|SETUPsqlblock{$$ =$2; }
85+
|setup{$$ =$1; }
86+
;
87+
88+
setup:
89+
SETUPsqlblock{$$ =$2; }
6890
;
6991

7092
opt_teardown:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp