2
# Testing of misc functions
6
DROP TABLE IF EXISTS t1, t2;
9
select format(1.5555,0),format(123.5555,1),format(1234.5555,2),format(12345.55555,3),format(123456.5555,4),format(1234567.5555,5),format("12345.2399",2);
11
select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8'')));
13
# As we can assume we are the only user for the mysqld server, the difference
14
# between two calls should be -1
17
select cast(@a - @b as signed);
20
# Test for core dump with nan
22
select length(format('nan', 2)) > 0;
27
select concat("$",format(2500,2));
30
create table t1 ( a timestamp );
31
insert into t1 values ( '2004-01-06 12:34' );
32
select a from t1 where left(a+0,6) in ( left(20040106,6) );
33
select a from t1 where left(a+0,6) = ( left(20040106,6) );
35
select a from t1 where right(a+0,6) in ( right(20040106123400,6) );
36
select a from t1 where right(a+0,6) = ( right(20040106123400,6) );
38
select a from t1 where mid(a+0,6,3) in ( mid(20040106123400,6,3) );
39
select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) );
45
# Bug #21531: EXPORT_SET() doesn't accept args with coercible character sets
47
select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
49
--echo End of 4.1 tests
56
create table t1 as select uuid(), length(uuid());
62
# Bug #30832: Assertion + crash with select name_const('test',now());
64
--error ER_WRONG_ARGUMENTS
65
SELECT NAME_CONST('test', NOW());
66
--error ER_WRONG_ARGUMENTS
67
SELECT NAME_CONST('test', UPPER('test'));
69
SELECT NAME_CONST('test', NULL);
70
SELECT NAME_CONST('test', 1);
71
SELECT NAME_CONST('test', -1);
72
SELECT NAME_CONST('test', 1.0);
73
SELECT NAME_CONST('test', -1.0);
74
SELECT NAME_CONST('test', 'test');
77
# Bug #34749: Server crash when using NAME_CONST() with an aggregate function
80
CREATE TABLE t1 (a INT);
81
INSERT INTO t1 VALUES (1),(2),(3);
82
# NAME_CONST() + aggregate.
83
SELECT NAME_CONST('flag',1) * MAX(a) FROM t1;
84
SELECT NAME_CONST('flag',1.5) * MAX(a) FROM t1;
85
# Now, wrap the INT_ITEM in Item_func_neg and watch the pretty explosions
86
SELECT NAME_CONST('flag',-1) * MAX(a) FROM t1;
87
SELECT NAME_CONST('flag',-1.5) * MAX(a) FROM t1;
88
--error ER_WRONG_ARGUMENTS
89
SELECT NAME_CONST('flag', SQRT(4)) * MAX(a) FROM t1;
90
--error ER_WRONG_ARGUMENTS
91
SELECT NAME_CONST('flag',-SQRT(4)) * MAX(a) FROM t1;
95
# Bug #27545: erroneous usage of NAME_CONST with a name as the first parameter
96
# resolved against a column name of a derived table hangs the client
99
CREATE TABLE t1 (a int);
100
INSERT INTO t1 VALUES (5), (2);
102
--error ER_WRONG_ARGUMENTS
103
SELECT NAME_CONST(x,2) FROM (SELECT a x FROM t1) t;
109
# Bug #32559: connection hangs on query with name_const
111
CREATE TABLE t1(a INT);
112
INSERT INTO t1 VALUES (), (), ();
113
--error ER_WRONG_ARGUMENTS
114
SELECT NAME_CONST(a, '1') FROM t1;
115
--error ER_WRONG_ARGUMENTS
116
SET INSERT_ID= NAME_CONST(a, a);
120
# BUG#34289 - Incorrect NAME_CONST substitution in stored procedures breaks
123
SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs;
125
--echo End of 5.0 tests
128
# Bug #30389: connection_id() always return 0 in embedded server
131
select connection_id() > 0;