diff --git a/proxy/router/router.go b/proxy/router/router.go index 5be4df0c..73beb3e5 100644 --- a/proxy/router/router.go +++ b/proxy/router/router.go @@ -678,7 +678,7 @@ func (r *Router) generateSelectSql(plan *Plan, stmt sqlparser.Statement) error { for i := 0; i < tableCount; i++ { tableIndex := plan.RouteTableIndexs[i] nodeIndex := plan.Rule.TableToNode[tableIndex] - nodeName := r.Nodes[nodeIndex] + nodeName := plan.Rule.Nodes[nodeIndex] selectSql := r.rewriteSelectSql(plan, node, tableIndex) if _, ok := sqls[nodeName]; ok == false { sqls[nodeName] = make([]string, 0, tableCount) @@ -710,7 +710,7 @@ func (r *Router) generateInsertSql(plan *Plan, stmt sqlparser.Statement) error { buf := sqlparser.NewTrackedBuffer(nil) tableIndex := plan.RouteTableIndexs[i] nodeIndex := plan.Rule.TableToNode[tableIndex] - nodeName := r.Nodes[nodeIndex] + nodeName := plan.Rule.Nodes[nodeIndex] buf.Fprintf("insert %v%s into %v", node.Comments, node.Ignore, node.Table) fmt.Fprintf(buf, "_%04d", plan.RouteTableIndexs[i]) @@ -761,7 +761,7 @@ func (r *Router) generateUpdateSql(plan *Plan, stmt sqlparser.Statement) error { ) tableIndex := plan.RouteTableIndexs[i] nodeIndex := plan.Rule.TableToNode[tableIndex] - nodeName := r.Nodes[nodeIndex] + nodeName := plan.Rule.Nodes[nodeIndex] if _, ok := sqls[nodeName]; ok == false { sqls[nodeName] = make([]string, 0, tableCount) } @@ -803,7 +803,7 @@ func (r *Router) generateDeleteSql(plan *Plan, stmt sqlparser.Statement) error { ) tableIndex := plan.RouteTableIndexs[i] nodeIndex := plan.Rule.TableToNode[tableIndex] - nodeName := r.Nodes[nodeIndex] + nodeName := plan.Rule.Nodes[nodeIndex] if _, ok := sqls[nodeName]; ok == false { sqls[nodeName] = make([]string, 0, tableCount) } @@ -834,7 +834,7 @@ func (r *Router) generateReplaceSql(plan *Plan, stmt sqlparser.Statement) error for i := 0; i < tableCount; i++ { tableIndex := plan.RouteTableIndexs[i] nodeIndex := plan.Rule.TableToNode[tableIndex] - nodeName := r.Nodes[nodeIndex] + nodeName := plan.Rule.Nodes[nodeIndex] buf := sqlparser.NewTrackedBuffer(nil) buf.Fprintf("replace %vinto %v", @@ -884,7 +884,7 @@ func (r *Router) generateTruncateSql(plan *Plan, stmt sqlparser.Statement) error fmt.Fprintf(buf, "_%04d", plan.RouteTableIndexs[i]) tableIndex := plan.RouteTableIndexs[i] nodeIndex := plan.Rule.TableToNode[tableIndex] - nodeName := r.Nodes[nodeIndex] + nodeName := plan.Rule.Nodes[nodeIndex] if _, ok := sqls[nodeName]; ok == false { sqls[nodeName] = make([]string, 0, tableCount) }