com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLockTableStatement Java Examples
The following examples show how to use
com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLockTableStatement.
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: TableHandler.java From dble with GNU General Public License v2.0 | 6 votes |
@Override public SQLStatement preHandle(DumpFileContext context, String stmt) throws SQLSyntaxErrorException { SQLStatement sqlStatement = RouteStrategyFactory.getRouteStrategy().parserSQL(stmt); String tableName; if (sqlStatement instanceof MySqlCreateTableStatement) { tableName = StringUtil.removeBackQuote(((MySqlCreateTableStatement) sqlStatement).getTableSource().getName().getSimpleName()); context.setTable(tableName); if (context.getTableType() == TableType.DEFAULT) { return null; } boolean isChanged = preHandleCreateTable(context, sqlStatement); return isChanged ? sqlStatement : null; } else if (sqlStatement instanceof SQLDropTableStatement) { tableName = StringUtil.removeBackQuote(((SQLDropTableStatement) sqlStatement).getTableSources().get(0).getName().getSimpleName()); context.setTable(tableName); } else if (sqlStatement instanceof MySqlLockTableStatement) { tableName = StringUtil.removeBackQuote(((MySqlLockTableStatement) sqlStatement).getTableSource().getName().getSimpleName()); context.setTable(tableName); } return null; }
Example #2
Source File: DruidLockTableParser.java From dble with GNU General Public License v2.0 | 6 votes |
private void handleSingleViewLock(Map<String, Set<String>> dataNodeToLocks, PlanNode viewQuery, String alias, MySqlLockTableStatement.LockType lockType, String schemaName) throws SQLNonTransientException { Map<String, Set<String>> tableMap = new HashMap<>(); findTableInPlanNode(tableMap, viewQuery, schemaName); for (Map.Entry<String, Set<String>> entry : tableMap.entrySet()) { SchemaConfig schemaConfig = DbleServer.getInstance().getConfig().getSchemas().get(entry.getKey()); for (String table : entry.getValue()) { TableConfig tableConfig = schemaConfig.getTables().get(table); if (tableConfig != null) { handleConfigTable(dataNodeToLocks, tableConfig, alias == null ? null : "view_" + alias + "_" + table, lockType); } else if (ProxyMeta.getInstance().getTmManager().getSyncTableMeta(schemaConfig.getName(), table) != null) { handleNoshardTable(dataNodeToLocks, table, schemaConfig.getDataNode(), alias == null ? null : "view_" + alias + "_" + table, lockType); } else { String msg = "Table '" + schemaConfig.getName() + "." + table + "' doesn't exist"; LOGGER.info(msg); throw new SQLNonTransientException(msg); } } } return; }
Example #3
Source File: DruidParserFactory.java From Mycat2 with GNU General Public License v3.0 | 5 votes |
public static DruidParser create(SchemaConfig schema, SQLStatement statement, SchemaStatVisitor visitor) { DruidParser parser = null; if (statement instanceof SQLSelectStatement) { if(schema.isNeedSupportMultiDBType()) { parser = getDruidParserForMultiDB(schema, statement, visitor); } if (parser == null) { parser = new DruidSelectParser(); } } else if (statement instanceof MySqlInsertStatement) { parser = new DruidInsertParser(); } else if (statement instanceof MySqlDeleteStatement) { parser = new DruidDeleteParser(); } else if (statement instanceof MySqlCreateTableStatement) { parser = new DruidCreateTableParser(); } else if (statement instanceof MySqlUpdateStatement) { parser = new DruidUpdateParser(); } else if (statement instanceof SQLAlterTableStatement) { parser = new DruidAlterTableParser(); } else if (statement instanceof MySqlLockTableStatement) { parser = new DruidLockTableParser(); } else { parser = new DefaultDruidParser(); } return parser; }
Example #4
Source File: DruidLockTableParser.java From dble with GNU General Public License v2.0 | 5 votes |
/** * handle single config table lock */ private void handleConfigTable(Map<String, Set<String>> dataNodeToLocks, TableConfig tableConfig, String alias, MySqlLockTableStatement.LockType lockType) { List<String> dataNodes = tableConfig.getDataNodes(); for (String dataNode : dataNodes) { StringBuilder sbItem = new StringBuilder(tableConfig.getName()); if (alias != null) { sbItem.append(" as "); sbItem.append(alias); } sbItem.append(" "); sbItem.append(lockType); Set<String> locks = dataNodeToLocks.computeIfAbsent(dataNode, k -> new HashSet<>()); locks.add(sbItem.toString()); } }
Example #5
Source File: DruidLockTableParser.java From dble with GNU General Public License v2.0 | 5 votes |
private void handleNoshardTable(Map<String, Set<String>> dataNodeToLocks, String tableName, String dataNode, String alias, MySqlLockTableStatement.LockType lockType) { StringBuilder sbItem = new StringBuilder(tableName); if (alias != null) { sbItem.append(" as "); sbItem.append(alias); } sbItem.append(" "); sbItem.append(lockType); Set<String> locks = dataNodeToLocks.computeIfAbsent(dataNode, k -> new HashSet<String>()); locks.add(sbItem.toString()); }