| 1 |
|
| 2 |
--source suite/funcs_1/storedproc/load_sp_tb.inc |
| 3 |
-------------------------------------------------------------------------------- |
| 4 |
SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; |
| 5 |
|
| 6 |
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc |
| 7 |
-------------------------------------------------------------------------------- |
| 8 |
DROP DATABASE IF EXISTS db_storedproc; |
| 9 |
DROP DATABASE IF EXISTS db_storedproc_1; |
| 10 |
CREATE DATABASE db_storedproc charset utf8mb4; |
| 11 |
CREATE DATABASE db_storedproc_1 charset utf8mb4; |
| 12 |
USE db_storedproc; |
| 13 |
create table t1(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) |
| 14 |
engine = <engine_to_be_tested>; |
| 15 |
load data infile '<MYSQLTEST_VARDIR>/std_data/funcs_1/t4.txt' into table t1; |
| 16 |
create table t2(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) |
| 17 |
engine = <engine_to_be_tested>; |
| 18 |
load data infile '<MYSQLTEST_VARDIR>/std_data/funcs_1/t4.txt' into table t2; |
| 19 |
create table t3(f1 char(20),f2 char(20),f3 integer) engine = <engine_to_be_tested>; |
| 20 |
load data infile '<MYSQLTEST_VARDIR>/std_data/funcs_1/t3.txt' into table t3; |
| 21 |
create table t4(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) |
| 22 |
engine = <engine_to_be_tested>; |
| 23 |
load data infile '<MYSQLTEST_VARDIR>/std_data/funcs_1/t4.txt' into table t4; |
| 24 |
USE db_storedproc_1; |
| 25 |
create table t6(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) |
| 26 |
engine = <engine_to_be_tested>; |
| 27 |
load data infile '<MYSQLTEST_VARDIR>/std_data/funcs_1/t4.txt' into table t6; |
| 28 |
USE db_storedproc; |
| 29 |
create table t7 (f1 char(20), f2 char(25), f3 date, f4 int) |
| 30 |
engine = <engine_to_be_tested>; |
| 31 |
load data infile '<MYSQLTEST_VARDIR>/std_data/funcs_1/t7.txt' into table t7; |
| 32 |
Warnings: |
| 33 |
Warning 1265 Data truncated for column 'f3' at row 1 |
| 34 |
Warning 1265 Data truncated for column 'f3' at row 2 |
| 35 |
Warning 1265 Data truncated for column 'f3' at row 3 |
| 36 |
Warning 1265 Data truncated for column 'f3' at row 4 |
| 37 |
Warning 1265 Data truncated for column 'f3' at row 5 |
| 38 |
Warning 1265 Data truncated for column 'f3' at row 6 |
| 39 |
Warning 1265 Data truncated for column 'f3' at row 7 |
| 40 |
Warning 1265 Data truncated for column 'f3' at row 8 |
| 41 |
Warning 1265 Data truncated for column 'f3' at row 9 |
| 42 |
Warning 1265 Data truncated for column 'f3' at row 10 |
| 43 |
create table t8 (f1 char(20), f2 char(25), f3 date, f4 int) |
| 44 |
engine = <engine_to_be_tested>; |
| 45 |
load data infile '<MYSQLTEST_VARDIR>/std_data/funcs_1/t7.txt' into table t8; |
| 46 |
Warnings: |
| 47 |
Warning 1265 Data truncated for column 'f3' at row 1 |
| 48 |
Warning 1265 Data truncated for column 'f3' at row 2 |
| 49 |
Warning 1265 Data truncated for column 'f3' at row 3 |
| 50 |
Warning 1265 Data truncated for column 'f3' at row 4 |
| 51 |
Warning 1265 Data truncated for column 'f3' at row 5 |
| 52 |
Warning 1265 Data truncated for column 'f3' at row 6 |
| 53 |
Warning 1265 Data truncated for column 'f3' at row 7 |
| 54 |
Warning 1265 Data truncated for column 'f3' at row 8 |
| 55 |
Warning 1265 Data truncated for column 'f3' at row 9 |
| 56 |
Warning 1265 Data truncated for column 'f3' at row 10 |
| 57 |
create table t9(f1 int, f2 char(25), f3 int) engine = <engine_to_be_tested>; |
| 58 |
load data infile '<MYSQLTEST_VARDIR>/std_data/funcs_1/t9.txt' into table t9; |
| 59 |
create table t10(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) |
| 60 |
engine = <engine_to_be_tested>; |
| 61 |
load data infile '<MYSQLTEST_VARDIR>/std_data/funcs_1/t4.txt' into table t10; |
| 62 |
create table t11(f1 char(20),f2 char(25),f3 date,f4 int,f5 char(25),f6 int) |
| 63 |
engine = <engine_to_be_tested>; |
| 64 |
load data infile '<MYSQLTEST_VARDIR>/std_data/funcs_1/t4.txt' into table t11; |
| 65 |
SET sql_mode = default; |
| 66 |
Warnings: |
| 67 |
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. |
| 68 |
|
| 69 |
Section 3.1.7 - SQL mode checks: |
| 70 |
-------------------------------------------------------------------------------- |
| 71 |
Warnings: |
| 72 |
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. |
| 73 |
USE db_storedproc; |
| 74 |
Warnings: |
| 75 |
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. |
| 76 |
|
| 77 |
Testcase 3.1.7.1: |
| 78 |
----------------- |
| 79 |
Ensure that the sql_mode setting in effect at the time a stored procedure is |
| 80 |
created is the same setting under which the stored procedure runs when it is |
| 81 |
called/executed. |
| 82 |
-------------------------------------------------------------------------------- |
| 83 |
Warnings: |
| 84 |
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. |
| 85 |
DROP PROCEDURE IF EXISTS sp1; |
| 86 |
DROP TABLE IF EXISTS temp_tbl; |
| 87 |
DROP TABLE IF EXISTS result; |
| 88 |
CREATE TABLE temp_tbl (f1 tinyint); |
| 89 |
CREATE TABLE result (f1 text(200), f2 char(20)); |
| 90 |
set @@sql_mode='traditional'; |
| 91 |
SHOW VARIABLES LIKE 'sql_mode'; |
| 92 |
Variable_name Value |
| 93 |
sql_mode STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_ENGINE_SUBSTITUTION |
| 94 |
CREATE PROCEDURE sp1() |
| 95 |
BEGIN |
| 96 |
declare a tinyint; |
| 97 |
declare count_ int default 1; |
| 98 |
declare continue handler for sqlstate '22003' set count_=1000; |
| 99 |
SHOW VARIABLES LIKE 'sql_mode'; |
| 100 |
SELECT @@sql_mode into @cur_val_sql_mode; |
| 101 |
insert into temp_tbl values (1000); |
| 102 |
if count_ = 1000 THEN |
| 103 |
INSERT INTO result VALUES (@cur_val_sql_mode, 'value restored'); |
| 104 |
ELSE |
| 105 |
INSERT INTO result VALUES (@cur_val_sql_mode, 'value not restored'); |
| 106 |
END if; |
| 107 |
END// |
| 108 |
SHOW CREATE PROCEDURE sp1; |
| 109 |
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation |
| 110 |
sp1 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `sp1`() |
| 111 |
BEGIN |
| 112 |
declare a tinyint; |
| 113 |
declare count_ int default 1; |
| 114 |
declare continue handler for sqlstate '22003' set count_=1000; |
| 115 |
SHOW VARIABLES LIKE 'sql_mode'; |
| 116 |
SELECT @@sql_mode into @cur_val_sql_mode; |
| 117 |
insert into temp_tbl values (1000); |
| 118 |
if count_ = 1000 THEN |
| 119 |
INSERT INTO result VALUES (@cur_val_sql_mode, 'value restored'); |
| 120 |
ELSE |
| 121 |
INSERT INTO result VALUES (@cur_val_sql_mode, 'value not restored'); |
| 122 |
END if; |
| 123 |
END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci |
| 124 |
set @@sql_mode=''; |
| 125 |
SHOW VARIABLES LIKE 'sql_mode'; |
| 126 |
Variable_name Value |
| 127 |
sql_mode |
| 128 |
CALL sp1(); |
| 129 |
Variable_name Value |
| 130 |
sql_mode STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_ENGINE_SUBSTITUTION |
| 131 |
SELECT * from result; |
| 132 |
f1 f2 |
| 133 |
STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_ENGINE_SUBSTITUTION value restored |
| 134 |
SHOW VARIABLES LIKE 'sql_mode'; |
| 135 |
Variable_name Value |
| 136 |
sql_mode |
| 137 |
SELECT @@sql_mode; |
| 138 |
@@sql_mode |
| 139 |
|
| 140 |
SET @@sql_mode='TRADITIONAL'; |
| 141 |
DROP PROCEDURE sp1; |
| 142 |
DROP TABLE temp_tbl; |
| 143 |
DROP TABLE result; |
| 144 |
Warnings: |
| 145 |
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. |
| 146 |
|
| 147 |
Testcase 3.1.7.2: |
| 148 |
----------------- |
| 149 |
Ensure that if the sql_mode setting is changed when a stored procedure is run, |
| 150 |
that the original setting is restored as soon as the stored procedure execution |
| 151 |
is complete. |
| 152 |
-------------------------------------------------------------------------------- |
| 153 |
Warnings: |
| 154 |
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. |
| 155 |
DROP PROCEDURE IF EXISTS sp2; |
| 156 |
... show initial value |
| 157 |
SHOW VARIABLES LIKE 'sql_mode'; |
| 158 |
Variable_name Value |
| 159 |
sql_mode STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_ENGINE_SUBSTITUTION |
| 160 |
CREATE PROCEDURE sp2() |
| 161 |
BEGIN |
| 162 |
SET @@sql_mode='PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE'; |
| 163 |
SHOW VARIABLES LIKE 'sql_mode'; |
| 164 |
END// |
| 165 |
SHOW CREATE PROCEDURE sp2; |
| 166 |
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation |
| 167 |
sp2 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `sp2`() |
| 168 |
BEGIN |
| 169 |
SET @@sql_mode='PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE'; |
| 170 |
SHOW VARIABLES LIKE 'sql_mode'; |
| 171 |
END utf8mb4 utf8mb4_0900_ai_ci utf8mb4_0900_ai_ci |
| 172 |
... show value prior calling procedure |
| 173 |
SHOW VARIABLES LIKE 'sql_mode'; |
| 174 |
Variable_name Value |
| 175 |
sql_mode STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_ENGINE_SUBSTITUTION |
| 176 |
... call procedure that changes sql_mode |
| 177 |
CALL sp2(); |
| 178 |
Variable_name Value |
| 179 |
sql_mode PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE |
| 180 |
... check whether old value is re-set |
| 181 |
SHOW VARIABLES LIKE 'sql_mode'; |
| 182 |
Variable_name Value |
| 183 |
sql_mode STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_ENGINE_SUBSTITUTION |
| 184 |
DROP PROCEDURE sp2; |
| 185 |
|
| 186 |
--source suite/funcs_1/storedproc/cleanup_sp_tb.inc |
| 187 |
-------------------------------------------------------------------------------- |
| 188 |
DROP DATABASE IF EXISTS db_storedproc; |
| 189 |
DROP DATABASE IF EXISTS db_storedproc_1; |
| 190 |
Warnings: |
| 191 |
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. |
| 192 |
|
| 193 |
. +++ END OF SCRIPT +++ |
| 194 |
-------------------------------------------------------------------------------- |
| 195 |
Warnings: |
| 196 |
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. |