@@ -74,8 +74,12 @@ func newTestWorkspace() *testWorkspace {
7474 return & testWorkspace {}
7575}
7676
77- func (txn * testWorkspace ) StartStatement (sql string ) {
77+ func (txn * testWorkspace ) StartStatement (stmt tree. Statement ) {
7878 if txn .start {
79+ var sql string
80+ if stmt != nil {
81+ sql = stmt .String ()
82+ }
7983 panic (fmt .Sprintf ("BUG: StartStatement called twice, sql: %s" , sql ))
8084 }
8185 txn .start = true
@@ -177,7 +181,7 @@ func TestWorkspace(t *testing.T) {
177181 convey .So (
178182 func () {
179183 wsp := newTestWorkspace ()
180- wsp .StartStatement ("" )
184+ wsp .StartStatement (nil )
181185 wsp .EndStatement ()
182186 },
183187 convey .ShouldNotPanic ,
@@ -196,8 +200,8 @@ func TestWorkspace(t *testing.T) {
196200 convey .So (
197201 func () {
198202 wsp := newTestWorkspace ()
199- wsp .StartStatement ("" )
200- wsp .StartStatement ("" )
203+ wsp .StartStatement (nil )
204+ wsp .StartStatement (nil )
201205 },
202206 convey .ShouldPanic ,
203207 )
@@ -217,7 +221,7 @@ func TestWorkspace(t *testing.T) {
217221 convey .So (
218222 func () {
219223 wsp := newTestWorkspace ()
220- wsp .StartStatement ("" )
224+ wsp .StartStatement (nil )
221225 err := wsp .IncrStatementID (context .TODO (), false )
222226 convey .So (err , convey .ShouldBeNil )
223227 //incr twice
@@ -231,7 +235,7 @@ func TestWorkspace(t *testing.T) {
231235 convey .So (
232236 func () {
233237 wsp := newTestWorkspace ()
234- wsp .StartStatement ("" )
238+ wsp .StartStatement (nil )
235239 err := wsp .RollbackLastStatement (context .TODO ())
236240 convey .So (err , convey .ShouldBeNil )
237241 },
@@ -242,7 +246,7 @@ func TestWorkspace(t *testing.T) {
242246 convey .So (
243247 func () {
244248 wsp := newTestWorkspace ()
245- wsp .StartStatement ("" )
249+ wsp .StartStatement (nil )
246250 err := wsp .IncrStatementID (context .TODO (), false )
247251 convey .So (err , convey .ShouldBeNil )
248252 err = wsp .RollbackLastStatement (context .TODO ())
@@ -484,7 +488,7 @@ func Test_rollbackStatement(t *testing.T) {
484488 NeedToBeCommittedInActiveTransaction (& tree.Insert {}), convey .ShouldBeFalse )
485489 convey .So (txnOp != nil && ! ses .IsDerivedStmt (), convey .ShouldBeTrue )
486490 //called incrStatement
487- txnOp .GetWorkspace ().StartStatement ("" )
491+ txnOp .GetWorkspace ().StartStatement (nil )
488492 err = txnOp .GetWorkspace ().IncrStatementID (ctx , false )
489493 convey .So (err , convey .ShouldBeNil )
490494 ec .stmt = & tree.Insert {}
@@ -514,7 +518,7 @@ func Test_rollbackStatement(t *testing.T) {
514518 NeedToBeCommittedInActiveTransaction (& tree.Insert {}), convey .ShouldBeFalse )
515519 convey .So (txnOp != nil && ! ses .IsDerivedStmt (), convey .ShouldBeTrue )
516520 //called incrStatement
517- txnOp .GetWorkspace ().StartStatement ("" )
521+ txnOp .GetWorkspace ().StartStatement (nil )
518522 err = txnOp .GetWorkspace ().IncrStatementID (ctx , false )
519523 convey .So (err , convey .ShouldBeNil )
520524 ec .stmt = & tree.Insert {}
@@ -671,7 +675,7 @@ func Test_rollbackStatement5(t *testing.T) {
671675 NeedToBeCommittedInActiveTransaction (& tree.Insert {}), convey .ShouldBeFalse )
672676 convey .So (txnOp != nil && ! ses .IsDerivedStmt (), convey .ShouldBeTrue )
673677 //called incrStatement
674- txnOp .GetWorkspace ().StartStatement ("" )
678+ txnOp .GetWorkspace ().StartStatement (nil )
675679 err = txnOp .GetWorkspace ().IncrStatementID (ctx , false )
676680 convey .So (err , convey .ShouldBeNil )
677681 ec .stmt = & tree.Insert {}
@@ -710,7 +714,7 @@ func Test_rollbackStatement6(t *testing.T) {
710714 NeedToBeCommittedInActiveTransaction (& tree.Insert {}), convey .ShouldBeFalse )
711715 convey .So (txnOp != nil && ! ses .IsDerivedStmt (), convey .ShouldBeTrue )
712716 //called incrStatement
713- txnOp .GetWorkspace ().StartStatement ("" )
717+ txnOp .GetWorkspace ().StartStatement (nil )
714718 err = txnOp .GetWorkspace ().IncrStatementID (ctx , false )
715719 convey .So (err , convey .ShouldBeNil )
716720 ec .stmt = & tree.Insert {}
@@ -745,7 +749,7 @@ func Test_rollbackStatement6(t *testing.T) {
745749 NeedToBeCommittedInActiveTransaction (& tree.Insert {}), convey .ShouldBeFalse )
746750 convey .So (txnOp != nil && ! ses .IsDerivedStmt (), convey .ShouldBeTrue )
747751 //called incrStatement
748- txnOp .GetWorkspace ().StartStatement ("" )
752+ txnOp .GetWorkspace ().StartStatement (nil )
749753 err = txnOp .GetWorkspace ().IncrStatementID (ctx , false )
750754 convey .So (err , convey .ShouldBeNil )
751755 ec .stmt = & tree.Insert {}
0 commit comments