@@ -74,8 +74,12 @@ func newTestWorkspace() *testWorkspace {
74
74
return & testWorkspace {}
75
75
}
76
76
77
- func (txn * testWorkspace ) StartStatement (sql string ) {
77
+ func (txn * testWorkspace ) StartStatement (stmt tree. Statement ) {
78
78
if txn .start {
79
+ var sql string
80
+ if stmt != nil {
81
+ sql = stmt .String ()
82
+ }
79
83
panic (fmt .Sprintf ("BUG: StartStatement called twice, sql: %s" , sql ))
80
84
}
81
85
txn .start = true
@@ -177,7 +181,7 @@ func TestWorkspace(t *testing.T) {
177
181
convey .So (
178
182
func () {
179
183
wsp := newTestWorkspace ()
180
- wsp .StartStatement ("" )
184
+ wsp .StartStatement (nil )
181
185
wsp .EndStatement ()
182
186
},
183
187
convey .ShouldNotPanic ,
@@ -196,8 +200,8 @@ func TestWorkspace(t *testing.T) {
196
200
convey .So (
197
201
func () {
198
202
wsp := newTestWorkspace ()
199
- wsp .StartStatement ("" )
200
- wsp .StartStatement ("" )
203
+ wsp .StartStatement (nil )
204
+ wsp .StartStatement (nil )
201
205
},
202
206
convey .ShouldPanic ,
203
207
)
@@ -217,7 +221,7 @@ func TestWorkspace(t *testing.T) {
217
221
convey .So (
218
222
func () {
219
223
wsp := newTestWorkspace ()
220
- wsp .StartStatement ("" )
224
+ wsp .StartStatement (nil )
221
225
err := wsp .IncrStatementID (context .TODO (), false )
222
226
convey .So (err , convey .ShouldBeNil )
223
227
//incr twice
@@ -231,7 +235,7 @@ func TestWorkspace(t *testing.T) {
231
235
convey .So (
232
236
func () {
233
237
wsp := newTestWorkspace ()
234
- wsp .StartStatement ("" )
238
+ wsp .StartStatement (nil )
235
239
err := wsp .RollbackLastStatement (context .TODO ())
236
240
convey .So (err , convey .ShouldBeNil )
237
241
},
@@ -242,7 +246,7 @@ func TestWorkspace(t *testing.T) {
242
246
convey .So (
243
247
func () {
244
248
wsp := newTestWorkspace ()
245
- wsp .StartStatement ("" )
249
+ wsp .StartStatement (nil )
246
250
err := wsp .IncrStatementID (context .TODO (), false )
247
251
convey .So (err , convey .ShouldBeNil )
248
252
err = wsp .RollbackLastStatement (context .TODO ())
@@ -484,7 +488,7 @@ func Test_rollbackStatement(t *testing.T) {
484
488
NeedToBeCommittedInActiveTransaction (& tree.Insert {}), convey .ShouldBeFalse )
485
489
convey .So (txnOp != nil && ! ses .IsDerivedStmt (), convey .ShouldBeTrue )
486
490
//called incrStatement
487
- txnOp .GetWorkspace ().StartStatement ("" )
491
+ txnOp .GetWorkspace ().StartStatement (nil )
488
492
err = txnOp .GetWorkspace ().IncrStatementID (ctx , false )
489
493
convey .So (err , convey .ShouldBeNil )
490
494
ec .stmt = & tree.Insert {}
@@ -514,7 +518,7 @@ func Test_rollbackStatement(t *testing.T) {
514
518
NeedToBeCommittedInActiveTransaction (& tree.Insert {}), convey .ShouldBeFalse )
515
519
convey .So (txnOp != nil && ! ses .IsDerivedStmt (), convey .ShouldBeTrue )
516
520
//called incrStatement
517
- txnOp .GetWorkspace ().StartStatement ("" )
521
+ txnOp .GetWorkspace ().StartStatement (nil )
518
522
err = txnOp .GetWorkspace ().IncrStatementID (ctx , false )
519
523
convey .So (err , convey .ShouldBeNil )
520
524
ec .stmt = & tree.Insert {}
@@ -671,7 +675,7 @@ func Test_rollbackStatement5(t *testing.T) {
671
675
NeedToBeCommittedInActiveTransaction (& tree.Insert {}), convey .ShouldBeFalse )
672
676
convey .So (txnOp != nil && ! ses .IsDerivedStmt (), convey .ShouldBeTrue )
673
677
//called incrStatement
674
- txnOp .GetWorkspace ().StartStatement ("" )
678
+ txnOp .GetWorkspace ().StartStatement (nil )
675
679
err = txnOp .GetWorkspace ().IncrStatementID (ctx , false )
676
680
convey .So (err , convey .ShouldBeNil )
677
681
ec .stmt = & tree.Insert {}
@@ -710,7 +714,7 @@ func Test_rollbackStatement6(t *testing.T) {
710
714
NeedToBeCommittedInActiveTransaction (& tree.Insert {}), convey .ShouldBeFalse )
711
715
convey .So (txnOp != nil && ! ses .IsDerivedStmt (), convey .ShouldBeTrue )
712
716
//called incrStatement
713
- txnOp .GetWorkspace ().StartStatement ("" )
717
+ txnOp .GetWorkspace ().StartStatement (nil )
714
718
err = txnOp .GetWorkspace ().IncrStatementID (ctx , false )
715
719
convey .So (err , convey .ShouldBeNil )
716
720
ec .stmt = & tree.Insert {}
@@ -745,7 +749,7 @@ func Test_rollbackStatement6(t *testing.T) {
745
749
NeedToBeCommittedInActiveTransaction (& tree.Insert {}), convey .ShouldBeFalse )
746
750
convey .So (txnOp != nil && ! ses .IsDerivedStmt (), convey .ShouldBeTrue )
747
751
//called incrStatement
748
- txnOp .GetWorkspace ().StartStatement ("" )
752
+ txnOp .GetWorkspace ().StartStatement (nil )
749
753
err = txnOp .GetWorkspace ().IncrStatementID (ctx , false )
750
754
convey .So (err , convey .ShouldBeNil )
751
755
ec .stmt = & tree.Insert {}
0 commit comments