mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-36390: Minor refactoring of the method get_expr_query at the classes sp_instr_cpush/sp_instr_cursor_copy_struct
Duplicated code from methods sp_instr_cpush::get_expr_query sp_instr_cursor_copy_struct::get_expr_query were extracted to the standalone function get_cursor_query Additionally, added correct parsing of a cursor definition with a new line or TAB instead of the space immediately after FOR/IS.
This commit is contained in:
committed by
Alexander Barkov
parent
7b3e02e1aa
commit
c76d17a917
@@ -1993,4 +1993,96 @@ f1()
|
||||
# Clean up
|
||||
DROP FUNCTION f1;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-36390: Minor refactoring of the method get_expr_query at the classes sp_instr_cpush/sp_instr_cursor_copy_struct
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1);
|
||||
CREATE OR REPLACE PROCEDURE p1()
|
||||
BEGIN
|
||||
DECLARE va INT;
|
||||
# Check that the TAB character after the clause FOR is skipped and
|
||||
# the body of cursor is remembered correctly for subsequent re-parsing
|
||||
DECLARE cur CURSOR FOR SELECT a FROM t1;
|
||||
OPEN cur;
|
||||
FETCH cur INTO va;
|
||||
SELECT va;
|
||||
CLOSE cur;
|
||||
END;
|
||||
$
|
||||
CREATE OR REPLACE PROCEDURE p2()
|
||||
BEGIN
|
||||
DECLARE va INT;
|
||||
# Check that the newline character after the clause FOR is skipped and
|
||||
# the body of cursor is remembered correctly for subsequent re-parsing
|
||||
DECLARE cur CURSOR FOR
|
||||
SELECT a FROM t1;
|
||||
OPEN cur;
|
||||
FETCH cur INTO va;
|
||||
SELECT va;
|
||||
CLOSE cur;
|
||||
END;
|
||||
$
|
||||
CREATE OR REPLACE PROCEDURE p3()
|
||||
BEGIN
|
||||
DECLARE va INT;
|
||||
# Check that C-style comment and the newline character after
|
||||
# the clause FOR is skipped and the body of cursor is remembered
|
||||
# correctly for subsequent re-parsing
|
||||
DECLARE cur CURSOR FOR /* Explicit comment */
|
||||
SELECT a FROM t1;
|
||||
OPEN cur;
|
||||
FETCH cur INTO va;
|
||||
SELECT va;
|
||||
CLOSE cur;
|
||||
END;
|
||||
$
|
||||
CREATE OR REPLACE PROCEDURE p4()
|
||||
BEGIN
|
||||
DECLARE va INT;
|
||||
# Check that SQL-style comment and the newline character after
|
||||
# the clause FOR is skipped and the body of cursor is remembered
|
||||
# correctly for subsequent re-parsing
|
||||
DECLARE cur CURSOR FOR -- Explicit comment
|
||||
SELECT a FROM t1;
|
||||
OPEN cur;
|
||||
FETCH cur INTO va;
|
||||
SELECT va;
|
||||
CLOSE cur;
|
||||
END;
|
||||
$
|
||||
CALL p1();
|
||||
va
|
||||
1
|
||||
CALL p2();
|
||||
va
|
||||
1
|
||||
CALL p3();
|
||||
va
|
||||
1
|
||||
CALL p4();
|
||||
va
|
||||
1
|
||||
ALTER TABLE t1 COMMENT 'The Comment 1';
|
||||
# The following statements will run re-parsing of
|
||||
# cursor declaration statements inside the stored
|
||||
# procedures p1, p2, p3, p4.
|
||||
CALL p1();
|
||||
va
|
||||
1
|
||||
CALL p2();
|
||||
va
|
||||
1
|
||||
CALL p3();
|
||||
va
|
||||
1
|
||||
CALL p4();
|
||||
va
|
||||
1
|
||||
# Clean up
|
||||
DROP PROCEDURE p1;
|
||||
DROP PROCEDURE p2;
|
||||
DROP PROCEDURE p3;
|
||||
DROP PROCEDURE p4;
|
||||
DROP TABLE t1;
|
||||
SET sql_mode = default;
|
||||
|
Reference in New Issue
Block a user