📄 func_view.inc
字号:
#let $message="Attention: CAST --> UNSIGNED INTEGER The file with expected results suffers from Bug 5913";--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.inclet $message= some statements disabled because ofBug#5913 Traditional mode: BIGINT range not correctly delimited;--source include/show_msg80.inc# Bug#8663 cant use bgint unsigned as input to castlet $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.2. BINARY# Manual: BINARY str is a shorthand for CAST(str AS BINARY).# Therefore we do not test it here in the moment.# FIXME: Add testcases for str in CHAR and VARCHAR only.# 1.3 CONVERT(expr USING transcoding_name)## 1.3.1 CONVERT(expr USING utf8)let $target_charset= utf8;#let $col_type= my_char_30;eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_varchar_1000;eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_binary_30;eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_varbinary_1000;eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inc## 1.3.2 CONVERT(expr USING koi8r)let $target_charset= koi8r;let $col_type= my_char_30;eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_varchar_1000;eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_binary_30;eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_varbinary_1000;eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inc# 2. Control Flow Functions# 2.1. CASE value WHEN [compare-value] THEN result [WHEN ...] [ELSE result]# END or# CASE WHEN [condition] THEN result [WHEN ...] [ELSE result] END## FIXME: to be implemented## 2.2. IF(expr1,expr2,expr3)# expr1 is TRUE when (expr1 <> 0 and expr1 <> NULL) is fulfilled## 2.2.1 IF(expr1,expr2,expr3) with expr1 = <column>## Note(mleich): Strings, which do not contain a number -> FALSE## suite/funcs_1/views/fv_if1.inc contains# SELECT IF($col_type, 'IS TRUE', 'IS NOT TRUE'), ...#let $col_type= my_char_30;--source suite/funcs_1/views/fv_if1.inc#let $col_type= my_varchar_1000;--source suite/funcs_1/views/fv_if1.inc#let $col_type= my_binary_30;--source suite/funcs_1/views/fv_if1.inc#let $col_type= my_varbinary_1000;--source suite/funcs_1/views/fv_if1.inc#let $col_type= my_bigint;--source suite/funcs_1/views/fv_if1.inc#let $col_type= my_decimal;--source suite/funcs_1/views/fv_if1.inc#let $col_type= my_double;--source suite/funcs_1/views/fv_if1.inc#let $col_type= my_datetime;--source suite/funcs_1/views/fv_if1.inc#let $col_type= my_date;--source suite/funcs_1/views/fv_if1.inc#let $col_type= my_timestamp;--source suite/funcs_1/views/fv_if1.inc#let $col_type= my_time;--source suite/funcs_1/views/fv_if1.inc#let $col_type= my_year;--source suite/funcs_1/views/fv_if1.inc# 2.2.2 IF(expr1,expr2,expr3) with expr1 != <column>## suite/funcs_1/views/fv_if2.inc contains# SELECT IF($col_type IS NULL, 'IS NULL', 'IS NOT NULL'), ...## Note(mleich): July 2005# IF($col_type IS NULL, ...) is mapped to a VIEW definition# create ... view ... as# select if(isnull(`test`.`t1`.`f1`),_latin1'IS NULL',# _latin1'IS NOT NULL'),...## Bug#11689 success on Create view .. IF(col1 IS NULL,...), col2 ; but SELECT failslet $col_type= my_char_30;--source suite/funcs_1/views/fv_if2.inc#let $col_type= my_varchar_1000;--source suite/funcs_1/views/fv_if2.inc#let $col_type= my_binary_30;--source suite/funcs_1/views/fv_if2.inc#let $col_type= my_varbinary_1000;--source suite/funcs_1/views/fv_if2.inc#let $col_type= my_bigint;--source suite/funcs_1/views/fv_if2.inc#let $col_type= my_decimal;--source suite/funcs_1/views/fv_if2.inc#let $col_type= my_double;--source suite/funcs_1/views/fv_if2.inc#let $col_type= my_datetime;--source suite/funcs_1/views/fv_if2.inc#let $col_type= my_date;--source suite/funcs_1/views/fv_if2.inc#let $col_type= my_timestamp;--source suite/funcs_1/views/fv_if2.inc#let $col_type= my_time;--source suite/funcs_1/views/fv_if2.inc#let $col_type= my_year;--source suite/funcs_1/views/fv_if2.inc# 2.3. IFNULL(expr1,expr2)# If expr1 is not NULL, IFNULL() returns expr1, else it returns expr2.## suite/funcs_1/views/fv_ifnull.inc contains# SELECT IFNULL($col_type, 'IS_NULL'), ....# FIXME: The mixup of non string column values# and the string 'IS NULL' within the first column of the# result table is extreme ugly.# CAST(IFNULL($col_type, 'IS_NULL') AS CHAR) looks better, but# it has the disadvantage, that it involves CAST as additional# function.#let $col_type= my_char_30;--source suite/funcs_1/views/fv_ifnull.inc#let $col_type= my_varchar_1000;--source suite/funcs_1/views/fv_ifnull.inc#let $col_type= my_binary_30;--source suite/funcs_1/views/fv_ifnull.inc#let $col_type= my_varbinary_1000;--source suite/funcs_1/views/fv_ifnull.inc#let $col_type= my_bigint;--source suite/funcs_1/views/fv_ifnull.inc#let $col_type= my_decimal;--source suite/funcs_1/views/fv_ifnull.inc#let $col_type= my_double;--source suite/funcs_1/views/fv_ifnull.inc#let $col_type= my_datetime;--source suite/funcs_1/views/fv_ifnull.inc#let $col_type= my_date;--source suite/funcs_1/views/fv_ifnull.inc#let $col_type= my_timestamp;--source suite/funcs_1/views/fv_ifnull.inc#let $col_type= my_time;--source suite/funcs_1/views/fv_ifnull.inc#let $col_type= my_year;--source suite/funcs_1/views/fv_ifnull.inc# 2.4. NULLIF(expr1,expr2)# Returns NULL if expr1 = expr2 is true, else returns expr1.# This is the same as# CASE WHEN expr1 = expr2 THEN NULL ELSE expr1 END.## FIXME: to be implemented## 3. String Functions# 3.1. ASCII(str)# 3.2. BIN(N)# FIXME: to be implemented## 3.3. BIT_LENGTH(str)# Returns the length of the string str in bits.#let $col_type= my_char_30;eval SET @my_select = 'SELECT BIT_LENGTH($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_varchar_1000;eval SET @my_select = 'SELECT BIT_LENGTH($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_binary_30;eval SET @my_select = 'SELECT BIT_LENGTH($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_varbinary_1000;eval SET @my_select = 'SELECT BIT_LENGTH($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inc# 3.4. CHAR(N,...)# 3.5. CHAR_LENGTH(str)# 3.6 CHARACTER_LENGTH(str)# CHARACTER_LENGTH() is a synonym for CHAR_LENGTH().# 3.7. COMPRESS(string_to_compress)# 3.8. CONCAT(str1,str2,...)# 3.9. CONCAT_WS(separator,str1,str2,...)# 3.10. CONV(N,from_base,to_base)# 3.11. ELT(N,str1,str2,str3,...)# 3.12. EXPORT_SET(bits,on,off[,separator[,number_of_bits]])# 3.13. FIELD(str,str1,str2,str3,...)# 3.14. FIND_IN_SET(str,strlist)# 3.15. HEX(N_or_S# 3.16. INSERT(str,pos,len,newstr)# 3.17. INSTR(str,substr)# This is the same as the two-argument form of LOCATE(),# except that the arguments are swapped.# The majority of the testcases should be made with LOCATE().# Therefore test only one example here.let $col_type= my_char_30;eval SET @my_select = 'SELECT INSTR($col_type, ''char''),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inc# 3.18. LCASE(str)# LCASE() is a synonym for LOWER().# The majority of the testcases should be made with LOWER().# Therefore test only one example here.let $col_type= my_varchar_1000;eval SET @my_select = 'SELECT LCASE($col_type),$col_type, id FROM t1_values';--source suite/funcs_1/views/fv2.inc# 3.19. LEFT(str,len)# Returns the leftmost len characters from the string str.let $col_type= my_char_30;eval SET @my_select ='SELECT LEFT($col_type, 2), $col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_varchar_1000;eval SET @my_select ='SELECT LEFT($col_type, 2), $col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_binary_30;eval SET @my_select ='SELECT LEFT($col_type, 2), $col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_varbinary_1000;eval SET @my_select ='SELECT LEFT($col_type, 2), $col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inc# Bug#11728 string function LEFT, strange undocumented behaviour, strict mode# Bug#10963 LEFT string function returns wrong result with large lengthlet $col_type= my_bigint;eval SET @my_select ='SELECT LEFT(''AaBbCcDdEeFfGgHhIiJjÄäÜüÖö'', $col_type), $col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inclet $col_type= my_decimal;eval SET @my_select ='SELECT LEFT(''AaBbCcDdEeFfGgHhIiJjÄäÜüÖö'', $col_type), $col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inc# Bug#10963 LEFT string function returns wrong result with large lengthlet $col_type= my_double;eval SET @my_select ='SELECT LEFT(''AaBbCcDdEeFfGgHhIiJjÄäÜüÖö'', $col_type), $col_type, id FROM t1_values';--source suite/funcs_1/views/fv1.inc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -