com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowColumnsStatement Java Examples
The following examples show how to use
com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowColumnsStatement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShowColumns.java From dble with GNU General Public License v2.0 | 5 votes |
public static void response(ServerConnection c, String stmt) { try { Pattern pattern = ShowColumns.PATTERN; Matcher ma = pattern.matcher(stmt); // always match if (ma.matches()) { int start = ma.start(6); int end = ma.end(6); String sub = stmt.substring(0, start); String sub2 = stmt.substring(end, stmt.length()); stmt = sub + " from " + sub2; } SQLStatement statement = RouteStrategyFactory.getRouteStrategy().parserSQL(stmt); MySqlShowColumnsStatement showColumnsStatement = (MySqlShowColumnsStatement) statement; String table = StringUtil.removeBackQuote(showColumnsStatement.getTable().getSimpleName()); SQLName database = showColumnsStatement.getDatabase(); String schema = database == null ? c.getSchema() : StringUtil.removeBackQuote(database.getSimpleName()); if (schema == null) { c.writeErrMessage("3D000", "No database selected", ErrorCode.ER_NO_DB_ERROR); return; } String sql = stmt; if (showColumnsStatement.getDatabase() != null) { showColumnsStatement.setDatabase(null); sql = showColumnsStatement.toString(); } if (DbleServer.getInstance().getSystemVariables().isLowerCaseTableNames()) { schema = schema.toLowerCase(); table = table.toLowerCase(); } SchemaInfo schemaInfo = new SchemaInfo(schema, table); c.routeSystemInfoAndExecuteSQL(sql, schemaInfo, ServerParse.SHOW); } catch (Exception e) { c.writeErrMessage(ErrorCode.ER_PARSE_ERROR, e.toString()); } }