Skip to content

Commit 4f4eac7

Browse files
author
James Cor
committed
comments
1 parent 8450a2a commit 4f4eac7

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

sql/base_session.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func (s *BaseSession) IncrementStatusVariable(ctx *Context, statVarName string,
256256

257257
// NewStoredProcParam creates a new Stored Procedure Parameter in the Session
258258
func (s *BaseSession) NewStoredProcParam(name string, param *StoredProcParam) {
259+
name = strings.ToLower(name)
259260
if _, ok := s.storedProcParams[name]; ok {
260261
return
261262
}
@@ -264,6 +265,7 @@ func (s *BaseSession) NewStoredProcParam(name string, param *StoredProcParam) {
264265

265266
// GetStoredProcParam retrieves the named stored procedure parameter, from the Session, returning nil if not found.
266267
func (s *BaseSession) GetStoredProcParam(name string) *StoredProcParam {
268+
name = strings.ToLower(name)
267269
if param, ok := s.storedProcParams[name]; ok {
268270
return param
269271
}

sql/planbuilder/proc.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,15 @@ func (b *Builder) buildCall(inScope *scope, c *ast.Call) (outScope *scope) {
347347

348348
params := make([]sql.Expression, len(c.Params))
349349
for i, param := range c.Params {
350+
// While it is possible to detect a parameter count mismatch here and throw an error,
351+
// there's some weirdness involving external procedures. The analyzer rule applyProceduresCall will
352+
// catch this discrepancy.
350353
if len(proc.Params) == len(c.Params) {
351354
procParam := proc.Params[i]
352355
rspp := &sql.StoredProcParam{Type: procParam.Type}
353356
b.ctx.Session.NewStoredProcParam(procParam.Name, rspp)
354357
if col, isCol := param.(*ast.ColName); isCol {
355-
colName := col.Name.String() // TODO: to lower?
358+
colName := col.Name.String()
356359
if spp := b.ctx.Session.GetStoredProcParam(colName); spp != nil {
357360
iv := &procedures.InterpreterVariable{
358361
Type: spp.Type,

sql/procedures/interpreter_operation.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ package procedures
1212

1313
import ast "github.com/dolthub/vitess/go/vt/sqlparser"
1414

15-
// OpCode states the operation to be performed. Most operations have a direct analogue to a Pl/pgSQL operation, however
16-
// some exist only in Doltgres (specific to our interpreter implementation).
15+
// OpCode is the internal representation queries run by Stored Procedures.
1716
type OpCode uint16
1817

1918
const (

sql/session.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,12 @@ type Session interface {
9292
GetAllStatusVariables(ctx *Context) map[string]StatusVarValue
9393
// IncrementStatusVariable increments the value of the status variable by the integer value
9494
IncrementStatusVariable(ctx *Context, statVarName string, val int)
95-
95+
// NewStoredProcParam creates a new Stored Procedure Parameter in the Session.
9696
NewStoredProcParam(name string, param *StoredProcParam)
97-
97+
// GetStoredProcParam finds and returns the Stored Procedure Parameter by the given name.
9898
GetStoredProcParam(name string) *StoredProcParam
99-
99+
// SetStoredProcParam sets the Stored Procedure Parameter of the given name to the given val.
100100
SetStoredProcParam(name string, val any) error
101-
102101
// GetCurrentDatabase gets the current database for this session
103102
GetCurrentDatabase() string
104103
// SetCurrentDatabase sets the current database for this session

0 commit comments

Comments
 (0)