Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,9 @@ compoundStatement
;

validStatement
: (createTable | alterTable | dropTable | dropDatabase | truncateTable
: (createTable | alterTable | dropTable | dropDatabase | truncateTable | startTransaction
| insert | replace | update | delete | select | call
| createView | prepare | executeStmt | commit | deallocate
| createView | prepare | executeStmt | commit | deallocate | rollback
| setVariable | beginStatement | declareStatement | flowControlStatement | cursorStatement | conditionHandlingStatement
| setStatement | showStatement) SEMI_?
;
Expand Down
5 changes: 5 additions & 0 deletions test/it/parser/src/main/resources/case/dal/set.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<parameter name="configuration_parameter" />
</parameter-assign>
</set-parameter>
<set-parameter sql-case-id="set_parameter_for_init_connect">
<parameter-assign value="'CREATE PROCEDURE p1(x INT) BEGIN SELECT COUNT(*) FROM t1; SELECT * FROM t1; SET @x = x; END'">
<parameter name="init_connect" scope="GLOBAL" />
</parameter-assign>
</set-parameter>
<set-parameter sql-case-id="set_timezone_with_zero_value" />
<set-parameter sql-case-id="set_timezone_with_positive_value" />
<set-parameter sql-case-id="set_timezone_with_negative_value" />
Expand Down
17 changes: 17 additions & 0 deletions test/it/parser/src/main/resources/case/ddl/create-procedure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,21 @@
</sql-statements>
</create-procedure>
<create-procedure sql-case-id="create_procedure_if_not_exists" />
<create-procedure sql-case-id="create_procedure_with_batch_insert">
<procedure-name name="BatchInsert" />
<sql-statements>
<sql-statement start-index="72" stop-index="82" statement-class-simple-name="MySQLSetStatement" />
<sql-statement start-index="91" stop-index="136" statement-class-simple-name="MySQLSetStatement" />
<sql-statement start-index="190" stop-index="205" statement-class-simple-name="MySQLSetStatement" />
</sql-statements>
</create-procedure>
<create-procedure sql-case-id="create_procedure_with_test_if_commit">
<procedure-name name="test_if_commit" />
</create-procedure>
<create-procedure sql-case-id="create_procedure_with_innodb_deadlock">
<procedure-name name="p1" />
<sql-statements>
<sql-statement start-index="666" stop-index="691" statement-class-simple-name="MySQLSetStatement" />
</sql-statements>
</create-procedure>
</sql-parser-test-cases>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<sql-case id="set_parameter_for_session_scope" value="SET SESSION configuration_parameter TO 'value'" db-types="PostgreSQL,openGauss" />
<sql-case id="set_parameter_for_local_scope" value="SET LOCAL configuration_parameter TO 'value'" db-types="PostgreSQL,openGauss" />
<sql-case id="set_parameter_for_default_scope" value="SET configuration_parameter TO DEFAULT" db-types="PostgreSQL,openGauss" />
<sql-case id="set_parameter_for_init_connect" value="SET GLOBAL init_connect='CREATE PROCEDURE p1(x INT) BEGIN SELECT COUNT(*) FROM t1; SELECT * FROM t1; SET @x = x; END'" db-types="MySQL" />
<sql-case id="set_timezone_with_zero_value" value="SET TIME ZONE 0" db-types="PostgreSQL,openGauss" />
<sql-case id="set_timezone_with_positive_value" value="SET TIME ZONE 8" db-types="PostgreSQL,openGauss" />
<sql-case id="set_timezone_with_negative_value" value="SET TIME ZONE -2" db-types="PostgreSQL,openGauss" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@
<sql-case id="create_procedure_with_transaction_read_only_and_isolation" value="CREATE PROCEDURE p1() SET SESSION TRANSACTION READ ONLY, ISOLATION LEVEL SERIALIZABLE" db-types="MySQL" />
<sql-case id="create_procedure_with_transaction_read_only" value="CREATE PROCEDURE p1() SET SESSION TRANSACTION READ ONLY" db-types="MySQL" />
<sql-case id="create_procedure_if_not_exists" value="CREATE PROCEDURE IF NOT EXISTS sp1() BEGIN END" db-types="MySQL" />
<sql-case id="create_procedure_with_batch_insert" value="CREATE PROCEDURE BatchInsert(IN row_count int) BEGIN START TRANSACTION; SET @n = 1; REPEAT SET @str = (CONCAT('test', CAST(@n AS CHAR))); INSERT INTO product(code, name) VALUES(@str, @str); SET @n = @n + 1; UNTIL @n > row_count END REPEAT; COMMIT; END" db-types="MySQL" />
<sql-case id="create_procedure_with_test_if_commit" value="CREATE PROCEDURE test_if_commit() BEGIN ROLLBACK; SELECT IF(COUNT(*) > 0, &quot;YES&quot;, &quot;NO&quot;) AS &quot;IMPLICIT COMMIT&quot; FROM trans; DELETE FROM trans; COMMIT; END" db-types="MySQL" />
<sql-case id="create_procedure_with_innodb_deadlock" value="CREATE PROCEDURE p1() BEGIN DECLARE counter INTEGER DEFAULT 0; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN SET counter = counter + 10; END; REPEAT IF RAND() > 0.5 THEN START TRANSACTION; END IF; IF RAND() > 0.5 THEN SELECT VARSAMP(1), EXISTS(SELECT 1 FROM t1 LOCK IN SHARE MODE) FROM t1 INTO @a, @b; END IF; IF RAND() > 0.5 THEN SELECT VARSAMP(1), EXISTS(SELECT 1 FROM t1 FOR UPDATE) FROM t1 INTO @a, @b; END IF; IF RAND() > 0.5 THEN INSERT IGNORE INTO t1 VALUES(); END IF; IF RAND() > 0.5 THEN INSERT IGNORE INTO t2 VALUES(); END IF; IF RAND() > 0.5 THEN DELETE FROM t1; END IF; IF RAND() > 0.5 THEN DELETE FROM t2; END IF; IF RAND() > 0.5 THEN COMMIT; END IF; SET counter = counter + 1; UNTIL counter >= 100 END REPEAT; END" db-types="MySQL" />
</sql-cases>