2 /*-------------------------------------------------------------------------
5 * bison grammar for the isolation test file format
7 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 *-------------------------------------------------------------------------
13 #include "postgres_fe.h"
15 #include "isolationtester.h"
18 TestSpec parseresult
; /* result of parsing is left here */
23 %name
-prefix
="spec_yy"
31 Permutation
*permutation
;
32 PermutationStep
*permutationstep
;
33 PermutationStepBlocker
*blocker
;
41 %type
<ptr_list
> setup_list
42 %type
<str
> opt_setup opt_teardown
44 %type
<ptr_list
> step_list session_list permutation_list opt_permutation_list
45 %type
<ptr_list
> permutation_step_list blocker_list
46 %type
<session
> session
48 %type
<permutation
> permutation
49 %type
<permutationstep
> permutation_step
50 %type
<blocker
> blocker
52 %token
<str
> sqlblock identifier
53 %token
<integer
> INTEGER
54 %token NOTICES PERMUTATION SESSION SETUP STEP TEARDOWN TEST
64 parseresult.setupsqls
= (char **) $1.elements
;
65 parseresult.nsetupsqls
= $1.nelements
;
66 parseresult.teardownsql
= $2;
67 parseresult.sessions
= (Session
**) $3.elements
;
68 parseresult.nsessions
= $3.nelements
;
69 parseresult.permutations
= (Permutation
**) $4.elements
;
70 parseresult.npermutations
= $4.nelements
;
82 $$.elements
= pg_realloc
($1.elements
,
83 ($1.nelements
+ 1) * sizeof
(void *));
84 $$.elements
[$1.nelements
] = $2;
85 $$.nelements
= $1.nelements
+ 1;
90 /* EMPTY */ { $$
= NULL
; }
95 SETUP sqlblock
{ $$
= $2; }
99 /* EMPTY */ { $$
= NULL
; }
100 | TEARDOWN sqlblock
{ $$
= $2; }
106 $$.elements
= pg_realloc
($1.elements
,
107 ($1.nelements
+ 1) * sizeof
(void *));
108 $$.elements
[$1.nelements
] = $2;
109 $$.nelements
= $1.nelements
+ 1;
114 $$.elements
= pg_malloc
(sizeof
(void *));
120 SESSION identifier opt_setup step_list opt_teardown
122 $$
= pg_malloc
(sizeof
(Session
));
125 $$
->steps
= (Step
**) $4.elements
;
126 $$
->nsteps
= $4.nelements
;
127 $$
->teardownsql
= $5;
134 $$.elements
= pg_realloc
($1.elements
,
135 ($1.nelements
+ 1) * sizeof
(void *));
136 $$.elements
[$1.nelements
] = $2;
137 $$.nelements
= $1.nelements
+ 1;
142 $$.elements
= pg_malloc
(sizeof
(void *));
149 STEP identifier sqlblock
151 $$
= pg_malloc
(sizeof
(Step
));
154 $$
->session
= -1; /* until filled */
160 opt_permutation_list:
172 permutation_list permutation
174 $$.elements
= pg_realloc
($1.elements
,
175 ($1.nelements
+ 1) * sizeof
(void *));
176 $$.elements
[$1.nelements
] = $2;
177 $$.nelements
= $1.nelements
+ 1;
182 $$.elements
= pg_malloc
(sizeof
(void *));
189 PERMUTATION permutation_step_list
191 $$
= pg_malloc
(sizeof
(Permutation
));
192 $$
->nsteps
= $2.nelements
;
193 $$
->steps
= (PermutationStep
**) $2.elements
;
197 permutation_step_list:
198 permutation_step_list permutation_step
200 $$.elements
= pg_realloc
($1.elements
,
201 ($1.nelements
+ 1) * sizeof
(void *));
202 $$.elements
[$1.nelements
] = $2;
203 $$.nelements
= $1.nelements
+ 1;
208 $$.elements
= pg_malloc
(sizeof
(void *));
216 $$
= pg_malloc
(sizeof
(PermutationStep
));
222 | identifier
'(' blocker_list
')'
224 $$
= pg_malloc
(sizeof
(PermutationStep
));
226 $$
->blockers
= (PermutationStepBlocker
**) $3.elements
;
227 $$
->nblockers
= $3.nelements
;
233 blocker_list
',' blocker
235 $$.elements
= pg_realloc
($1.elements
,
236 ($1.nelements
+ 1) * sizeof
(void *));
237 $$.elements
[$1.nelements
] = $3;
238 $$.nelements
= $1.nelements
+ 1;
243 $$.elements
= pg_malloc
(sizeof
(void *));
251 $$
= pg_malloc
(sizeof
(PermutationStepBlocker
));
253 $$
->blocktype
= PSB_OTHER_STEP
;
254 $$
->num_notices
= -1;
256 $$
->target_notices
= -1;
258 | identifier NOTICES INTEGER
260 $$
= pg_malloc
(sizeof
(PermutationStepBlocker
));
262 $$
->blocktype
= PSB_NUM_NOTICES
;
263 $$
->num_notices
= $3;
265 $$
->target_notices
= -1;
269 $$
= pg_malloc
(sizeof
(PermutationStepBlocker
));
271 $$
->blocktype
= PSB_ONCE
;
272 $$
->num_notices
= -1;
274 $$
->target_notices
= -1;
280 #include "specscanner.c"