📄 crash-me
字号:
"number", "long","raw(16)","long raw","rowid","mlslabel","clob", "nclob","bfile" );@types=(["sql",\@sql_types], ["odbc",\@odbc_types], ["extra",\@extra_types]);foreach $types (@types){ print "\nSupported $types->[0] types\n"; $tmp=@$types->[1]; foreach $use_type (@$tmp) { $type=$use_type; $type =~ s/\(.*\)/(1 arg)/; if (index($use_type,",")>= 0) { $type =~ s/\(1 arg\)/(2 arg)/; } if (($tmp2=index($type,",unique")) >= 0) { $type=substr($type,0,$tmp2); } $tmp2=$type; $tmp2 =~ s/ /_/g; $tmp2 =~ s/_not_null//g; report("Type $type","type_$types->[0]_$tmp2", "create table crash_q (q $use_type)", "drop table crash_q $drop_attr"); }}## Test some type limits#check_and_report("Remembers end space in char()","remember_end_space", ["create table crash_q (a char(10))", "insert into crash_q values('hello ')"], "select a from crash_q where a = 'hello '", ["drop table crash_q $drop_attr"], 'hello ',6);check_and_report("Remembers end space in varchar()", "remember_end_space_varchar", ["create table crash_q (a varchar(10))", "insert into crash_q values('hello ')"], "select a from crash_q where a = 'hello '", ["drop table crash_q $drop_attr"], 'hello ',6);if (($limits{'type_extra_float(2_arg)'} eq "yes" || $limits{'type_sql_decimal(2_arg)'} eq "yes") && (!defined($limits{'storage_of_float'}))){ my $type=$limits{'type_extra_float(2_arg)'} eq "yes" ? "float(4,1)" : "decimal(4,1)"; my $result="undefined"; if (execute_and_check("storage_of_float",["create table crash_q (q1 $type)", "insert into crash_q values(1.14)"], "select q1 from crash_q", ["drop table crash_q $drop_attr"],1.1,0) && execute_and_check("storage_of_float",["create table crash_q (q1 $type)", "insert into crash_q values(1.16)"], "select q1 from crash_q", ["drop table crash_q $drop_attr"],1.1,0)) { $result="truncate"; } elsif (execute_and_check("storage_of_float",["create table crash_q (q1 $type)", "insert into crash_q values(1.14)"], "select q1 from crash_q", ["drop table crash_q $drop_attr"],1.1,0) && execute_and_check("storage_of_float",["create table crash_q (q1 $type)", "insert into crash_q values(1.16)"], "select q1 from crash_q", ["drop table crash_q $drop_attr"],1.2,0)) { $result="round"; } elsif (execute_and_check("storage_of_float",["create table crash_q (q1 $type)", "insert into crash_q values(1.14)"], "select q1 from crash_q", ["drop table crash_q $drop_attr"],1.14,0) && execute_and_check("storage_of_float",["create table crash_q (q1 $type)", "insert into crash_q values(1.16)"], "select q1 from crash_q", ["drop table crash_q $drop_attr"],1.16,0)) { $result="exact"; } $prompt="Storage of float values"; print "$prompt: $result\n"; save_config_data("storage_of_float", $result, $prompt);}try_and_report("Type for row id", "rowid", ["rowid", "create table crash_q (a rowid)", "drop table crash_q $drop_attr"], ["auto_increment", "create table crash_q (a int not null auto_increment". ", primary key(a))","drop table crash_q $drop_attr"], ["oid", "create table crash_q (a oid, primary key(a))", "drop table crash_q $drop_attr"], ["serial", "create table crash_q (a serial, primary key(a))", "drop table crash_q $drop_attr"]);try_and_report("Automatic row id", "automatic_rowid", ["_rowid", "create table crash_q (a int not null, primary key(a))", "insert into crash_q values (1)", "select _rowid from crash_q", "drop table crash_q $drop_attr"]);## Test functions#@sql_functions= (["+, -, * and /","+","5*3-4/2+1",14,0], ["ANSI SQL SUBSTRING","substring","substring('abcd' from 2 for 2)","bc",1], ["BIT_LENGTH","bit_length","bit_length('abc')",24,0], ["searched CASE","searched_case", "case when 1 > 2 then 'false' when 2 > 1 then 'true' end", "true",1], ["simple CASE","simple_case", "case 2 when 1 then 'false' when 2 then 'true' end", "true",1], ["CAST","cast","CAST(1 as CHAR)","1",1], ["CHARACTER_LENGTH","character_length","character_length('abcd')","4",0], ["CHAR_LENGTH","char_length","char_length(b)","10",0], ["CHAR_LENGTH(constant)","char_length(constant)", "char_length('abcd')","4",0], ["COALESCE","coalesce","coalesce($char_null,'bcd','qwe')","bcd",1], ["CURRENT_DATE","current_date","current_date",0,2], ["CURRENT_TIME","current_time","current_time",0,2], ["CURRENT_TIMESTAMP","current_timestamp","current_timestamp",0,2], ["EXTRACT","extract_sql", "extract(minute from timestamp '2000-02-23 18:43:12.987')",43,0], ["LOCALTIME","localtime","localtime",0,2], ["LOCALTIMESTAMP","localtimestamp","localtimestamp",0,2], ["LOWER","lower","LOWER('ABC')","abc",1], ["NULLIF with strings","nullif_string", "NULLIF(NULLIF('first','second'),'first')",undef(),4], ["NULLIF with numbers","nullif_num","NULLIF(NULLIF(1,2),1)",undef(),4], ["OCTET_LENGTH","octet_length","octet_length('abc')",3,0], ["POSITION","position","position('ll' in 'hello')",3,0], ["TRIM","trim","trim(trailing from trim(LEADING FROM ' abc '))","abc",3], ["UPPER","upper","UPPER('abc')","ABC",1], ["concatenation with ||","concat_as_||","'abc' || 'def'","abcdef",1], );@odbc_functions= (["ASCII", "ascii", "ASCII('A')","65",0], ["CHAR", "char", "CHAR(65)" ,"A",1], ["CONCAT(2 arg)","concat", "concat('a','b')","ab",1], ["DIFFERENCE()","difference","difference('abc','abe')",3,0], ["INSERT","insert","insert('abcd',2,2,'ef')","aefd",1], ["LEFT","left","left('abcd',2)","ab",1], ["LTRIM","ltrim","ltrim(' abcd')","abcd",1], ["REAL LENGTH","length","length('abcd ')","5",0], ["ODBC LENGTH","length_without_space","length('abcd ')","4",0], ["LOCATE(2 arg)","locate_2","locate('bcd','abcd')","2",0], ["LOCATE(3 arg)","locate_3","locate('bcd','abcd',3)","0",0], ["LCASE","lcase","lcase('ABC')","abc",1], ["REPEAT","repeat","repeat('ab',3)","ababab",1], ["REPLACE","replace","replace('abbaab','ab','ba')","bababa",1], ["RIGHT","right","right('abcd',2)","cd",1], ["RTRIM","rtrim","rtrim(' abcd ')"," abcd",1], ["SPACE","space","space(5)"," ",3], ["SOUNDEX","soundex","soundex('hello')",0,2], ["ODBC SUBSTRING","substring","substring('abcd',3,2)","cd",1], ["UCASE","ucase","ucase('abc')","ABC",1], ["ABS","abs","abs(-5)",5,0], ["ACOS","acos","acos(0)","1.570796",0], ["ASIN","asin","asin(1)","1.570796",0], ["ATAN","atan","atan(1)","0.785398",0], ["ATAN2","atan2","atan2(1,0)","1.570796",0], ["CEILING","ceiling","ceiling(-4.5)",-4,0], ["COS","cos","cos(0)","1.00000",0], ["COT","cot","cot(1)","0.64209262",0], ["DEGREES","degrees","degrees(6.283185)","360",0], ["EXP","exp","exp(1.0)","2.718282",0], ["FLOOR","floor","floor(2.5)","2",0], ["LOG","log","log(2)","0.693147",0], ["LOG10","log10","log10(10)","1",0], ["MOD","mod","mod(11,7)","4",0], ["PI","pi","pi()","3.141593",0], ["POWER","power","power(2,4)","16",0], ["RAND","rand","rand(1)",0,2], # Any value is acceptable ["RADIANS","radians","radians(360)","6.283185",0], ["ROUND(2 arg)","round","round(5.63,2)","5.6",0], ["SIGN","sign","sign(-5)",-1,0], ["SIN","sin","sin(1)","0.841471",0], ["SQRT","sqrt","sqrt(4)",2,0], ["TAN","tan","tan(1)","1.557408",0], ["TRUNCATE","truncate","truncate(18.18,-1)",10,0], ["NOW","now","now()",0,2], # Any value is acceptable ["CURDATE","curdate","curdate()",0,2], ["CURTIME","curtime","curtime()",0,2], ["TIMESTAMPADD","timestampadd", "timestampadd(SQL_TSI_SECOND,1,'1997-01-01 00:00:00')", "1997-01-01 00:00:01",1], ["TIMESTAMPDIFF","timestampdiff", "timestampdiff(SQL_TSI_SECOND,'1997-01-01 00:00:02',". " '1997-01-01 00:00:01')","1",0], ["USER()","user()","user()",0,2], ["DATABASE","database","database()",0,2], ["IFNULL","ifnull","ifnull(2,3)",2,0], ["ODBC syntax LEFT & RIGHT", "fn_left", "{ fn LEFT( { fn RIGHT('abcd',2) },1) }","c",1], );@extra_functions= ( ["& (bitwise and)",'&',"5 & 3",1,0], ["| (bitwise or)",'|',"1 | 2",3,0], ["<< and >> (bitwise shifts)",'binary_shifts',"(1 << 4) >> 2",4,0], ["<> in SELECT","<>","1<>1","0",0], ["=","=","(1=1)",1,$logical_value], ["~* (case insensitive compare)","~*","'hi' ~* 'HI'",1,$logical_value], ["AND and OR in SELECT","and_or","1=1 AND 2=2",$logical_value,0], ["AND as '&&'",'&&',"1=1 && 2=2",$logical_value,0], ["ASCII_CHAR", "ascii_char", "ASCII_CHAR(65)","A",1], ["ASCII_CODE", "ascii_code", "ASCII_CODE('A')","65",0], ["ATN2","atn2","atn2(1,0)","1.570796",0], ["BETWEEN in SELECT","between","5 between 4 and 6",$logical_value,0], ["BIT_COUNT","bit_count","bit_count(5)",2,0], ["CEIL","ceil","ceil(-4.5)",-4,0], # oracle ["CHARINDEX","charindex","charindex('a','crash')",3,0], ["CHR", "chr", "CHR(65)" ,"A",1], # oracle ["CONCAT(list)","concat_list", "concat('a','b','c','d')","abcd",1], ["CONVERT","convert","convert(CHAR,5)","5",1], ["COSH","cosh","cosh(0)","1",0], # oracle hyperbolic cosine of n. ["ELT","elt","elt(2,'ONE','TWO','THREE')","TWO",1], ["ENCRYPT","encrypt","encrypt('hello')",0,2], ["FIELD","field","field('IBM','NCA','ICL','SUN','IBM','DIGITAL')",4,0], ["FORMAT","format","format(1234.5555,2)","1,234.56",1], ["GETDATE","getdate","getdate()",0,2], ["GREATEST","greatest","greatest('HARRY','HARRIOT','HAROLD')","HARRY",1], ["IF","if", "if(5,6,7)",6,0], ["IN on numbers in SELECT","in_num","2 in (3,2,5,9,5,1)",$logical_value,0], ["IN on strings in SELECT","in_str","'monty' in ('david','monty','allan')", $logical_value,0], ["INITCAP","initcap","initcap('the soap')","The Soap",1], # oracle Returns char, with the first letter of each word in uppercase ["INSTR (Oracle syntax)", "instr_oracle", "INSTR('CORPORATE FLOOR','OR',3,2)" ,"14",0], # oracle instring ["INSTRB", "instrb", "INSTRB('CORPORATE FLOOR','OR',5,2)" ,"27",0], # oracle instring in bytes ["INTERVAL","interval","interval(55,10,20,30,40,50,60,70,80,90,100)",5,0], ["LAST_INSERT_ID","last_insert_id","last_insert_id()",0,2], ["LEAST","least","least('HARRY','HARRIOT','HAROLD')","HAROLD",1], # oracle ["LENGTHB","lengthb","lengthb('CANDIDE')","14",0], # oracle length in bytes ["LIKE ESCAPE in SELECT","like_escape", "'%' like 'a%' escape 'a'",$logical_value,0], ["LIKE in SELECT","like","'a' like 'a%'",$logical_value,0], ["LN","ln","ln(95)","4.55387689",0], # oracle natural logarithm of n ["LOCATE as INSTR","instr","instr('hello','ll')",3,0], ["LOG(m,n)","log(m_n)","log(10,100)","2",0], # oracle logarithm, base m, of n ["LOGN","logn","logn(2)","0.693147",0], # informix ["LPAD","lpad","lpad('hi',4,'??')",'??hi',3], ["MOD as %","%","10%7","3",0], ["NOT BETWEEN in SELECT","not_between","5 not between 4 and 6",0,0], ["NOT LIKE in SELECT","not_like","'a' not like 'a%'",0,0], ["NOT as '!' in SELECT","!","! 1",0,0], ["NOT in SELECT","not","not $false",$logical_value,0], ["ODBC CONVERT","odbc_convert","convert(5,SQL_CHAR)","5",1], ["OR as '||'",'||',"1=0 || 1=1",$logical_value,0], ["PASSWORD","password","password('hello')",0,2], ["PASTE", "paste", "paste('ABCDEFG',3,2,'1234')","AB1234EFG",1], ["PATINDEX","patindex","patindex('%a%','crash')",3,0], ["POW","pow","pow(3,2)",9,0], ["RANGE","range","range(a)","0.0",0], # informix range(a) = max(a) - min(a) ["REGEXP in SELECT","regexp","'a' regexp '^(a|b)*\$'",$logical_value,0], ["REPLICATE","replicate","replicate('a',5)","aaaaa",1], ["REVERSE","reverse","reverse('abcd')","dcba",1], ["ROOT","root","root(4)",2,0], # informix ["ROUND(1 arg)","round1","round(5.63)","6",0], ["RPAD","rpad","rpad('hi',4,'??')",'hi??',3], ["SINH","sinh","sinh(1)","1.17520119",0], # oracle hyperbolic sine of n ["STR","str","str(123.45,5,1)",123.5,3], ["STRCMP","strcmp","strcmp('abc','adc')",-1,0], ["STUFF","stuff","stuff('abc',2,3,'xyz')",'axyz',3], ["SUBSTRB", "substrb", "SUBSTRB('ABCDEFG',5,4.2)" ,"CD",1], # oracle substring with bytes ["SUBSTRING as MID","mid","mid('hello',3,2)","ll",1], ["SUBSTRING_INDEX","substring_index", "substring_index('www.tcx.se','.',-2)", "tcx.se",1], ["SYSDATE","sysdate","sysdate()",0,2], ["TAIL","tail","tail('ABCDEFG',3)","EFG",0], ["TANH","tanh","tanh(1)","0.462117157",0], # oracle hyperbolic tangent of n ["TRANSLATE","translate","translate('abc','bc','de')",'ade',3], ["TRIM; Many char extension", "trim_many_char","trim(':!' FROM ':abc!')","abc",3], ["TRIM; Substring extension", "trim_substring","trim('cb' FROM 'abccb')","abc",3], ["TRUNC","trunc","trunc(18.18,-1)",10,0], # oracle ["UID","uid","uid",0,2], # oracle uid from user ["UNIX_TIMESTAMP","unix_timestamp","unix_timestamp()",0,2], ["USERENV","userenv","userenv",0,2], # oracle user enviroment ["VERSION","version","version()",0,2], ["automatic num->string convert","auto_num2string","concat('a',2)","a2",1], ["automatic string->num convert","auto_string2num","'1'+2",3,0], ["concatenation with +","concat_as_+","'abc' + 'def'","abcdef",1], ["SUBSTR (2 arg)",'substr2arg',"substr('abcd',2)",'bcd',1], #sapdb func ["SUBSTR (3 arg)",'substr3arg',"substr('abcd',2,2)",'bc',1], ["LFILL (3 arg)",'lfill3arg',"lfill('abcd','.',6)",'..abcd',1], ["RFILL (3 arg)",'rfill3arg',"rfill('abcd','.',6)",'abcd..',1], ["RPAD (4 arg)",'rpad4arg',"rpad('abcd',2,'+-',8)",'abcd+-+-',1], ["LPAD (4 arg)",'rpad4arg',"lpad('abcd',2,'+-',8)",'+-+-abcd',1], ["TRIM (1 arg)",'trim1arg',"trim(' abcd ')",'abcd',1], ["TRIM (2 arg)",'trim2arg',"trim('..abcd..','.')",'abcd',1], ["LTRIM (2 arg)",'ltrim2arg',"ltrim('..abcd..','.')",'abcd..',1], ["RTRIM (2 arg)",'rtrim2arg',"rtrim('..abcd..','.')",'..abcd',1], ["EXPAND",'expand2arg',"expand('abcd',6)",'abcd ',0], ["REPLACE (2 arg) ",'replace2arg',"replace('AbCd','bC')",'Ad',1], ["MAPCHAR",'mapchar',"mapchar('A
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -