Skip to content

Commit a205f74

Browse files
author
James Cor
committed
fix schemas
1 parent 50fbea8 commit a205f74

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

sql/procedures/interpreter_logic.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,11 +768,11 @@ func execOp(ctx *sql.Context, runner sql.StatementRunner, stack *InterpreterStac
768768
return 0, nil, nil, nil, err
769769
}
770770
// TODO: create a OpCode_Call to store procedures in the stack
771-
_, rowIter, err := query(ctx, runner, stmt.(ast.Statement))
771+
sch, rowIter, err := query(ctx, runner, stmt.(ast.Statement))
772772
if err != nil {
773773
return 0, nil, nil, nil, err
774774
}
775-
return counter, nil, nil, rowIter, err
775+
return counter, sch, nil, rowIter, err
776776

777777
case OpCode_Exception:
778778
return 0, nil, nil, nil, operation.Error
@@ -819,6 +819,7 @@ func Call(ctx *sql.Context, iNode InterpreterNode) (sql.RowIter, *InterpreterSta
819819
// Run the statements
820820
// TODO: eventually return multiple sql.RowIters
821821
var rowIters []sql.RowIter
822+
var retSch sql.Schema
822823
runner := iNode.GetRunner()
823824
statements := iNode.GetStatements()
824825
for {
@@ -838,7 +839,7 @@ func Call(ctx *sql.Context, iNode InterpreterNode) (sql.RowIter, *InterpreterSta
838839
subCtx.Session = ctx.Session
839840

840841
operation := statements[counter]
841-
newCounter, newSelSch, newSelIter, rowIter, err := execOp(subCtx, runner, stack, operation, statements, asOf, counter)
842+
newCounter, sch, newSelIter, rowIter, err := execOp(subCtx, runner, stack, operation, statements, asOf, counter)
842843
if err != nil {
843844
hCounter, hErr := handleError(subCtx, runner, stack, statements, counter, err)
844845
if hErr != nil && hErr != io.EOF {
@@ -852,10 +853,11 @@ func Call(ctx *sql.Context, iNode InterpreterNode) (sql.RowIter, *InterpreterSta
852853
}
853854
if rowIter != nil {
854855
rowIters = append(rowIters, rowIter)
856+
retSch = sch
855857
}
856858
if newSelIter != nil {
857859
selIter = newSelIter
858-
selSch = newSelSch
860+
selSch = sch
859861
}
860862
counter = newCounter
861863
}
@@ -865,7 +867,10 @@ func Call(ctx *sql.Context, iNode InterpreterNode) (sql.RowIter, *InterpreterSta
865867
return selIter, stack, nil
866868
}
867869
if len(rowIters) == 0 {
870+
iNode.SetSchema(types.OkResultSchema)
868871
rowIters = append(rowIters, sql.RowsToRowIter(sql.Row{types.NewOkResult(0)}))
872+
} else {
873+
iNode.SetSchema(retSch)
869874
}
870875

871876
// TODO: probably need to set result schema for these too

0 commit comments

Comments
 (0)