From d002ad6f854cc765dae893c9fc678b1d5f25c8ea Mon Sep 17 00:00:00 2001 From: dancebear Date: Mon, 15 Sep 2014 16:32:01 +0800 Subject: [PATCH] Update conn_query.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复getShardConns写操作时操作从库的bug --- proxy/conn_query.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proxy/conn_query.go b/proxy/conn_query.go index f48922f..3c59822 100644 --- a/proxy/conn_query.go +++ b/proxy/conn_query.go @@ -123,7 +123,7 @@ func (c *Conn) getConn(n *Node, isSelect bool) (co *client.SqlConn, err error) { return } -func (c *Conn) getShardConns(stmt sqlparser.Statement, bindVars map[string]interface{}) ([]*client.SqlConn, error) { +func (c *Conn) getShardConns(isSelect bool,stmt sqlparser.Statement, bindVars map[string]interface{}) ([]*client.SqlConn, error) { nodes, err := c.getShardList(stmt, bindVars) if err != nil { return nil, err @@ -135,7 +135,7 @@ func (c *Conn) getShardConns(stmt sqlparser.Statement, bindVars map[string]inter var co *client.SqlConn for _, n := range nodes { - co, err = c.getConn(n, true) + co, err = c.getConn(n, isSelect) if err != nil { break } @@ -236,7 +236,7 @@ func makeBindVars(args []interface{}) map[string]interface{} { func (c *Conn) handleSelect(stmt *sqlparser.Select, sql string, args []interface{}) error { bindVars := makeBindVars(args) - conns, err := c.getShardConns(stmt, bindVars) + conns, err := c.getShardConns(true,stmt, bindVars) if err != nil { return err } else if conns == nil { @@ -288,7 +288,7 @@ func (c *Conn) commitShardConns(conns []*client.SqlConn) error { func (c *Conn) handleExec(stmt sqlparser.Statement, sql string, args []interface{}) error { bindVars := makeBindVars(args) - conns, err := c.getShardConns(stmt, bindVars) + conns, err := c.getShardConns(false,stmt, bindVars) if err != nil { return err } else if conns == nil {