本文整理汇总了Java中com.alibaba.cobar.server.parser.ServerParseSelect.indexAfterIdentity方法的典型用法代码示例。如果您正苦于以下问题:Java ServerParseSelect.indexAfterIdentity方法的具体用法?Java ServerParseSelect.indexAfterIdentity怎么用?Java ServerParseSelect.indexAfterIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.cobar.server.parser.ServerParseSelect
的用法示例。
在下文中一共展示了ServerParseSelect.indexAfterIdentity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: 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);
}
}
示例3: 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);
}
}