Skip to content

Commit

Permalink
Fix mysql create procedure syntax error. (apache#24100)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuichenchuxin authored Feb 10, 2023
1 parent c88d5c2 commit db812fd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

grammar DDLStatement;

import DMLStatement, DALStatement;
import DMLStatement, DALStatement, TCLStatement;

alterStatement
: alterTable
Expand Down Expand Up @@ -665,7 +665,7 @@ compoundStatement
validStatement
: (createTable | alterTable | dropTable | truncateTable
| insert | replace | update | delete | select | call
| createView
| createView | prepare | executeStmt | commit | deallocate
| setVariable | beginStatement | declareStatement | flowControlStatement | cursorStatement | conditionHandlingStatement) SEMI_?
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
<create-procedure sql-case-id="create_procedure_with_sqlexception_and_create_view" />
<create-procedure sql-case-id="create_procedure_with_deterministic_create_view" />
<create-procedure sql-case-id="create_procedure_with_update_statement_oracle" />
<create-procedure sql-case-id="create_procedure_with_prepare_commit" />
</sql-parser-test-cases>
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@
<sql-case id="create_procedure_with_sqlexception_and_create_view" value="create procedure p() begin declare continue handler for sqlexception begin end; create view a as select 1; end" db-types="MySQL" />
<sql-case id="create_procedure_with_deterministic_create_view" value="create procedure p1 () deterministic begin create view v1 as select 1; end;" db-types="MySQL" />
<sql-case id="create_procedure_with_update_statement_oracle" value="CREATE PROCEDURE update_order (order_id NUMBER,status NUMBER) AS BEGIN UPDATE t_order SET status = status WHERE order_id = order_id;END;" db-types="Oracle" />
<sql-case id="create_procedure_with_prepare_commit" value="CREATE DEFINER=`sys_data`@`%` PROCEDURE `TEST1` (a VARCHAR(64),b VARCHAR(64),c VARCHAR(64),d VARCHAR(8),e INT) BEGIN DECLARE f VARCHAR(8); SET f=DATE_FORMAT(DATE_ADD((STR_TO_DATE(d,'%Y%m%d')),INTERVAL -(e) MONTH),'%Y%m%d'); SET @aaa=CONCAT('delete from ',a,'.',b,' where ',c,'&lt;=',f,' or ', c,'&lt;&gt; LAST_DAY(',c,')', 'or ',c,'=', d); PREPARE stmt FROM @aaa; EXECUTE stmt; COMMIT; DEALLOCATE PREPARE stmt; END" db-types="MySQL" />
</sql-cases>

0 comments on commit db812fd

Please sign in to comment.