📄 func_view.inc
字号:
# 3.20. LENGTH(str)let $col_type= my_char_30;eval SET @my_select = 'SELECT LENGTH($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_varchar_1000;eval SET @my_select = 'SELECT LENGTH($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_binary_30;eval SET @my_select = 'SELECT LENGTH($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_varbinary_1000;eval SET @my_select = 'SELECT LENGTH($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inc# 3.21. LOAD_FILE(file_name)# Reads the file and returns the file contents as a string.# If the file doesn't exist or cannot be read ... ,# the function returns NULL.# SELECT LOADFILE--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>eval SET @my_select ='SELECT LOAD_FILE(''$MYSQLTEST_VARDIR/std_data_ln/funcs_1/load_file.txt'') AS my_col, id FROM t1_values';--source suite/funcs_1/views/fv1.inc# 3.22. LOCATE(substr,str) , LOCATE(substr,str,pos)let $col_type= my_char_30;eval SET @my_select = 'SELECT LOCATE(''char'', $col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_varchar_1000;eval SET @my_select = 'SELECT LOCATE(''char'', $col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_binary_30;eval SET @my_select = 'SELECT LOCATE(''char'', $col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_varbinary_1000;eval SET @my_select = 'SELECT LOCATE(''char'', $col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inc#------------------------------------------------------let $col_type1= my_char_30;# against all othereval SET @my_select = 'SELECT LOCATE($col_type1, $col_type1 ),$col_type1, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_varchar_1000;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_binary_30;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_varbinary_1000;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inc#------------------------------------------------------let $col_type1= my_varchar_1000;# against all othereval SET @my_select = 'SELECT LOCATE($col_type1, $col_type1 ),$col_type1, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_char_30;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_binary_30;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_varbinary_1000;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inc#------------------------------------------------------let $col_type1= my_binary_30;# against all othereval SET @my_select = 'SELECT LOCATE($col_type1, $col_type1 ),$col_type1, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_char_30;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_varchar_1000;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_varbinary_1000;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inc#------------------------------------------------------let $col_type1= my_varbinary_1000;# against all othereval SET @my_select = 'SELECT LOCATE($col_type1, $col_type1 ),$col_type1, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_char_30;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_varchar_1000;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type2= my_binary_30;eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),$col_type1, $col_type2 id FROM t1_values';--source suite/funcs_1/views/fv2.inc# FIXME How to test exotic or interesting substr values like NULL, '', ' '# without getting too much result rows# FIXME Testcases with LOCATE(substr,str,pos)let $col_type= my_char_30;eval SET @my_select = 'SELECT LOCATE(''-'', $col_type, 3),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_varchar_1000;eval SET @my_select = 'SELECT LOCATE(''-'', $col_type, 3),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_binary_30;eval SET @my_select = 'SELECT LOCATE(''-'', $col_type, 3),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_varbinary_1000;eval SET @my_select = 'SELECT LOCATE(''-'', $col_type, 3),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inc#--------------------------------------------------------let $col_type= my_bigint;eval SET @my_select = 'SELECT LOCATE(''-'', '' - -ABC'', $col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_double;eval SET @my_select = 'SELECT LOCATE(''-'', '' - -ABC'', $col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_decimal;eval SET @my_select = 'SELECT LOCATE(''-'', '' - -ABC'', $col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inc# 3.23. LOWER(str)let $col_type= my_char_30;eval SET @my_select = 'SELECT LOWER($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_varchar_1000;eval SET @my_select = 'SELECT LOWER($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_binary_30;eval SET @my_select = 'SELECT LOWER($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_varbinary_1000;eval SET @my_select = 'SELECT LOWER($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inc# 3.24. LPAD(str,len,padstr)# 3.25. LTRIM(str)let $col_type= my_char_30;eval SET @my_select = 'SELECT LTRIM($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_varchar_1000;eval SET @my_select = 'SELECT LTRIM($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_binary_30;eval SET @my_select = 'SELECT LTRIM($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inclet $col_type= my_varbinary_1000;eval SET @my_select = 'SELECT LTRIM($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inc# 3.26. MAKE_SET(bits,str1,str2,...)# .....# FIXME: to be implemented################################################################################# Please do not add SELECTs and interesting records after this line. ## These last SELECTs are mostly for checking the testcase code itself. #################################################################################eval SET @my_select = 'SELECT CONCAT(''A'',my_char_30), my_char_30, id FROM t1_values'; #--source suite/funcs_1/views/fv1.inc#eval SET @my_select = 'SELECT my_char_30, id FROM t1_values'; #--source suite/funcs_1/views/fv2.inceval INSERT INTO t1_values SET select_id = @select_id, my_char_30 = 'Viana do Castelo';################################################################################SET sql_mode = ''; ###### END Basic preparations #######################################let $message= "# The basic preparations end and the main test starts here";--source include/show_msg80.inc--disable_ps_protocol##### The tests start here ###################################################### Determine the number of different SELECTs to be checked--disable_query_logSELECT COUNT(*) INTO @num_selects FROM t1_selects;--enable_query_log# Debug statement# SELECT @num_selects AS "number of SELECTS:";--disable_abort_on_errorlet $select_id= `SELECT @num_selects`;while ($select_id){ # Determine the SELECT --disable_query_log eval SELECT my_select, disable_result INTO @my_select, @disable_result FROM t1_selects WHERE id = $select_id; let $run_no_result= `SELECT @disable_result = 'Yes'`; --enable_query_log # Debug statement # SELECT @my_select AS "SELECT:"; let $my_select= `SELECT @my_select`; let $run0= 0; if ($view_select_result) { # Create the VIEW --replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> eval CREATE VIEW v1 AS $my_select; --disable_query_log eval set @got_errno= $mysql_errno ; let $run0= `SELECT @got_errno = 0`; --enable_query_log if (!$run0) { --echo --echo Attention: The last CREATE VIEW failed --echo } } # FIXME The loop over the modes will start here. if ($simple_select_result) { # Simple SELECT on the base table of the VIEW for comparison if ($run_no_result) { --disable_result_log } --replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> eval $my_select WHERE select_id = $select_id OR select_id IS NULL order by id; if ($run_no_result) { --enable_result_log } if ($mysql_errno) { --echo --echo Attention: The last SELECT on the base table failed --echo } } # $run0 is 1, if CREATE VIEW was successful. # That means SHOW CREATE VIEW/SELECT/DROP should be executed. if ($run0) { # Check the CREATE VIEW statement --replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR> SHOW CREATE VIEW v1; if ($mysql_errno) { --echo --echo Attention: The last SHOW CREATE VIEW failed --echo } # Maybe a Join is faster if ($run_no_result) { --disable_result_log } eval SELECT v1.* FROM v1 WHERE v1.id IN (SELECT id FROM t1_values WHERE select_id = $select_id OR select_id IS NULL) order by id; if ($run_no_result) { --enable_result_log } if ($mysql_errno) { --echo --echo Attention: The last SELECT from VIEW failed --echo } DROP VIEW v1; } # FIXME The loop over the modes will end here. # Produce two empty lines as separator between different SELECTS # to be tested. --echo --echo dec $select_id ;}--enable_ps_protocolDROP TABLE t1_selects, t1_modes, t1_values;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -