提交 6e18d576 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Build Select directly in Parser.parseHelp()

上级 77649d06
......@@ -1271,23 +1271,23 @@ public class Parser {
}
private Prepared parseHelp() {
StringBuilder buff = new StringBuilder(
"SELECT * FROM INFORMATION_SCHEMA.HELP");
int i = 0;
ArrayList<Value> paramValues = Utils.newSmallArrayList();
Select select = new Select(session);
select.setWildcard();
Table table = database.getSchema("INFORMATION_SCHEMA").resolveTableOrView(session, "HELP");
Function function = Function.getFunction(database, "UPPER");
function.setParameter(0, new ExpressionColumn(database, "INFORMATION_SCHEMA", "HELP", "TOPIC"));
function.doneWithParameters();
TableFilter filter = new TableFilter(session, table, null, rightsChecked, select, 0, null);
select.addTableFilter(filter, true);
while (currentTokenType != END) {
String s = currentToken;
read();
if (i == 0) {
buff.append(" WHERE ");
} else {
buff.append(" AND ");
}
i++;
buff.append("UPPER(TOPIC) LIKE ?");
paramValues.add(ValueString.get("%" + s + "%"));
CompareLike like = new CompareLike(database, function,
ValueExpression.get(ValueString.get('%' + s + '%')), null, false);
select.addCondition(like);
}
return prepare(session, buff.toString(), paramValues);
select.init();
return select;
}
private Prepared parseShow() {
......
......@@ -12,3 +12,15 @@ HELP ABCDE EF_GH;
> ID SECTION TOPIC SYNTAX TEXT
> -- ------- ----- ------ ----
> rows: 0
HELP HELP;
> ID SECTION TOPIC SYNTAX TEXT
> -- ---------------- ----- ----------------------- ----------------------------------------------------
> 64 Commands (Other) HELP HELP [ anything [...] ] Displays the help pages of SQL commands or keywords.
> rows: 1
HELP he lp;
> ID SECTION TOPIC SYNTAX TEXT
> -- ---------------- ----- ----------------------- ----------------------------------------------------
> 64 Commands (Other) HELP HELP [ anything [...] ] Displays the help pages of SQL commands or keywords.
> rows: 1
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论