Skip to content

Commit a443c1b

Browse files
committed
Allow non-quoted identifiers as isolation test session/step names.
For no obvious reason, isolationtester has always insisted that session and step names be written with double quotes. This is fairly tedious and does little for test readability, especially since the names that people actually choose almost always look like normal identifiers. Hence, let's tweak the lexer to allow SQL-like identifiers not only double-quoted strings. (They're SQL-like, not exactly SQL, because I didn't add any case-folding logic. Also there's no provision for U&"..." names, not that anyone's likely to care.) There is one incompatibility introduced by this change: if you write "foo""bar" with no space, that used to be taken as two identifiers, but now it's just one identifier with an embedded quote mark. I converted all the src/test/isolation/ specfiles to remove unnecessary double quotes, but stopped there because my eyes were glazing over already. Like 741d7f1, back-patch to all supported branches, so that this isn't a stumbling block for back-patching isolation test changes. Discussion: https://postgr.es/m/759113.1623861959@sss.pgh.pa.us
1 parent 2031e16 commit a443c1b

File tree

104 files changed

+3867
-3841
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+3867
-3841
lines changed

contrib/test_decoding/specs/oldest_xmin.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ step "s1_commit" { COMMIT; }
3939
# composite type is a rare form of DDL which allows T1 to see the tuple which
4040
# will be removed (xmax set) before T1 commits. That is, interlocking doesn't
4141
# forbid modifying catalog after someone read it (and didn't commit yet).
42-
permutation "s0_begin" "s0_getxid" "s1_begin" "s1_insert" "s0_alter" "s0_commit" "s0_checkpoint" "s0_get_changes" "s0_get_changes""s1_commit" "s0_vacuum" "s0_get_changes"
42+
permutation "s0_begin" "s0_getxid" "s1_begin" "s1_insert" "s0_alter" "s0_commit" "s0_checkpoint" "s0_get_changes" "s0_get_changes" "s1_commit" "s0_vacuum" "s0_get_changes"

src/test/isolation/README

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ teardown { <SQL> }
8080
this to clean up in preparation for the next permutation, e.g dropping
8181
any test tables created by setup. This part is optional.
8282

83-
session "<name>"
83+
session <name>
8484

8585
There are normally several "session" parts in a spec file. Each
8686
session is executed in its own connection. A session part consists
@@ -91,25 +91,35 @@ session "<name>"
9191

9292
Each step has the syntax
9393

94-
step "<name>" { <SQL> }
94+
step <name> { <SQL> }
9595

96-
where <name> is a name identifying this step, and SQL is a SQL statement
96+
where <name> is a name identifying this step, and <SQL> is a SQL statement
9797
(or statements, separated by semicolons) that is executed in the step.
9898
Step names must be unique across the whole spec file.
9999

100-
permutation "<step name>" ...
100+
permutation <step name> ...
101101

102102
A permutation line specifies a list of steps that are run in that order.
103103
Any number of permutation lines can appear. If no permutation lines are
104-
given, the test program automatically generates all possible orderings
104+
given, the test program automatically runs all possible interleavings
105105
of the steps from each session (running the steps of any one session in
106106
order). Note that the list of steps in a manually specified
107107
"permutation" line doesn't actually have to be a permutation of the
108108
available steps; it could for instance repeat some steps more than once,
109109
or leave others out. Also, each step name can be annotated with some
110110
parenthesized markers, which are described below.
111111

112-
Lines beginning with a # are considered comments.
112+
Session and step names are SQL identifiers, either plain or double-quoted.
113+
A difference from standard SQL is that no case-folding occurs, so that
114+
FOO and "FOO" are the same name while FOO and Foo are different,
115+
whether you quote them or not. You must use quotes if you want to use
116+
an isolation test keyword (such as "permutation") as a name.
117+
118+
A # character begins a comment, which extends to the end of the line.
119+
(This does not work inside <SQL> blocks, however. Use the usual SQL
120+
comment conventions there.)
121+
122+
There is no way to include a "}" character in an <SQL> block.
113123

114124
For each permutation of the session steps (whether these are manually
115125
specified in the spec file, or automatically generated), the isolation

src/test/isolation/specparse.y

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ TestSpec parseresult; /* result of parsing is left here */
4949
%type <permutationstep> permutation_step
5050
%type <blocker> blocker
5151

52-
%token <str> sqlblock string_literal
52+
%token <str> sqlblock identifier
5353
%token <integer> INTEGER
5454
%token NOTICES PERMUTATION SESSION SETUP STEP TEARDOWN TEST
5555

@@ -117,7 +117,7 @@ session_list:
117117
;
118118

119119
session:
120-
SESSION string_literal opt_setup step_list opt_teardown
120+
SESSION identifier opt_setup step_list opt_teardown
121121
{
122122
$$ = pg_malloc(sizeof(Session));
123123
$$->name = $2;
@@ -146,7 +146,7 @@ step_list:
146146

147147

148148
step:
149-
STEP string_literal sqlblock
149+
STEP identifier sqlblock
150150
{
151151
$$ = pg_malloc(sizeof(Step));
152152
$$->name = $2;
@@ -211,15 +211,15 @@ permutation_step_list:
211211
;
212212

213213
permutation_step:
214-
string_literal
214+
identifier
215215
{
216216
$$ = pg_malloc(sizeof(PermutationStep));
217217
$$->name = $1;
218218
$$->blockers = NULL;
219219
$$->nblockers = 0;
220220
$$->step = NULL;
221221
}
222-
| string_literal '(' blocker_list ')'
222+
| identifier '(' blocker_list ')'
223223
{
224224
$$ = pg_malloc(sizeof(PermutationStep));
225225
$$->name = $1;
@@ -246,7 +246,7 @@ blocker_list:
246246
;
247247

248248
blocker:
249-
string_literal
249+
identifier
250250
{
251251
$$ = pg_malloc(sizeof(PermutationStepBlocker));
252252
$$->stepname = $1;
@@ -255,7 +255,7 @@ blocker:
255255
$$->step = NULL;
256256
$$->target_notices = -1;
257257
}
258-
| string_literal NOTICES INTEGER
258+
| identifier NOTICES INTEGER
259259
{
260260
$$ = pg_malloc(sizeof(PermutationStepBlocker));
261261
$$->stepname = $1;

src/test/isolation/specs/aborted-keyrevoke.spec

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ teardown
1717
DROP TABLE foo;
1818
}
1919

20-
session "s1"
20+
session s1
2121
setup { BEGIN; }
22-
step "s1s" { SAVEPOINT f; }
23-
step "s1u" { UPDATE foo SET key = 2; } # obtain KEY REVOKE
24-
step "s1r" { ROLLBACK TO f; } # lose KEY REVOKE
25-
step "s1l" { SELECT * FROM foo FOR KEY SHARE; }
26-
step "s1c" { COMMIT; }
22+
step s1s { SAVEPOINT f; }
23+
step s1u { UPDATE foo SET key = 2; } # obtain KEY REVOKE
24+
step s1r { ROLLBACK TO f; } # lose KEY REVOKE
25+
step s1l { SELECT * FROM foo FOR KEY SHARE; }
26+
step s1c { COMMIT; }
2727

28-
session "s2"
28+
session s2
2929
setup { BEGIN; }
30-
step "s2l" { SELECT * FROM foo FOR KEY SHARE; }
31-
step "s2c" { COMMIT; }
30+
step s2l { SELECT * FROM foo FOR KEY SHARE; }
31+
step s2c { COMMIT; }
3232

33-
permutation "s1s" "s1u" "s1r" "s1l" "s1c" "s2l" "s2c"
34-
permutation "s1s" "s1u" "s1r" "s1l" "s2l" "s1c" "s2c"
35-
permutation "s1s" "s1u" "s1r" "s1l" "s2l" "s2c" "s1c"
36-
permutation "s1s" "s1u" "s1r" "s2l" "s1l" "s1c" "s2c"
37-
permutation "s1s" "s1u" "s1r" "s2l" "s1l" "s2c" "s1c"
38-
permutation "s1s" "s1u" "s1r" "s2l" "s2c" "s1l" "s1c"
39-
permutation "s1s" "s1u" "s2l" "s1r" "s1l" "s1c" "s2c"
40-
permutation "s1s" "s1u" "s2l" "s1r" "s1l" "s2c" "s1c"
41-
permutation "s1s" "s1u" "s2l" "s1r" "s2c" "s1l" "s1c"
42-
permutation "s1s" "s2l" "s1u" "s2c" "s1r" "s1l" "s1c"
43-
permutation "s1s" "s2l" "s2c" "s1u" "s1r" "s1l" "s1c"
44-
permutation "s2l" "s1s" "s1u" "s2c" "s1r" "s1l" "s1c"
45-
permutation "s2l" "s1s" "s2c" "s1u" "s1r" "s1l" "s1c"
46-
permutation "s2l" "s2c" "s1s" "s1u" "s1r" "s1l" "s1c"
33+
permutation s1s s1u s1r s1l s1c s2l s2c
34+
permutation s1s s1u s1r s1l s2l s1c s2c
35+
permutation s1s s1u s1r s1l s2l s2c s1c
36+
permutation s1s s1u s1r s2l s1l s1c s2c
37+
permutation s1s s1u s1r s2l s1l s2c s1c
38+
permutation s1s s1u s1r s2l s2c s1l s1c
39+
permutation s1s s1u s2l s1r s1l s1c s2c
40+
permutation s1s s1u s2l s1r s1l s2c s1c
41+
permutation s1s s1u s2l s1r s2c s1l s1c
42+
permutation s1s s2l s1u s2c s1r s1l s1c
43+
permutation s1s s2l s2c s1u s1r s1l s1c
44+
permutation s2l s1s s1u s2c s1r s1l s1c
45+
permutation s2l s1s s2c s1u s1r s1l s1c
46+
permutation s2l s2c s1s s1u s1r s1l s1c

0 commit comments

Comments
 (0)