Commit 91db48e3 authored by unknown's avatar unknown

Precision Math implementation


BitKeeper/etc/ignore:
  Added client/decimal.c client/my_decimal.cc client/my_decimal.h to the ignore list
parent 63bcbfc4
......@@ -1056,3 +1056,6 @@ include/mysqld_ername.h
include/mysqld_error.h
include/sql_state.h
support-files/ndb-config-2-node.ini
client/decimal.c
client/my_decimal.cc
client/my_decimal.h
......@@ -34,7 +34,8 @@ mysqltest_SOURCES= mysqltest.c $(top_srcdir)/mysys/my_getsystime.c
mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD)
mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c
mysqlmanagerc_SOURCES = mysqlmanagerc.c
sql_src=log_event.h mysql_priv.h log_event.cc
sql_src=log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc
strings_src=decimal.c
# Fix for mit-threads
DEFS = -DUNDEF_THREADS_HACK
......@@ -43,6 +44,10 @@ link_sources:
for f in $(sql_src) ; do \
rm -f $(srcdir)/$$f; \
@LN_CP_F@ $(top_srcdir)/sql/$$f $(srcdir)/$$f; \
done; \
for f in $(strings_src) ; do \
rm -f $(srcdir)/$$f; \
@LN_CP_F@ $(top_srcdir)/strings/$$f $(srcdir)/$$f; \
done;
# Don't update the files from bitkeeper
......
......@@ -1280,8 +1280,14 @@ int main(int argc, char** argv)
*/
#ifdef __WIN__
#include "my_decimal.h"
#include "decimal.c"
#include "my_decimal.cpp"
#include "log_event.cpp"
#else
#include "my_decimal.h"
#include "decimal.c"
#include "my_decimal.cc"
#include "log_event.cc"
#endif
......
......@@ -26,7 +26,9 @@ typedef struct st_decimal {
decimal_digit *buf;
} decimal;
int decimal2string(decimal *from, char *to, int *to_len);
int decimal2string(decimal *from, char *to, int *to_len,
int fixed_precision, int fixed_decimals,
char filler);
int string2decimal(char *from, decimal *to, char **end);
int string2decimal_fixed(char *from, decimal *to, char **end);
int decimal2ulonglong(decimal *from, ulonglong *to);
......@@ -35,6 +37,7 @@ int decimal2longlong(decimal *from, longlong *to);
int longlong2decimal(longlong from, decimal *to);
int decimal2double(decimal *from, double *to);
int double2decimal(double from, decimal *to);
void decimal_optimize_fraction(decimal *from);
int decimal2bin(decimal *from, char *to, int precision, int scale);
int bin2decimal(char *from, decimal *to, int precision, int scale);
......@@ -50,6 +53,7 @@ int decimal_div(decimal *from1, decimal *from2, decimal *to, int scale_incr);
int decimal_mod(decimal *from1, decimal *from2, decimal *to);
int decimal_round(decimal *from, decimal *to, int new_scale, decimal_round_mode mode);
int decimal_is_zero(decimal *from);
void max_decimal(int precision, int frac, decimal *to);
/* set a decimal to zero */
......@@ -65,7 +69,8 @@ int decimal_is_zero(decimal *from);
of the decimal (including decimal dot, possible sign and \0)
*/
#define decimal_string_size(dec) ((dec)->intg + (dec)->frac + ((dec)->frac > 0) + 2)
#define decimal_string_size(dec) (((dec)->intg ? (dec)->intg : 1) + \
(dec)->frac + ((dec)->frac > 0) + 2)
/* negate a decimal */
#define decimal_neg(dec) do { (dec)->sign^=1; } while(0)
......
......@@ -211,6 +211,7 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
MYSQL_TYPE_BIT,
MYSQL_TYPE_NEWDECIMAL=246,
MYSQL_TYPE_ENUM=247,
MYSQL_TYPE_SET=248,
MYSQL_TYPE_TINY_BLOB=249,
......@@ -226,6 +227,7 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
/* For backward compatibility */
#define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS
#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
#define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL
#define FIELD_TYPE_TINY MYSQL_TYPE_TINY
#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
#define FIELD_TYPE_LONG MYSQL_TYPE_LONG
......@@ -341,7 +343,8 @@ struct rand_struct {
/* The following is for user defined functions */
enum Item_result {STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT};
enum Item_result {STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT,
DECIMAL_RESULT};
typedef struct st_udf_args
{
......
......@@ -3186,6 +3186,8 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind)
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
param->store_param_func= store_param_str;
/*
For variable length types user must set either length or
......@@ -3512,6 +3514,8 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value,
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
default:
{
/*
......@@ -4249,6 +4253,8 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field)
break;
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
DBUG_ASSERT(param->buffer_length != 0);
param->fetch_result= fetch_result_str;
break;
......@@ -4308,6 +4314,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field)
field->max_length= MAX_DATE_STRING_REP_LENGTH;
break;
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
case MYSQL_TYPE_GEOMETRY:
......
......@@ -62,7 +62,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
unireg.cc uniques.cc stacktrace.c sql_union.cc hash_filo.cc \
spatial.cc gstream.cc sql_help.cc tztime.cc protocol_cursor.cc \
sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \
parse_file.cc sql_view.cc sql_trigger.cc
parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc
libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
libmysqld_a_SOURCES=
......
......@@ -7,7 +7,7 @@ select 9223372036854775807,-009223372036854775808;
9223372036854775807 -9223372036854775808
select +9999999999999999999,-9999999999999999999;
9999999999999999999 -9999999999999999999
9999999999999999999 -10000000000000000000
9999999999999999999 -9999999999999999999
select cast(9223372036854775808 as unsigned)+1;
cast(9223372036854775808 as unsigned)+1
9223372036854775809
......@@ -16,7 +16,7 @@ select 9223372036854775808+1;
9223372036854775809
select -(0-3),round(-(0-3)), round(9999999999999999999);
-(0-3) round(-(0-3)) round(9999999999999999999)
3 3 10000000000000000000
3 3 9999999999999999999
create table t1 (a bigint unsigned not null, primary key(a));
insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
select * from t1;
......
......@@ -91,7 +91,10 @@ CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
CASE WHEN 1 THEN 1.0 END AS c9
CASE WHEN 1 THEN 1.0 END AS c9,
CASE WHEN 1 THEN 0.1e1 else 0.1 END AS c10,
CASE WHEN 1 THEN 0.1e1 else 1 END AS c11,
CASE WHEN 1 THEN 0.1e1 else '1' END AS c12
;
SHOW CREATE TABLE t1;
Table Create Table
......@@ -100,11 +103,14 @@ t1 CREATE TABLE `t1` (
`c2` varchar(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
`c3` varbinary(1) NOT NULL default '',
`c4` varbinary(1) NOT NULL default '',
`c5` varbinary(3) NOT NULL default '',
`c6` varbinary(3) NOT NULL default '',
`c7` double(3,1) NOT NULL default '0.0',
`c8` double(3,1) NOT NULL default '0.0',
`c9` double(3,1) default NULL
`c5` varbinary(4) NOT NULL default '',
`c6` varbinary(4) NOT NULL default '',
`c7` decimal(5,1) NOT NULL default '0.0',
`c8` decimal(5,1) NOT NULL default '0.0',
`c9` decimal(5,1) default NULL,
`c10` double NOT NULL default '0',
`c11` double NOT NULL default '0',
`c12` varbinary(5) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
SELECT CASE
......@@ -146,11 +152,11 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`COALESCE(1)` int(1) NOT NULL default '0',
`COALESCE(1.0)` double(3,1) NOT NULL default '0.0',
`COALESCE(1.0)` decimal(5,1) NOT NULL default '0.0',
`COALESCE('a')` varchar(1) NOT NULL default '',
`COALESCE(1,1.0)` double(3,1) NOT NULL default '0.0',
`COALESCE(1,1.0)` decimal(5,1) NOT NULL default '0.0',
`COALESCE(1,'1')` varbinary(1) NOT NULL default '',
`COALESCE(1.1,'1')` varbinary(3) NOT NULL default '',
`COALESCE(1.1,'1')` varbinary(4) NOT NULL default '',
`COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) character set latin1 collate latin1_bin NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
......@@ -103,9 +103,9 @@ Field Type Null Key Default Extra
a datetime NO 0000-00-00 00:00:00
b time NO 00:00:00
c date NO 0000-00-00
d bigint(17) NO 0
e double(18,1) NO 0.0
f bigint(17) NO 0
d int(2) NO 0
e decimal(6,1) NO 0.0
f bigint(18) NO 0
drop table t2;
create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt;
describe t2;
......@@ -418,7 +418,7 @@ d date YES NULL
e varchar(1) NO
f datetime YES NULL
g time YES NULL
h longblob NO
h varbinary(23) NO
dd time YES NULL
select * from t2;
a b c d e f g h dd
......@@ -437,7 +437,7 @@ t2 CREATE TABLE `t2` (
`ifnull(e,e)` bigint(20) default NULL,
`ifnull(f,f)` float(3,2) default NULL,
`ifnull(g,g)` double(4,3) default NULL,
`ifnull(h,h)` decimal(5,4) default NULL,
`ifnull(h,h)` decimal(6,4) default NULL,
`ifnull(i,i)` year(4) default NULL,
`ifnull(j,j)` date default NULL,
`ifnull(k,k)` datetime NOT NULL default '0000-00-00 00:00:00',
......
......@@ -462,5 +462,5 @@ rout int(11) default '0'
INSERT INTO t1 VALUES ('1',1,0);
SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
html prod
1 0.00
1 0.00000
drop table t1;
drop table if exists t1,t2;
select 0<=>0,0.0<=>0.0,"A"<=>"A",NULL<=>NULL;
0<=>0 0.0<=>0.0 "A"<=>"A" NULL<=>NULL
1 1 1 1
select 0<=>0,0.0<=>0.0,0E0=0E0,"A"<=>"A",NULL<=>NULL;
0<=>0 0.0<=>0.0 0E0=0E0 "A"<=>"A" NULL<=>NULL
1 1 1 1 1
select 1<=>0,0<=>NULL,NULL<=>0;
1<=>0 0<=>NULL NULL<=>0
0 0 0
......@@ -11,6 +11,12 @@ select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0;
select "A"<=>"B","A"<=>NULL,NULL<=>"A";
"A"<=>"B" "A"<=>NULL NULL<=>"A"
0 0 0
select 0<=>0.0, 0.0<=>0E0, 0E0<=>"0", 10.0<=>1E1, 10<=>10.0, 10<=>1E1;
0<=>0.0 0.0<=>0E0 0E0<=>"0" 10.0<=>1E1 10<=>10.0 10<=>1E1
1 1 1 1 1 1
select 1.0<=>0E1,10<=>NULL,NULL<=>0.0, NULL<=>0E0;
1.0<=>0E1 10<=>NULL NULL<=>0.0 NULL<=>0E0
0 0 0 0
create table t1 (id int, value int);
create table t2 (id int, value int);
insert into t1 values (1,null);
......
select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
1+1 1-1 1+1*2 8/5 8%5 mod(8,5) mod(8,5)|0 -(1+1)*-2
2 0 3 1.60 3 3 3 4
2 0 3 1.60000 3 3 3 4
explain extended select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
......
......@@ -440,12 +440,12 @@ create table t2 (user_id integer not null, date date);
insert into t2 values (1, '2002-06-09'),(2, '2002-06-09'),(1, '2002-06-09'),(3, '2002-06-09'),(4, '2002-06-09'),(4, '2002-06-09');
select u.gender as gender, count(distinct u.id) as dist_count, (count(distinct u.id)/5*100) as percentage from t1 u, t2 l where l.user_id = u.id group by u.gender;
gender dist_count percentage
F 3 60.00
M 1 20.00
F 3 60.00000
M 1 20.00000
select u.gender as gender, count(distinct u.id) as dist_count, (count(distinct u.id)/5*100) as percentage from t1 u, t2 l where l.user_id = u.id group by u.gender order by percentage;
gender dist_count percentage
M 1 20.00
F 3 60.00
M 1 20.00000
F 3 60.00000
drop table t1,t2;
CREATE TABLE t1 (ID1 int, ID2 int, ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID
));
......
......@@ -69,9 +69,11 @@ id select_type table type possible_keys key key_len ref rows Extra
select pk from t1 where key2 = 1 and key1 = 1;
pk
26
27
select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1;
pk
26
27
drop table t1;
create table t1 (
pk int primary key auto_increment,
......
......@@ -56,7 +56,7 @@ pk1 pk2
95 59
explain select * from t1 where badkey=1 and key1=10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref key1 key1 4 const 101 Using where
1 SIMPLE t1 ref key1 key1 4 const 100 Using where
explain select * from t1 where pk1 < 7500 and key1 = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge PRIMARY,key1 key1,PRIMARY 4,4 NULL 38 Using intersect(key1,PRIMARY); Using where
......@@ -74,13 +74,13 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge PRIMARY,key1,pktail2ok pktail2ok,key1 8,4 NULL 199 Using sort_union(pktail2ok,key1); Using where
explain select * from t1 where pktail3bad=1 and key1=10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref key1,pktail3bad pktail3bad 4 const ROWS Using where
1 SIMPLE t1 ref key1,pktail3bad key1 4 const 100 Using where
explain select * from t1 where pktail4bad=1 and key1=10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref key1,pktail4bad pktail4bad 4 const 99 Using where
1 SIMPLE t1 ref key1,pktail4bad key1 4 const 100 Using where
explain select * from t1 where pktail5bad=1 and key1=10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref key1,pktail5bad pktail5bad 4 const 99 Using where
1 SIMPLE t1 ref key1,pktail5bad key1 4 const 100 Using where
explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2 key1,key2 4,4 NULL 1 Using intersect(key1,key2); Using where; Using index
......
......@@ -2,7 +2,7 @@ drop table if exists t1,t2;
select 1, 1.0, -1, "hello", NULL;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def 1 8 1 1 N 32897 0 63
def 1.0 5 3 3 N 32897 1 63
def 1.0 246 4 3 N 161 1 63
def -1 8 2 2 N 32897 0 63
def hello 253 5 5 N 1 31 8
def NULL 6 0 0 Y 32896 0 63
......@@ -18,7 +18,7 @@ def test t1 t1 d d 3 11 0 Y 32768 0 63
def test t1 t1 e e 8 20 0 Y 32768 0 63
def test t1 t1 f f 4 3 0 Y 32768 2 63
def test t1 t1 g g 5 4 0 Y 32768 3 63
def test t1 t1 h h 0 7 0 Y 32768 4 63
def test t1 t1 h h 246 5 0 Y 0 4 63
def test t1 t1 i i 13 4 0 Y 32864 0 63
def test t1 t1 j j 10 10 0 Y 128 0 63
def test t1 t1 k k 7 19 0 N 1249 0 63
......
......@@ -19,13 +19,13 @@ INSERT INTO t1 VALUES (1), (2);
</database>
</mysqldump>
DROP TABLE t1;
CREATE TABLE t1 (a decimal(240, 20));
CREATE TABLE t1 (a decimal(64, 20));
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
("0987654321098765432109876543210987654321");
CREATE TABLE `t1` (
`a` decimal(240,20) default NULL
`a` decimal(64,20) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `t1` VALUES ('1234567890123456789012345678901234567890.00000000000000000000'),('0987654321098765432109876543210987654321.00000000000000000000');
INSERT INTO `t1` VALUES ('1234567890123456789012345678901234567890.00000000000000000000'),('987654321098765432109876543210987654321.00000000000000000000');
DROP TABLE t1;
CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES ('-9e999999');
......
......@@ -164,48 +164,48 @@ product country_id year sum(profit)
NULL NULL NULL 7785
select concat(product,':',country_id) as 'prod', concat(":",year,":") as 'year',1+1, sum(profit)/count(*) from t1 group by 1,2 with rollup;
prod year 1+1 sum(profit)/count(*)
Calculator:1 :1999: 2 50.00
Calculator:1 :2000: 2 75.00
Calculator:1 NULL 2 62.50
Calculator:2 :2000: 2 75.00
Calculator:2 NULL 2 75.00
Computer:1 :1999: 2 1350.00
Computer:1 :2000: 2 1500.00
Computer:1 NULL 2 1400.00
Computer:2 :2000: 2 1350.00
Computer:2 NULL 2 1350.00
Phone:3 :2003: 2 10.00
Phone:3 NULL 2 10.00
TV:1 :1999: 2 125.00
TV:1 :2000: 2 150.00
TV:1 NULL 2 133.33
TV:2 :2000: 2 100.00
TV:2 NULL 2 100.00
NULL NULL 2 519.00
Calculator:1 :1999: 2 50.00000
Calculator:1 :2000: 2 75.00000
Calculator:1 NULL 2 62.50000
Calculator:2 :2000: 2 75.00000
Calculator:2 NULL 2 75.00000
Computer:1 :1999: 2 1350.00000
Computer:1 :2000: 2 1500.00000
Computer:1 NULL 2 1400.00000
Computer:2 :2000: 2 1350.00000
Computer:2 NULL 2 1350.00000
Phone:3 :2003: 2 10.00000
Phone:3 NULL 2 10.00000
TV:1 :1999: 2 125.00000
TV:1 :2000: 2 150.00000
TV:1 NULL 2 133.33333
TV:2 :2000: 2 100.00000
TV:2 NULL 2 100.00000
NULL NULL 2 519.00000
select product, sum(profit)/count(*) from t1 group by product with rollup;
product sum(profit)/count(*)
Calculator 68.75
Computer 1380.00
Phone 10.00
TV 120.00
NULL 519.00
Calculator 68.75000
Computer 1380.00000
Phone 10.00000
TV 120.00000
NULL 519.00000
select left(product,4) as prod, sum(profit)/count(*) from t1 group by prod with rollup;
prod sum(profit)/count(*)
Calc 68.75
Comp 1380.00
Phon 10.00
TV 120.00
NULL 519.00
Calc 68.75000
Comp 1380.00000
Phon 10.00000
TV 120.00000
NULL 519.00000
select concat(product,':',country_id), 1+1, sum(profit)/count(*) from t1 group by concat(product,':',country_id) with rollup;
concat(product,':',country_id) 1+1 sum(profit)/count(*)
Calculator:1 2 62.50
Calculator:2 2 75.00
Computer:1 2 1400.00
Computer:2 2 1350.00
Phone:3 2 10.00
TV:1 2 133.33
TV:2 2 100.00
NULL 2 519.00
Calculator:1 2 62.50000
Calculator:2 2 75.00000
Computer:1 2 1400.00000
Computer:2 2 1350.00000
Phone:3 2 10.00000
TV:1 2 133.33333
TV:2 2 100.00000
NULL 2 519.00000
select product, country , year, sum(profit) from t1,t2 where t1.country_id=t2.country_id group by product, country, year with rollup;
product country year sum(profit)
Calculator India 2000 150
......
......@@ -293,7 +293,7 @@ t2 MyISAM 9 Fixed 0 0 0 64424509439 1024 0 NULL # # # latin1_swedish_ci NULL
prepare stmt4 from ' show table status from test like ''t9%'' ';
execute stmt4;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t9 MyISAM 10 Dynamic 2 220 440 4294967295 2048 0 NULL # # # latin1_swedish_ci NULL
t9 MyISAM 10 Dynamic 2 216 432 4294967295 2048 0 NULL # # # latin1_swedish_ci NULL
prepare stmt4 from ' show status like ''Threads_running'' ';
execute stmt4;
Variable_name Value
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2674,6 +2674,7 @@ Warning 1265 Data truncated for column 'c4' at row 1
Warning 1265 Data truncated for column 'c5' at row 1
Warning 1265 Data truncated for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 1
......@@ -2724,6 +2725,7 @@ Warning 1265 Data truncated for column 'c4' at row 1
Warning 1265 Data truncated for column 'c5' at row 1
Warning 1265 Data truncated for column 'c6' at row 1
Warning 1264 Out of range value adjusted for column 'c7' at row 1
Note 1265 Data truncated for column 'c12' at row 1
Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ;
c1 -1
......
......@@ -14,6 +14,8 @@ row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3))
select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a'));
row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a'))
1
Warnings:
Error 1366 Incorrect decimal value: '' for column '' at row -1
select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3));
row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3))
1
......
......@@ -84,27 +84,27 @@ slave-bin.000001 229 User var 2 272 @`i2`=-12345678901234
slave-bin.000001 272 User var 2 315 @`i3`=0
slave-bin.000001 315 User var 2 358 @`i4`=-1
slave-bin.000001 358 Query 1 470 use `test`; insert into t1 values (@i1), (@i2), (@i3), (@i4)
slave-bin.000001 470 User var 2 513 @`r1`=12.5
slave-bin.000001 513 User var 2 556 @`r2`=-12.5
slave-bin.000001 556 Query 1 654 use `test`; insert into t1 values (@r1), (@r2)
slave-bin.000001 654 User var 2 703 @`s1`=_latin1 0x5468697320697320612074657374 COLLATE latin1_swedish_ci
slave-bin.000001 703 User var 2 738 @`s2`=_latin1 "" COLLATE latin1_swedish_ci
slave-bin.000001 738 User var 2 780 @`s3`=_latin1 0x61626327646566 COLLATE latin1_swedish_ci
slave-bin.000001 780 User var 2 822 @`s4`=_latin1 0x6162635C646566 COLLATE latin1_swedish_ci
slave-bin.000001 822 User var 2 864 @`s5`=_latin1 0x61626327646566 COLLATE latin1_swedish_ci
slave-bin.000001 864 Query 1 983 use `test`; insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5)
slave-bin.000001 983 User var 2 1009 @`n1`=NULL
slave-bin.000001 1009 Query 1 1100 use `test`; insert into t1 values (@n1)
slave-bin.000001 1100 User var 2 1126 @`n2`=NULL
slave-bin.000001 1126 Query 1 1217 use `test`; insert into t1 values (@n2)
slave-bin.000001 1217 Query 1 1334 use `test`; insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1)
slave-bin.000001 1334 User var 2 1376 @`a`=2
slave-bin.000001 1376 Query 1 1477 use `test`; insert into t1 values (@a+(@b:=@a+1))
slave-bin.000001 1477 User var 2 1514 @`q`=_latin1 0x616263 COLLATE latin1_swedish_ci
slave-bin.000001 1514 Query 1 1647 use `test`; insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2'))
slave-bin.000001 1647 User var 2 1689 @`a`=5
slave-bin.000001 1689 Query 1 1784 use `test`; insert into t1 values (@a),(@a)
slave-bin.000001 1784 User var 2 1809 @`a`=NULL
slave-bin.000001 1809 Query 1 1911 use `test`; insert into t1 values (@a),(@a),(@a*5)
slave-bin.000001 470 User var 2 509 @`r1`=12.5
slave-bin.000001 509 User var 2 548 @`r2`=-12.5
slave-bin.000001 548 Query 1 646 use `test`; insert into t1 values (@r1), (@r2)
slave-bin.000001 646 User var 2 695 @`s1`=_latin1 0x5468697320697320612074657374 COLLATE latin1_swedish_ci
slave-bin.000001 695 User var 2 730 @`s2`=_latin1 "" COLLATE latin1_swedish_ci
slave-bin.000001 730 User var 2 772 @`s3`=_latin1 0x61626327646566 COLLATE latin1_swedish_ci
slave-bin.000001 772 User var 2 814 @`s4`=_latin1 0x6162635C646566 COLLATE latin1_swedish_ci
slave-bin.000001 814 User var 2 856 @`s5`=_latin1 0x61626327646566 COLLATE latin1_swedish_ci
slave-bin.000001 856 Query 1 975 use `test`; insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5)
slave-bin.000001 975 User var 2 1001 @`n1`=NULL
slave-bin.000001 1001 Query 1 1092 use `test`; insert into t1 values (@n1)
slave-bin.000001 1092 User var 2 1118 @`n2`=NULL
slave-bin.000001 1118 Query 1 1209 use `test`; insert into t1 values (@n2)
slave-bin.000001 1209 Query 1 1326 use `test`; insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1)
slave-bin.000001 1326 User var 2 1368 @`a`=2
slave-bin.000001 1368 Query 1 1469 use `test`; insert into t1 values (@a+(@b:=@a+1))
slave-bin.000001 1469 User var 2 1506 @`q`=_latin1 0x616263 COLLATE latin1_swedish_ci
slave-bin.000001 1506 Query 1 1639 use `test`; insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2'))
slave-bin.000001 1639 User var 2 1681 @`a`=5
slave-bin.000001 1681 Query 1 1776 use `test`; insert into t1 values (@a),(@a)
slave-bin.000001 1776 User var 2 1801 @`a`=NULL
slave-bin.000001 1801 Query 1 1903 use `test`; insert into t1 values (@a),(@a),(@a*5)
drop table t1;
stop slave;
......@@ -1672,7 +1672,7 @@ fld1 count(*)
158402 4181
select sum(Period)/count(*) from t1;
sum(Period)/count(*)
9410.00
9410.00000
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func
37 12543 309394878010 0.0000 464091
......@@ -2109,7 +2109,7 @@ select @b;
aaaa
select @c;
@c
6.26
6.260
create table t1 (a int not null auto_increment primary key);
insert into t1 values ();
insert into t1 values ();
......
......@@ -531,7 +531,6 @@ Warning 1264 Out of range value adjusted for column 'col1' at row 1
Warning 1264 Out of range value adjusted for column 'col2' at row 1
Warning 1264 Out of range value adjusted for column 'col1' at row 2
Warning 1264 Out of range value adjusted for column 'col2' at row 2
Warning 1264 Out of range value adjusted for column 'col2' at row 2
UPDATE IGNORE t1 SET col2=1/NULL where col1=0;
SELECT * FROM t1;
col1 col2
......@@ -556,6 +555,7 @@ INSERT INTO t1 VALUES(-9223372036854775808,0),(0,0),(9223372036854775807,1844674
INSERT INTO t1 VALUES('-9223372036854775808','0'),('9223372036854775807','18446744073709551615');
INSERT INTO t1 VALUES(-9223372036854774000.0,0.0),(9223372036854775700.0,1844674407370954000.0);
INSERT INTO t1 (col1) VALUES(-9223372036854775809);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(9223372036854775808);
INSERT INTO t1 (col2) VALUES(-1);
INSERT INTO t1 (col2) VALUES(18446744073709551616);
......@@ -595,6 +595,7 @@ Error 1365 Division by 0
Error 1365 Division by 0
INSERT IGNORE INTO t1 VALUES(-9223372036854775809,-1),(9223372036854775808,18446744073709551616);
Warnings:
Warning 1264 Out of range value adjusted for column 'col1' at row 1
Warning 1264 Out of range value adjusted for column 'col2' at row 2
INSERT IGNORE INTO t1 VALUES('-9223372036854775809','-1'),('9223372036854775808','18446744073709551616');
Warnings:
......@@ -616,9 +617,8 @@ col1 col2
9223372036854775807 18446744073709551615
-9223372036854775808 0
9223372036854775807 18446744073709551615
-9223372036854773760 0
9223372036854775807 1844674407370953984
-9223372036854775808 NULL
-9223372036854774000 0
9223372036854775700 1844674407370954000
-9223372036854775808 NULL
NULL 18446744073709551615
2 NULL
......@@ -632,12 +632,17 @@ NULL NULL
DROP TABLE t1;
CREATE TABLE t1 (col1 NUMERIC(4,2));
INSERT INTO t1 VALUES (10.55),(10.5555),(0),(-10.55),(-10.5555),(11),(1e+01);
Warnings:
Note 1265 Data truncated for column 'col1' at row 2
Note 1265 Data truncated for column 'col1' at row 5
INSERT INTO t1 VALUES ('10.55'),('10.5555'),('-10.55'),('-10.5555'),('11'),('1e+01');
Warnings:
Note 1265 Data truncated for column 'col1' at row 2
Note 1265 Data truncated for column 'col1' at row 4
INSERT INTO t1 VALUES (101.55);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES (101);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES (-101.55);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES (1010.55);
......@@ -645,7 +650,9 @@ ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES (1010);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES ('101.55');
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES ('101');
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES ('-101.55');
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES ('-1010.55');
......@@ -661,14 +668,15 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
ERROR 01000: Data truncated for column 'col1' at row 1
ERROR HY000: Incorrect decimal value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b');
ERROR 01000: Data truncated for column 'col1' at row 1
ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('1a');
ERROR 01000: Data truncated for column 'col1' at row 1
Warnings:
Note 1265 Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
Warnings:
Warning 1265 Data truncated for column 'col1' at row 1
Note 1265 Data truncated for column 'col1' at row 1
INSERT IGNORE INTO t1 values (1/0);
Warnings:
Error 1365 Division by 0
......@@ -695,22 +703,19 @@ NULL
11.00
10.00
10.55
10.55
-10.55
10.56
-10.55
-10.56
11.00
10.00
101.55
101.00
101.55
101.00
1.00
2.00
NULL
999.99
99.99
-99.99
999.99
99.99
-99.99
999.99
99.99
-99.99
DROP TABLE t1;
CREATE TABLE t1 (col1 FLOAT, col2 FLOAT UNSIGNED);
......
......@@ -890,7 +890,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 Using index
2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 Using index
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a chicking NULL))) AS `t1.a in (select t2.a from t2)` from `test`.`t1`
Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL))) AS `t1.a in (select t2.a from t2)` from `test`.`t1`
CREATE TABLE t3 (a int(11) default '0');
INSERT INTO t3 VALUES (1),(2),(3);
SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
......@@ -1462,25 +1462,25 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 5 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
Warnings:
Note 1003 select `test`.`t1`.`s1` AS `s1`,not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 chicking NULL)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
Note 1003 select `test`.`t1`.`s1` AS `s1`,not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 5 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
Warnings:
Note 1003 select `test`.`t1`.`s1` AS `s1`,<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 chicking NULL))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
Note 1003 select `test`.`t1`.`s1` AS `s1`,<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 5 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
Warnings:
Note 1003 select `test`.`t1`.`s1` AS `s1`,not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 chicking NULL)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
Note 1003 select `test`.`t1`.`s1` AS `s1`,not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 5 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 1 Using index; Using where
Warnings:
Note 1003 select `test`.`t1`.`s1` AS `s1`,not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 chicking NULL where (`test`.`t2`.`s1` < _latin1'a2'))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1`
Note 1003 select `test`.`t1`.`s1` AS `s1`,not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < _latin1'a2'))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1`
drop table t1,t2;
create table t2 (a int, b int);
create table t3 (a int);
......
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
gender CHAR(1),
......
......@@ -156,6 +156,9 @@ insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
insert into t1 values ("-.1"),("+.1"),(".1");
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
Warning 1264 Out of range value adjusted for column 'a' at row 2
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
......@@ -164,7 +167,7 @@ Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
Warning 1265 Data truncated for column 'a' at row 2
Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings:
......@@ -172,24 +175,24 @@ Note 1265 Data truncated for column 'a' at row 3
select * from t1;
a
0.00
-0.00
+0.00
01.00
+01.00
-01.00
0.00
0.00
1.00
1.00
-1.00
-0.10
+0.10
0.10
000000001.00
+00000001.00
-00000001.00
111111111.11
111111111.11
0.10
1.00
1.00
-1.00
99999999.99
99999999.99
-11111111.11
-99999999.99
999999999.99
999999999.99
999999999.99
99999999.99
99999999.99
99999999.99
0.00
-99999999.99
123.40
......@@ -222,7 +225,7 @@ Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
Warning 1265 Data truncated for column 'a' at row 2
Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings:
......@@ -231,15 +234,15 @@ select * from t1;
a
0.00
0.00
+0.00
01.00
+01.00
0.00
1.00
1.00
0.00
0.00
+0.10
0.10
00000001.00
+0000001.00
0.10
1.00
1.00
0.00
99999999.99
99999999.99
......@@ -280,7 +283,7 @@ Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
Warning 1265 Data truncated for column 'a' at row 2
Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings:
......@@ -319,6 +322,9 @@ insert into t1 values (0.0),("-0.0"),(+0.0),(01.0),(+01.0),(-01.0);
insert into t1 values (-.1),(+.1),(.1);
insert into t1 values (00000000000001),(+0000000000001),(-0000000000001);
insert into t1 values (+111111111.11),(111111111.11),(-11111111.11);
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
Warning 1264 Out of range value adjusted for column 'a' at row 2
insert into t1 values (-111111111.11),(+1111111111.11),(1111111111.11);
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
......@@ -327,12 +333,15 @@ Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values (1e+100),(1e-100),(-1e+100);
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values (123.4e0),(123.4e+2),(123.4e-2),(123e1),(123e+0);
Warnings:
Note 1265 Data truncated for column 'a' at row 3
select * from t1;
a
0.00
-0.00
0.00
0.00
1.00
1.00
......@@ -343,13 +352,13 @@ a
1.00
1.00
-1.00
111111111.11
111111111.11
99999999.99
99999999.99
-11111111.11
-99999999.99
999999999.99
999999999.99
999999999.99
99999999.99
99999999.99
99999999.99
0.00
-99999999.99
123.40
......@@ -362,16 +371,17 @@ create table t1 (a decimal);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+12345678901'),(99999999999999);
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
Warning 1264 Out of range value adjusted for column 'a' at row 6
Warning 1264 Out of range value adjusted for column 'a' at row 7
select * from t1;
a
-9999999999
-1
+1
01
+0000000001
12345678901
99999999999
1
1
1
9999999999
9999999999
drop table t1;
create table t1 (a decimal unsigned);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
......@@ -381,11 +391,11 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 7
select * from t1;
a
0
0
+1
01
+000000001
9999999999
9999999999
1
1
1
1234567890
9999999999
drop table t1;
......@@ -397,8 +407,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 7
select * from t1;
a
0000000000
0000000000
9999999999
9999999999
0000000001
0000000001
0000000001
......@@ -413,8 +423,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 7
select * from t1;
a
0000000000
0000000000
9999999999
9999999999
0000000001
0000000001
0000000001
......@@ -424,19 +434,17 @@ drop table t1;
create table t1(a decimal(10,0));
insert into t1 values ("1e4294967295");
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
Warning 1264 Out of range value adjusted for column 'a' at row 1
select * from t1;
a
99999999999
9999999999
delete from t1;
insert into t1 values("1e4294967297");
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
Warning 1264 Out of range value adjusted for column 'a' at row 1
select * from t1;
a
99999999999
9999999999
drop table t1;
CREATE TABLE t1 (a_dec DECIMAL(-1,0));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1,0))' at line 1
......@@ -448,7 +456,7 @@ CREATE TABLE t1 (a_dec DECIMAL(0,11));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a_dec` decimal(12,11) default NULL
`a_dec` decimal(11,11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
create table t1(a decimal(7,3));
......@@ -456,64 +464,64 @@ insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000
select * from t1;
a
1.000
+1.000
1.000
-1.000
00001.000
+0001.000
-0001.000
1.000
1.000
-1.000
10.000
10.000
-10.000
10.000
10.000
+10.000
-10.000
00010.000
+0010.000
-0010.000
100.000
+100.000
100.000
-100.000
100.000
100.000
-100.000
00100.000
+0100.000
-0100.000
1000.000
+1000.000
1000.000
-1000.000
01000.000
+1000.000
1000.000
1000.000
-1000.000
10000.000
10000.000
9999.999
9999.999
-9999.999
10000.000
10000.000
9999.999
9999.999
-9999.999
99999.999
99999.999
9999.999
9999.999
-9999.999
99999.999
99999.999
9999.999
9999.999
-9999.999
99999.999
99999.999
9999.999
9999.999
-9999.999
99999.999
99999.999
9999.999
9999.999
-9999.999
99999.999
99999.999
9999.999
9999.999
-9999.999
99999.999
99999.999
9999.999
9999.999
-9999.999
99999.999
99999.999
9999.999
9999.999
-9999.999
99999.999
99999.999
9999.999
9999.999
-9999.999
99999.999
99999.999
9999.999
9999.999
-9999.999
99999.999
99999.999
9999.999
9999.999
-9999.999
drop table t1;
create table t1(a decimal(7,3) unsigned);
......@@ -521,22 +529,22 @@ insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000
select * from t1;
a
1.000
+1.000
1.000
0.000
0001.000
+001.000
1.000
1.000
0.000
10.000
+10.000
10.000
0.000
0010.000
+010.000
10.000
10.000
0.000
100.000
+100.000
100.000
0.000
0100.000
+100.000
100.000
100.000
0.000
1000.000
1000.000
......
......@@ -66,7 +66,7 @@ select a from t1 order by a;
a
-0.010
-0.002
-0.000
0.000
0.000
1.000
select min(a) from t1;
......@@ -119,7 +119,7 @@ select a from t1 order by a;
a
-0.010
-0.002
-0.000
0.000
0.000
1.000
select min(a) from t1;
......@@ -142,6 +142,9 @@ create table t1 (c20 char);
insert into t1 values (5000.0);
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
insert into t1 values (0.5e4);
Warnings:
Warning 1265 Data truncated for column 'c20' at row 1
drop table t1;
create table t1 (f float(54));
ERROR 42000: Incorrect column specifier for column 'f'
......
This diff is collapsed.
......@@ -87,6 +87,8 @@ DROP INDEX test ON t1;
insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one');
insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one');
insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303101010','','','','3',3,3);
Warnings:
Warning 1265 Data truncated for column 'string' at row 1
insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1);
Warnings:
Warning 1264 Out of range value adjusted for column 'utiny' at row 1
......@@ -122,7 +124,7 @@ select auto,string,tiny,short,medium,long_int,longlong,real_float,real_double,ut
auto string tiny short medium long_int longlong real_float real_double utiny ushort umedium ulong ulonglong mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000) date_field time_field date_time blob_col tinyblob_col mediumblob_col longblob_col
10 1 1 1 1 1 1 1.0 1.0000 1 00001 1 1 1 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 1 1 1
11 2 2 2 2 2 2 2.0 2.0000 2 00002 2 2 2 0 NULL NULL NULL NULL NULL 2 2
12 0.33 3 3 3 3 3 3.0 3.0000 3 00003 3 3 3 0 1997-03-03 10:10:10 1997-03-03 10:10:10 3
12 0.33333333 3 3 3 3 3 3.0 3.0000 3 00003 3 3 3 0 1997-03-03 10:10:10 1997-03-03 10:10:10 3
13 -1 -1 -1 -1 -1 -1 -1.0 -1.0000 0 00000 0 0 18446744073709551615 0 1997-08-07 08:07:06 1997-04-03 09:08:07 -1 -1 -1 -1
14 -429496729 -128 -32768 -8388608 -2147483648 -4294967295 -4294967296.0 -4294967295.0000 0 00000 0 0 18446744069414584321 0 0000-00-00 00:00:00 0000-00-00 00:00:00 -4294967295 -4294967295 -4294967295 -4294967295
15 4294967295 127 32767 8388607 2147483647 4294967295 4294967296.0 4294967295.0000 255 65535 16777215 4294967295 4294967295 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4294967295 4294967295 4294967295 4294967295
......@@ -174,7 +176,7 @@ Warning 1265 Data truncated for column 'new_field' at row 7
select * from t2;
auto string mediumblob_col new_field
1 2 2 ne
2 0.33 ne
2 0.33333333 ne
3 -1 -1 ne
4 -429496729 -4294967295 ne
5 4294967295 4294967295 ne
......@@ -268,7 +270,7 @@ drop table t2;
create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, 'a' as t2, repeat('a',256) as t3, binary repeat('b',256) as t4, repeat('a',4096) as t5, binary repeat('b',4096) as t6, '' as t7, binary '' as t8 from t1;
show full columns from t2;
Field Type Collation Null Key Default Extra Privileges Comment
auto bigint(17) unsigned NULL NO PRI 0 select,insert,update,references
auto int(6) unsigned NULL NO PRI 0 select,insert,update,references
t1 bigint(1) NULL NO 0 select,insert,update,references
t2 varchar(1) latin1_swedish_ci NO select,insert,update,references
t3 varchar(256) latin1_swedish_ci NO select,insert,update,references
......
......@@ -565,7 +565,7 @@ a
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` double(53,1) NOT NULL default '0.0'
`a` decimal(20,1) NOT NULL default '0.0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text);
......@@ -788,11 +788,11 @@ create table t3 select * from t2 union select * from t1;
select * from t3;
d
1.234567800
100000000.0
100000000.000000000
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`d` decimal(10,9) default NULL
`d` decimal(19,9) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1,t2,t3;
create table t1 select 1 union select -1;
......
......@@ -500,14 +500,15 @@ t1 CREATE TABLE `t1` (
`c5` bigint(20) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
set @arg00= 8, @arg01= 8.8, @arg02= 'a string';
create table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3;
set @arg00= 8, @arg01= 8.8, @arg02= 'a string', @arg03= 0.2e0;
create table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3, @arg03 as c4;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` bigint(20) default NULL,
`c2` double default NULL,
`c3` longtext
`c2` decimal(64,30) default NULL,
`c3` longtext,
`c4` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8;
......
......@@ -448,7 +448,7 @@ create view v1 as select a+1 from t1;
create table t2 select * from v1;
show columns from t2;
Field Type Null Key Default Extra
a+1 bigint(17) YES NULL
a+1 bigint(12) YES NULL
select * from t2;
a+1
2
......
......@@ -58,7 +58,10 @@ CREATE TABLE t1 SELECT
CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
CASE WHEN 1 THEN 1.0 END AS c9
CASE WHEN 1 THEN 1.0 END AS c9,
CASE WHEN 1 THEN 0.1e1 else 0.1 END AS c10,
CASE WHEN 1 THEN 0.1e1 else 1 END AS c11,
CASE WHEN 1 THEN 0.1e1 else '1' END AS c12
;
SHOW CREATE TABLE t1;
DROP TABLE t1;
......
......@@ -11,10 +11,12 @@ drop table if exists t1,t2;
# First some simple tests
#
select 0<=>0,0.0<=>0.0,"A"<=>"A",NULL<=>NULL;
select 0<=>0,0.0<=>0.0,0E0=0E0,"A"<=>"A",NULL<=>NULL;
select 1<=>0,0<=>NULL,NULL<=>0;
select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0;
select "A"<=>"B","A"<=>NULL,NULL<=>"A";
select 0<=>0.0, 0.0<=>0E0, 0E0<=>"0", 10.0<=>1E1, 10<=>10.0, 10<=>1E1;
select 1.0<=>0E1,10<=>NULL,NULL<=>0.0, NULL<=>0E0;
#
# Test with tables
......
......@@ -14,7 +14,7 @@ DROP TABLE t1;
# Bug #2005
#
CREATE TABLE t1 (a decimal(240, 20));
CREATE TABLE t1 (a decimal(64, 20));
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
("0987654321098765432109876543210987654321");
--exec $MYSQL_DUMP --compact test t1
......
......@@ -388,9 +388,7 @@ INSERT INTO t1 VALUES(-9223372036854775808,0),(0,0),(9223372036854775807,1844674
INSERT INTO t1 VALUES('-9223372036854775808','0'),('9223372036854775807','18446744073709551615');
INSERT INTO t1 VALUES(-9223372036854774000.0,0.0),(9223372036854775700.0,1844674407370954000.0);
# The following should give an error, but doesn't until we fix the interface
# for Field_longlong::store()
-- error 1264
INSERT INTO t1 (col1) VALUES(-9223372036854775809);
INSERT INTO t1 (col1) VALUES(9223372036854775808);
INSERT INTO t1 (col2) VALUES(-1);
......@@ -449,7 +447,9 @@ INSERT INTO t1 VALUES ('10.55'),('10.5555'),('-10.55'),('-10.5555'),('11'),('1e+
-- The 2 following inserts should generate a warning, but doesn't yet
-- because NUMERIC works like DECIMAL
--error 1264
INSERT INTO t1 VALUES (101.55);
--error 1264
INSERT INTO t1 VALUES (101);
--error 1264
INSERT INTO t1 VALUES (-101.55);
......@@ -459,7 +459,9 @@ INSERT INTO t1 VALUES (1010.55);
INSERT INTO t1 VALUES (1010);
-- The 2 following inserts should generate a warning, but doesn't yet
-- because NUMERIC works like DECIMAL
--error 1264
INSERT INTO t1 VALUES ('101.55');
--error 1264
INSERT INTO t1 VALUES ('101');
--error 1264
INSERT INTO t1 VALUES ('-101.55');
......@@ -475,11 +477,13 @@ UPDATE t1 SET col1 =col1 * 50000 WHERE col1 =11;
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
--error 1365
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
--error 1265
#--error 1265
--error 1366
INSERT INTO t1 (col1) VALUES ('');
--error 1265
#--error 1265
--error 1366
INSERT INTO t1 (col1) VALUES ('a59b');
--error 1265
#--error 1265
INSERT INTO t1 (col1) VALUES ('1a');
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
INSERT IGNORE INTO t1 values (1/0);
......
......@@ -2,7 +2,7 @@
# Various tests for SUM(DISTINCT ...)
#
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
CREATE TABLE t1 (
......
......@@ -84,6 +84,7 @@ drop table t1;
#
create table t1 (c20 char);
insert into t1 values (5000.0);
insert into t1 values (0.5e4);
drop table t1;
# Errors
......
This diff is collapsed.
......@@ -368,8 +368,8 @@ show create table t1;
drop table t1;
#
# What types and widths have variables?
set @arg00= 8, @arg01= 8.8, @arg02= 'a string';
create table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3;
set @arg00= 8, @arg01= 8.8, @arg02= 'a string', @arg03= 0.2e0;
create table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3, @arg03 as c4;
show create table t1;
drop table t1;
......
......@@ -58,7 +58,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
log_event.h sql_repl.h slave.h \
stacktrace.h sql_sort.h sql_cache.h set_var.h \
spatial.h gstream.h client_settings.h tzfile.h \
tztime.h \
tztime.h my_decimal.h\
sp_head.h sp_pcontext.h sp_rcontext.h sp.h sp_cache.h \
parse_file.h sql_view.h sql_trigger.h \
examples/ha_example.h examples/ha_archive.h \
......@@ -95,7 +95,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
stacktrace.c repl_failsafe.h repl_failsafe.cc \
sql_olap.cc sql_view.cc \
gstream.cc spatial.cc sql_help.cc protocol_cursor.cc \
tztime.cc my_time.c \
tztime.cc my_time.c my_decimal.cc\
sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \
sp_cache.cc parse_file.cc sql_trigger.cc \
examples/ha_example.cc examples/ha_archive.cc \
......
This diff is collapsed.
This diff is collapsed.
......@@ -586,6 +586,9 @@ void field_conv(Field *to,Field *from)
!(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) &&
to->real_type() != FIELD_TYPE_ENUM &&
to->real_type() != FIELD_TYPE_SET &&
(to->real_type() != FIELD_TYPE_NEWDECIMAL ||
(to->field_length == from->field_length &&
(((Field_num*)to)->dec == ((Field_num*)from)->dec))) &&
from->charset() == to->charset() &&
to->table->s->db_low_byte_first == from->table->s->db_low_byte_first)
{ // Identical fields
......@@ -623,6 +626,11 @@ void field_conv(Field *to,Field *from)
}
else if (from->result_type() == REAL_RESULT)
to->store(from->val_real());
else if (from->result_type() == DECIMAL_RESULT)
{
my_decimal buff;
to->store_decimal(from->val_decimal(&buff));
}
else
to->store(from->val_int());
}
......@@ -703,6 +703,22 @@ static void make_sortkey(register SORTPARAM *param,
#endif
break;
}
case DECIMAL_RESULT:
{
my_decimal dec_buf, *dec_val= item->val_decimal(&dec_buf);
if ((maybe_null=item->null_value))
{
bzero((char*)to, sort_field->length+1);
to++;
break;
}
if ((maybe_null=item->maybe_null))
*to++=1;
my_decimal2binary(E_DEC_FATAL_ERROR, dec_val, (byte*)to,
item->max_length - (item->decimals ? 1:0),
item->decimals);
break;
}
case REAL_RESULT:
{
double value= item->val_real();
......@@ -1212,6 +1228,12 @@ sortlength(SORT_FIELD *sortorder, uint s_length, bool *multi_byte_charset)
sortorder->length=4;
#endif
break;
case DECIMAL_RESULT:
sortorder->length=
my_decimal_get_binary_size(sortorder->item->max_length -
(sortorder->item->decimals ? 1 : 0),
sortorder->item->decimals);
break;
case REAL_RESULT:
sortorder->length=sizeof(double);
break;
......
......@@ -2159,6 +2159,8 @@ get_innobase_type_from_mysql_type(
} else {
return(DATA_MYSQL);
}
case FIELD_TYPE_NEWDECIMAL:
return(DATA_BINARY);
case FIELD_TYPE_LONG:
case FIELD_TYPE_LONGLONG:
case FIELD_TYPE_TINY:
......
......@@ -727,7 +727,7 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt)
if ((error= mi_assign_to_key_cache(file, map, new_key_cache)))
{
char buf[80];
char buf[STRING_BUFFER_USUAL_SIZE];
my_snprintf(buf, sizeof(buf),
"Failed to flush to index file (errno: %d)", error);
errmsg= buf;
......
This diff is collapsed.
This diff is collapsed.
......@@ -28,11 +28,21 @@ Item_buff *new_Item_buff(Item *item)
if (item->type() == Item::FIELD_ITEM &&
!(((Item_field *) item)->field->flags & BLOB_FLAG))
return new Item_field_buff((Item_field *) item);
if (item->result_type() == STRING_RESULT)
switch (item->result_type())
{
case STRING_RESULT:
return new Item_str_buff((Item_field *) item);
if (item->result_type() == INT_RESULT)
case INT_RESULT:
return new Item_int_buff((Item_field *) item);
case REAL_RESULT:
return new Item_real_buff(item);
case DECIMAL_RESULT:
return new Item_decimal_buff(item);
case ROW_RESULT:
default:
DBUG_ASSERT(0);
return 0;
}
}
Item_buff::~Item_buff() {}
......@@ -107,6 +117,27 @@ bool Item_field_buff::cmp(void)
}
Item_decimal_buff::Item_decimal_buff(Item *it)
:item(it)
{
my_decimal_set_zero(&value);
}
bool Item_decimal_buff::cmp()
{
my_decimal tmp;
my_decimal *ptmp= item->val_decimal(&tmp);
if (null_value != item->null_value || my_decimal_cmp(&value, ptmp) == 0)
{
null_value= item->null_value;
my_decimal2decimal(ptmp, &value);
return TRUE;
}
return FALSE;
}
/*****************************************************************************
** Instansiate templates
*****************************************************************************/
......
This diff is collapsed.
This diff is collapsed.
......@@ -289,7 +289,7 @@ Item *create_func_period_diff(Item* a, Item *b)
Item *create_func_pi(void)
{
return new Item_static_real_func("pi()", M_PI, 6, 8);
return new Item_static_float_func("pi()", M_PI, 6, 8);
}
Item *create_func_pow(Item* a, Item *b)
......@@ -454,7 +454,7 @@ Item *create_load_file(Item* a)
}
Item *create_func_cast(Item *a, Cast_target cast_type, int len,
Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
CHARSET_INFO *cs)
{
Item *res;
......@@ -467,6 +467,9 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len,
case ITEM_CAST_DATE: res= new Item_date_typecast(a); break;
case ITEM_CAST_TIME: res= new Item_time_typecast(a); break;
case ITEM_CAST_DATETIME: res= new Item_datetime_typecast(a); break;
case ITEM_CAST_DECIMAL:
res= new Item_decimal_typecast(a, (len>0) ? len : 10, dec ? dec : 2);
break;
case ITEM_CAST_CHAR:
res= new Item_char_typecast(a, len, cs ? cs :
current_thd->variables.collation_connection);
......
......@@ -28,7 +28,8 @@ Item *create_func_bit_length(Item* a);
Item *create_func_coercibility(Item* a);
Item *create_func_ceiling(Item* a);
Item *create_func_char_length(Item* a);
Item *create_func_cast(Item *a, Cast_target cast_type, int len, CHARSET_INFO *cs);
Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
CHARSET_INFO *cs);
Item *create_func_connection_id(void);
Item *create_func_conv(Item* a, Item *b, Item *c);
Item *create_func_cos(Item* a);
......
This diff is collapsed.
This diff is collapsed.
......@@ -100,10 +100,9 @@ void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array,
(item->used_tables() && item->type() != REF_ITEM))
{
uint el= fields.elements;
ref_pointer_array[el]=*arg;
ref_pointer_array[el]= *arg;
Item *new_item= new Item_ref(ref_pointer_array + el, 0, (*arg)->name);
fields.push_front(*arg);
ref_pointer_array[el]= *arg;
thd->change_item_tree(arg, new_item);
}
}
......
......@@ -56,6 +56,11 @@ class Item_row: public Item
illegal_method_call((const char*)"val_str");
return 0;
};
my_decimal *val_decimal(my_decimal *)
{
illegal_method_call((const char*)"val_decimal");
return 0;
};
bool fix_fields(THD *thd, TABLE_LIST *tables, Item **ref);
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
table_map used_tables() const { return used_tables_cache; };
......
......@@ -49,6 +49,8 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
uint nr_of_decimals(const char *str)
{
if (strchr(str,'e') || strchr(str,'E'))
return NOT_FIXED_DEC;
if ((str=strchr(str,'.')))
{
const char *start= ++str;
......@@ -1784,10 +1786,9 @@ void Item_func_make_set::split_sum_func(THD *thd, Item **ref_pointer_array,
(item->used_tables() && item->type() != REF_ITEM))
{
uint el= fields.elements;
ref_pointer_array[el]=item;
ref_pointer_array[el]= item;
Item *new_item= new Item_ref(ref_pointer_array + el, 0, item->name);
fields.push_front(item);
ref_pointer_array[el]= item;
thd->change_item_tree(&item, new_item);
}
Item_str_func::split_sum_func(thd, ref_pointer_array, fields);
......
......@@ -397,8 +397,7 @@ class Item_func_make_set :public Item_str_func
bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
{
DBUG_ASSERT(fixed == 0);
return (!item->fixed &&
item->fix_fields(thd, tlist, &item) ||
return ((!item->fixed && item->fix_fields(thd, tlist, &item)) ||
item->check_cols(1) ||
Item_func::fix_fields(thd, tlist, ref));
}
......
This diff is collapsed.
......@@ -142,6 +142,8 @@ class Item_singlerow_subselect :public Item_subselect
double val_real();
longlong val_int ();
String *val_str (String *);
my_decimal *val_decimal(my_decimal *);
bool val_bool();
enum Item_result result_type() const;
void fix_length_and_dec();
......@@ -155,7 +157,7 @@ class Item_singlerow_subselect :public Item_subselect
friend class select_singlerow_subselect;
};
/* used in static ALL/ANY optimisation */
/* used in static ALL/ANY optimization */
class select_max_min_finder_subselect;
class Item_maxmin_subselect :public Item_singlerow_subselect
{
......@@ -193,6 +195,8 @@ class Item_exists_subselect :public Item_subselect
longlong val_int();
double val_real();
String *val_str(String*);
my_decimal *val_decimal(my_decimal *);
bool val_bool();
void fix_length_and_dec();
void print(String *str);
......@@ -294,7 +298,7 @@ class subselect_engine: public Sql_alloc
virtual int prepare()= 0;
virtual void fix_length_and_dec(Item_cache** row)= 0;
virtual int exec()= 0;
virtual uint cols()= 0; /* return number of columnss in select */
virtual uint cols()= 0; /* return number of columns in select */
virtual uint8 uncacheable()= 0; /* query is uncacheable */
enum Item_result type() { return res_type; }
virtual void exclude()= 0;
......
This diff is collapsed.
This diff is collapsed.
......@@ -315,7 +315,9 @@ class Item_func_time_to_sec :public Item_int_func
};
/* This can't be a Item_str_func, because the val() functions are special */
/*
This can't be a Item_str_func, because the val_real() functions are special
*/
class Item_date :public Item_func
{
......
......@@ -20,3 +20,9 @@
#endif
#include "mysql_priv.h"
Field *Item_sum_unique_users::create_tmp_field(bool group, TABLE *table,
uint convert_blob_length)
{
return new Field_long(9,maybe_null,name,table,1);
}
......@@ -57,4 +57,5 @@ class Item_sum_unique_users :public Item_sum_num
return new Item_sum_unique_users(thd, this);
}
void print(String *str) { str->append("0.0", 3); }
Field *create_tmp_field(bool group, TABLE *table, uint convert_blob_length);
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -343,6 +343,8 @@ void debug_sync_point(const char* lock_name, uint lock_timeout);
#define WEEK_YEAR 2
#define WEEK_FIRST_WEEKDAY 4
#define STRING_BUFFER_USUAL_SIZE 80
enum enum_parsing_place
{
NO_MATTER,
......@@ -413,6 +415,7 @@ typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key,
#include "sql_string.h"
#include "sql_list.h"
#include "sql_map.h"
#include "my_decimal.h"
#include "handler.h"
#include "parse_file.h"
#include "table.h"
......@@ -421,6 +424,7 @@ typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key,
#include "sql_udf.h"
class user_var_entry;
#include "item.h"
extern my_decimal decimal_zero;
typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
/* sql_parse.cc */
void free_items(Item *item);
......
......@@ -261,11 +261,12 @@ bool opt_large_files= sizeof(my_off_t) > 4;
bool opt_help= 0;
bool opt_verbose= 0;
arg_cmp_func Arg_comparator::comparator_matrix[4][2] =
arg_cmp_func Arg_comparator::comparator_matrix[5][2] =
{{&Arg_comparator::compare_string, &Arg_comparator::compare_e_string},
{&Arg_comparator::compare_real, &Arg_comparator::compare_e_real},
{&Arg_comparator::compare_int_signed, &Arg_comparator::compare_e_int},
{&Arg_comparator::compare_row, &Arg_comparator::compare_e_row}};
{&Arg_comparator::compare_row, &Arg_comparator::compare_e_row},
{&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}};
/* Global variables */
......@@ -372,6 +373,7 @@ const char *sql_mode_str="OFF";
const char *in_left_expr_name= "<left expr>";
/* name of additional condition */
const char *in_additional_cond= "<IN COND>";
my_decimal decimal_zero;
/* classes for comparation parsing/processing */
Eq_creator eq_creator;
Ne_creator ne_creator;
......@@ -2384,6 +2386,7 @@ static int init_common_variables(const char *conf_file_name, int argc,
char **argv, const char **groups)
{
umask(((~my_umask) & 0666));
my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
tzset(); // Set tzname
max_system_variables.pseudo_thread_id= (ulong)~0;
......
This diff is collapsed.
......@@ -71,6 +71,7 @@ class Item_proc_real :public Item_proc
s->set(value,decimals,default_charset());
return s;
}
my_decimal *val_decimal(my_decimal *);
unsigned int size_of() { return sizeof(*this);}
};
......@@ -89,6 +90,7 @@ class Item_proc_int :public Item_proc
double val_real() { return (double) value; }
longlong val_int() { return value; }
String *val_str(String *s) { s->set(value, default_charset()); return s; }
my_decimal *val_decimal(my_decimal *);
unsigned int size_of() { return sizeof(*this);}
};
......@@ -122,6 +124,7 @@ class Item_proc_string :public Item_proc
{
return null_value ? (String*) 0 : (String*) &str_value;
}
my_decimal *val_decimal(my_decimal *);
unsigned int size_of() { return sizeof(*this);}
};
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment