@@ -40,6 +40,8 @@ type InterpreterNode interface {
4040 SetSchema (sch sql.Schema )
4141}
4242
43+ // replaceVariablesInExpr will search for every ast.Node and handle each one on a case by case basis.
44+ // If a new ast.Node is added to the vitess parser we may need to add a case for it here.
4345func replaceVariablesInExpr (ctx * sql.Context , stack * InterpreterStack , expr ast.SQLNode , asOf * ast.AsOf ) (ast.SQLNode , error ) {
4446 switch e := expr .(type ) {
4547 case * ast.ColName :
@@ -286,6 +288,9 @@ func query(ctx *sql.Context, runner sql.StatementRunner, stmt ast.Statement) (sq
286288 if rErr == io .EOF {
287289 break
288290 }
291+ if cErr := rowIter .Close (ctx ); cErr != nil {
292+ return nil , nil , cErr
293+ }
289294 return nil , nil , rErr
290295 }
291296 rows = append (rows , row )
@@ -402,6 +407,9 @@ func execOp(ctx *sql.Context, runner sql.StatementRunner, stack *InterpreterStac
402407 return 0 , nil , nil , nil , err
403408 }
404409 if _ , err = rowIter .Next (ctx ); err != io .EOF {
410+ if rErr := rowIter .Close (ctx ); rErr != nil {
411+ return 0 , nil , nil , nil , rErr
412+ }
405413 return 0 , nil , nil , nil , err
406414 }
407415 if err = rowIter .Close (ctx ); err != nil {
@@ -507,7 +515,7 @@ func execOp(ctx *sql.Context, runner sql.StatementRunner, stack *InterpreterStac
507515 return 0 , nil , nil , nil , fmt .Errorf ("warnings not yet implemented" )
508516 }
509517 } else {
510- cond := stack .GetCondition (strings . ToLower ( signalStmt .ConditionName ) )
518+ cond := stack .GetCondition (signalStmt .ConditionName )
511519 if cond == nil {
512520 return 0 , nil , nil , nil , sql .ErrDeclareConditionNotFound .New (signalStmt .ConditionName )
513521 }
@@ -587,7 +595,7 @@ func execOp(ctx *sql.Context, runner sql.StatementRunner, stack *InterpreterStac
587595
588596 case OpCode_Open :
589597 openCur := operation .PrimaryData .(* ast.OpenCursor )
590- cursor := stack .GetCursor (strings . ToLower ( openCur .Name ) )
598+ cursor := stack .GetCursor (openCur .Name )
591599 if cursor == nil {
592600 return 0 , nil , nil , nil , sql .ErrCursorNotFound .New (openCur .Name )
593601 }
@@ -607,7 +615,7 @@ func execOp(ctx *sql.Context, runner sql.StatementRunner, stack *InterpreterStac
607615
608616 case OpCode_Fetch :
609617 fetchCur := operation .PrimaryData .(* ast.FetchCursor )
610- cursor := stack .GetCursor (strings . ToLower ( fetchCur .Name ) )
618+ cursor := stack .GetCursor (fetchCur .Name )
611619 if cursor == nil {
612620 return 0 , nil , nil , nil , sql .ErrCursorNotFound .New (fetchCur .Name )
613621 }
@@ -641,7 +649,7 @@ func execOp(ctx *sql.Context, runner sql.StatementRunner, stack *InterpreterStac
641649
642650 case OpCode_Close :
643651 closeCur := operation .PrimaryData .(* ast.CloseCursor )
644- cursor := stack .GetCursor (strings . ToLower ( closeCur .Name ) )
652+ cursor := stack .GetCursor (closeCur .Name )
645653 if cursor == nil {
646654 return 0 , nil , nil , nil , sql .ErrCursorNotFound .New (closeCur .Name )
647655 }
@@ -680,7 +688,7 @@ func execOp(ctx *sql.Context, runner sql.StatementRunner, stack *InterpreterStac
680688 return 0 , nil , nil , nil , err
681689 }
682690
683- err = stack .SetVariable (strings . ToLower ( operation .Target ) , row [0 ])
691+ err = stack .SetVariable (operation .Target , row [0 ])
684692 if err != nil {
685693 err = ctx .Session .SetStoredProcParam (operation .Target , row [0 ])
686694 if err != nil {
0 commit comments