[alibaba/druid]sql parse 打印alter view语句有问题

2025-11-11 582 views
7

druid : 1.2.4 and 1.2.5

 String sql2 = "ALTER \n" +
                "ALGORITHM=UNDEFINED \n" +
                "SQL SECURITY DEFINER \n" +
                "View `test2`.`v1` AS  \n" +
                "select `test_table1`.`id` AS `id`,`test_table1`.`value` AS `value` from `test_table1` ;";

        SQLStatementParser parser2 = SQLParserUtils.createSQLStatementParser(sql2,
                JdbcConstants.MYSQL , false);

        SQLStatement statement = parser2.parseStatement();

        System.out.println(SQLUtils.toSQLString(statement, DbType.mysql,
                new SQLUtils.FormatOption(false,false)));

输出结果:

atler algorithm = UNDEFINED sql security = DEFINER view `test2`.`v1` as select `test_table1`.`id` as `id`, `test_table1`.`value` as `value` from `test_table1`

问题: (1) sql security = DEFINER 错误,mysql中是 sql security DEFINER,不需要 等号; (2)小写打印, alter 关键字输出有误,atler。

回答

2

@wenshao

2

修复不完全,CREATE VIEW 仍然存在上述问题