Skip to content

Commit 7862ef1

Browse files
author
James Cor
committed
fix?
1 parent b67e4ec commit 7862ef1

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

sql/base_session.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,13 @@ func (s *BaseSession) IncrementStatusVariable(ctx *Context, statVarName string,
255255
}
256256

257257
// NewStoredProcParam creates a new Stored Procedure Parameter in the Session
258-
func (s *BaseSession) NewStoredProcParam(name string, param *StoredProcParam) {
258+
func (s *BaseSession) NewStoredProcParam(name string, param *StoredProcParam) *StoredProcParam {
259259
name = strings.ToLower(name)
260-
if _, ok := s.storedProcParams[name]; ok {
261-
return
260+
if spp, ok := s.storedProcParams[name]; ok {
261+
return spp
262262
}
263263
s.storedProcParams[name] = param
264+
return param
264265
}
265266

266267
// GetStoredProcParam retrieves the named stored procedure parameter, from the Session, returning nil if not found.

sql/planbuilder/proc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ func (b *Builder) buildCall(inScope *scope, c *ast.Call) (outScope *scope) {
350350
// catch this discrepancy.
351351
if len(proc.Params) == len(c.Params) {
352352
procParam := proc.Params[i]
353-
rspp := &sql.StoredProcParam{Type: procParam.Type}
354-
b.ctx.Session.NewStoredProcParam(procParam.Name, rspp)
353+
rSpp := &sql.StoredProcParam{Type: procParam.Type}
354+
rSpp = b.ctx.Session.NewStoredProcParam(procParam.Name, rSpp)
355355
if col, isCol := param.(*ast.ColName); isCol {
356356
colName := col.Name.String()
357357
if spp := b.ctx.Session.GetStoredProcParam(colName); spp != nil {
@@ -360,7 +360,7 @@ func (b *Builder) buildCall(inScope *scope, c *ast.Call) (outScope *scope) {
360360
Value: spp.Value,
361361
}
362362
param = iv.ToAST()
363-
rspp.Reference = spp
363+
rSpp.Reference = spp
364364
}
365365
}
366366
}

sql/procedures/interpreter_logic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ func execOp(ctx *sql.Context, runner sql.StatementRunner, stack *InterpreterStac
740740
Type: iv.Type,
741741
Value: iv.Value,
742742
}
743-
ctx.Session.NewStoredProcParam(paramName, spp)
743+
spp = ctx.Session.NewStoredProcParam(paramName, spp)
744744
stackToParam[iv] = spp
745745
}
746746
sch, rowIter, err := query(ctx, runner, callStmt)

sql/session.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ type Session interface {
9393
// IncrementStatusVariable increments the value of the status variable by the integer value
9494
IncrementStatusVariable(ctx *Context, statVarName string, val int)
9595
// NewStoredProcParam creates a new Stored Procedure Parameter in the Session.
96-
NewStoredProcParam(name string, param *StoredProcParam)
96+
NewStoredProcParam(name string, param *StoredProcParam) *StoredProcParam
9797
// GetStoredProcParam finds and returns the Stored Procedure Parameter by the given name.
9898
GetStoredProcParam(name string) *StoredProcParam
9999
// SetStoredProcParam sets the Stored Procedure Parameter of the given name to the given val.

0 commit comments

Comments
 (0)