// Always select instead of update/delete func (this *FunServantImpl) MyQueryShards(ctx *rpc.Context, pool string, table string, sql string, args []string) (r *rpc.MysqlResult, ex error) { const IDENT = "my.qshards" profiler, err := this.getSession(ctx).startProfiler() if err != nil { ex = err return } svtStats.inc(IDENT) iargs := make([]interface{}, len(args), len(args)) for i, arg := range args { iargs[i] = arg } cols, rows, err := this.my.QueryShards(pool, table, sql, iargs) if err != nil { ex = err return } r = rpc.NewMysqlResult() r.Cols = cols r.Rows = rows profiler.do(IDENT, ctx, "{pool^%s table^%s sql^%s args^%+v} {rows^%d r^%+v}", pool, table, sql, args, len(rows), *r) return }
// TODO ServantByKey(cacheKey) func (this *FunServantImpl) doMyQuery(ident string, ctx *rpc.Context, pool string, table string, hintId int64, sql string, args []string, cacheKey string) (r *rpc.MysqlResult, ex error) { const ( SQL_SELECT = "SELECT" SQL_UPDATE = "UPDATE" ) // convert []string to []interface{} iargs := make([]interface{}, len(args), len(args)) for i, arg := range args { iargs[i] = arg } r = rpc.NewMysqlResult() if strings.HasPrefix(sql, SQL_SELECT) { // SELECT MUST be in upper case ex = this.doMySelect(r, ident, ctx, pool, table, hintId, sql, args, iargs, cacheKey) } else { ex = this.doMyExec(r, ident, ctx, pool, table, hintId, sql, args, iargs, cacheKey) } return }