// SQLExecute is part of the SQLExecuter interface. func (se *splitQuerySQLExecuter) SQLExecute( sql string, bindVariables map[string]interface{}, ) (*sqltypes.Result, error) { // We need to parse the query since we're dealing with bind-vars. // TODO(erez): Add an SQLExecute() to SQLExecuterInterface that gets a parsed query so that // we don't have to parse the query again here. ast, err := sqlparser.Parse(sql) if err != nil { return nil, fmt.Errorf("splitQuerySQLExecuter: parsing sql failed with: %v", err) } parsedQuery := sqlparser.GenerateParsedQuery(ast) // We clone "bindVariables" since fullFetch() changes it. return se.queryExecutor.fullFetch( se.conn, parsedQuery, utils.CloneBindVariables(bindVariables), nil /* buildStreamComment */) }
// TODO(erez): Add an SQLExecute() to SQLExecuterInterface that gets a parsed query so that // we don't have to parse the query again here. func (se *splitQuerySQLExecuter) SQLExecute( sql string, bindVariables map[string]interface{}) (*sqltypes.Result, error) { ast, err := sqlparser.Parse(sql) if err != nil { return nil, fmt.Errorf("splitQuerySQLExecuter: parsing sql failed with: %v", err) } parsedQuery := sqlparser.GenerateParsedQuery(ast) conn, err := se.queryExecutor.getConn(se.queryExecutor.qe.connPool) if err != nil { return nil, err } defer conn.Recycle() // TODO(erez): Find out what 'buildStreamComment' is, and see if we need to use it or comment why // we don't. // We clone "bindVariables" since fullFetch() changes it. return se.queryExecutor.fullFetch( conn, parsedQuery, utils.CloneBindVariables(bindVariables), nil /* buildStreamComment */) }