本文整理汇总了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));
}
示例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));
}
示例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));
}
示例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);
}
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
}