Ensure maps are initialised before parsing sql

This commit is contained in:
Tobie Morgan Hitchcock 2016-11-05 13:59:39 +00:00
parent 4452339bd1
commit 85fcdccab5

View file

@ -86,6 +86,14 @@ func Exit() {
// Execute parses the query and executes it against the data layer
func Execute(ctx *fibre.Context, txt interface{}, vars map[string]interface{}) (out []*Response, err error) {
// If no preset variables have been defined
// then ensure that the variables is
// instantiated for future use.
if vars == nil {
vars = make(map[string]interface{})
}
// Parse the received SQL batch query strings
// into SQL ASTs, using any immutable preset
// variables if set.
@ -95,14 +103,6 @@ func Execute(ctx *fibre.Context, txt interface{}, vars map[string]interface{}) (
return
}
// If no preset variables have been defined
// then ensure that the variables is
// instantiated for future use.
if vars == nil {
vars = make(map[string]interface{})
}
// Create 2 channels, one for force quitting
// the query processor, and the other for
// receiving and buffering any query results.