diff --git a/README.md b/README.md
index 14fe5c847f79f6963d6ae06fcec65b2067266d0b..dd00bce21f6fc1575b5f833661c6c94abb963846 100644
--- a/README.md
+++ b/README.md
@@ -14,13 +14,13 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus
根据SQL语句在MySQL5.7官方文档和openGauss 3.0.0官方文档的差异对比,对各SQL语句进行翻译。下表展示SQL语句的翻译情况。
-| SQL语句 | 翻译情况 |
-| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
-| [ALTER EVENT Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-event.html)、[ALTER INSTANCE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-instance.html)、[ALTER LOGFILE GROUP Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-logfile-group.html)、[ALTER PROCEDURE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-procedure.html)、[CREATE EVENT Statement](https://dev.mysql.com/doc/refman/5.7/en/create-event.html)、[CREATE LOGFILE GROUP Statement](https://dev.mysql.com/doc/refman/5.7/en/create-logfile-group.html)、[DROP EVENT Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-event.html)、[DROP LOGFILE GROUP Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-logfile-group.html)、[DO Statement](https://dev.mysql.com/doc/refman/5.7/en/do.html)、[HANDLER Statement](https://dev.mysql.com/doc/refman/5.7/en/handler.html)、[REPLACE Statement](https://dev.mysql.com/doc/refman/5.7/en/replace.html)、[Replication Statements](https://dev.mysql.com/doc/refman/5.7/en/sql-replication-statements.html)、[ITERATE Statement](https://dev.mysql.com/doc/refman/5.7/en/iterate.html)、[Condition Handling](https://dev.mysql.com/doc/refman/5.7/en/condition-handling.html)、[SET PASSWORD Statement](https://dev.mysql.com/doc/refman/5.7/en/set-password.html)、[CHECK TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/check-table.html)、[CHECKSUM TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/checksum-table.html)、[OPTIMIZE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/optimize-table.html)、[REPAIR TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/repair-table.html)、[Plugin and Loadable Function Statements](https://dev.mysql.com/doc/refman/5.7/en/component-statements.html)、[SET NAMES Statement](https://dev.mysql.com/doc/refman/5.7/en/set-names.html)、[SET CHARACTER Statement](https://dev.mysql.com/doc/refman/5.7/en/set-character-set.html)、[SHOW Statements](https://dev.mysql.com/doc/refman/5.7/en/show.html)、[BINLOG Statement](https://dev.mysql.com/doc/refman/5.7/en/binlog.html)、[CACHE INDEX Statement](https://dev.mysql.com/doc/refman/5.7/en/cache-index.html)、[FLUSH Statement](https://dev.mysql.com/doc/refman/5.7/en/flush.html)、[KILL Statement](https://dev.mysql.com/doc/refman/5.7/en/kill.html)、[LOAD INDEX INTO CACHE Statement](https://dev.mysql.com/doc/refman/5.7/en/load-index.html)、[DESCRIBE Statement](https://dev.mysql.com/doc/refman/5.7/en/describe.html)、[HELP Statement](https://dev.mysql.com/doc/refman/5.7/en/help.html) | openGauss不支持 |
-| [SHUTDOWN Statement](https://dev.mysql.com/doc/refman/5.7/en/shutdown.html) | Druid不支持 |
-| [ALTER DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-database.html)、[ALTER FUNCTION Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-function.html)、[ALTER SERVER Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-server.html)、[ALTER TABLESPACE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-tablespace.html)、[CREATE SERVER Statement](https://dev.mysql.com/doc/refman/5.7/en/create-server.html)、[CREATE TABLESPACE Statement](https://dev.mysql.com/doc/refman/5.7/en/create-tablespace.html)、[DROP TRIGGER Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-trigger.html)、[Prepared Statements](https://dev.mysql.com/doc/refman/5.7/en/sql-prepared-statements.html)、[Cursors](https://dev.mysql.com/doc/refman/5.7/en/cursors.html)、[ANALYZE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/analyze-table.html)、[RESET Statement](https://dev.mysql.com/doc/refman/5.7/en/reset.html)、[EXPLAIN Statement](https://dev.mysql.com/doc/refman/5.7/en/explain.html) | 无法兼容 |
-| [ALTER TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-table.html)、[ALTER VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-view.html)、[CREATE DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/create-database.html)、[CREATE FUNCTION Statement](https://dev.mysql.com/doc/refman/5.7/en/create-function.html)、[CREATE INDEX Statement](https://dev.mysql.com/doc/refman/5.7/en/create-index.html)、[CREATE PROCEDURE Statements](https://dev.mysql.com/doc/refman/5.7/en/create-procedure.html)、[CREATE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/create-table.html)、[CREATE TRIGGER Statement](https://dev.mysql.com/doc/refman/5.7/en/create-trigger.html)、[CREATE VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/create-view.html)、[DROP DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-database.html)、[DROP INDEX Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-index.html)、[DROP TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-table.html)、[DROP TABLESPACE Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-tablespace.html)、[DELETE Statement](https://dev.mysql.com/doc/refman/5.7/en/delete.html)、[INSERT Statement](https://dev.mysql.com/doc/refman/5.7/en/insert.html)、[SELECT Statement](https://dev.mysql.com/doc/refman/5.7/en/select.html)、[Subqueries](https://dev.mysql.com/doc/refman/5.7/en/subqueries.html)、[UPDATE Statement](https://dev.mysql.com/doc/refman/5.7/en/update.html)、[START TRANSACTION, COMMIT, and ROLLBACK Statements](https://dev.mysql.com/doc/refman/5.7/en/commit.html)、[SET TRANSACTION Statement](https://dev.mysql.com/doc/refman/5.7/en/set-transaction.html)、[ALTER USER Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-user.html)、[CREATE USER Statement](https://dev.mysql.com/doc/refman/5.7/en/create-user.html)、[RENAME USER Statement](https://dev.mysql.com/doc/refman/5.7/en/rename-user.html)、[GRANT Statement](https://dev.mysql.com/doc/refman/5.7/en/grant.html)、[REVOKE Statement](https://dev.mysql.com/doc/refman/5.7/en/revoke.html)、[SET param_name](https://dev.mysql.com/doc/refman/5.7/en/set-variable.html)、[USE Statement](https://dev.mysql.com/doc/refman/5.7/en/use.html) | 部分支持 |
-| [DROP FUNCTION Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-function.html)、[DROP PROCEDURE](https://dev.mysql.com/doc/refman/5.7/en/drop-procedure.html)[and DROP FUNCTION Statements](https://dev.mysql.com/doc/refman/5.7/en/drop-procedure.html)、[DROP SERVER Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-server.html)、[DROP VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-view.html)、[RENAME TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/rename-table.html)、[TRUNCATE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/truncate-table.html)、[CALL Statement](https://dev.mysql.com/doc/refman/5.7/en/call.html)、[BEGIN ... END Compound Statement](https://dev.mysql.com/doc/refman/5.7/en/begin-end.html)、[Statement Labels](https://dev.mysql.com/doc/refman/5.7/en/statement-labels.html)、[DECLARE Statement](https://dev.mysql.com/doc/refman/5.7/en/declare.html)、[CASE Statement](https://dev.mysql.com/doc/refman/5.7/en/case.html)、[IF Statement](https://dev.mysql.com/doc/refman/5.7/en/if.html)、[LEAVE Statement](https://dev.mysql.com/doc/refman/5.7/en/leave.html)、[LOOP Statement](https://dev.mysql.com/doc/refman/5.7/en/loop.html)、[REPEAT Statement](https://dev.mysql.com/doc/refman/5.7/en/repeat.html)、[RETURN Statement](https://dev.mysql.com/doc/refman/5.7/en/return.html)、[WHILE Statement](https://dev.mysql.com/doc/refman/5.7/en/while.html)、[DROP USER Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-user.html) | 完全支持 |
+| SQL语句 | 翻译情况 |
+| ------------------------------------------------------------ | --------------- |
+| [ALTER EVENT Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-event.html)、[ALTER INSTANCE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-instance.html)、[ALTER LOGFILE GROUP Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-logfile-group.html)、[CREATE EVENT Statement](https://dev.mysql.com/doc/refman/5.7/en/create-event.html)、[CREATE LOGFILE GROUP Statement](https://dev.mysql.com/doc/refman/5.7/en/create-logfile-group.html)、[DROP EVENT Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-event.html)、[DROP LOGFILE GROUP Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-logfile-group.html)、[HANDLER Statement](https://dev.mysql.com/doc/refman/5.7/en/handler.html)、[REPLACE Statement](https://dev.mysql.com/doc/refman/5.7/en/replace.html)、[Replication Statements](https://dev.mysql.com/doc/refman/5.7/en/sql-replication-statements.html)、[SET PASSWORD Statement](https://dev.mysql.com/doc/refman/5.7/en/set-password.html)、[CHECK TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/check-table.html)、[CHECKSUM TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/checksum-table.html)、[OPTIMIZE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/optimize-table.html)、[REPAIR TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/repair-table.html)、[Plugin and Loadable Function Statements](https://dev.mysql.com/doc/refman/5.7/en/component-statements.html)、[SET NAMES Statement](https://dev.mysql.com/doc/refman/5.7/en/set-names.html)、[SET CHARACTER Statement](https://dev.mysql.com/doc/refman/5.7/en/set-character-set.html)、[SHOW Statements](https://dev.mysql.com/doc/refman/5.7/en/show.html)、[BINLOG Statement](https://dev.mysql.com/doc/refman/5.7/en/binlog.html)、[CACHE INDEX Statement](https://dev.mysql.com/doc/refman/5.7/en/cache-index.html)、[FLUSH Statement](https://dev.mysql.com/doc/refman/5.7/en/flush.html)、[KILL Statement](https://dev.mysql.com/doc/refman/5.7/en/kill.html)、[LOAD INDEX INTO CACHE Statement](https://dev.mysql.com/doc/refman/5.7/en/load-index.html)、[DESCRIBE Statement](https://dev.mysql.com/doc/refman/5.7/en/describe.html)、[HELP Statement](https://dev.mysql.com/doc/refman/5.7/en/help.html) | openGauss不支持 |
+| [SHUTDOWN Statement](https://dev.mysql.com/doc/refman/5.7/en/shutdown.html)、[DO Statement](https://dev.mysql.com/doc/refman/5.7/en/do.html)、[ITERATE Statement](https://dev.mysql.com/doc/refman/5.7/en/iterate.html) | Druid不支持 |
+| [ALTER DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-database.html)、[ALTER SERVER Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-server.html)、[ALTER TABLESPACE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-tablespace.html)、[CREATE SERVER Statement](https://dev.mysql.com/doc/refman/5.7/en/create-server.html)、[CREATE TABLESPACE Statement](https://dev.mysql.com/doc/refman/5.7/en/create-tablespace.html)、[Prepared Statements](https://dev.mysql.com/doc/refman/5.7/en/sql-prepared-statements.html)、[ANALYZE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/analyze-table.html)、[RESET Statement](https://dev.mysql.com/doc/refman/5.7/en/reset.html)、[EXPLAIN Statement](https://dev.mysql.com/doc/refman/5.7/en/explain.html) | 无法兼容 |
+| [ALTER TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-table.html)、[ALTER VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-view.html)、[CREATE DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/create-database.html)、[CREATE FUNCTION Statement](https://dev.mysql.com/doc/refman/5.7/en/create-function.html)、[CREATE INDEX Statement](https://dev.mysql.com/doc/refman/5.7/en/create-index.html)、[CREATE PROCEDURE Statements](https://dev.mysql.com/doc/refman/5.7/en/create-procedure.html)、[CREATE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/create-table.html)、[CREATE TRIGGER Statement](https://dev.mysql.com/doc/refman/5.7/en/create-trigger.html)、[CREATE VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/create-view.html)、[DROP DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-database.html)、[DROP INDEX Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-index.html)、[DROP TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-table.html)、[DROP TABLESPACE Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-tablespace.html)、[DELETE Statement](https://dev.mysql.com/doc/refman/5.7/en/delete.html)、[INSERT Statement](https://dev.mysql.com/doc/refman/5.7/en/insert.html)、[SELECT Statement](https://dev.mysql.com/doc/refman/5.7/en/select.html)、[Subqueries](https://dev.mysql.com/doc/refman/5.7/en/subqueries.html)、[UPDATE Statement](https://dev.mysql.com/doc/refman/5.7/en/update.html)、[START TRANSACTION, COMMIT, and ROLLBACK Statements](https://dev.mysql.com/doc/refman/5.7/en/commit.html)、[SET TRANSACTION Statement](https://dev.mysql.com/doc/refman/5.7/en/set-transaction.html)、[ALTER USER Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-user.html)、[CREATE USER Statement](https://dev.mysql.com/doc/refman/5.7/en/create-user.html)、[RENAME USER Statement](https://dev.mysql.com/doc/refman/5.7/en/rename-user.html)、[GRANT Statement](https://dev.mysql.com/doc/refman/5.7/en/grant.html)、[REVOKE Statement](https://dev.mysql.com/doc/refman/5.7/en/revoke.html)、[SET param_name](https://dev.mysql.com/doc/refman/5.7/en/set-variable.html)、[USE Statement](https://dev.mysql.com/doc/refman/5.7/en/use.html)、[ALTER FUNCTION Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-function.html)、[ALTER PROCEDURE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-procedure.html) | 部分支持 |
+| [DROP FUNCTION Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-function.html)、[DROP PROCEDURE](https://dev.mysql.com/doc/refman/5.7/en/drop-procedure.html)[and DROP FUNCTION Statements](https://dev.mysql.com/doc/refman/5.7/en/drop-procedure.html)、[DROP SERVER Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-server.html)、[DROP VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-view.html)、[RENAME TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/rename-table.html)、[TRUNCATE TABLE Statement](https://dev.mysql.com/doc/refman/5.7/en/truncate-table.html)、[CALL Statement](https://dev.mysql.com/doc/refman/5.7/en/call.html)、[BEGIN ... END Compound Statement](https://dev.mysql.com/doc/refman/5.7/en/begin-end.html)、[Statement Labels](https://dev.mysql.com/doc/refman/5.7/en/statement-labels.html)、[DECLARE Statement](https://dev.mysql.com/doc/refman/5.7/en/declare.html)、[CASE Statement](https://dev.mysql.com/doc/refman/5.7/en/case.html)、[IF Statement](https://dev.mysql.com/doc/refman/5.7/en/if.html)、[LEAVE Statement](https://dev.mysql.com/doc/refman/5.7/en/leave.html)、[LOOP Statement](https://dev.mysql.com/doc/refman/5.7/en/loop.html)、[REPEAT Statement](https://dev.mysql.com/doc/refman/5.7/en/repeat.html)、[RETURN Statement](https://dev.mysql.com/doc/refman/5.7/en/return.html)、[WHILE Statement](https://dev.mysql.com/doc/refman/5.7/en/while.html)、[DROP USER Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-user.html)、[DROP TRIGGER Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-trigger.html)、[Cursors](https://dev.mysql.com/doc/refman/5.7/en/cursors.html)、[Condition Handling](https://dev.mysql.com/doc/refman/5.7/en/condition-handling.html) | 完全支持 |
* openGauss不支持,表明会在日志中输出ERROR,由于该语句存在于需迁移的数据库对象中,所以该数据库对象迁移失败;
* Druid不支持,表明该语句解析不成功,拥有该语句的数据库对象也迁移失败;
@@ -40,7 +40,7 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus
### [13.1.3 ALTER FUNCTION Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-function.html)
-> 1. 无法支持,在openGauss中该字段的argtype是必须的,而Druid的alter function无法获取该字段。就算可以获取,MySQL的characteristic也只能翻译SECURITY字段
+> 1. 部分支持,druid不能解析NO SQL、READS SQL DATA、MODIFIES SQL DATA字段
### [13.1.4 ALTER INSTANCE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-instance.html)
@@ -52,7 +52,7 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus
### [13.1.6 ALTER PROCEDURE Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-procedure.html)
-> 1. openGauss不存在该语句,同时Druid也没有该语句的解析
+> 1. 部分支持,druid不能解析NO SQL、READS SQL DATA、MODIFIES SQL DATA字段
### [13.1.7 ALTER SERVER Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-server.html)
@@ -72,7 +72,7 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus
### [13.1.10 ALTER VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-view.html)
-> 1. MySQL存在ALGORITHM、DEFINER、SQL SECURITY、 [WITH [CASCADED | LOCAL] CHECK OPTION]字段,openGauss不支持这些字段
+> 1. MySQL存在[WITH [CASCADED | LOCAL] CHECK OPTION]字段,openGauss不支持这些字段
### [13.1.11 CREATE DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/create-database.html)
@@ -84,9 +84,9 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus
### [13.1.13 CREATE FUNCTION Statement](https://dev.mysql.com/doc/refman/5.7/en/create-function.html)
-> 1. MySQL存在DEFINER、COMMENT、LANGUAGE SQL、SECURITY、CONTAINS SQL|NO SQL|READS SQL DATA|MODIFIES SQL DATA字段,openGauss不支持这些字段
+> 1. MySQL存在SECURITY、CONTAINS SQL|NO SQL|READS SQL DATA|MODIFIES SQL DATA字段,openGauss不支持这些字段
> 2. Druid不支持解析CONTAINS SQL、NO SQL、READS SQL DATA、MODIFIES SQL DATA、SECURITY
-> 3. 把DETERMINISTIC翻译成openGauss的IMMUTABLE,当需要修改数据库时不能使用IMMUTABLE,此时用VOLATILE替换
+> 3. 把DETERMINISTIC翻译成openGauss的DETERMINISTIC,当需要修改数据库时不能使用DETERMINISTIC,此时用VOLATILE替换
### [13.1.14 CREATE INDEX Statement](https://dev.mysql.com/doc/refman/5.7/en/create-index.html)
@@ -107,9 +107,9 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus
### [13.1.16 CREATE PROCEDURE Statements](https://dev.mysql.com/doc/refman/5.7/en/create-procedure.html)
-> 1. MySQL存在DEFINER、COMMENT、LANGUAGE SQL、CONTAINS SQL|NO SQL|READS SQL DATA|MODIFIES SQL 字段,openGauss不支持该字段
+> 1. MySQL存在CONTAINS SQL|NO SQL|READS SQL DATA|MODIFIES SQL 字段,openGauss不支持该字段
> 2. Druid不支持解析NO SQL|READS SQL DATA|MODIFIES SQL字段druid不支持解析SECURITY字
-> 3. 把DETERMINISTIC翻译成openGauss的IMMUTABLE,当需要修改数据库时不能使用IMMUTABLE,此时用VOLATILE替换用IMMUTABLE替换MySQL的DETERMINISTI
+> 3. 把DETERMINISTIC翻译成openGauss的DETERMINISTIC,当需要修改数据库时不能使用DETERMINISTIC,此时用VOLATILE替换
### [13.1.17 CREATE SERVER Statement](https://dev.mysql.com/doc/refman/5.7/en/create-server.html)
@@ -149,7 +149,7 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus
### [13.1.21 CREATE VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/create-view.html)
-> 1. MySQL存在ALGORITHM、DEFINER、SQL SECURITY、 [WITH [CASCADED | LOCAL] CHECK OPTION]字段,openGauss不支持这些字段
+> 1. MySQL存在 [WITH [CASCADED | LOCAL] CHECK OPTION]字段,openGauss不支持这些字段
### [13.1.22 DROP DATABASE Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-database.html)
@@ -192,11 +192,11 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus
### [13.1.30 DROP TABLESPACE Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-tablespace.html)
-> 1. ENGINE字段不支持该语句在openGauss中需要有ON table_name,而druid的drop trigger无法获取该字
+> 1. ENGINE字段不支持
### [13.1.31 DROP TRIGGER Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-trigger.html)
-> 1. 该语句openGauss和MySQL无法兼容。opengauss的drop trigger需要ON table_name 而druid内该语句没有该字段定义
+> 1. 在B兼容模式下部分支持,不支持trigger_name前指定schema_name格式[drop trigger](https://docs.opengauss.org/zh/docs/5.0.0/docs/SQLReference/DROP-TRIGGER.html)
### [13.1.32 DROP VIEW Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-view.html)
@@ -223,7 +223,7 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus
### [13.2.3 DO Statement](https://dev.mysql.com/doc/refman/5.7/en/do.html)
-> 1. openGauss不存在该语句,且Druid不支持解析此语句
+> 1. openGauss存在该语句,但是Druid不支持解析此语句
### [13.2.4 HANDLER Statement](https://dev.mysql.com/doc/refman/5.7/en/handler.html)
@@ -296,18 +296,18 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus
### [13.6.5 Flow Control Statements](https://dev.mysql.com/doc/refman/5.7/en/flow-control-statements.html)
-> 1. 其中openGauss不支持ITERATE
-> 2. openGauss不存在REPEAT语句,用LOOP语句替换
+> 1. druid不支持解析ITERATE语句
+> 2. openGauss存在REPEAT语句,当前用LOOP语句替换
> 3. druid不支持解析case语句的第二种语法,因此无法转换
> 4. CASE、IF、LEAVE、LOOP、REPEAT、RETURN、WHILE完全支持
### [13.6.6 Cursors](https://dev.mysql.com/doc/refman/5.7/en/cursors.html)
-> 1. 无法兼容。MySQL的FETCH有INTO var_name字段,openGauss没有,无法提取的列存储在命名变量中
+> 1. 完全兼容
### [13.6.7 Condition Handling](https://dev.mysql.com/doc/refman/5.7/en/condition-handling.html)
-> 1. openGauss不存在该语句
+> 1. 完全兼容
### [13.7.1.1 ALTER USER Statement](https://dev.mysql.com/doc/refman/5.7/en/alter-user.html)
@@ -319,8 +319,7 @@ openGauss-tools-sql-translator是一个使用java编写的实现MySQL向openGaus
### [13.7.1.2 CREATE USER Statement](https://dev.mysql.com/doc/refman/5.7/en/create-user.html)
> 1. druid不解析REQUIRE、WITH resourceoption、passwordoption、lock_option字段且openGauss也不支持
-> 2. openGauss不支持IF NOT EXISTS、auth_plugin字段
-> 3. openGauss的Account names不需要单引号,且没有hostname的部分,目前解决方法是截取username的部分并去除双引号
+> 2. openGauss不支持auth_plugin字段
### [13.7.1.3 DROP USER Statement](https://dev.mysql.com/doc/refman/5.7/en/drop-user.html)
diff --git a/pom.xml b/pom.xml
index 60a7b083381742443bd9d015165bca217ee01d67..0665dae1bdd92c11f4c1b1b89cab419d72ffe9f5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,6 +76,16 @@
slf4j-api
1.7.25
+
+ org.slf4j
+ slf4j-api
+ 1.8.0-beta4
+
+
+ org.slf4j
+ slf4j-simple
+ 1.8.0-beta4
+
commons-io
commons-io
diff --git a/src/main/java/org/opengauss/sqltranslator/ExecuteTranslate.java b/src/main/java/org/opengauss/sqltranslator/ExecuteTranslate.java
index 964b517b7f399dec6a6d1f20223d590f5d456fa2..61201aca948dad663f2d48ecb11f6aaf89ee279a 100644
--- a/src/main/java/org/opengauss/sqltranslator/ExecuteTranslate.java
+++ b/src/main/java/org/opengauss/sqltranslator/ExecuteTranslate.java
@@ -17,10 +17,7 @@ public class ExecuteTranslate {
public static void main(String[] args) {
String raw_sql = "";
- boolean column_case_sensitive = true;
- if (args.length == 3) {
- column_case_sensitive = false;
- }
+ boolean column_case_sensitive = false;
byte[] decode = Base64.getDecoder().decode(args[1]);
try {
raw_sql = new String(decode, "utf-8");
diff --git a/src/main/java/org/opengauss/sqltranslator/dialect/mysql/MySqlToOpenGaussOutputVisitor.java b/src/main/java/org/opengauss/sqltranslator/dialect/mysql/MySqlToOpenGaussOutputVisitor.java
index 88d98188b4a4b3ecfebd69e9fe33ef2c7d4ac330..65bfb10a9914a4886f1971c2b890662722395b82 100644
--- a/src/main/java/org/opengauss/sqltranslator/dialect/mysql/MySqlToOpenGaussOutputVisitor.java
+++ b/src/main/java/org/opengauss/sqltranslator/dialect/mysql/MySqlToOpenGaussOutputVisitor.java
@@ -213,6 +213,7 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
List statementList = x.getStatementList();
int currentStatement = 0;
int statementSize = statementList.size();
+ boolean isBeginPosition = false;
for (; currentStatement < statementSize; ++currentStatement) {
if (!(statementList.get(currentStatement) instanceof MySqlDeclareStatement)
&& !(statementList.get(currentStatement) instanceof MySqlCursorDeclareStatement)) {
@@ -221,7 +222,13 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
if (currentStatement != 0) {
println();
}
+
SQLStatement stmt = statementList.get(currentStatement);
+ if (stmt instanceof MySqlCursorDeclareStatement && !isBeginPosition) {
+ isBeginPosition = true;
+ print0(ucase ? "BEGIN" : "begin");
+ println();
+ }
stmt.accept(this);
if (statementList.get(currentStatement) instanceof MySqlCursorDeclareStatement) {
print(';');
@@ -230,7 +237,9 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
if (currentStatement > 0) {
println();
}
- print0(ucase ? "BEGIN" : "begin");
+ if (!isBeginPosition) {
+ print0(ucase ? "BEGIN" : "begin");
+ }
if (!x.isEndOfCommit()) {
this.indentCount++;
} else {
@@ -473,8 +482,10 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
print0(" = ");
x.getValue().accept(this);
} else {
- logger.error("openGauss does not support set " + tagetString.toUpperCase() + getTypeAttribute(x));
- errHandle(x);
+ print0("SET ");
+ x.getTarget().accept(this);
+ print0(" = ");
+ x.getValue().accept(this);
}
}
return false;
@@ -493,10 +504,6 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
errHandle(x);
}
String varName = x.getName();
- if (varName.startsWith("@")) {
- logger.error("openGauss does not support variable started with @" + getTypeAttribute(x));
- errHandle(x);
- }
printName0(varName);
String collate = (String) x.getAttribute("COLLATE");
if (collate != null) {
@@ -599,6 +606,7 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
if (x instanceof SQLCreateFunctionStatement) {
println();
print("$$language plpgsql;");
+ println();
}
if (x instanceof SQLCreateProcedureStatement) {
println();
@@ -671,12 +679,10 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
@Override
public boolean visit(SQLCreateFunctionStatement x) {
print0(ucase ? "CREATE " : "create ");
- // ignore definer
- if (Objects.nonNull(x.getDefiner())) {
- println();
- print("-- " + (ucase ? "DEFINER " : "definer ") + x.getDefiner().toString());
+ if (x.getDefiner() != null) {
+ print(ucase ? "DEFINER = " : "definer = ");
+ x.getDefiner().accept(this);
println();
- gaussFeatureNotSupportLog("DEFINER when it creates function statement" + getTypeAttribute(x));
}
if (x.isOrReplace()) {
print0(ucase ? "OR REPLACE " : "or replace ");
@@ -707,23 +713,18 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
String comment = x.getComment();
if (comment != null) {
println();
- print("-- ");
print(ucase ? " COMMENT " : " comment ");
- print(ucase ? comment.toUpperCase() : comment.toLowerCase());
+ print("'" + comment + "'");
println();
- gaussFeatureNotSupportLog("COMMENT when it creates function statement" + getTypeAttribute(x));
- }
- String language = x.getLanguage();
- if (x.getLanguage() != null) {
- println();
- print("-- ");
- print(ucase ? " LANGUAGE " : " language ");
- print(ucase ? language.toUpperCase() : language.toLowerCase());
- println();
- gaussFeatureNotSupportLog("LANGUAGE SQL when it creates function statement" + getTypeAttribute(x));
}
if (x.isDeterministic()) {
- print(ucase ? " IMMUTABLE" : " immutable");
+ print(ucase ? " DETERMINISTIC " : " deterministic ");
+ }
+ SQLName authid = x.getAuthid();
+ if (authid != null) {
+ this.println();
+ printUcase("SQL SECURITY ");
+ printUcase(authid.toString());
}
println();
print0("AS $$");
@@ -733,7 +734,6 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
} else {
println("BEGIN");
x.getBlock().accept(this);
- print0(";");
println();
printUcase("END");
}
@@ -742,18 +742,51 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
@Override
public boolean visit(SQLAlterFunctionStatement x) {
- logger.error("openGauss does not support alter function statement" + getTypeAttribute(x));
- errHandle(x);
+ printUcase("alter function ");
+ print(x.getName().toString());
+ if (x.isContainsSql()) {
+ print(ucase ? " CONTAINS SQL" : "contains sql");
+ }
+ if (x.getComment() != null) {
+ print(ucase ? " COMMENT " + x.getComment() : " comment " + x.getComment());
+ }
+ if (x.getSqlSecurity() != null) {
+ print(ucase ? " SQL SECURITY " + x.getSqlSecurity() : " sql security " + x.getSqlSecurity());
+ }
+ if (x.isLanguageSql()) {
+ print(" language sql");
+ }
+ return false;
+ }
+
+ @Override
+ public boolean visit(SQLAlterProcedureStatement x) {
+ printUcase("alter procedure ");
+ print(x.getName().toString());
+ if (x.isContainsSql()) {
+ print(ucase ? " CONTAINS SQL" : "contains sql");
+ }
+ if (x.getComment() != null) {
+ print(ucase ? " COMMENT " + x.getComment() : " comment " + x.getComment());
+ }
+ if (x.getSqlSecurity() != null) {
+ print(ucase ? " SQL SECURITY " + x.getSqlSecurity() : " sql security " + x.getSqlSecurity());
+ }
+ if (x.isLanguageSql()) {
+ print(" language sql");
+ }
return false;
}
@Override
public boolean visit(SQLCreateProcedureStatement x) {
- printUcase("create procedure ");
- if (Objects.nonNull(x.getDefiner())) {
- printNotSupportWord((ucase ? "DEFINER = " : "definer = ") + x.getDefiner());
- gaussFeatureNotSupportLog("DEFINER when it creates procedure" + getTypeAttribute(x));
+ printUcase("create ");
+ if (x.getDefiner() != null) {
+ print(ucase ? "DEFINER = " : "definer = ");
+ x.getDefiner().accept(this);
+ println();
}
+ printUcase("procedure ");
x.getName().accept(this);
int paramSize = x.getParameters().size();
this.print0(" (");
@@ -772,13 +805,16 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
this.println();
}
this.print(')');
+
if (x.getComment() != null) {
- printNotSupportWord((ucase ? "COMMENT " : "comment ") + x.getComment().toString());
- gaussFeatureNotSupportLog("COMMENT when it creates procedure" + getTypeAttribute(x));
+ String comment = x.getComment().toString();
+ println();
+ print(ucase ? " COMMENT " : " comment ");
+ print(comment);
+ println();
}
if (x.isLanguageSql()) {
- printUcaseNotSupportWord("LANGUAGE SQL");
- gaussFeatureNotSupportLog("LANGUAGE SQL when it creates procedure" + getTypeAttribute(x));
+ print(ucase ? " LANGUAGE SQL " : " language sql ");
}
if (x.isDeterministic()) {
boolean isModifyDatabase = false;
@@ -797,31 +833,27 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
logger.warn(
"a stable and immutable function cannot modify the database,deterministic will be translated to volatile"
+ getTypeAttribute(x));
- printUcase("volatile");
+ printUcase("volatile ");
} else {
- printUcase("immutable");
+ printUcase("deterministic ");
}
}
if (x.isContainsSql()) {
- printUcaseNotSupportWord("CONTAINS SQL");
- gaussFeatureNotSupportLog("CONTAINS SQL when it creates procedure" + getTypeAttribute(x));
+ print(ucase ? "CONTAINS SQL " : "contains sql ");
}
if (x.isNoSql()) {
- printUcaseNotSupportWord("NO SQL");
- gaussFeatureNotSupportLog("NO SQL when it creates procedure" + getTypeAttribute(x));
+ print(ucase ? "NO SQL " : "no sql ");
}
if (x.isReadSqlData()) {
- printUcaseNotSupportWord("READS SQL DATA");
- gaussFeatureNotSupportLog("READ SQL DATA when it creates procedure" + getTypeAttribute(x));
+ print(ucase ? "READS SQL DATA" : "reads sql data ");
}
if (x.isModifiesSqlData()) {
- printUcaseNotSupportWord("MODIFIES SQL DATA");
- gaussFeatureNotSupportLog("MODIFIES SQL DATA when it creates procedure" + getTypeAttribute(x));
+ print(ucase ? "MODIFIES SQL DATA " : "modifies sql data ");
}
SQLName authid = x.getAuthid();
if (authid != null) {
this.println();
- printUcase("SECURITY ");
+ printUcase("SQL SECURITY ");
printUcase(authid.toString());
}
println();
@@ -832,7 +864,9 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
} else {
println("BEGIN");
x.getBlock().accept(this);
- print0(";");
+ if ((x.getBlock().getClass()) == SQLSelectStatement.class) {
+ print0(";");
+ }
println();
printUcase("END");
}
@@ -1765,11 +1799,11 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
printUcaseNotSupportWord("storage " + storage);
gaussFeatureNotSupportLog("STORAGE in column definition" + getTypeAttribute(x));
}
- // SQLExpr onUpdate = x.getOnUpdate();
- // if (onUpdate != null) {
- // this.print0(this.ucase ? " ON UPDATE " : " on update ");
- // onUpdate.accept(this);
- // }
+ SQLExpr onUpdate = x.getOnUpdate();
+ if (onUpdate != null) {
+ this.print0(this.ucase ? " ON UPDATE " : " on update ");
+ onUpdate.accept(this);
+ }
if (x.getAsExpr() != null) {
printUcaseNotSupportWord("as");
gaussFeatureNotSupportLog("AS in column definition" + getTypeAttribute(x));
@@ -2024,7 +2058,8 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
public boolean visit(SQLCreateTriggerStatement x) {
// openGauss has no DEFINER field
if (Objects.nonNull(x.getDefiner())) {
- print("-- " + (ucase ? "DEFINER " : "definer ") + x.getDefiner().toString());
+ print("-- " + (ucase ? "DEFINER " : "definer "));
+ x.getDefiner().accept(this);
println();
gaussFeatureNotSupportLog("DEFINER when it creates trigger" + getTypeAttribute(x));
}
@@ -2074,10 +2109,12 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
println();
}
}
- if (x.isUpdate() || x.isInsert()) {
- println("RETURN NEW;");
- } else {
- println("RETURN OLD;");
+ if (! (x.getBody() instanceof SQLSetStatement)) {
+ if (x.isUpdate() || x.isInsert()) {
+ println("RETURN NEW;");
+ } else {
+ println("RETURN OLD;");
+ }
}
println("END;");
println("$$ LANGUAGE plpgsql;");
@@ -2108,13 +2145,6 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
return false;
}
- @Override
- public boolean visit(SQLDropTriggerStatement x) {
- logger.error("drop trigger statement is incompatible with OpenGauss" + getTypeAttribute(x));
- errHandle(x);
- return false;
- }
-
@Override
public boolean visit(MySqlDeleteStatement x) {
SQLTableSource from = x.getFrom();
@@ -2373,14 +2403,6 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
return false;
}
- // 13.2.8 REPLACE Statement
- @Override
- public boolean visit(SQLReplaceStatement x) {
- logger.error("replace statement is incompatible with openGauss" + getTypeAttribute(x));
- errHandle(x);
- return false;
- }
-
@Override
public boolean visit(SQLCreateViewStatement x) {
print0(ucase ? "CREATE " : "create ");
@@ -2394,27 +2416,21 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
println();
String algorithm = x.getAlgorithm();
if (algorithm != null && algorithm.length() > 0) {
- print("-- ");
print0(ucase ? "ALGORITHM = " : "algorithm = ");
print0(algorithm);
println();
- gaussFeatureNotSupportLog("ALGORITHM when it creates view" + getTypeAttribute(x));
}
SQLName definer = x.getDefiner();
if (definer != null) {
- print("-- ");
print0(ucase ? "DEFINER = " : "definer = ");
definer.accept(this);
println();
- gaussFeatureNotSupportLog("DEFINER when it creates view" + getTypeAttribute(x));
}
String sqlSecurity = x.getSqlSecurity();
if (sqlSecurity != null && sqlSecurity.length() > 0) {
- print("-- ");
- print0(ucase ? "SQL SECURITY = " : "sql security = ");
+ print0(ucase ? "SQL SECURITY " : "sql security ");
print0(sqlSecurity);
println();
- gaussFeatureNotSupportLog("SQL SECURITY when it creates view" + getTypeAttribute(x));
}
}
this.indentCount--;
@@ -2475,35 +2491,25 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
@Override
public boolean visit(SQLAlterViewStatement x) {
- print0(ucase ? "CREATE OR REPLACE " : "create or replace ");
+ print0(ucase ? "ALTER " : "alter ");
this.indentCount++;
String algorithm = x.getAlgorithm();
if (algorithm != null && algorithm.length() > 0) {
- println();
- print("-- ");
print0(ucase ? "ALGORITHM = " : "algorithm = ");
print0(algorithm);
println();
- gaussFeatureNotSupportLog("ALGORITHM when it alters view" + getTypeAttribute(x));
}
- // ignore definer
SQLName definer = x.getDefiner();
if (definer != null) {
- println();
- print("-- ");
print0(ucase ? "DEFINER = " : "definer = ");
definer.accept(this);
println();
- gaussFeatureNotSupportLog("DEFINER when it alters view" + getTypeAttribute(x));
}
String sqlSecurity = x.getSqlSecurity();
if (sqlSecurity != null && sqlSecurity.length() > 0) {
- println();
- print("-- ");
print0(ucase ? "SQL SECURITY " : "sql security ");
print0(sqlSecurity);
println();
- gaussFeatureNotSupportLog("SQL SECURITY when it alters view" + getTypeAttribute(x));
}
this.indentCount--;
print0(ucase ? "VIEW " : "view ");
@@ -3194,10 +3200,10 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
@Override
public boolean visit(MySqlCreateUserStatement x) {
print0(this.ucase ? "CREATE USER " : "create user ");
- if (x.getUsers().size() > 1)
- printAndAccept(x.getUsers(), ";CREATE USER ");
- else
- printAndAccept(x.getUsers(), " ");
+ if (x.isIfNotExists()) {
+ print0(this.ucase ? "IF NOT EXISTS " : "if not exists");
+ }
+ printAndAccept(x.getUsers(), " ");
return false;
}
@@ -3221,30 +3227,41 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
@Override
public boolean visit(MySqlUserName x) {
+ StringBuilder buf = new StringBuilder();
String userName = x.getUserName();
- printnamewithquote(userName);
- if (x.getHost() != null) {
- println();
- print("-- ");
- print('@');
- String host = x.getHost();
- if (host.length() > 0 && host.charAt(0) == '\'') {
- print0(host);
+ String host = x.getHost();
+ if (userName.length() != 0 && (userName.charAt(0) == '\'' || userName.charAt(0) == '`')) {
+ buf.append(userName);
+ } else {
+ buf.append('\'');
+ buf.append(userName);
+ buf.append('\'');
+ }
+
+ // For openGauss, the hostname `%` is not supported, it only support IP.
+ if (!"`%`".equals(host)) {
+ buf.append('@');
+ if (host.length() != 0 && (host.charAt(0) == '\'' || host.charAt(0) == '`')) {
+ buf.append(host);
} else {
- print('\'');
- print0(host);
- print('\'');
+ buf.append('\'');
+ buf.append(host);
+ buf.append('\'');
}
- println();
- gaussFeatureNotSupportLog("host_name when it creates user" + getTypeAttribute(x));
}
- // related to ALTER USER
+
String identifiedBy = x.getIdentifiedBy();
if (identifiedBy != null) {
- print0(this.ucase ? " IDENTIFIED BY '" : " identified by '");
- print0(identifiedBy);
- print('\'');
+ if (this.ucase) {
+ buf.append(" IDENTIFIED BY '");
+ } else {
+ buf.append("identified by '");
+ }
+ buf.append(identifiedBy);
+ buf.append("'");
}
+
+ print(buf.toString());
return false;
}
@@ -3443,42 +3460,9 @@ public class MySqlToOpenGaussOutputVisitor extends MySqlOutputVisitor {
return false;
}
- @Override
- public boolean visit(MySqlCursorDeclareStatement x) {
- printUcase("cursor ");
- printExpr((SQLExpr) x.getCursorName(), this.parameterized);
- this.indentCount++;
- println();
- x.getSelect().accept(this);
- this.indentCount--;
- return false;
- }
-
- @Override
- public boolean visit(SQLFetchStatement x) {
- logger.error("the cursor fetch statement is incompatible with openGauss" + getTypeAttribute(x));
- errHandle(x, "FETCH");
- return false;
- }
-
- @Override
- public boolean visit(SQLOpenStatement x) {
- logger.error("openGauss does not support cursor open statement" + getTypeAttribute(x));
- errHandle(x);
- return false;
- }
-
- @Override
- public boolean visit(MySqlDeclareConditionStatement x) {
- logger.error("openGauss does not support declare ... condition Statement" + getTypeAttribute(x));
- errHandle(x);
- return false;
- }
-
@Override
public boolean visit(MySqlDeclareHandlerStatement x) {
- logger.error("openGauss does not support declare ... handler statement" + getTypeAttribute(x));
- errHandle(x);
+ println(x.toString());
return false;
}
diff --git a/src/test/java/org/opengauss/sqltranslator/SqlTranslateTest.java b/src/test/java/org/opengauss/sqltranslator/SqlTranslateTest.java
index f2fa1e87b70077c07efdfdea496c3b3d8f6ef6ec..2a11501cac98af16d84e2166e41c525a3e02745a 100644
--- a/src/test/java/org/opengauss/sqltranslator/SqlTranslateTest.java
+++ b/src/test/java/org/opengauss/sqltranslator/SqlTranslateTest.java
@@ -6,9 +6,11 @@ import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
+import com.alibaba.druid.sql.parser.ParserException;
import java.util.Objects;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class SqlTranslateTest {
@@ -62,8 +64,7 @@ public class SqlTranslateTest {
@Test
public void test_if() throws IOException {
String[] sqlContents = execFile("if_statement.sql");
- // output to screen
- System.out.println(sqlContents[2]);
+ assertEquals(sqlContents[1], sqlContents[2]);
}
@Test
@@ -103,10 +104,21 @@ public class SqlTranslateTest {
}
@Test
- public void test_createTrigger() throws IOException {
- String[] sqlContents = execFile("createTrigger_statement.sql");
- System.out.println(sqlContents[2]);
- // assertEquals(sqlContents[1], sqlContents[2]);
+ public void test_createTrigger01() throws IOException {
+ String[] sqlContents = execFile("createTrigger_statement_01.sql");
+ assertEquals(sqlContents[1], sqlContents[2]);
+ }
+
+ @Test
+ public void test_createTrigger02() throws IOException {
+ String[] sqlContents = execFile("createTrigger_statement_02.sql");
+ assertEquals(sqlContents[1], sqlContents[2]);
+ }
+
+ @Test
+ public void test_createTrigger03() throws IOException {
+ String[] sqlContents = execFile("createTrigger_statement_03.sql");
+ assertEquals(sqlContents[1], sqlContents[2]);
}
@Test
@@ -166,20 +178,20 @@ public class SqlTranslateTest {
@Test
public void test_createServer() throws IOException {
String[] sqlContents = execFile("createServer_statement.sql");
- System.out.println(sqlContents[2]);
+ assertTrue(sqlContents[2].contains("-- err"));
}
// druid will failed when alter server content over one parameter
@Test
public void test_alterServer() throws IOException {
String[] sqlContents = execFile("alterServer_statement.sql");
- System.out.println(sqlContents[2]);
+ assertTrue(sqlContents[2].contains("-- err"));
}
@Test
public void test_dropServer() throws IOException {
String[] sqlContents = execFile("dropServer_statement.sql");
- System.out.println(sqlContents[2]);
+ assertEquals(sqlContents[1], sqlContents[2]);
}
@Test
@@ -241,4 +253,66 @@ public class SqlTranslateTest {
String[] sqlContents = execFile("hasReservedWord_statement.sql");
assertEquals(sqlContents[1], sqlContents[2]);
}
+
+ @Test
+ public void test_dropTrigger() throws IOException {
+ String[] sqlContents = execFile("dropTrigger_statement.sql");
+ assertEquals(sqlContents[1], sqlContents[2]);
+ }
+
+ @Test
+ public void test_createUser() throws IOException {
+ String[] sqlContents = execFile("createUser_statement.sql");
+ assertEquals(sqlContents[1], sqlContents[2]);
+ }
+
+ @Test
+ public void test_alterView() throws IOException {
+ String[] sqlContents = execFile("alterView_statement.sql");
+ assertEquals(sqlContents[1], sqlContents[2]);
+ }
+
+ @Test
+ public void test_cursor() throws IOException {
+ String[] sqlContents = execFile("cursor_statement.sql");
+ assertEquals(sqlContents[1], sqlContents[2]);
+ }
+
+ @Test
+ // DO statement not support in druid parse
+ public void test_do() throws IOException {
+ try {
+ String[] sqlContents = execFile("do_statement.sql");
+ } catch (ParserException exp) {
+ assertEquals("", "");
+ }
+ }
+
+ @Test
+ // ITERATE statement not support in druid parse
+ public void test_iterate() throws IOException {
+ try {
+ String[] sqlContents = execFile("iterate_statement.sql");
+ } catch (ParserException exp) {
+ assertEquals("", "");
+ }
+ }
+
+ @Test
+ public void test_replace() throws IOException {
+ String[] sqlContents = execFile("replace_statement.sql");
+ assertEquals(sqlContents[1], sqlContents[2]);
+ }
+
+ @Test
+ public void test_alterFunction() throws IOException {
+ String[] sqlContents = execFile("alterFunction_statement.sql");
+ assertEquals(sqlContents[1], sqlContents[2]);
+ }
+
+ @Test
+ public void test_alterProcedure() throws IOException {
+ String[] sqlContents = execFile("alterProcedure_statement.sql");
+ assertEquals(sqlContents[1], sqlContents[2]);
+ }
}
diff --git a/src/test/resources/dialect/mysql/expect/alterFunction_statement.sql b/src/test/resources/dialect/mysql/expect/alterFunction_statement.sql
new file mode 100644
index 0000000000000000000000000000000000000000..b5edd2fee4a85c35cac8426c0ec5927a65b89d31
--- /dev/null
+++ b/src/test/resources/dialect/mysql/expect/alterFunction_statement.sql
@@ -0,0 +1,5 @@
+ALTER FUNCTION f1 COMMENT 'function comment';
+ALTER FUNCTION f1 CONTAINS SQL;
+ALTER FUNCTION f1 SQL SECURITY definer;
+ALTER FUNCTION f1 SQL SECURITY invoker;
+ALTER FUNCTION f1 language sql;
\ No newline at end of file
diff --git a/src/test/resources/dialect/mysql/expect/alterProcedure_statement.sql b/src/test/resources/dialect/mysql/expect/alterProcedure_statement.sql
new file mode 100644
index 0000000000000000000000000000000000000000..d63d2be7e78ab4ca5ff93ec2fb929049de605c1d
--- /dev/null
+++ b/src/test/resources/dialect/mysql/expect/alterProcedure_statement.sql
@@ -0,0 +1,5 @@
+ALTER PROCEDURE f1 COMMENT 'procedure comment';
+ALTER PROCEDURE f1 CONTAINS SQL;
+ALTER PROCEDURE f1 SQL SECURITY definer;
+ALTER PROCEDURE f1 SQL SECURITY invoker;
+ALTER PROCEDURE f1 language sql;
\ No newline at end of file
diff --git a/src/test/resources/dialect/mysql/expect/alterView_statement.sql b/src/test/resources/dialect/mysql/expect/alterView_statement.sql
new file mode 100644
index 0000000000000000000000000000000000000000..2b73d06a397fae0e700e055f965251e3bef8d1fa
--- /dev/null
+++ b/src/test/resources/dialect/mysql/expect/alterView_statement.sql
@@ -0,0 +1,40 @@
+ALTER ALGORITHM = UNDEFINED
+ DEFINER = 'mysql_test'@'%'
+ SQL SECURITY DEFINER
+ VIEW "view1"
+AS
+SELECT "test"."id" AS "id"
+FROM "test";
+ALTER ALGORITHM = UNDEFINED
+ DEFINER = mysql_test
+ SQL SECURITY DEFINER
+ VIEW "view1"
+AS
+SELECT "test"."id" AS "id"
+FROM "test";
+ALTER ALGORITHM = merge
+ DEFINER = current_user
+ SQL SECURITY definer
+ VIEW "vwEmployeesByDepartment"
+AS
+SELECT emp."ID", emp."Name", emp."Salary", CAST(emp."DOB" AS DATE) AS "DOB", emp."Gender"
+ , dept."Name" AS "DepartmentName"
+FROM "Employee" emp
+ INNER JOIN "Department" dept ON emp."DeptID" = dept."ID";
+CREATE TABLE test (
+ id INTEGER
+);
+ALTER ALGORITHM = UNDEFINED
+ DEFINER = 'mysql_test'@'%'
+ SQL SECURITY DEFINER
+ VIEW "view1"
+AS
+SELECT "test"."id" AS "id"
+FROM "test";
+ALTER ALGORITHM = UNDEFINED
+ DEFINER = mysql_test
+ SQL SECURITY DEFINER
+ VIEW "view1"
+AS
+SELECT "test"."id" AS "id"
+FROM "test";
\ No newline at end of file
diff --git a/src/test/resources/dialect/mysql/expect/columnDefinition_statement.sql b/src/test/resources/dialect/mysql/expect/columnDefinition_statement.sql
index bd06d8695f45ba7374941b799df53753c196000c..034d3f90379c651a5a311a3b6890d218e0258f1b 100644
--- a/src/test/resources/dialect/mysql/expect/columnDefinition_statement.sql
+++ b/src/test/resources/dialect/mysql/expect/columnDefinition_statement.sql
@@ -4,6 +4,7 @@ CREATE TABLE test1 (
-- COMMENT 'char'
-- COLUMN_FORMAT fixed
-- STORAGE DISK
+
);
COMMENT ON COLUMN test1.name IS 'char';
CREATE TABLE "testIndexKey" (
@@ -34,6 +35,7 @@ CREATE TABLE "testPrimaryUniqueKey" (
col5 INTEGER,
CONSTRAINT ck_con CHECK (id > 0)
-- NOT ENFORCED
+
);
CREATE TABLE "testIndexKey" (
id INTEGER,
diff --git a/src/test/resources/dialect/mysql/expect/compound_statement.sql b/src/test/resources/dialect/mysql/expect/compound_statement.sql
index 7d36a18e16b646784531d7178cbb442753dd1cb5..a194b24ef1d32aa5f6804d56eb6a580f2cb52394 100644
--- a/src/test/resources/dialect/mysql/expect/compound_statement.sql
+++ b/src/test/resources/dialect/mysql/expect/compound_statement.sql
@@ -1 +1,36 @@
--- FETCH
\ No newline at end of file
+DECLARE done INTEGER DEFAULT false;
+DECLARE a CHAR(16);
+DECLARE b INTEGER;
+DECLARE c INTEGER;
+BEGIN
+DECLARE cur1 CURSOR FOR
+ SELECT id, data
+ FROM test.t1;
+DECLARE cur2 CURSOR FOR
+ SELECT i
+ FROM test.t2;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
+ SET done = true
+ ;
+ OPEN cur1;
+ OPEN cur2;
+ <>LOOP
+ FETCH cur1 INTO a, b;
+ FETCH cur2 INTO c;
+ IF done THEN
+ EXIT read_loop;
+ END IF;
+ IF b < c THEN
+ INSERT
+ INTO test.t3
+ VALUES (a, b);
+ ELSE
+ INSERT
+ INTO test.t3
+ VALUES (a, c);
+ END IF;
+ END LOOP read_loop;
+ CLOSE cur1;
+ CLOSE cur2;
+END;
\ No newline at end of file
diff --git a/src/test/resources/dialect/mysql/expect/createDatabase_statement.sql b/src/test/resources/dialect/mysql/expect/createDatabase_statement.sql
index 3d78833b81fc3bce6b6155c64d1b46bf477cb54b..c75a07ce5f7235da3829fe2b2a68fb94957adfbb 100644
--- a/src/test/resources/dialect/mysql/expect/createDatabase_statement.sql
+++ b/src/test/resources/dialect/mysql/expect/createDatabase_statement.sql
@@ -1,4 +1,4 @@
-CREATE DATABASE test_db_char
+CREATE SCHEMA test_db_char
-- utf8
-- utf8_chinese_ci
;
\ No newline at end of file
diff --git a/src/test/resources/dialect/mysql/expect/createFunction_statement.sql b/src/test/resources/dialect/mysql/expect/createFunction_statement.sql
index 33a854613c82b3c4bad9294be57edcbb806cfa9a..14f3fa2777984fe10d44252b283841c4e38bd3cf 100644
--- a/src/test/resources/dialect/mysql/expect/createFunction_statement.sql
+++ b/src/test/resources/dialect/mysql/expect/createFunction_statement.sql
@@ -1,10 +1,9 @@
-CREATE
--- DEFINER 'root'@'%'
+CREATE DEFINER = `root`
FUNCTION "doIterate"(
p INTEGER,
q INTEGER
)
- RETURNS INTEGER IMMUTABLE
+ RETURNS INTEGER DETERMINISTIC
AS $$
DECLARE x INTEGER DEFAULT 5;
BEGIN
@@ -36,4 +35,92 @@ FUNCTION "doIterate"(
END CASE;
RETURN x;
END;
-$$language plpgsql;
\ No newline at end of file
+$$language plpgsql;
+
+CREATE DEFINER = `mysql_test`
+FUNCTION "double_input"(
+ x INTEGER
+ )
+ RETURNS INTEGER
+ COMMENT 'test function comment'
+
+ AS $$
+ DECLARE result INTEGER;
+ BEGIN
+ result := x * 2;
+ RETURN result;
+ END
+ $$language plpgsql;
+
+ CREATE DEFINER = `mysql_test`
+ FUNCTION "double_input1"(
+ x INTEGER,
+ y INTEGER,
+ z INTEGER
+ )
+ RETURNS INTEGER
+ COMMENT 'test function comment'
+
+ AS $$
+ DECLARE result1 INTEGER;
+ DECLARE result2 INTEGER;
+ DECLARE result3 INTEGER;
+ BEGIN
+ result1 := x * y * z;
+ result2 := x + y + z;
+ result3 := x * y - z;
+ RETURN result1 + result2 + result3;
+ END;
+ $$language plpgsql;
+
+ CREATE FUNCTION name_from_employee1(
+ emp_id INTEGER
+ )
+ RETURNS VARCHAR(20)
+ AS $$
+ BEGIN
+ RETURN (
+ SELECT name
+ FROM employee
+ WHERE num = emp_id);
+ END;
+ $$language plpgsql;
+
+ CREATE FUNCTION name_from_employee1(
+ emp_id INTEGER
+ )
+ RETURNS VARCHAR(20)
+ AS $$
+ BEGIN
+ RETURN (
+ SELECT name
+ FROM employee
+ WHERE num = emp_id);
+ END;
+ $$language plpgsql;
+
+ CREATE FUNCTION fun12345(
+ p INTEGER
+ )
+ RETURNS INTEGER
+ AS $$
+ BEGIN
+ WHILE p >= 0 LOOP
+ p := p - 1;
+ INSERT
+ INTO testdbc.testdd1
+ VALUES (p);
+ END LOOP;
+ RETURN p;
+ END;
+ $$language plpgsql;
+
+ CREATE FUNCTION mysql_func1(
+ s CHAR(20)
+ )
+ RETURNS CHAR(50) DETERMINISTIC
+ AS $$
+ BEGIN
+ RETURN concat('mysql_func1, ', s, '!');
+ END
+ $$language plpgsql;
\ No newline at end of file
diff --git a/src/test/resources/dialect/mysql/expect/createProcedure_statement.sql b/src/test/resources/dialect/mysql/expect/createProcedure_statement.sql
index e3172352d0ea80c317236b2ba12ab77f14684ae5..c72097cd9ac4093beb69e3c72adefd479f310716 100644
--- a/src/test/resources/dialect/mysql/expect/createProcedure_statement.sql
+++ b/src/test/resources/dialect/mysql/expect/createProcedure_statement.sql
@@ -1,14 +1,11 @@
-CREATE PROCEDURE
--- DEFINER = root
-p1 (
+CREATE DEFINER = `root`
+PROCEDURE p1 (
IN id INTEGER,
OUT res INTEGER,
INOUT a INTEGER
-)
--- LANGUAGE SQL
-IMMUTABLE
--- CONTAINS SQL
-SECURITY INVOKER
+) LANGUAGE SQL
+DETERMINISTIC CONTAINS SQL
+SQL SECURITY INVOKER
AS
BEGIN
SELECT count(id)
@@ -17,12 +14,9 @@ BEGIN
WHERE data.id > id;
END;
/
-CREATE PROCEDURE
--- DEFINER = root
-p2 ()
--- LANGUAGE SQL
--- CONTAINS SQL
-SECURITY DEFINER
+CREATE DEFINER = `root`
+PROCEDURE p2 () LANGUAGE SQL CONTAINS SQL
+SQL SECURITY DEFINER
AS
BEGIN
CREATE TABLE data2 (
@@ -30,19 +24,15 @@ BEGIN
);
END;
/
-CREATE PROCEDURE p3 ()
--- LANGUAGE SQL
-VOLATILE
--- CONTAINS SQL
+CREATE PROCEDURE p3 () LANGUAGE SQL
+VOLATILE CONTAINS SQL
AS
BEGIN
DROP TABLE IF EXISTS data1 RESTRICT;
END;
/
-CREATE PROCEDURE p4 ()
--- LANGUAGE SQL
-VOLATILE
--- CONTAINS SQL
+CREATE PROCEDURE p4 () LANGUAGE SQL
+VOLATILE CONTAINS SQL
AS
BEGIN
ALTER TABLE "testAlterTable1"
@@ -50,11 +40,56 @@ BEGIN
END;
/
CREATE PROCEDURE p5 ()
--- COMMENT 'good'
+ COMMENT 'good'
+
VOLATILE
AS
BEGIN
UPDATE data
SET data.id = data.id * 1.2;
END;
+/
+CREATE USER 'usr2'@'%' IDENTIFIED BY 'Test@123';
+CREATE DEFINER = `usr2`
+PROCEDURE definer ()
+SQL SECURITY DEFINER
+AS
+BEGIN
+ UPDATE data
+ SET data.id = data.id * 1.2;
+END;
+/
+CREATE DEFINER = `usr2`
+PROCEDURE definer1 ()
+AS
+BEGIN
+ UPDATE data
+ SET data.id = data.id * 1.2;
+END;
+/
+CREATE TABLE user1 (
+ id INTEGER PRIMARY KEY,
+ username VARCHAR(50),
+ password VARCHAR(50)
+);
+CREATE PROCEDURE proc16_while (
+ IN insertcount INTEGER
+)
+AS
+DECLARE i INTEGER DEFAULT 1;
+BEGIN
+ <