当前位置: 首页>>代码示例>>Java>>正文


Java ServerParseSelect类代码示例

本文整理汇总了Java中com.alibaba.cobar.server.parser.ServerParseSelect的典型用法代码示例。如果您正苦于以下问题:Java ServerParseSelect类的具体用法?Java ServerParseSelect怎么用?Java ServerParseSelect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServerParseSelect类属于com.alibaba.cobar.server.parser包,在下文中一共展示了ServerParseSelect类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIsSelectVersionComment

import com.alibaba.cobar.server.parser.ServerParseSelect; //导入依赖的package包/类
@Test
public void testIsSelectVersionComment() {
    Assert.assertEquals(ServerParseSelect.VERSION_COMMENT,
        ServerParseSelect.parse(" select @@version_comment  ", 7));
    Assert.assertEquals(ServerParseSelect.VERSION_COMMENT, ServerParseSelect.parse("SELECT @@VERSION_COMMENT", 6));
    Assert.assertEquals(ServerParseSelect.VERSION_COMMENT,
        ServerParseSelect.parse(" selECT    @@VERSION_comment  ", 7));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:9,代码来源:ServerParserTest.java

示例2: testIdentity

import com.alibaba.cobar.server.parser.ServerParseSelect; //导入依赖的package包/类
@Test
public void testIdentity() {
    String stmt = "select @@identity";
    int indexAfterLastInsertIdFunc = ServerParseSelect.indexAfterIdentity(stmt, stmt.indexOf('i'));
    Assert.assertEquals(stmt.length(), indexAfterLastInsertIdFunc);
    Assert.assertEquals(ServerParseSelect.IDENTITY, ServerParseSelect.parse(stmt, 6));
    stmt = "select  @@identity as id";
    Assert.assertEquals(ServerParseSelect.IDENTITY, ServerParseSelect.parse(stmt, 6));
    stmt = "select  @@identitY  id";
    Assert.assertEquals(ServerParseSelect.IDENTITY, ServerParseSelect.parse(stmt, 6));
    stmt = "select  /*foo*/@@identitY  id";
    Assert.assertEquals(ServerParseSelect.IDENTITY, ServerParseSelect.parse(stmt, 6));
    stmt = "select/*foo*/ @@identitY  id";
    Assert.assertEquals(ServerParseSelect.IDENTITY, ServerParseSelect.parse(stmt, 6));
    stmt = "select/*foo*/ @@identitY As id";
    Assert.assertEquals(ServerParseSelect.IDENTITY, ServerParseSelect.parse(stmt, 6));

    stmt = "select  @@identity ,";
    Assert.assertEquals(ServerParseSelect.OTHER, ServerParseSelect.parse(stmt, 6));
    stmt = "select  @@identity as, ";
    Assert.assertEquals(ServerParseSelect.OTHER, ServerParseSelect.parse(stmt, 6));
    stmt = "select  @@identity as id  , ";
    Assert.assertEquals(ServerParseSelect.OTHER, ServerParseSelect.parse(stmt, 6));
    stmt = "select  @@identity ass id   ";
    Assert.assertEquals(ServerParseSelect.OTHER, ServerParseSelect.parse(stmt, 6));

}
 
开发者ID:loye168,项目名称:tddl5,代码行数:28,代码来源:ServerParserTest.java

示例3: testIsSelectVersionComment

import com.alibaba.cobar.server.parser.ServerParseSelect; //导入依赖的package包/类
@Test
public void testIsSelectVersionComment() {
    Assert.assertEquals(
            ServerParseSelect.VERSION_COMMENT,
            ServerParseSelect.parse(" select @@version_comment  ", 7));
    Assert.assertEquals(ServerParseSelect.VERSION_COMMENT, ServerParseSelect.parse("SELECT @@VERSION_COMMENT", 6));
    Assert.assertEquals(
            ServerParseSelect.VERSION_COMMENT,
            ServerParseSelect.parse(" selECT    @@VERSION_comment  ", 7));
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:11,代码来源:ServerParserTest.java

示例4: handle

import com.alibaba.cobar.server.parser.ServerParseSelect; //导入依赖的package包/类
public static void handle(String stmt, ServerConnection c, int offs) {
    int offset = offs;
    switch (ServerParseSelect.parse(stmt, offs)) {
        case ServerParseSelect.VERSION_COMMENT:
            SelectVersionComment.response(c);
            break;
        case ServerParseSelect.DATABASE:
            SelectDatabase.response(c);
            break;
        case ServerParseSelect.USER:
            SelectUser.response(c);
            break;
        case ServerParseSelect.VERSION:
            SelectVersion.response(c);
            break;
        case ServerParseSelect.LAST_INSERT_ID:
            // offset = ParseUtil.move(stmt, 0, "select".length());
            loop: for (; offset < stmt.length(); ++offset) {
                switch (stmt.charAt(offset)) {
                    case ' ':
                        continue;
                    case '/':
                    case '#':
                        offset = ParseUtil.comment(stmt, offset);
                        continue;
                    case 'L':
                    case 'l':
                        break loop;
                }
            }
            offset = ServerParseSelect.indexAfterLastInsertIdFunc(stmt, offset);
            offset = ServerParseSelect.skipAs(stmt, offset);
            SelectLastInsertId.response(c, stmt, offset);
            break;
        case ServerParseSelect.IDENTITY:
            // offset = ParseUtil.move(stmt, 0, "select".length());
            loop: for (; offset < stmt.length(); ++offset) {
                switch (stmt.charAt(offset)) {
                    case ' ':
                        continue;
                    case '/':
                    case '#':
                        offset = ParseUtil.comment(stmt, offset);
                        continue;
                    case '@':
                        break loop;
                }
            }
            int indexOfAtAt = offset;
            offset += 2;
            offset = ServerParseSelect.indexAfterIdentity(stmt, offset);
            String orgName = stmt.substring(indexOfAtAt, offset);
            offset = ServerParseSelect.skipAs(stmt, offset);
            SelectIdentity.response(c, stmt, offset, orgName);
            break;
        default:
            c.execute(stmt, ServerParse.SELECT);
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:60,代码来源:SelectHandler.java

示例5: testIsSelectVersion

import com.alibaba.cobar.server.parser.ServerParseSelect; //导入依赖的package包/类
@Test
public void testIsSelectVersion() {
    Assert.assertEquals(ServerParseSelect.VERSION, ServerParseSelect.parse(" select version ()  ", 7));
    Assert.assertEquals(ServerParseSelect.VERSION, ServerParseSelect.parse("SELECT VERSION(  )", 6));
    Assert.assertEquals(ServerParseSelect.VERSION, ServerParseSelect.parse(" selECT    VERSION()  ", 7));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:7,代码来源:ServerParserTest.java

示例6: testIsSelectDatabase

import com.alibaba.cobar.server.parser.ServerParseSelect; //导入依赖的package包/类
@Test
public void testIsSelectDatabase() {
    Assert.assertEquals(ServerParseSelect.DATABASE, ServerParseSelect.parse(" select database()  ", 7));
    Assert.assertEquals(ServerParseSelect.DATABASE, ServerParseSelect.parse("SELECT DATABASE()", 6));
    Assert.assertEquals(ServerParseSelect.DATABASE, ServerParseSelect.parse(" selECT    DATABASE()  ", 7));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:7,代码来源:ServerParserTest.java

示例7: testIsSelectUser

import com.alibaba.cobar.server.parser.ServerParseSelect; //导入依赖的package包/类
@Test
public void testIsSelectUser() {
    Assert.assertEquals(ServerParseSelect.USER, ServerParseSelect.parse(" select user()  ", 7));
    Assert.assertEquals(ServerParseSelect.USER, ServerParseSelect.parse("SELECT USER()", 6));
    Assert.assertEquals(ServerParseSelect.USER, ServerParseSelect.parse(" selECT    USER()  ", 7));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:7,代码来源:ServerParserTest.java

示例8: handle

import com.alibaba.cobar.server.parser.ServerParseSelect; //导入依赖的package包/类
public static void handle(String stmt, ServerConnection c, int offs) {
    int offset = offs;
    switch (ServerParseSelect.parse(stmt, offs)) {
    case ServerParseSelect.VERSION_COMMENT:
        SelectVersionComment.response(c);
        break;
    case ServerParseSelect.DATABASE:
        SelectDatabase.response(c);
        break;
    case ServerParseSelect.USER:
        SelectUser.response(c);
        break;
    case ServerParseSelect.VERSION:
        SelectVersion.response(c);
        break;
    case ServerParseSelect.LAST_INSERT_ID:
        // offset = ParseUtil.move(stmt, 0, "select".length());
        loop: for (; offset < stmt.length(); ++offset) {
            switch (stmt.charAt(offset)) {
            case ' ':
                continue;
            case '/':
            case '#':
                offset = ParseUtil.comment(stmt, offset);
                continue;
            case 'L':
            case 'l':
                break loop;
            }
        }
        offset = ServerParseSelect.indexAfterLastInsertIdFunc(stmt, offset);
        offset = ServerParseSelect.skipAs(stmt, offset);
        SelectLastInsertId.response(c, stmt, offset);
        break;
    case ServerParseSelect.IDENTITY:
        // offset = ParseUtil.move(stmt, 0, "select".length());
        loop: for (; offset < stmt.length(); ++offset) {
            switch (stmt.charAt(offset)) {
            case ' ':
                continue;
            case '/':
            case '#':
                offset = ParseUtil.comment(stmt, offset);
                continue;
            case '@':
                break loop;
            }
        }
        int indexOfAtAt = offset;
        offset += 2;
        offset = ServerParseSelect.indexAfterIdentity(stmt, offset);
        String orgName = stmt.substring(indexOfAtAt, offset);
        offset = ServerParseSelect.skipAs(stmt, offset);
        SelectIdentity.response(c, stmt, offset, orgName);
        break;
    default:
        c.execute(stmt, ServerParse.SELECT);
    }
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:60,代码来源:SelectHandler.java


注:本文中的com.alibaba.cobar.server.parser.ServerParseSelect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。