📄 func_view.inc
字号:
# eval SET @my_select =# '<your SELECT>';# --source suite/funcs_1/views/fv1.inc# fv1.inc sets t1_selects.disable_result to 'No' and the effect will be,# that the result set will be logged.## If you do not have the time to check the result sets do the insert of the# SELECT with function via:# eval SET @my_select =# '<your SELECT>';# --source suite/funcs_1/views/fv2.inc# fv2.inc sets t1_selects.disable_result to 'Yes' and the effect will be,# that the result set will be not logged.# This should be only a temporary solution and it does not remove the# need to check the server return codes.# That means even when we do not have the time to check the correctness of# the result sets, we check if# - SELECT <function> or# - SELECT * FROM <VIEW with function># crash the server or get suspicious server responses.## - the SELECTs will be applied to the rows defined here (3.) +# all predefined rows (2.)# - the rows dedicated to the SELECT should contain especially interesting# column values or combinations of column values, which are not covered# by the predefined records# - The records have to be inserted when sql_mode = 'traditional' is valid.# - Please do not insert records with column values where the allowed# range is exceeded. The SQL mode 'traditional' will prevent such# inserts. Such experiments should be done in other tests, because# they inflate the current test without giving an appropriate value.## Example:# The function to be tested is "sqrt".# The minimum, maximum, default and NULL value are covered by the# predefined rows.# A value where sqrt(<value>) = <integer value> in strict mathematics# would be of interest.# --> Add a record with my_bigint = 4# --> Just for fun my_bigint = -25 .## Some internal stuffPREPARE ins_sel_with_result FROM "INSERT INTO t1_selects SET my_select = @my_select,disable_result = 'No'" ;PREPARE ins_sel_no_result FROM "INSERT INTO t1_selects SET my_select = @my_select,disable_result = 'Yes'" ;SET sql_mode = 'traditional';# --disable_query_loglet $col_type= my_bigint;# Example:# eval SET @my_select = 'SELECT CONCAT(''A'', $col_type), $col_type, id';eval SET @my_select = 'SELECT sqrt($col_type), $col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inc# Content of suite/funcs_1/views/fv1.inc :# --disable_query_log# EXECUTE ins_sel_with_result;# SET @select_id = LAST_INSERT_ID();# --enable_query_logeval INSERT INTO t1_values SET select_id = @select_id, $col_type = 4;eval INSERT INTO t1_values SET select_id = @select_id, $col_type = -25;# SELECT * FROM t1_values;# 1. Cast Functions and Operators# 1.1 CAST## Note(mleich): I guess the CAST routines are used in many other functions.# Therefore check also nearly all "ugly" variants like# CAST(<string composed of non digits> AS DECIMAL) here.## suite/funcs_1/views/fv_cast.inc contains# SELECT CAST($col_type AS $target_type), ...### 1.1.1. CAST --> BINARY--echo ##### 1.1.1. CAST --> BINARYlet $target_type= BINARY;#let $col_type= my_char_30;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_varchar_1000;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_binary_30;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_varbinary_1000;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_bigint;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_decimal;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_double;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_datetime;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_date;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_timestamp;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_time;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_year;--source suite/funcs_1/views/fv_cast.inc# 1.1.2. CAST --> CHAR--echo ##### 1.1.2. CAST --> CHARlet $target_type= CHAR;#let $col_type= my_char_30;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_varchar_1000;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_binary_30;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_varbinary_1000;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_bigint;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_decimal;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_double;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_datetime;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_date;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_timestamp;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_time;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_year;--source suite/funcs_1/views/fv_cast.inc# 1.1.3. CAST --> DATE--echo ##### 1.1.3. CAST --> DATElet $target_type= DATE;#let $col_type= my_char_30;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '2005-06-27';let $col_type= my_varchar_1000;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '2005-06-27';let $col_type= my_binary_30;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '2005-06-27';let $col_type= my_varbinary_1000;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '2005-06-27';let $col_type= my_bigint;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = 20050627;let $col_type= my_double;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = +20.050627E+6;let $col_type= my_datetime;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_date;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_timestamp;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_time;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_year;--source suite/funcs_1/views/fv_cast.inc# 1.1.4. CAST --> DATETIME--echo ##### 1.1.4. CAST --> DATETIMElet $target_type= DATETIME;#let $col_type= my_char_30;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '2005-06-27 17:58';let $col_type= my_varchar_1000;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '2005-06-27 17:58';let $col_type= my_binary_30;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '2005-06-27 17:58';let $col_type= my_varbinary_1000;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '2005-06-27 17:58';let $col_type= my_bigint;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = 200506271758;let $col_type= my_double;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = +0.0200506271758E+13;let $col_type= my_datetime;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_date;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_timestamp;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_time;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_year;--source suite/funcs_1/views/fv_cast.inc# 1.1.5. CAST --> TIME--echo ##### 1.1.5. CAST --> TIMElet $target_type= TIME;#let $col_type= my_char_30;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '1 17:58';let $col_type= my_varchar_1000;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '1 17:58';let $col_type= my_binary_30;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '1 17:58';let $col_type= my_varbinary_1000;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '1 17:58';let $col_type= my_bigint;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = 1758;let $col_type= my_double;# Bug#12440: CAST(data type DOUBLE AS TIME) strange results;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = +1.758E+3;let $col_type= my_datetime;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_date;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_timestamp;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_time;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_year;--source suite/funcs_1/views/fv_cast.inc# 1.1.6. CAST --> DECIMAL--echo ##### 1.1.6. CAST --> DECIMAL# Set the following to (37,2) since the default was changed to (10,0) - OBNlet $target_type= DECIMAL(37,2);#let $col_type= my_char_30;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '-3333.3333';let $col_type= my_varchar_1000;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '-3333.3333';let $col_type= my_binary_30;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '-3333.3333';let $col_type= my_varbinary_1000;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = '-3333.3333';let $col_type= my_bigint;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_decimal;--source suite/funcs_1/views/fv_cast.inc# Bug#13349: CAST(1.0E+300 TO DECIMAL) returns wrong result + diff little/big endian;let $col_type= my_double;--source suite/funcs_1/views/fv_cast.inceval INSERT INTO t1_values SET select_id = @select_id, $col_type = -0.33333333E+4;let $col_type= my_datetime;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_date;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_timestamp;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_time;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_year;--source suite/funcs_1/views/fv_cast.inc# 1.1.7. CAST --> SIGNED INTEGER--echo ##### 1.1.7. CAST --> SIGNED INTEGERlet $target_type= SIGNED INTEGER;#let $message="Attention: CAST --> SIGNED INTEGER Bug#5913 Traditional mode: BIGINT range not correctly delimited Status: To be fixed later";--source include/show_msg80.inclet $col_type= my_char_30;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_varchar_1000;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_binary_30;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_varbinary_1000;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_bigint;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_decimal;--source suite/funcs_1/views/fv_cast.inc# Bug #13344: CAST(1E+300 TO signed int) on little endian CPU, wrong result;let $col_type= my_double;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_datetime;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_date;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_timestamp;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_time;--source suite/funcs_1/views/fv_cast.inclet $col_type= my_year;--source suite/funcs_1/views/fv_cast.inc# 1.1.8. CAST --> UNSIGNED INTEGER--echo ##### 1.1.8. CAST --> UNSIGNED INTEGERlet $target_type= UNSIGNED INTEGER;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -