diff options
author | unknown <anozdrin@mysql.com> | 2005-12-07 17:01:17 +0300 |
---|---|---|
committer | unknown <anozdrin@mysql.com> | 2005-12-07 17:01:17 +0300 |
commit | 6b2f13098a59d9ad520828dca4cb63da8c86b5e3 (patch) | |
tree | 82814a574624a8e813cc8dfad8c31d3fa4adf898 /mysql-test/r/sp-vars.result | |
parent | 29eac312cda3bebddeb7f5ab7a2af6b81ea89205 (diff) | |
download | mariadb-git-6b2f13098a59d9ad520828dca4cb63da8c86b5e3.tar.gz |
Patch for WL#2894: Make stored routine variables work
according to the standard.
The idea is to use Field-classes to implement stored routines
variables. Also, we should provide facade to Item-hierarchy
by Item_field class (it is necessary, since SRVs take part
in expressions).
The patch fixes the following bugs:
- BUG#8702: Stored Procedures: No Error/Warning shown for inappropriate data
type matching;
- BUG#8768: Functions: For any unsigned data type, -ve values can be passed
and returned;
- BUG#8769: Functions: For Int datatypes, out of range values can be passed
and returned;
- BUG#9078: STORED PROCDURE: Decimal digits are not displayed when we use
DECIMAL datatype;
- BUG#9572: Stored procedures: variable type declarations ignored;
- BUG#12903: upper function does not work inside a function;
- BUG#13705: parameters to stored procedures are not verified;
- BUG#13808: ENUM type stored procedure parameter accepts non-enumerated
data;
- BUG#13909: Varchar Stored Procedure Parameter always BINARY string (ignores
CHARACTER SET);
- BUG#14161: Stored procedure cannot retrieve bigint unsigned;
- BUG#14188: BINARY variables have no 0x00 padding;
- BUG#15148: Stored procedure variables accept non-scalar values;
mysql-test/r/ctype_ujis.result:
Explicitly specify correct charset.
mysql-test/r/schema.result:
Drop our test database to not affect this test if some test
left it cause of failure.
mysql-test/r/show_check.result:
Drop our test database to not affect this test if some test
left it cause of failure.
mysql-test/r/skip_name_resolve.result:
Ignore columns with unpredictable values.
mysql-test/r/sp-big.result:
Add cleanup statement.
mysql-test/r/sp-dynamic.result:
Add cleanup statements.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sum_distinct-big.result:
Update result file.
mysql-test/r/type_newdecimal-big.result:
Update result file.
mysql-test/t/ctype_ujis.test:
Explicitly specify correct charset.
mysql-test/t/schema.test:
Drop our test database to not affect this test if some test
left it cause of failure.
mysql-test/t/show_check.test:
Drop our test database to not affect this test if some test
left it cause of failure.
mysql-test/t/skip_name_resolve.test:
Ignore columns with unpredictable values.
mysql-test/t/sp-big.test:
Add cleanup statement.
mysql-test/t/sp-dynamic.test:
Add cleanup statements.
mysql-test/t/sp.test:
Non-scalar values prohibited for assignment to SP-vars;
polishing.
mysql-test/t/type_newdecimal-big.test:
Update type specification so that the variables
can contain the large values used in the test.
sql/field.cc:
Extract create_field::init() to initialize an existing
instance of create_field from new_create_field().
sql/field.h:
Extract create_field::init() to initialize an existing
instance of create_field from new_create_field().
sql/item.cc:
- Introduce a new class: Item_sp_variable -- a base class
of stored-routine-variables classes;
- Introduce Item_case_expr -- an Item, which is used to access
to the expression of CASE statement;
sql/item.h:
- Introduce a new class: Item_sp_variable -- a base class
of stored-routine-variables classes;
- Introduce Item_case_expr -- an Item, which is used to access
to the expression of CASE statement;
sql/item_func.cc:
Pass the Field (instead of Item) for the return value of
a function to the function execution routine.
sql/item_func.h:
Pass the Field (instead of Item) for the return value of
a function to the function execution routine.
sql/mysql_priv.h:
Move create_virtual_tmp_table() out of sql_select.h.
sql/sp.cc:
Use create_result_field() instead of make_field().
sql/sp_head.cc:
- Add a function to map enum_field_types to Item::Type;
- Add sp_instr_push_case_expr instruction -- an instruction
to push CASE expression into the active running context;
- Add sp_instr_pop_case_expr instruction -- an instruction
to pop CASE expression from the active running context;
- Adapt the SP-execution code to using Fields instead of Items
for SP-vars;
- Use create_field structure for field description instead of
a set of members.
sql/sp_head.h:
- Add a function to map enum_field_types to Item::Type;
- Add sp_instr_push_case_expr instruction -- an instruction
to push CASE expression into the active running context;
- Add sp_instr_pop_case_expr instruction -- an instruction
to pop CASE expression from the active running context;
- Adapt the SP-execution code to using Fields instead of Items
for SP-vars;
- Use create_field structure for field description instead of
a set of members.
sql/sp_pcontext.cc:
- Change rules to assign an index of SP-variable: use
transparent index;
- Add an operation to retrieve a list of defined SP-vars
from the processing context recursively.
sql/sp_pcontext.h:
- Change rules to assign an index of SP-variable: use
transparent index;
- Add an operation to retrieve a list of defined SP-vars
from the processing context recursively.
sql/sp_rcontext.cc:
- Change rules to assign an index of SP-variable: use
transparent index;
- Use a tmp virtual table to store SP-vars instead of Items;
- Provide operations to work with CASE expresion.
sql/sp_rcontext.h:
- Change rules to assign an index of SP-variable: use
transparent index;
- Use a tmp virtual table to store SP-vars instead of Items;
- Provide operations to work with CASE expresion.
sql/sql_class.cc:
- Reflect Item_splocal ctor changes;
- Item_splocal::get_offset() has been renamed to get_var_idx().
sql/sql_class.h:
Polishing.
sql/sql_parse.cc:
Extract create_field::init() to initialize an existing
instance of create_field from new_create_field().
sql/sql_select.cc:
Take care of BLOB columns in create_virtual_tmp_table().
sql/sql_select.h:
Move create_virtual_tmp_table() out of sql_select.h.
sql/sql_trigger.cc:
Use boolean constants for boolean type instead of numerical ones.
sql/sql_yacc.yy:
Provide an instance of create_field for each SP-var.
mysql-test/include/sp-vars.inc:
The definitions of common-procedures, which are created
under different circumstances.
mysql-test/r/sp-vars.result:
Result file for the SP-vars test.
mysql-test/sp-vars.test:
A new test for checking SP-vars functionality.
Diffstat (limited to 'mysql-test/r/sp-vars.result')
-rw-r--r-- | mysql-test/r/sp-vars.result | 1077 |
1 files changed, 1077 insertions, 0 deletions
diff --git a/mysql-test/r/sp-vars.result b/mysql-test/r/sp-vars.result new file mode 100644 index 00000000000..6b4d7b1a6d3 --- /dev/null +++ b/mysql-test/r/sp-vars.result @@ -0,0 +1,1077 @@ +DROP PROCEDURE IF EXISTS sp_vars_check_dflt; +DROP PROCEDURE IF EXISTS sp_vars_check_assignment; +DROP FUNCTION IF EXISTS sp_vars_check_ret1; +DROP FUNCTION IF EXISTS sp_vars_check_ret2; +DROP FUNCTION IF EXISTS sp_vars_check_ret3; +DROP FUNCTION IF EXISTS sp_vars_check_ret4; +SET @@sql_mode = 'ansi'; +CREATE PROCEDURE sp_vars_check_dflt() +BEGIN +DECLARE v1 TINYINT DEFAULT 1e200; +DECLARE v1u TINYINT UNSIGNED DEFAULT 1e200; +DECLARE v2 TINYINT DEFAULT -1e200; +DECLARE v2u TINYINT UNSIGNED DEFAULT -1e200; +DECLARE v3 TINYINT DEFAULT 300; +DECLARE v3u TINYINT UNSIGNED DEFAULT 300; +DECLARE v4 TINYINT DEFAULT -300; +DECLARE v4u TINYINT UNSIGNED DEFAULT -300; +DECLARE v5 TINYINT DEFAULT 10 * 10 * 10; +DECLARE v5u TINYINT UNSIGNED DEFAULT 10 * 10 * 10; +DECLARE v6 TINYINT DEFAULT -10 * 10 * 10; +DECLARE v6u TINYINT UNSIGNED DEFAULT -10 * 10 * 10; +DECLARE v7 TINYINT DEFAULT '10'; +DECLARE v8 TINYINT DEFAULT '10 '; +DECLARE v9 TINYINT DEFAULT ' 10 '; +DECLARE v10 TINYINT DEFAULT 'String 10 '; +DECLARE v11 TINYINT DEFAULT 'String10'; +DECLARE v12 TINYINT DEFAULT '10 String'; +DECLARE v13 TINYINT DEFAULT '10String'; +DECLARE v14 TINYINT DEFAULT concat('10', ' '); +DECLARE v15 TINYINT DEFAULT concat(' ', '10'); +DECLARE v16 TINYINT DEFAULT concat('Hello, ', 'world'); +DECLARE v17 DECIMAL(64, 2) DEFAULT 12; +DECLARE v18 DECIMAL(64, 2) DEFAULT 12.123; +DECLARE v19 DECIMAL(64, 2) DEFAULT 11 + 1; +DECLARE v20 DECIMAL(64, 2) DEFAULT 12 + 0.123; +SELECT v1, v1u, v2, v2u, v3, v3u, v4, v4u; +SELECT v5, v5u, v6, v6u; +SELECT v7, v8, v9, v10, v11, v12, v13, v14, v15, v16; +SELECT v17, v18, v19, v20; +END| +CREATE PROCEDURE sp_vars_check_assignment() +BEGIN +DECLARE i1, i2, i3, i4 TINYINT; +DECLARE u1, u2, u3, u4 TINYINT UNSIGNED; +DECLARE d1, d2, d3 DECIMAL(64, 2); +SET i1 = 1e200; +SET i2 = -1e200; +SET i3 = 300; +SET i4 = -300; +SELECT i1, i2, i3, i4; +SET i1 = 10 * 10 * 10; +SET i2 = -10 * 10 * 10; +SET i3 = sign(10 * 10) * 10 * 20; +SET i4 = sign(-10 * 10) * -10 * 20; +SELECT i1, i2, i3, i4; +SET u1 = 1e200; +SET u2 = -1e200; +SET u3 = 300; +SET u4 = -300; +SELECT u1, u2, u3, u4; +SET u1 = 10 * 10 * 10; +SET u2 = -10 * 10 * 10; +SET u3 = sign(10 * 10) * 10 * 20; +SET u4 = sign(-10 * 10) * -10 * 20; +SELECT u1, u2, u3, u4; +SET d1 = 1234; +SET d2 = 1234.12; +SET d3 = 1234.1234; +SELECT d1, d2, d3; +SET d1 = 12 * 100 + 34; +SET d2 = 12 * 100 + 34 + 0.12; +SET d3 = 12 * 100 + 34 + 0.1234; +SELECT d1, d2, d3; +END| +CREATE FUNCTION sp_vars_check_ret1() RETURNS TINYINT +BEGIN +RETURN 1e200; +END| +CREATE FUNCTION sp_vars_check_ret2() RETURNS TINYINT +BEGIN +RETURN 10 * 10 * 10; +END| +CREATE FUNCTION sp_vars_check_ret3() RETURNS TINYINT +BEGIN +RETURN 'Hello, world'; +END| +CREATE FUNCTION sp_vars_check_ret4() RETURNS DECIMAL(64, 2) +BEGIN +RETURN 12 * 10 + 34 + 0.1234; +END| + +--------------------------------------------------------------- +Calling the routines, created in ANSI mode. +--------------------------------------------------------------- + +CALL sp_vars_check_dflt(); +v1 v1u v2 v2u v3 v3u v4 v4u +127 255 -128 0 127 255 -128 0 +v5 v5u v6 v6u +127 255 -128 0 +v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 +10 10 10 0 0 10 10 10 10 0 +v17 v18 v19 v20 +12.00 12.12 12.00 12.12 +Warnings: +Warning 1264 Out of range value adjusted for column 'v1' at row 1 +Warning 1264 Out of range value adjusted for column 'v1u' at row 1 +Warning 1264 Out of range value adjusted for column 'v2' at row 1 +Warning 1264 Out of range value adjusted for column 'v2u' at row 1 +Warning 1264 Out of range value adjusted for column 'v3' at row 1 +Warning 1264 Out of range value adjusted for column 'v3u' at row 1 +Warning 1264 Out of range value adjusted for column 'v4' at row 1 +Warning 1264 Out of range value adjusted for column 'v4u' at row 1 +Warning 1264 Out of range value adjusted for column 'v5' at row 1 +Warning 1264 Out of range value adjusted for column 'v5u' at row 1 +Warning 1264 Out of range value adjusted for column 'v6' at row 1 +Warning 1264 Out of range value adjusted for column 'v6u' at row 1 +Warning 1366 Incorrect integer value: 'String 10 ' for column 'v10' at row 1 +Warning 1366 Incorrect integer value: 'String10' for column 'v11' at row 1 +Warning 1265 Data truncated for column 'v12' at row 1 +Warning 1265 Data truncated for column 'v13' at row 1 +Warning 1366 Incorrect integer value: 'Hello, world' for column 'v16' at row 1 +Note 1265 Data truncated for column 'v18' at row 1 +Note 1265 Data truncated for column 'v20' at row 1 +CALL sp_vars_check_assignment(); +i1 i2 i3 i4 +127 -128 127 -128 +i1 i2 i3 i4 +127 -128 127 127 +u1 u2 u3 u4 +255 0 255 0 +u1 u2 u3 u4 +255 0 200 200 +d1 d2 d3 +1234.00 1234.12 1234.12 +d1 d2 d3 +1234.00 1234.12 1234.12 +Warnings: +Warning 1264 Out of range value adjusted for column 'i1' at row 1 +Warning 1264 Out of range value adjusted for column 'i2' at row 1 +Warning 1264 Out of range value adjusted for column 'i3' at row 1 +Warning 1264 Out of range value adjusted for column 'i4' at row 1 +Warning 1264 Out of range value adjusted for column 'i1' at row 1 +Warning 1264 Out of range value adjusted for column 'i2' at row 1 +Warning 1264 Out of range value adjusted for column 'i3' at row 1 +Warning 1264 Out of range value adjusted for column 'i4' at row 1 +Warning 1264 Out of range value adjusted for column 'u1' at row 1 +Warning 1264 Out of range value adjusted for column 'u2' at row 1 +Warning 1264 Out of range value adjusted for column 'u3' at row 1 +Warning 1264 Out of range value adjusted for column 'u4' at row 1 +Warning 1264 Out of range value adjusted for column 'u1' at row 1 +Warning 1264 Out of range value adjusted for column 'u2' at row 1 +Note 1265 Data truncated for column 'd3' at row 1 +Note 1265 Data truncated for column 'd3' at row 1 +SELECT sp_vars_check_ret1(); +sp_vars_check_ret1() +127 +Warnings: +Warning 1264 Out of range value adjusted for column 'sp_vars_check_ret1()' at row 1 +SELECT sp_vars_check_ret2(); +sp_vars_check_ret2() +127 +Warnings: +Warning 1264 Out of range value adjusted for column 'sp_vars_check_ret2()' at row 1 +SELECT sp_vars_check_ret3(); +sp_vars_check_ret3() +0 +Warnings: +Warning 1366 Incorrect integer value: 'Hello, world' for column 'sp_vars_check_ret3()' at row 1 +SELECT sp_vars_check_ret4(); +sp_vars_check_ret4() +154.12 +Warnings: +Note 1265 Data truncated for column 'sp_vars_check_ret4()' at row 1 +SET @@sql_mode = 'traditional'; + +--------------------------------------------------------------- +Calling in TRADITIONAL mode the routines, created in ANSI mode. +--------------------------------------------------------------- + +CALL sp_vars_check_dflt(); +v1 v1u v2 v2u v3 v3u v4 v4u +127 255 -128 0 127 255 -128 0 +v5 v5u v6 v6u +127 255 -128 0 +v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 +10 10 10 0 0 10 10 10 10 0 +v17 v18 v19 v20 +12.00 12.12 12.00 12.12 +Warnings: +Warning 1264 Out of range value adjusted for column 'v1' at row 1 +Warning 1264 Out of range value adjusted for column 'v1u' at row 1 +Warning 1264 Out of range value adjusted for column 'v2' at row 1 +Warning 1264 Out of range value adjusted for column 'v2u' at row 1 +Warning 1264 Out of range value adjusted for column 'v3' at row 1 +Warning 1264 Out of range value adjusted for column 'v3u' at row 1 +Warning 1264 Out of range value adjusted for column 'v4' at row 1 +Warning 1264 Out of range value adjusted for column 'v4u' at row 1 +Warning 1264 Out of range value adjusted for column 'v5' at row 1 +Warning 1264 Out of range value adjusted for column 'v5u' at row 1 +Warning 1264 Out of range value adjusted for column 'v6' at row 1 +Warning 1264 Out of range value adjusted for column 'v6u' at row 1 +Warning 1366 Incorrect integer value: 'String 10 ' for column 'v10' at row 1 +Warning 1366 Incorrect integer value: 'String10' for column 'v11' at row 1 +Warning 1265 Data truncated for column 'v12' at row 1 +Warning 1265 Data truncated for column 'v13' at row 1 +Warning 1366 Incorrect integer value: 'Hello, world' for column 'v16' at row 1 +Note 1265 Data truncated for column 'v18' at row 1 +Note 1265 Data truncated for column 'v20' at row 1 +CALL sp_vars_check_assignment(); +i1 i2 i3 i4 +127 -128 127 -128 +i1 i2 i3 i4 +127 -128 127 127 +u1 u2 u3 u4 +255 0 255 0 +u1 u2 u3 u4 +255 0 200 200 +d1 d2 d3 +1234.00 1234.12 1234.12 +d1 d2 d3 +1234.00 1234.12 1234.12 +Warnings: +Warning 1264 Out of range value adjusted for column 'i1' at row 1 +Warning 1264 Out of range value adjusted for column 'i2' at row 1 +Warning 1264 Out of range value adjusted for column 'i3' at row 1 +Warning 1264 Out of range value adjusted for column 'i4' at row 1 +Warning 1264 Out of range value adjusted for column 'i1' at row 1 +Warning 1264 Out of range value adjusted for column 'i2' at row 1 +Warning 1264 Out of range value adjusted for column 'i3' at row 1 +Warning 1264 Out of range value adjusted for column 'i4' at row 1 +Warning 1264 Out of range value adjusted for column 'u1' at row 1 +Warning 1264 Out of range value adjusted for column 'u2' at row 1 +Warning 1264 Out of range value adjusted for column 'u3' at row 1 +Warning 1264 Out of range value adjusted for column 'u4' at row 1 +Warning 1264 Out of range value adjusted for column 'u1' at row 1 +Warning 1264 Out of range value adjusted for column 'u2' at row 1 +Note 1265 Data truncated for column 'd3' at row 1 +Note 1265 Data truncated for column 'd3' at row 1 +SELECT sp_vars_check_ret1(); +sp_vars_check_ret1() +127 +Warnings: +Warning 1264 Out of range value adjusted for column 'sp_vars_check_ret1()' at row 1 +SELECT sp_vars_check_ret2(); +sp_vars_check_ret2() +127 +Warnings: +Warning 1264 Out of range value adjusted for column 'sp_vars_check_ret2()' at row 1 +SELECT sp_vars_check_ret3(); +sp_vars_check_ret3() +0 +Warnings: +Warning 1366 Incorrect integer value: 'Hello, world' for column 'sp_vars_check_ret3()' at row 1 +SELECT sp_vars_check_ret4(); +sp_vars_check_ret4() +154.12 +Warnings: +Note 1265 Data truncated for column 'sp_vars_check_ret4()' at row 1 +DROP PROCEDURE sp_vars_check_dflt; +DROP PROCEDURE sp_vars_check_assignment; +DROP FUNCTION sp_vars_check_ret1; +DROP FUNCTION sp_vars_check_ret2; +DROP FUNCTION sp_vars_check_ret3; +DROP FUNCTION sp_vars_check_ret4; +CREATE PROCEDURE sp_vars_check_dflt() +BEGIN +DECLARE v1 TINYINT DEFAULT 1e200; +DECLARE v1u TINYINT UNSIGNED DEFAULT 1e200; +DECLARE v2 TINYINT DEFAULT -1e200; +DECLARE v2u TINYINT UNSIGNED DEFAULT -1e200; +DECLARE v3 TINYINT DEFAULT 300; +DECLARE v3u TINYINT UNSIGNED DEFAULT 300; +DECLARE v4 TINYINT DEFAULT -300; +DECLARE v4u TINYINT UNSIGNED DEFAULT -300; +DECLARE v5 TINYINT DEFAULT 10 * 10 * 10; +DECLARE v5u TINYINT UNSIGNED DEFAULT 10 * 10 * 10; +DECLARE v6 TINYINT DEFAULT -10 * 10 * 10; +DECLARE v6u TINYINT UNSIGNED DEFAULT -10 * 10 * 10; +DECLARE v7 TINYINT DEFAULT '10'; +DECLARE v8 TINYINT DEFAULT '10 '; +DECLARE v9 TINYINT DEFAULT ' 10 '; +DECLARE v10 TINYINT DEFAULT 'String 10 '; +DECLARE v11 TINYINT DEFAULT 'String10'; +DECLARE v12 TINYINT DEFAULT '10 String'; +DECLARE v13 TINYINT DEFAULT '10String'; +DECLARE v14 TINYINT DEFAULT concat('10', ' '); +DECLARE v15 TINYINT DEFAULT concat(' ', '10'); +DECLARE v16 TINYINT DEFAULT concat('Hello, ', 'world'); +DECLARE v17 DECIMAL(64, 2) DEFAULT 12; +DECLARE v18 DECIMAL(64, 2) DEFAULT 12.123; +DECLARE v19 DECIMAL(64, 2) DEFAULT 11 + 1; +DECLARE v20 DECIMAL(64, 2) DEFAULT 12 + 0.123; +SELECT v1, v1u, v2, v2u, v3, v3u, v4, v4u; +SELECT v5, v5u, v6, v6u; +SELECT v7, v8, v9, v10, v11, v12, v13, v14, v15, v16; +SELECT v17, v18, v19, v20; +END| +CREATE PROCEDURE sp_vars_check_assignment() +BEGIN +DECLARE i1, i2, i3, i4 TINYINT; +DECLARE u1, u2, u3, u4 TINYINT UNSIGNED; +DECLARE d1, d2, d3 DECIMAL(64, 2); +SET i1 = 1e200; +SET i2 = -1e200; +SET i3 = 300; +SET i4 = -300; +SELECT i1, i2, i3, i4; +SET i1 = 10 * 10 * 10; +SET i2 = -10 * 10 * 10; +SET i3 = sign(10 * 10) * 10 * 20; +SET i4 = sign(-10 * 10) * -10 * 20; +SELECT i1, i2, i3, i4; +SET u1 = 1e200; +SET u2 = -1e200; +SET u3 = 300; +SET u4 = -300; +SELECT u1, u2, u3, u4; +SET u1 = 10 * 10 * 10; +SET u2 = -10 * 10 * 10; +SET u3 = sign(10 * 10) * 10 * 20; +SET u4 = sign(-10 * 10) * -10 * 20; +SELECT u1, u2, u3, u4; +SET d1 = 1234; +SET d2 = 1234.12; +SET d3 = 1234.1234; +SELECT d1, d2, d3; +SET d1 = 12 * 100 + 34; +SET d2 = 12 * 100 + 34 + 0.12; +SET d3 = 12 * 100 + 34 + 0.1234; +SELECT d1, d2, d3; +END| +CREATE FUNCTION sp_vars_check_ret1() RETURNS TINYINT +BEGIN +RETURN 1e200; +END| +CREATE FUNCTION sp_vars_check_ret2() RETURNS TINYINT +BEGIN +RETURN 10 * 10 * 10; +END| +CREATE FUNCTION sp_vars_check_ret3() RETURNS TINYINT +BEGIN +RETURN 'Hello, world'; +END| +CREATE FUNCTION sp_vars_check_ret4() RETURNS DECIMAL(64, 2) +BEGIN +RETURN 12 * 10 + 34 + 0.1234; +END| + +--------------------------------------------------------------- +Calling the routines, created in TRADITIONAL mode. +--------------------------------------------------------------- + +CALL sp_vars_check_dflt(); +ERROR 22003: Out of range value adjusted for column 'v1' at row 1 +CALL sp_vars_check_assignment(); +ERROR 22003: Out of range value adjusted for column 'i1' at row 1 +SELECT sp_vars_check_ret1(); +ERROR 22003: Out of range value adjusted for column 'sp_vars_check_ret1()' at row 1 +SELECT sp_vars_check_ret2(); +ERROR 22003: Out of range value adjusted for column 'sp_vars_check_ret2()' at row 1 +SELECT sp_vars_check_ret3(); +ERROR HY000: Incorrect integer value: 'Hello, world' for column 'sp_vars_check_ret3()' at row 1 +SELECT sp_vars_check_ret4(); +sp_vars_check_ret4() +154.12 +Warnings: +Note 1265 Data truncated for column 'sp_vars_check_ret4()' at row 1 +SET @@sql_mode = 'ansi'; +DROP PROCEDURE sp_vars_check_dflt; +DROP PROCEDURE sp_vars_check_assignment; +DROP FUNCTION sp_vars_check_ret1; +DROP FUNCTION sp_vars_check_ret2; +DROP FUNCTION sp_vars_check_ret3; +DROP FUNCTION sp_vars_check_ret4; + +--------------------------------------------------------------- +BIT data type tests +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1() +BEGIN +DECLARE v1 BIT; +DECLARE v2 BIT(1); +DECLARE v3 BIT(3) DEFAULT b'101'; +DECLARE v4 BIT(64) DEFAULT 0x5555555555555555; +DECLARE v5 BIT(3); +DECLARE v6 BIT(64); +DECLARE v7 BIT(8) DEFAULT 128; +DECLARE v8 BIT(8) DEFAULT '128'; +DECLARE v9 BIT(8) DEFAULT ' 128'; +DECLARE v10 BIT(8) DEFAULT 'x 128'; +SET v1 = v4; +SET v2 = 0; +SET v5 = v4; # check overflow +SET v6 = v3; # check padding +SELECT HEX(v1); +SELECT HEX(v2); +SELECT HEX(v3); +SELECT HEX(v4); +SELECT HEX(v5); +SELECT HEX(v6); +SELECT HEX(v7); +SELECT HEX(v8); +SELECT HEX(v9); +SELECT HEX(v10); +END| +CALL p1(); +HEX(v1) +01 +HEX(v2) +00 +HEX(v3) +05 +HEX(v4) +5555555555555555 +HEX(v5) +07 +HEX(v6) +0000000000000005 +HEX(v7) +80 +HEX(v8) +FF +HEX(v9) +FF +HEX(v10) +FF +Warnings: +Warning 1264 Out of range value adjusted for column 'v8' at row 1 +Warning 1264 Out of range value adjusted for column 'v9' at row 1 +Warning 1264 Out of range value adjusted for column 'v10' at row 1 +Warning 1264 Out of range value adjusted for column 'v1' at row 1 +Warning 1264 Out of range value adjusted for column 'v5' at row 1 +DROP PROCEDURE p1; + +--------------------------------------------------------------- +CASE expression tests. +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +Warnings: +Note 1305 PROCEDURE p1 does not exist +DROP PROCEDURE IF EXISTS p2; +Warnings: +Note 1305 PROCEDURE p2 does not exist +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1(log_msg VARCHAR(1024)); +CREATE PROCEDURE p1(arg VARCHAR(255)) +BEGIN +INSERT INTO t1 VALUES('p1: step1'); +CASE arg * 10 +WHEN 10 * 10 THEN +INSERT INTO t1 VALUES('p1: case1: on 10'); +WHEN 10 * 10 + 10 * 10 THEN +BEGIN +CASE arg / 10 +WHEN 1 THEN +INSERT INTO t1 VALUES('p1: case1: case2: on 1'); +WHEN 2 THEN +BEGIN +DECLARE i TINYINT DEFAULT 10; +WHILE i > 0 DO +INSERT INTO t1 VALUES(CONCAT('p1: case1: case2: loop: i: ', i)); +CASE MOD(i, 2) +WHEN 0 THEN +INSERT INTO t1 VALUES('p1: case1: case2: loop: i is even'); +WHEN 1 THEN +INSERT INTO t1 VALUES('p1: case1: case2: loop: i is odd'); +ELSE +INSERT INTO t1 VALUES('p1: case1: case2: loop: ERROR'); +END CASE; +SET i = i - 1; +END WHILE; +END; +ELSE +INSERT INTO t1 VALUES('p1: case1: case2: ERROR'); +END CASE; +CASE arg +WHEN 10 THEN +INSERT INTO t1 VALUES('p1: case1: case3: on 10'); +WHEN 20 THEN +INSERT INTO t1 VALUES('p1: case1: case3: on 20'); +ELSE +INSERT INTO t1 VALUES('p1: case1: case3: ERROR'); +END CASE; +END; +ELSE +INSERT INTO t1 VALUES('p1: case1: ERROR'); +END CASE; +CASE arg * 10 +WHEN 10 * 10 THEN +INSERT INTO t1 VALUES('p1: case4: on 10'); +WHEN 10 * 10 + 10 * 10 THEN +BEGIN +CASE arg / 10 +WHEN 1 THEN +INSERT INTO t1 VALUES('p1: case4: case5: on 1'); +WHEN 2 THEN +BEGIN +DECLARE i TINYINT DEFAULT 10; +WHILE i > 0 DO +INSERT INTO t1 VALUES(CONCAT('p1: case4: case5: loop: i: ', i)); +CASE MOD(i, 2) +WHEN 0 THEN +INSERT INTO t1 VALUES('p1: case4: case5: loop: i is even'); +WHEN 1 THEN +INSERT INTO t1 VALUES('p1: case4: case5: loop: i is odd'); +ELSE +INSERT INTO t1 VALUES('p1: case4: case5: loop: ERROR'); +END CASE; +SET i = i - 1; +END WHILE; +END; +ELSE +INSERT INTO t1 VALUES('p1: case4: case5: ERROR'); +END CASE; +CASE arg +WHEN 10 THEN +INSERT INTO t1 VALUES('p1: case4: case6: on 10'); +WHEN 20 THEN +INSERT INTO t1 VALUES('p1: case4: case6: on 20'); +ELSE +INSERT INTO t1 VALUES('p1: case4: case6: ERROR'); +END CASE; +END; +ELSE +INSERT INTO t1 VALUES('p1: case4: ERROR'); +END CASE; +END| +CREATE PROCEDURE p2() +BEGIN +DECLARE i TINYINT DEFAULT 3; +WHILE i > 0 DO +IF MOD(i, 2) = 0 THEN +SET @_test_session_var = 10; +ELSE +SET @_test_session_var = 'test'; +END IF; +CASE @_test_session_var +WHEN 10 THEN +INSERT INTO t1 VALUES('p2: case: numerical type'); +WHEN 'test' THEN +INSERT INTO t1 VALUES('p2: case: string type'); +ELSE +INSERT INTO t1 VALUES('p2: case: ERROR'); +END CASE; +SET i = i - 1; +END WHILE; +END| +CALL p1(10); +CALL p1(20); +CALL p2(); +SELECT * FROM t1; +log_msg +p1: step1 +p1: case1: on 10 +p1: case4: on 10 +p1: step1 +p1: case1: case2: loop: i: 10 +p1: case1: case2: loop: i is even +p1: case1: case2: loop: i: 9 +p1: case1: case2: loop: i is odd +p1: case1: case2: loop: i: 8 +p1: case1: case2: loop: i is even +p1: case1: case2: loop: i: 7 +p1: case1: case2: loop: i is odd +p1: case1: case2: loop: i: 6 +p1: case1: case2: loop: i is even +p1: case1: case2: loop: i: 5 +p1: case1: case2: loop: i is odd +p1: case1: case2: loop: i: 4 +p1: case1: case2: loop: i is even +p1: case1: case2: loop: i: 3 +p1: case1: case2: loop: i is odd +p1: case1: case2: loop: i: 2 +p1: case1: case2: loop: i is even +p1: case1: case2: loop: i: 1 +p1: case1: case2: loop: i is odd +p1: case1: case3: on 20 +p1: case4: case5: loop: i: 10 +p1: case4: case5: loop: i is even +p1: case4: case5: loop: i: 9 +p1: case4: case5: loop: i is odd +p1: case4: case5: loop: i: 8 +p1: case4: case5: loop: i is even +p1: case4: case5: loop: i: 7 +p1: case4: case5: loop: i is odd +p1: case4: case5: loop: i: 6 +p1: case4: case5: loop: i is even +p1: case4: case5: loop: i: 5 +p1: case4: case5: loop: i is odd +p1: case4: case5: loop: i: 4 +p1: case4: case5: loop: i is even +p1: case4: case5: loop: i: 3 +p1: case4: case5: loop: i is odd +p1: case4: case5: loop: i: 2 +p1: case4: case5: loop: i is even +p1: case4: case5: loop: i: 1 +p1: case4: case5: loop: i is odd +p1: case4: case6: on 20 +p2: case: string type +p2: case: numerical type +p2: case: string type +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP TABLE t1; + +--------------------------------------------------------------- +BUG#14161 +--------------------------------------------------------------- + +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1(col BIGINT UNSIGNED); +INSERT INTO t1 VALUE(18446744073709551614); +CREATE PROCEDURE p1(IN arg BIGINT UNSIGNED) +BEGIN +SELECT arg; +SELECT * FROM t1; +SELECT * FROM t1 WHERE col = arg; +END| +CALL p1(18446744073709551614); +arg +18446744073709551614 +col +18446744073709551614 +col +18446744073709551614 +DROP TABLE t1; +DROP PROCEDURE p1; + +--------------------------------------------------------------- +BUG#13705 +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1(x VARCHAR(10), y CHAR(3)) READS SQL DATA +BEGIN +SELECT x, y; +END| +CALL p1('alpha', 'abc'); +x y +alpha abc +CALL p1('alpha', 'abcdef'); +x y +alpha abc +Warnings: +Warning 1265 Data truncated for column 'y' at row 1 +DROP PROCEDURE p1; + +--------------------------------------------------------------- +BUG#13675 +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +DROP TABLE IF EXISTS t1; +CREATE PROCEDURE p1(x DATETIME) +BEGIN +CREATE TABLE t1 SELECT x; +SHOW CREATE TABLE t1; +DROP TABLE t1; +END| +CALL p1(NOW()); +Table Create Table +t1 CREATE TABLE "t1" ( + "x" varbinary(19) default NULL +) +CALL p1('test'); +Table Create Table +t1 CREATE TABLE "t1" ( + "x" varbinary(19) default NULL +) +Warnings: +Warning 1264 Out of range value adjusted for column 'x' at row 1 +DROP PROCEDURE p1; + +--------------------------------------------------------------- +BUG#12976 +--------------------------------------------------------------- + +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +CREATE TABLE t1(b BIT(1)); +INSERT INTO t1(b) VALUES(b'0'), (b'1'); +CREATE PROCEDURE p1() +BEGIN +SELECT HEX(b), +b = 0, +b = FALSE, +b IS FALSE, +b = 1, +b = TRUE, +b IS TRUE +FROM t1; +END| +CREATE PROCEDURE p2() +BEGIN +DECLARE vb BIT(1); +SELECT b INTO vb FROM t1 WHERE b = 0; +SELECT HEX(vb), +vb = 0, +vb = FALSE, +vb IS FALSE, +vb = 1, +vb = TRUE, +vb IS TRUE; +SELECT b INTO vb FROM t1 WHERE b = 1; +SELECT HEX(vb), +vb = 0, +vb = FALSE, +vb IS FALSE, +vb = 1, +vb = TRUE, +vb IS TRUE; +END| +call p1(); +HEX(b) b = 0 b = FALSE b IS FALSE b = 1 b = TRUE b IS TRUE + +0 1 1 1 0 0 0 +1 0 0 0 1 1 1 +call p2(); +HEX(vb) vb = 0 vb = FALSE vb IS FALSE vb = 1 vb = TRUE vb IS TRUE +00 1 1 1 0 0 0 +HEX(vb) vb = 0 vb = FALSE vb IS FALSE vb = 1 vb = TRUE vb IS TRUE +01 0 0 1 1 1 0 +DROP TABLE t1; +DROP PROCEDURE p1; +DROP PROCEDURE p2; + +--------------------------------------------------------------- +BUG#9572 +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP PROCEDURE IF EXISTS p3; +DROP PROCEDURE IF EXISTS p4; +DROP PROCEDURE IF EXISTS p5; +DROP PROCEDURE IF EXISTS p6; +SET @@sql_mode = 'traditional'; +CREATE PROCEDURE p1() +BEGIN +DECLARE v TINYINT DEFAULT 1e200; +SELECT v; +END| +CREATE PROCEDURE p2() +BEGIN +DECLARE v DECIMAL(5) DEFAULT 1e200; +SELECT v; +END| +CREATE PROCEDURE p3() +BEGIN +DECLARE v CHAR(5) DEFAULT 'abcdef'; +SELECT v LIKE 'abc___'; +END| +CREATE PROCEDURE p4(arg VARCHAR(2)) +BEGIN +DECLARE var VARCHAR(1); +SET var := arg; +SELECT arg, var; +END| +CREATE PROCEDURE p5(arg CHAR(2)) +BEGIN +DECLARE var CHAR(1); +SET var := arg; +SELECT arg, var; +END| +CREATE PROCEDURE p6(arg DECIMAL(2)) +BEGIN +DECLARE var DECIMAL(1); +SET var := arg; +SELECT arg, var; +END| +CALL p1(); +ERROR 22003: Out of range value adjusted for column 'v' at row 1 +CALL p2(); +ERROR 22003: Out of range value adjusted for column 'v' at row 1 +CALL p3(); +ERROR 22001: Data too long for column 'v' at row 1 +CALL p4('aaa'); +ERROR 22001: Data too long for column 'arg' at row 1 +CALL p5('aa'); +ERROR 22001: Data too long for column 'var' at row 1 +CALL p6(10); +ERROR 22003: Out of range value adjusted for column 'var' at row 1 +SET @@sql_mode = 'ansi'; +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; +DROP PROCEDURE p5; +DROP PROCEDURE p6; + +--------------------------------------------------------------- +BUG#9078 +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1 (arg DECIMAL(64,2)) +BEGIN +DECLARE var DECIMAL(64,2); +SET var = arg; +SELECT var; +END| +CALL p1(1929); +var +1929.00 +CALL p1(1929.00); +var +1929.00 +CALL p1(1929.003); +var +1929.00 +Warnings: +Note 1265 Data truncated for column 'arg' at row 1 +DROP PROCEDURE p1; + +--------------------------------------------------------------- +BUG#8768 +--------------------------------------------------------------- + +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1(arg TINYINT UNSIGNED) RETURNS TINYINT +BEGIN +RETURN arg; +END| +SELECT f1(-2500); +f1(-2500) +0 +Warnings: +Warning 1264 Out of range value adjusted for column 'arg' at row 1 +SET @@sql_mode = 'traditional'; +SELECT f1(-2500); +ERROR 22003: Out of range value adjusted for column 'arg' at row 1 +DROP FUNCTION f1; +CREATE FUNCTION f1(arg TINYINT UNSIGNED) RETURNS TINYINT +BEGIN +RETURN arg; +END| +SELECT f1(-2500); +ERROR 22003: Out of range value adjusted for column 'arg' at row 1 +SET @@sql_mode = 'ansi'; +DROP FUNCTION f1; + +--------------------------------------------------------------- +BUG#8769 +--------------------------------------------------------------- + +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1(arg MEDIUMINT) RETURNS MEDIUMINT +BEGIN +RETURN arg; +END| +SELECT f1(8388699); +f1(8388699) +8388607 +Warnings: +Warning 1264 Out of range value adjusted for column 'arg' at row 1 +SET @@sql_mode = 'traditional'; +SELECT f1(8388699); +ERROR 22003: Out of range value adjusted for column 'arg' at row 1 +DROP FUNCTION f1; +CREATE FUNCTION f1(arg MEDIUMINT) RETURNS MEDIUMINT +BEGIN +RETURN arg; +END| +SELECT f1(8388699); +ERROR 22003: Out of range value adjusted for column 'arg' at row 1 +SET @@sql_mode = 'ansi'; +DROP FUNCTION f1; + +--------------------------------------------------------------- +BUG#8702 +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(col VARCHAR(255)); +INSERT INTO t1(col) VALUES('Hello, world!'); +CREATE PROCEDURE p1() +BEGIN +DECLARE sp_var INTEGER; +SELECT col INTO sp_var FROM t1 LIMIT 1; +SET @user_var = sp_var; +SELECT sp_var; +SELECT @user_var; +END| +CALL p1(); +sp_var +0 +@user_var +0 +Warnings: +Warning 1264 Out of range value adjusted for column 'sp_var' at row 1 +DROP PROCEDURE p1; +DROP TABLE t1; + +--------------------------------------------------------------- +BUG#12903 +--------------------------------------------------------------- + +DROP FUNCTION IF EXISTS f1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(txt VARCHAR(255)); +CREATE FUNCTION f1(arg VARCHAR(255)) RETURNS VARCHAR(255) +BEGIN +DECLARE v1 VARCHAR(255); +DECLARE v2 VARCHAR(255); +SET v1 = CONCAT(LOWER(arg), UPPER(arg)); +SET v2 = CONCAT(LOWER(v1), UPPER(v1)); +INSERT INTO t1 VALUES(v1), (v2); +RETURN CONCAT(LOWER(arg), UPPER(arg)); +END| +SELECT f1('_aBcDe_'); +f1('_aBcDe_') +_abcde__ABCDE_ +SELECT * FROM t1; +txt +_abcde__ABCDE_ +_abcde__abcde__ABCDE__ABCDE_ +DROP FUNCTION f1; +DROP TABLE t1; + +--------------------------------------------------------------- +BUG#13808 +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +DROP FUNCTION IF EXISTS f1; +CREATE PROCEDURE p1(arg ENUM('a', 'b')) +BEGIN +SELECT arg; +END| +CREATE PROCEDURE p2(arg ENUM('a', 'b')) +BEGIN +DECLARE var ENUM('c', 'd') DEFAULT arg; +SELECT arg, var; +END| +CREATE FUNCTION f1(arg ENUM('a', 'b')) RETURNS ENUM('c', 'd') +BEGIN +RETURN arg; +END| +CALL p1('c'); +arg + +Warnings: +Warning 1265 Data truncated for column 'arg' at row 1 +CALL p2('a'); +arg var +a +Warnings: +Warning 1265 Data truncated for column 'var' at row 1 +SELECT f1('a'); +f1('a') + +Warnings: +Warning 1265 Data truncated for column 'f1('a')' at row 1 +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP FUNCTION f1; + +--------------------------------------------------------------- +BUG#13909 +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +DROP PROCEDURE IF EXISTS p2; +CREATE PROCEDURE p1(arg VARCHAR(255)) +BEGIN +SELECT CHARSET(arg); +END| +CREATE PROCEDURE p2(arg VARCHAR(255) CHARACTER SET UTF8) +BEGIN +SELECT CHARSET(arg); +END| +CALL p1('t'); +CHARSET(arg) +latin1 +CALL p1(_UTF8 't'); +CHARSET(arg) +latin1 +CALL p2('t'); +CHARSET(arg) +utf8 +CALL p2(_LATIN1 't'); +CHARSET(arg) +utf8 +DROP PROCEDURE p1; +DROP PROCEDURE p2; + +--------------------------------------------------------------- +BUG#14188 +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1(arg1 BINARY(2), arg2 VARBINARY(2)) +BEGIN +DECLARE var1 BINARY(2) DEFAULT 0x41; +DECLARE var2 VARBINARY(2) DEFAULT 0x42; +SELECT HEX(arg1), HEX(arg2); +SELECT HEX(var1), HEX(var2); +END| +CALL p1(0x41, 0x42); +HEX(arg1) HEX(arg2) +4100 42 +HEX(var1) HEX(var2) +4100 42 +DROP PROCEDURE p1; + +--------------------------------------------------------------- +BUG#15148 +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(col1 TINYINT, col2 TINYINT); +INSERT INTO t1 VALUES(1, 2), (11, 12); +CREATE PROCEDURE p1(arg TINYINT) +BEGIN +SELECT arg; +END| +CALL p1((1, 2)); +ERROR 21000: Operand should contain 1 column(s) +CALL p1((SELECT * FROM t1 LIMIT 1)); +ERROR 21000: Operand should contain 1 column(s) +CALL p1((SELECT col1, col2 FROM t1 LIMIT 1)); +ERROR 21000: Operand should contain 1 column(s) +DROP PROCEDURE p1; +DROP TABLE t1; + +--------------------------------------------------------------- +BUG#13613 +--------------------------------------------------------------- + +DROP PROCEDURE IF EXISTS p1; +DROP FUNCTION IF EXISTS f1; +CREATE PROCEDURE p1(x VARCHAR(50)) +BEGIN +SET x = SUBSTRING(x, 1, 3); +SELECT x; +END| +CREATE FUNCTION f1(x VARCHAR(50)) RETURNS VARCHAR(50) +BEGIN +RETURN SUBSTRING(x, 1, 3); +END| +CALL p1('abcdef'); +x +abc +SELECT f1('ABCDEF'); +f1('ABCDEF') +ABC +DROP PROCEDURE p1; +DROP FUNCTION f1; + +--------------------------------------------------------------- +BUG#13665 +--------------------------------------------------------------- + +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS VARCHAR(20000) +BEGIN +DECLARE var VARCHAR(2000); +SET var = ''; +SET var = CONCAT(var, 'abc'); +SET var = CONCAT(var, ''); +RETURN var; +END| +SELECT f1(); +f1() +abc +DROP FUNCTION f1; |