예제 #1
0
 public virtual void TestCobarHint()
 {
     var schema = schemaMap["cndb"];
     var sql = "  /*!cobar: $dataNodeId=2.1, $table='offer'*/ select * from `dual`";
     var rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(1, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("offer_dn[2]", rrs.Nodes[0].Name);
     Assert.AreEqual(" select * from `dual`", rrs.Nodes[0].Statement);
     sql = "/*!cobar: $dataNodeId=2.1, $table='offer', $replica =2*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(1, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("offer_dn[2]", rrs.Nodes[0].Name);
     Assert.AreEqual(" select * from `dual`", rrs.Nodes[0].Statement);
     sql = "/*!cobar: $dataNodeId   = [ 1,2,5.2]  , $table =  'offer'   */ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     var nodeMap = GetNodeMap(rrs, 3);
     var nameAsserter = new NodeNameAsserter("offer_dn[1]", "offer_dn[2]", "offer_dn[5]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     var sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, " select * from `dual`")
                .AddExpectSql(1, " select * from `dual`")
                .AddExpectSql(2, " select * from `dual`");
     var asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter, new _ReplicaAsserter_1468());
     foreach (var node in nodeMap.Values)
     {
         asserter.AssertNode(node);
     }
     sql = "/*!cobar: $dataNodeId   = [ 1,2,5.2]  , $table =  'offer'  , $replica =1 */ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(3, rrs.Nodes.Length);
     nodeMap = GetNodeMap(rrs, 3);
     nameAsserter = new NodeNameAsserter("offer_dn[1]", "offer_dn[2]",
         "offer_dn[5]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, " select * from `dual`")
                .AddExpectSql(1, " select * from `dual`")
                .AddExpectSql(2, " select * from `dual`");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter, new _ReplicaAsserter_1492());
     foreach (var node_1 in nodeMap.Values)
     {
         asserter.AssertNode(node_1);
     }
     sql = "/*!cobar: $partitionOperand=( 'member_id' = 'pavarotti17'), $table='offer'*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("offer_dn[123]", rrs.Nodes[0].Name);
     Assert.AreEqual(" select * from `dual`", rrs.Nodes[0].Statement);
     sql =
         "/*!cobar:$partitionOperand =   ( 'member_id' = ['pavarotti17'  ,   'qaa' ]  ), $table='offer'  , $replica =  2*/  select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[10]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, "  select * from `dual`").AddExpectSql(1, "  select * from `dual`");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter, new _ReplicaAsserter_1521());
     foreach (var node_2 in nodeMap.Values)
     {
         asserter.AssertNode(node_2);
     }
     sql =
         "/*!cobar:$partitionOperand = ( ['group_id','offer_id'] = [234,4]), $table='offer'*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("offer_dn[29]", rrs.Nodes[0].Name);
     Assert.AreEqual(" select * from `dual`", rrs.Nodes[0].Statement);
     sql =
         "/*!cobar:$partitionOperand=(['offer_id','group_id']=[[123,3],[234,4]]), $table='offer'  , $replica =2*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("offer_dn[29]", "offer_dn[15]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, " select * from `dual`").AddExpectSql(1, " select * from `dual`");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter, new _ReplicaAsserter_1547());
     foreach (var node_3 in nodeMap.Values)
     {
         asserter.AssertNode(node_3);
     }
     sql =
         "/*!cobar:$partitionOperand=(['group_id','offer_id']=[[123,3], [ 234,4 ] ]), $table='offer'  */ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("offer_dn[29]", "offer_dn[15]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, " select * from `dual`").AddExpectSql(1, " select * from `dual`");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter, new _ReplicaAsserter_1565());
     foreach (var node_4 in nodeMap.Values)
     {
         asserter.AssertNode(node_4);
     }
     sql =
         "/*!cobar:$partitionOperand=(['offer_id','NON_EXistence']=[[123,3],[234,4]]), $table='offer'  , $replica =2*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 128);
     nameAsserter = new IndexedNodeNameAsserter("offer_dn", 0, 128);
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     for (var i = 0; i < 128; i++)
     {
         sqlAsserter.AddExpectSql(i, " select * from `dual`");
     }
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter, new _ReplicaAsserter_1585());
     foreach (var node_5 in nodeMap.Values)
     {
         asserter.AssertNode(node_5);
     }
     sql = "/*!cobar:  $dataNodeId   = 1  ,$table =  'wp_image'*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 1);
     nameAsserter = new NodeNameAsserter("offer_dn[1]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, " select * from `dual`");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_6 in nodeMap.Values)
     {
         asserter.AssertNode(node_6);
     }
     sql = "/*!cobar:  $dataNodeId   = [0,3]  ,$table =  'wp_image'*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("offer_dn[0]", "offer_dn[3]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, " select * from `dual`").AddExpectSql(1, " select * from `dual`");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_7 in nodeMap.Values)
     {
         asserter.AssertNode(node_7);
     }
     sql = "/*!cobar:  $table =  'wp_image'*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 128);
     nameAsserter = new IndexedNodeNameAsserter("offer_dn", 0, 128);
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     for (var i_1 = 0; i_1 < 128; i_1++)
     {
         sqlAsserter.AddExpectSql(i_1, " select * from `dual`");
     }
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_8 in nodeMap.Values)
     {
         asserter.AssertNode(node_8);
     }
     sql = "/*!cobar:  $dataNodeId   = 0  ,$table =  'independent'*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 1);
     nameAsserter = new NodeNameAsserter("independent_dn[0]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, " select * from `dual`");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_9 in nodeMap.Values)
     {
         asserter.AssertNode(node_9);
     }
     sql = "/*!cobar:  $dataNodeId   = [ 1,2,5]  ,$table =  'independent'*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 3);
     nameAsserter = new NodeNameAsserter("independent_dn[1]", "independent_dn[2]", "independent_dn[5]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, " select * from `dual`")
                .AddExpectSql(1, " select * from `dual`")
                .AddExpectSql(2, " select * from `dual`");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_10 in nodeMap.Values)
     {
         asserter.AssertNode(node_10);
     }
     sql = "/*!cobar:  $table =  'independent'*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 128);
     nameAsserter = new IndexedNodeNameAsserter("independent_dn", 0, 128);
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     for (var i_2 = 0; i_2 < 128; i_2++)
     {
         sqlAsserter.AddExpectSql(i_2, " select * from `dual`");
     }
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_11 in nodeMap.Values)
     {
         asserter.AssertNode(node_11);
     }
     sql =
         "/*!cobar:$partitionOperand=(['member_id','NON_EXistence']=[['pavarotti17'],['qaa',4]]), $table='offer'  , $replica=2*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[10]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, " select * from `dual`").AddExpectSql(1, " select * from `dual`");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter, new _ReplicaAsserter_1687());
     foreach (var node_12 in nodeMap.Values)
     {
         asserter.AssertNode(node_12);
     }
     sql =
         "/*!cobar:$partitionOperand=(['offer_id','NON_EXistence']=[[123,3],[234,4]]), $table='non_existence'  , $replica=2*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(2, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("cndb_dn", rrs.Nodes[0].Name);
     Assert.AreEqual(" select * from `dual`", rrs.Nodes[0].Statement);
     sql =
         "/*!cobar:$partitionOperand=(['offer_id','group_id']=[[123,3],[234,4]]), $table='non_existence'  , $replica=2*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(2, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("cndb_dn", rrs.Nodes[0].Name);
     Assert.AreEqual(" select * from `dual`", rrs.Nodes[0].Statement);
     schema = schemaMap["dubbo"];
     sql = "/*!cobar: $replica=2*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(2, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("dubbo_dn", rrs.Nodes[0].Name);
     Assert.AreEqual(" select * from `dual`", rrs.Nodes[0].Statement);
     schema = schemaMap["dubbo"];
     sql = "/*!cobar: $dataNodeId = [ 0.1],$replica=2*/ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(1, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("dubbo_dn", rrs.Nodes[0].Name);
     Assert.AreEqual(" select * from `dual`", rrs.Nodes[0].Statement);
     schema = schemaMap["dubbo"];
     sql = "/*!cobar: */ select * from `dual`";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("dubbo_dn", rrs.Nodes[0].Name);
     Assert.AreEqual(" select * from `dual`", rrs.Nodes[0].Statement);
 }
예제 #2
0
 public virtual void TestRoute()
 {
     var sql = "select * from offer.wp_image where member_id='pavarotti17' or member_id='1qq'";
     var schema = schemaMap["cndb"];
     var rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[0].ReplicaIndex);
     var nodeMap = GetNodeMap(rrs, 2);
     var nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[66]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     var sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, "SELECT * FROM wp_image WHERE member_id = 'pavarotti17' OR FALSE")
                .AddExpectSql(1, "SELECT * FROM wp_image WHERE FALSE OR member_id = '1qq'");
     var asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node in nodeMap.Values)
     {
         asserter.AssertNode(node);
     }
     sql = "select * from independent where member='abc'";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     nodeMap = GetNodeMap(rrs, 128);
     nameAsserter = new IndexedNodeNameAsserter("independent_dn", 0, 128);
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     for (var i = 0; i < 128; ++i)
     {
         sqlAsserter.AddExpectSql(i, "select * from independent where member='abc'");
     }
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_1 in nodeMap.Values)
     {
         asserter.AssertNode(node_1);
     }
     sql = "select * from independent A where cndb.a.member='abc'";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     nodeMap = GetNodeMap(rrs, 128);
     nameAsserter = new IndexedNodeNameAsserter("independent_dn", 0, 128);
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     for (var i_1 = 0; i_1 < 128; ++i_1)
     {
         sqlAsserter.AddExpectSql(i_1, "SELECT * FROM independent AS A WHERE a.member = 'abc'");
     }
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_2 in nodeMap.Values)
     {
         asserter.AssertNode(node_2);
     }
     sql = "select * from tb where member='abc'";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("cndb_dn", rrs.Nodes[0].Name);
     Assert.AreEqual("select * from tb where member='abc'", rrs.Nodes[0].Statement);
     sql = "select * from offer.wp_image where member_id is null";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("offer_dn[48]", rrs.Nodes[0].Name);
     Assert.AreEqual("SELECT * FROM wp_image WHERE member_id IS NULL",
         rrs.Nodes[0].Statement);
     sql = "select * from offer.wp_image where member_id between 'pavarotti17' and 'pavarotti17'";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("offer_dn[123]", rrs.Nodes[0].Name);
     Assert.AreEqual("SELECT * FROM wp_image WHERE member_id BETWEEN 'pavarotti17' AND 'pavarotti17'", rrs.Nodes[0].Statement);
     sql =
         "select * from  offer A where a.member_id='abc' union select * from product_visit b where B.offer_id =123";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(128, rrs.Nodes.Length);
     Assert.AreEqual(-1L, rrs.LimitSize);
     for (var i_2 = 0; i_2 < 128; i_2++)
     {
         Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[i_2].ReplicaIndex);
         Assert.AreEqual("offer_dn[" + i_2 + "]", rrs.Nodes[i_2].Name);
         Assert.AreEqual(
             "select * from  offer A where a.member_id='abc' union select * from product_visit b where B.offer_id =123", rrs.Nodes[i_2].Statement);
     }
     sql =
         "update offer.offer a join offer_detail b set id=123 where a.offer_id=b.offer_id and a.offer_id=123 and group_id=234";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("offer_dn[44]", rrs.Nodes[0].Name);
     Assert.AreEqual("UPDATE offer AS " + AliasConvert("a") + " INNER JOIN offer_detail AS "
                     + AliasConvert("b") +
                     " SET id = 123 WHERE a.offer_id = b.offer_id AND a.offer_id = 123 AND group_id = 234", rrs.Nodes[0].Statement);
     sql =
         "update    offer./*kjh*/offer a join offer_detail B set id:=123 where A.offer_id=b.offer_id and b.offer_id=123 and group_id=234";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("detail_dn[15]", rrs.Nodes[0].Name);
     Assert.AreEqual("UPDATE offer AS " + AliasConvert("a") + " INNER JOIN offer_detail AS "
                     + AliasConvert("b") +
                     " SET id = 123 WHERE A.offer_id = b.offer_id AND b.offer_id = 123 AND group_id = 234", rrs.Nodes[0].Statement);
     sql =
         "select * from offer.wp_image where member_id in ('pavarotti17', 'qaa') or offer.wp_image.member_id='1qq'";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 3);
     nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[10]", "offer_dn[66]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, "SELECT * FROM wp_image WHERE member_id IN ('pavarotti17') OR FALSE")
                .AddExpectSql(1, "SELECT * FROM wp_image WHERE member_id IN ('qaa') OR FALSE")
                .
                 AddExpectSql(2, "SELECT * FROM wp_image WHERE FALSE OR wp_image.member_id = '1qq'");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_3 in nodeMap.Values)
     {
         asserter.AssertNode(node_3);
     }
     sql =
         "select * from offer.wp_image,tb2 as t2 where member_id in ('pavarotti17', 'qaa') or offer.wp_image.member_id='1qq'";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(3, rrs.Nodes.Length);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 3);
     nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[10]", "offer_dn[66]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0,
         "SELECT * FROM wp_image, tb2 AS " + AliasConvert("t2") + " WHERE member_id IN ('pavarotti17') OR FALSE")
                .AddExpectSql(1, "SELECT * FROM wp_image, tb2 AS "
                                 + AliasConvert("t2") + " WHERE member_id IN ('qaa') OR FALSE").AddExpectSql(2,
                                     "SELECT * FROM wp_image, tb2 AS " + AliasConvert("t2") +
                                     " WHERE FALSE OR wp_image.member_id = '1qq'");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_4 in nodeMap.Values)
     {
         asserter.AssertNode(node_4);
     }
     sql =
         "select * from offer.wp_image,tb2 as t2 where member_id in ('pavarotti17', 'sf', 's22f', 'sdddf', 'sd') ";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 4);
     nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[126]", "offer_dn[74]", "offer_dn[26]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0,
         "SELECT * FROM wp_image, tb2 AS " + AliasConvert("t2") + " WHERE member_id IN ('pavarotti17')")
                .AddExpectSql(1, "SELECT * FROM wp_image, tb2 AS "
                                 + AliasConvert("t2") + " WHERE member_id IN ('sdddf')")
                .AddExpectSql(2, "SELECT * FROM wp_image, tb2 AS "
                                 + AliasConvert("t2") + " WHERE member_id IN ('sf', 'sd')",
                    "SELECT * FROM wp_image, tb2 AS "
                    + AliasConvert("t2") + " WHERE member_id IN ('sd', 'sf')")
                .AddExpectSql(3, "SELECT * FROM wp_image, tb2 AS "
                                 + AliasConvert("t2") + " WHERE member_id IN ('s22f')");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_5 in nodeMap.Values)
     {
         asserter.AssertNode(node_5);
     }
     sql =
         "select * from tb2 as t2 ,offer.wp_image where member_id in ('pavarotti17', 'qaa') or offer.wp_image.member_id='1qq'";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 3);
     nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[10]", "offer_dn[66]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0,
         "SELECT * FROM tb2 AS " + AliasConvert("t2") + ", wp_image WHERE member_id IN ('pavarotti17') OR FALSE")
                .AddExpectSql(1,
                    "SELECT * FROM tb2 AS " + AliasConvert("t2") +
                    ", wp_image WHERE member_id IN ('qaa') OR FALSE")
                .AddExpectSql(2,
                    "SELECT * FROM tb2 AS " + AliasConvert("t2") +
                    ", wp_image WHERE FALSE OR wp_image.member_id = '1qq'");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_6 in nodeMap.Values)
     {
         asserter.AssertNode(node_6);
     }
     sql =
         "select * from tb2 as t2 ,offer.wp_image where member_id in ('pavarotti17', 'qaa') or offer.wp_image.member_id='1qq' and t2.member_id='123'";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 3);
     nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[10]", "offer_dn[66]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0,
         "SELECT * FROM tb2 AS " + AliasConvert("t2") +
         ", wp_image WHERE member_id IN ('pavarotti17') OR FALSE AND t2.member_id = '123'")
                .AddExpectSql(1,
                    "SELECT * FROM tb2 AS " + AliasConvert("t2") +
                    ", wp_image WHERE member_id IN ('qaa') OR FALSE AND t2.member_id = '123'")
                .AddExpectSql(2,
                    "SELECT * FROM tb2 AS " + AliasConvert("t2") +
                    ", wp_image WHERE FALSE OR wp_image.member_id = '1qq' AND t2.member_id = '123'");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_7 in nodeMap.Values)
     {
         asserter.AssertNode(node_7);
     }
     sql =
         "select * from wp_image wB inner join offer.offer o on wB.member_id=O.member_ID where wB.member_iD='pavarotti17' and o.id=3";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("offer_dn[123]", rrs.Nodes[0].Name);
     Assert.AreEqual("SELECT * FROM wp_image AS " + AliasConvert("wB")
                     + " INNER JOIN offer AS " + AliasConvert("o") +
                     " ON wB.member_id = O.member_ID WHERE wB.member_iD = 'pavarotti17' AND o.id = 3", rrs.Nodes[0].Statement);
     sql =
         "select * from wp_image w inner join offer o on w.member_id=O.member_ID where w.member_iD in ('pavarotti17','13') and o.id=3";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[68]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, "SELECT * FROM wp_image AS " + AliasConvert("w") + " INNER JOIN offer AS "
                                 + AliasConvert("o") +
                                 " ON w.member_id = O.member_ID WHERE w.member_iD IN ('pavarotti17') AND o.id = 3")
                .AddExpectSql(1, "SELECT * FROM wp_image AS " + AliasConvert("w") + " INNER JOIN offer AS "
                                 + AliasConvert("o") +
                                 " ON w.member_id = O.member_ID WHERE w.member_iD IN ('13') AND o.id = 3");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_8 in nodeMap.Values)
     {
         asserter.AssertNode(node_8);
     }
     sql = "insert into wp_image (member_id,gmt) values ('pavarotti17',now()),('123',now())";
     schema = schemaMap["cndb"];
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[70]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, "INSERT INTO wp_image (member_id, gmt) VALUES ('pavarotti17', NOW())")
                .AddExpectSql(1, "INSERT INTO wp_image (member_id, gmt) VALUES ('123', NOW())");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_9 in nodeMap.Values)
     {
         asserter.AssertNode(node_9);
     }
 }
예제 #3
0
 public virtual void TestRouteInsertLong()
 {
     var sb = new StringBuilder("insert into offer_detail (offer_id, gmt) values ");
     for (var i = 0; i < 1024; ++i)
     {
         if (i > 0)
         {
             sb.Append(", ");
         }
         sb.Append("(" + i + ", now())");
     }
     var schema = schemaMap["cndb"];
     var rrs = ServerRouter.Route(schema, sb.ToString(), null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     var nodeMap = GetNodeMap(rrs, 128);
     var nameAsserter = new IndexedNodeNameAsserter("detail_dn", 0, 128);
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     var asserter = new RouteNodeAsserter(nameAsserter, new _ParseredSQLAsserter_351());
     foreach (var node in nodeMap.Values)
     {
         asserter.AssertNode(node);
     }
 }
예제 #4
0
 public virtual void TestGroupLimit()
 {
     var schema = schemaMap["cndb"];
     var sql = "select Count(*) from wp_image where member_id = 'pavarotti17'";
     var rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     Assert.AreEqual(0, rrs.Flag);
     Assert.AreEqual(1, rrs.Nodes.Length);
     Assert.AreEqual(RouteResultsetNode.DefaultReplicaIndex, rrs.Nodes[0].ReplicaIndex);
     Assert.AreEqual("offer_dn[123]", rrs.Nodes[0].Name);
     Assert.AreEqual("select Count(*) from wp_image where member_id = 'pavarotti17'", rrs.Nodes[0].Statement);
     sql = "select Count(*) from wp_image where member_id in ('pavarotti17','qaa')";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(-1L, rrs.LimitSize);
     if (rrs.Nodes.Length > 1)
     {
         Assert.AreEqual(RouteResultset.SumFlag, rrs.Flag);
     }
     var nodeMap = GetNodeMap(rrs, 2);
     var nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[10]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     var sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, "SELECT COUNT(*) FROM wp_image WHERE member_id IN ('pavarotti17')")
                .AddExpectSql(1, "SELECT COUNT(*) FROM wp_image WHERE member_id IN ('qaa')");
     var asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node in nodeMap.Values)
     {
         asserter.AssertNode(node);
     }
     sql = "select min(id) from wp_image where member_id in ('pavarotti17','qaa') limit 99";
     rrs = ServerRouter.Route(schema, sql, null, null);
     if (rrs.Nodes.Length > 1)
     {
         Assert.AreEqual(RouteResultset.MinFlag, rrs.Flag);
     }
     if (rrs.Nodes.Length > 1)
     {
         Assert.AreEqual(99L, rrs.LimitSize);
     }
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[10]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0, "SELECT MIN(id) FROM wp_image WHERE member_id IN ('pavarotti17') LIMIT 0, 99")
                .AddExpectSql(1, "SELECT MIN(id) FROM wp_image WHERE member_id IN ('qaa') LIMIT 0, 99");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_1 in nodeMap.Values)
     {
         asserter.AssertNode(node_1);
     }
     sql =
         "select max(offer_id) from offer.wp_image where member_id in ('pavarotti17','pavarotti17', 'qaa') or member_id in ('pavarotti17','1qq','pavarotti17') or offer.wp_image.member_id='pavarotti17' limit 99 offset 1";
     rrs = ServerRouter.Route(schema, sql, null, null);
     if (rrs.Nodes.Length > 1)
     {
         Assert.AreEqual(RouteResultset.MaxFlag, rrs.Flag);
     }
     if (rrs.Nodes.Length > 1)
     {
         Assert.AreEqual(99L, rrs.LimitSize);
     }
     nodeMap = GetNodeMap(rrs, 3);
     nameAsserter = new NodeNameAsserter("offer_dn[123]", "offer_dn[10]", "offer_dn[66]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0,
         "SELECT MAX(offer_id) FROM wp_image WHERE member_id IN ('pavarotti17', 'pavarotti17') OR member_id IN ('pavarotti17', 'pavarotti17') OR wp_image.member_id = 'pavarotti17' LIMIT 1, 99")
                .AddExpectSql(1,
                    "SELECT MAX(offer_id) FROM wp_image WHERE member_id IN ('qaa') OR FALSE OR FALSE LIMIT 1, 99")
                .AddExpectSql(2,
                    "SELECT MAX(offer_id) FROM wp_image WHERE FALSE OR member_id IN ('1qq') OR FALSE LIMIT 1, 99");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_2 in nodeMap.Values)
     {
         asserter.AssertNode(node_2);
     }
     sql = "select Count(*) from (select * from wp_image) w, (select * from offer) o "
           + " where o.member_id=w.member_id and o.member_id='pavarotti17' limit 99";
     rrs = ServerRouter.Route(schema, sql, null, null);
     if (rrs.Nodes.Length > 1)
     {
         Assert.AreEqual(RouteResultset.SumFlag, rrs.Flag);
     }
     if (rrs.Nodes.Length > 1)
     {
         Assert.AreEqual(99L, rrs.LimitSize);
     }
     nodeMap = GetNodeMap(rrs, 128);
     nameAsserter = new IndexedNodeNameAsserter("offer_dn", 0, 128);
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     for (var i = 0; i < 128; ++i)
     {
         sqlAsserter.AddExpectSql(i,
             "select Count(*) from (select * from wp_image) w, (select * from offer) o  where o.member_id=w.member_id and o.member_id='pavarotti17' limit 99");
     }
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_3 in nodeMap.Values)
     {
         asserter.AssertNode(node_3);
     }
     sql = "select Count(*) from (select * from wp_image) w, (select * from offer limit 99) o "
           + " where o.member_id=w.member_id and o.member_id='pavarotti17' ";
     rrs = ServerRouter.Route(schema, sql, null, null);
     if (rrs.Nodes.Length > 1)
     {
         Assert.AreEqual(RouteResultset.SumFlag, rrs.Flag);
     }
     if (rrs.Nodes.Length > 1)
     {
         Assert.AreEqual(99L, rrs.LimitSize);
     }
     nodeMap = GetNodeMap(rrs, 128);
     nameAsserter = new IndexedNodeNameAsserter("offer_dn", 0, 128);
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     for (var i_1 = 0; i_1 < 128; ++i_1)
     {
         sqlAsserter.AddExpectSql(i_1,
             "select Count(*) from (select * from wp_image) w, (select * from offer limit 99) o  where o.member_id=w.member_id and o.member_id='pavarotti17' ");
     }
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_4 in nodeMap.Values)
     {
         asserter.AssertNode(node_4);
     }
     sql = "select Count(*) from (select * from wp_image where member_id='abc' or member_id='pavarotti17' limit 100) w, (select * from offer_detail where offer_id='123') o "
           + " where o.member_id=w.member_id and o.member_id='pavarotti17' limit 99";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(RouteResultset.SumFlag, rrs.Flag);
     Assert.AreEqual(100L, rrs.LimitSize);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("offer_dn[12]", "offer_dn[123]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0,
         "SELECT COUNT(*) FROM (SELECT * FROM wp_image WHERE member_id = 'abc' OR FALSE LIMIT 0, 100) AS "
         + AliasConvert("w") + ", (SELECT * FROM offer_detail WHERE offer_id = '123') AS "
         + AliasConvert("o") + " WHERE o.member_id = w.member_id AND o.member_id = 'pavarotti17' LIMIT 0, 99")
                .AddExpectSql(1,
                    "SELECT COUNT(*) FROM (SELECT * FROM wp_image WHERE FALSE OR member_id = 'pavarotti17' LIMIT 0, 100) AS "
                    + AliasConvert("w") + ", (SELECT * FROM offer_detail WHERE offer_id = '123') AS "
                    + AliasConvert("o") +
                    " WHERE o.member_id = w.member_id AND o.member_id = 'pavarotti17' LIMIT 0, 99");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_5 in nodeMap.Values)
     {
         asserter.AssertNode(node_5);
     }
     sql = "select Count(*) from (select * from(select * from offer_detail where offer_id='123' or offer_id='234' limit 88)offer  where offer.member_id='abc' limit 60) w "
           + " where w.member_id ='pavarotti17' limit 99";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(88L, rrs.LimitSize);
     Assert.AreEqual(RouteResultset.SumFlag, rrs.Flag);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("detail_dn[29]", "detail_dn[15]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0,
         "SELECT COUNT(*) FROM (SELECT * FROM (SELECT * FROM offer_detail WHERE FALSE OR offer_id = '234' LIMIT 0, 88) AS "
         + AliasConvert("offer") + " WHERE offer.member_id = 'abc' LIMIT 0, 60) AS " + AliasConvert("w") +
         " WHERE w.member_id = 'pavarotti17' LIMIT 0, 99")
                .AddExpectSql(1,
                    "SELECT COUNT(*) FROM (SELECT * FROM (SELECT * FROM offer_detail WHERE offer_id = '123' OR FALSE LIMIT 0, 88) AS "
                    + AliasConvert("offer") + " WHERE offer.member_id = 'abc' LIMIT 0, 60) AS " +
                    AliasConvert("w") + " WHERE w.member_id = 'pavarotti17' LIMIT 0, 99");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_6 in nodeMap.Values)
     {
         asserter.AssertNode(node_6);
     }
     sql = "select Count(*) from (select * from(select max(id) from offer_detail where offer_id='123' or offer_id='234' limit 88)offer  where offer.member_id='abc' limit 60) w "
           + " where w.member_id ='pavarotti17' limit 99";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(88L, rrs.LimitSize);
     Assert.AreEqual(0, rrs.Flag);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("detail_dn[29]", "detail_dn[15]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0,
         "SELECT COUNT(*) FROM (SELECT * FROM (SELECT MAX(id) FROM offer_detail WHERE FALSE OR offer_id = '234' LIMIT 0, 88) AS "
         + AliasConvert("offer") + " WHERE offer.member_id = 'abc' LIMIT 0, 60) AS " + AliasConvert("w") +
         " WHERE w.member_id = 'pavarotti17' LIMIT 0, 99")
                .AddExpectSql(1,
                    "SELECT COUNT(*) FROM (SELECT * FROM (SELECT MAX(id) FROM offer_detail WHERE offer_id = '123' OR FALSE LIMIT 0, 88) AS "
                    + AliasConvert("offer") + " WHERE offer.member_id = 'abc' LIMIT 0, 60) AS " +
                    AliasConvert("w") + " WHERE w.member_id = 'pavarotti17' LIMIT 0, 99");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_7 in nodeMap.Values)
     {
         asserter.AssertNode(node_7);
     }
     sql = "select * from (select * from(select max(id) from offer_detail where offer_id='123' or offer_id='234' limit 88)offer  where offer.member_id='abc' limit 60) w "
           + " where w.member_id ='pavarotti17' limit 99";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(88L, rrs.LimitSize);
     Assert.AreEqual(RouteResultset.MaxFlag, rrs.Flag);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("detail_dn[29]", "detail_dn[15]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0,
         "SELECT * FROM (SELECT * FROM (SELECT MAX(id) FROM offer_detail WHERE FALSE OR offer_id = '234' LIMIT 0, 88) AS "
         + AliasConvert("offer") + " WHERE offer.member_id = 'abc' LIMIT 0, 60) AS " + AliasConvert("w") +
         " WHERE w.member_id = 'pavarotti17' LIMIT 0, 99")
                .AddExpectSql(1,
                    "SELECT * FROM (SELECT * FROM (SELECT MAX(id) FROM offer_detail WHERE offer_id = '123' OR FALSE LIMIT 0, 88) AS "
                    + AliasConvert("offer") + " WHERE offer.member_id = 'abc' LIMIT 0, 60) AS " +
                    AliasConvert("w") + " WHERE w.member_id = 'pavarotti17' LIMIT 0, 99");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_8 in nodeMap.Values)
     {
         asserter.AssertNode(node_8);
     }
     sql = "select * from (select Count(*) from(select * from offer_detail where offer_id='123' or offer_id='234' limit 88)offer  where offer.member_id='abc' limit 60) w "
           + " where w.member_id ='pavarotti17' limit 99";
     rrs = ServerRouter.Route(schema, sql, null, null);
     Assert.AreEqual(88L, rrs.LimitSize);
     Assert.AreEqual(RouteResultset.SumFlag, rrs.Flag);
     nodeMap = GetNodeMap(rrs, 2);
     nameAsserter = new NodeNameAsserter("detail_dn[29]", "detail_dn[15]");
     nameAsserter.AssertRouteNodeNames(nodeMap.Keys);
     sqlAsserter = new SimpleSqlAsserter();
     sqlAsserter.AddExpectSql(0,
         "SELECT * FROM (SELECT COUNT(*) FROM (SELECT * FROM offer_detail WHERE FALSE OR offer_id = '234' LIMIT 0, 88) AS "
         + AliasConvert("offer") + " WHERE offer.member_id = 'abc' LIMIT 0, 60) AS " + AliasConvert("w") +
         " WHERE w.member_id = 'pavarotti17' LIMIT 0, 99")
                .AddExpectSql(1,
                    "SELECT * FROM (SELECT COUNT(*) FROM (SELECT * FROM offer_detail WHERE offer_id = '123' OR FALSE LIMIT 0, 88) AS "
                    + AliasConvert("offer") + " WHERE offer.member_id = 'abc' LIMIT 0, 60) AS " +
                    AliasConvert("w") + " WHERE w.member_id = 'pavarotti17' LIMIT 0, 99");
     asserter = new RouteNodeAsserter(nameAsserter, sqlAsserter);
     foreach (var node_9 in nodeMap.Values)
     {
         asserter.AssertNode(node_9);
     }
 }