Search in sources :

Example 1 with DruidSelectPostgresqlParser

use of io.mycat.route.parser.druid.impl.DruidSelectPostgresqlParser in project Mycat-Server by MyCATApache.

the class DruidParserFactory method getDruidParserForMultiDB.

private static DruidParser getDruidParserForMultiDB(SchemaConfig schema, SQLStatement statement, SchemaStatVisitor visitor) {
    DruidParser parser = null;
    //先解出表,判断表所在db的类型,再根据不同db类型返回不同的解析
    List<String> tables = parseTables(statement, visitor);
    for (String table : tables) {
        Set<String> dbTypes = null;
        TableConfig tableConfig = schema.getTables().get(table);
        if (tableConfig == null) {
            dbTypes = new HashSet<>();
            dbTypes.add(schema.getDefaultDataNodeDbType());
        } else {
            dbTypes = tableConfig.getDbTypes();
        }
        if (dbTypes.contains("oracle")) {
            parser = new DruidSelectOracleParser();
            break;
        } else if (dbTypes.contains("db2")) {
            parser = new DruidSelectDb2Parser();
            break;
        } else if (dbTypes.contains("sqlserver")) {
            parser = new DruidSelectSqlServerParser();
            break;
        } else if (dbTypes.contains("postgresql")) {
            parser = new DruidSelectPostgresqlParser();
            break;
        }
    }
    return parser;
}
Also used : DruidSelectOracleParser(io.mycat.route.parser.druid.impl.DruidSelectOracleParser) DruidSelectSqlServerParser(io.mycat.route.parser.druid.impl.DruidSelectSqlServerParser) DefaultDruidParser(io.mycat.route.parser.druid.impl.DefaultDruidParser) DruidSelectDb2Parser(io.mycat.route.parser.druid.impl.DruidSelectDb2Parser) DruidSelectPostgresqlParser(io.mycat.route.parser.druid.impl.DruidSelectPostgresqlParser) TableConfig(io.mycat.config.model.TableConfig)

Aggregations

TableConfig (io.mycat.config.model.TableConfig)1 DefaultDruidParser (io.mycat.route.parser.druid.impl.DefaultDruidParser)1 DruidSelectDb2Parser (io.mycat.route.parser.druid.impl.DruidSelectDb2Parser)1 DruidSelectOracleParser (io.mycat.route.parser.druid.impl.DruidSelectOracleParser)1 DruidSelectPostgresqlParser (io.mycat.route.parser.druid.impl.DruidSelectPostgresqlParser)1 DruidSelectSqlServerParser (io.mycat.route.parser.druid.impl.DruidSelectSqlServerParser)1