Commit 48bc6d47 authored by mleich@mysql.com's avatar mleich@mysql.com

Merge mysql.com:/home/matthias/Arbeit/mysql-5.0/src

into mysql.com:/home/matthias/Arbeit/mysql-5.0/src-WL1420
parents f227e270 7df94d5e
...@@ -1056,3 +1056,7 @@ include/mysqld_ername.h ...@@ -1056,3 +1056,7 @@ include/mysqld_ername.h
include/mysqld_error.h include/mysqld_error.h
include/sql_state.h include/sql_state.h
support-files/ndb-config-2-node.ini support-files/ndb-config-2-node.ini
client/decimal.c
client/my_decimal.cc
client/my_decimal.h
libmysqld/my_decimal.cc
...@@ -34,7 +34,8 @@ mysqltest_SOURCES= mysqltest.c $(top_srcdir)/mysys/my_getsystime.c ...@@ -34,7 +34,8 @@ mysqltest_SOURCES= mysqltest.c $(top_srcdir)/mysys/my_getsystime.c
mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD) mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD)
mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c
mysqlmanagerc_SOURCES = mysqlmanagerc.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 # Fix for mit-threads
DEFS = -DUNDEF_THREADS_HACK DEFS = -DUNDEF_THREADS_HACK
...@@ -43,7 +44,11 @@ link_sources: ...@@ -43,7 +44,11 @@ link_sources:
for f in $(sql_src) ; do \ for f in $(sql_src) ; do \
rm -f $(srcdir)/$$f; \ rm -f $(srcdir)/$$f; \
@LN_CP_F@ $(top_srcdir)/sql/$$f $(srcdir)/$$f; \ @LN_CP_F@ $(top_srcdir)/sql/$$f $(srcdir)/$$f; \
done; 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 # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%
...@@ -1280,8 +1280,14 @@ int main(int argc, char** argv) ...@@ -1280,8 +1280,14 @@ int main(int argc, char** argv)
*/ */
#ifdef __WIN__ #ifdef __WIN__
#include "my_decimal.h"
#include "decimal.c"
#include "my_decimal.cpp"
#include "log_event.cpp" #include "log_event.cpp"
#else #else
#include "my_decimal.h"
#include "decimal.c"
#include "my_decimal.cc"
#include "log_event.cc" #include "log_event.cc"
#endif #endif
......
...@@ -26,7 +26,9 @@ typedef struct st_decimal { ...@@ -26,7 +26,9 @@ typedef struct st_decimal {
decimal_digit *buf; decimal_digit *buf;
} decimal; } 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(char *from, decimal *to, char **end);
int string2decimal_fixed(char *from, decimal *to, char **end); int string2decimal_fixed(char *from, decimal *to, char **end);
int decimal2ulonglong(decimal *from, ulonglong *to); int decimal2ulonglong(decimal *from, ulonglong *to);
...@@ -35,6 +37,7 @@ int decimal2longlong(decimal *from, longlong *to); ...@@ -35,6 +37,7 @@ int decimal2longlong(decimal *from, longlong *to);
int longlong2decimal(longlong from, decimal *to); int longlong2decimal(longlong from, decimal *to);
int decimal2double(decimal *from, double *to); int decimal2double(decimal *from, double *to);
int double2decimal(double from, decimal *to); int double2decimal(double from, decimal *to);
void decimal_optimize_fraction(decimal *from);
int decimal2bin(decimal *from, char *to, int precision, int scale); int decimal2bin(decimal *from, char *to, int precision, int scale);
int bin2decimal(char *from, decimal *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); ...@@ -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_mod(decimal *from1, decimal *from2, decimal *to);
int decimal_round(decimal *from, decimal *to, int new_scale, decimal_round_mode mode); int decimal_round(decimal *from, decimal *to, int new_scale, decimal_round_mode mode);
int decimal_is_zero(decimal *from); int decimal_is_zero(decimal *from);
void max_decimal(int precision, int frac, decimal *to);
/* set a decimal to zero */ /* set a decimal to zero */
...@@ -65,7 +69,8 @@ int decimal_is_zero(decimal *from); ...@@ -65,7 +69,8 @@ int decimal_is_zero(decimal *from);
of the decimal (including decimal dot, possible sign and \0) 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 */ /* negate a decimal */
#define decimal_neg(dec) do { (dec)->sign^=1; } while(0) #define decimal_neg(dec) do { (dec)->sign^=1; } while(0)
......
...@@ -211,6 +211,7 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, ...@@ -211,6 +211,7 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
MYSQL_TYPE_BIT, MYSQL_TYPE_BIT,
MYSQL_TYPE_NEWDECIMAL=246,
MYSQL_TYPE_ENUM=247, MYSQL_TYPE_ENUM=247,
MYSQL_TYPE_SET=248, MYSQL_TYPE_SET=248,
MYSQL_TYPE_TINY_BLOB=249, MYSQL_TYPE_TINY_BLOB=249,
...@@ -226,6 +227,7 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, ...@@ -226,6 +227,7 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
/* For backward compatibility */ /* For backward compatibility */
#define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS #define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS
#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL #define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
#define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL
#define FIELD_TYPE_TINY MYSQL_TYPE_TINY #define FIELD_TYPE_TINY MYSQL_TYPE_TINY
#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT #define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
#define FIELD_TYPE_LONG MYSQL_TYPE_LONG #define FIELD_TYPE_LONG MYSQL_TYPE_LONG
...@@ -341,7 +343,8 @@ struct rand_struct { ...@@ -341,7 +343,8 @@ struct rand_struct {
/* The following is for user defined functions */ /* 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 typedef struct st_udf_args
{ {
......
...@@ -3186,6 +3186,8 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind) ...@@ -3186,6 +3186,8 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind)
case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
param->store_param_func= store_param_str; param->store_param_func= store_param_str;
/* /*
For variable length types user must set either length or 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, ...@@ -3512,6 +3514,8 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value,
case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB: case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
default: default:
{ {
/* /*
...@@ -4249,6 +4253,8 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) ...@@ -4249,6 +4253,8 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field)
break; break;
case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
DBUG_ASSERT(param->buffer_length != 0); DBUG_ASSERT(param->buffer_length != 0);
param->fetch_result= fetch_result_str; param->fetch_result= fetch_result_str;
break; break;
...@@ -4308,6 +4314,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) ...@@ -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; field->max_length= MAX_DATE_STRING_REP_LENGTH;
break; break;
case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_ENUM: case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET: case MYSQL_TYPE_SET:
case MYSQL_TYPE_GEOMETRY: case MYSQL_TYPE_GEOMETRY:
......
...@@ -62,7 +62,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \ ...@@ -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 \ unireg.cc uniques.cc stacktrace.c sql_union.cc hash_filo.cc \
spatial.cc gstream.cc sql_help.cc tztime.cc protocol_cursor.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 \ 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_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
libmysqld_a_SOURCES= libmysqld_a_SOURCES=
......
...@@ -7,7 +7,7 @@ select 9223372036854775807,-009223372036854775808; ...@@ -7,7 +7,7 @@ select 9223372036854775807,-009223372036854775808;
9223372036854775807 -9223372036854775808 9223372036854775807 -9223372036854775808
select +9999999999999999999,-9999999999999999999; select +9999999999999999999,-9999999999999999999;
9999999999999999999 -9999999999999999999 9999999999999999999 -9999999999999999999
9999999999999999999 -10000000000000000000 9999999999999999999 -9999999999999999999
select cast(9223372036854775808 as unsigned)+1; select cast(9223372036854775808 as unsigned)+1;
cast(9223372036854775808 as unsigned)+1 cast(9223372036854775808 as unsigned)+1
9223372036854775809 9223372036854775809
...@@ -16,7 +16,7 @@ select 9223372036854775808+1; ...@@ -16,7 +16,7 @@ select 9223372036854775808+1;
9223372036854775809 9223372036854775809
select -(0-3),round(-(0-3)), round(9999999999999999999); select -(0-3),round(-(0-3)), round(9999999999999999999);
-(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)); create table t1 (a bigint unsigned not null, primary key(a));
insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
select * from t1; select * from t1;
......
...@@ -91,7 +91,10 @@ CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5, ...@@ -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.0 ELSE 'a' END AS c6,
CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7, 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 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; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
...@@ -100,11 +103,14 @@ t1 CREATE TABLE `t1` ( ...@@ -100,11 +103,14 @@ t1 CREATE TABLE `t1` (
`c2` varchar(1) character set latin1 collate latin1_danish_ci NOT NULL default '', `c2` varchar(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
`c3` varbinary(1) NOT NULL default '', `c3` varbinary(1) NOT NULL default '',
`c4` varbinary(1) NOT NULL default '', `c4` varbinary(1) NOT NULL default '',
`c5` varbinary(3) NOT NULL default '', `c5` varbinary(4) NOT NULL default '',
`c6` varbinary(3) NOT NULL default '', `c6` varbinary(4) NOT NULL default '',
`c7` double(3,1) NOT NULL default '0.0', `c7` decimal(5,1) NOT NULL default '0.0',
`c8` double(3,1) NOT NULL default '0.0', `c8` decimal(5,1) NOT NULL default '0.0',
`c9` double(3,1) default NULL `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 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
SELECT CASE SELECT CASE
...@@ -146,11 +152,11 @@ SHOW CREATE TABLE t1; ...@@ -146,11 +152,11 @@ SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`COALESCE(1)` int(1) NOT NULL default '0', `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('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')` 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 '' `COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) character set latin1 collate latin1_bin NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
...@@ -103,9 +103,9 @@ Field Type Null Key Default Extra ...@@ -103,9 +103,9 @@ Field Type Null Key Default Extra
a datetime NO 0000-00-00 00:00:00 a datetime NO 0000-00-00 00:00:00
b time NO 00:00:00 b time NO 00:00:00
c date NO 0000-00-00 c date NO 0000-00-00
d bigint(17) NO 0 d int(2) NO 0
e double(18,1) NO 0.0 e decimal(6,1) NO 0.0
f bigint(17) NO 0 f bigint(18) NO 0
drop table t2; 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; 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; describe t2;
...@@ -418,7 +418,7 @@ d date YES NULL ...@@ -418,7 +418,7 @@ d date YES NULL
e varchar(1) NO e varchar(1) NO
f datetime YES NULL f datetime YES NULL
g time YES NULL g time YES NULL
h longblob NO h varbinary(23) NO
dd time YES NULL dd time YES NULL
select * from t2; select * from t2;
a b c d e f g h dd a b c d e f g h dd
...@@ -437,7 +437,7 @@ t2 CREATE TABLE `t2` ( ...@@ -437,7 +437,7 @@ t2 CREATE TABLE `t2` (
`ifnull(e,e)` bigint(20) default NULL, `ifnull(e,e)` bigint(20) default NULL,
`ifnull(f,f)` float(3,2) default NULL, `ifnull(f,f)` float(3,2) default NULL,
`ifnull(g,g)` double(4,3) 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(i,i)` year(4) default NULL,
`ifnull(j,j)` date default NULL, `ifnull(j,j)` date default NULL,
`ifnull(k,k)` datetime NOT NULL default '0000-00-00 00:00:00', `ifnull(k,k)` datetime NOT NULL default '0000-00-00 00:00:00',
......
...@@ -462,5 +462,5 @@ rout int(11) default '0' ...@@ -462,5 +462,5 @@ rout int(11) default '0'
INSERT INTO t1 VALUES ('1',1,0); INSERT INTO t1 VALUES ('1',1,0);
SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin; SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
html prod html prod
1 0.00 1 0.00000
drop table t1; drop table t1;
drop table if exists t1,t2; drop table if exists t1,t2;
select 0<=>0,0.0<=>0.0,"A"<=>"A",NULL<=>NULL; select 0<=>0,0.0<=>0.0,0E0=0E0,"A"<=>"A",NULL<=>NULL;
0<=>0 0.0<=>0.0 "A"<=>"A" NULL<=>NULL 0<=>0 0.0<=>0.0 0E0=0E0 "A"<=>"A" NULL<=>NULL
1 1 1 1 1 1 1 1 1
select 1<=>0,0<=>NULL,NULL<=>0; select 1<=>0,0<=>NULL,NULL<=>0;
1<=>0 0<=>NULL NULL<=>0 1<=>0 0<=>NULL NULL<=>0
0 0 0 0 0 0
...@@ -11,6 +11,12 @@ select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0; ...@@ -11,6 +11,12 @@ select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0;
select "A"<=>"B","A"<=>NULL,NULL<=>"A"; select "A"<=>"B","A"<=>NULL,NULL<=>"A";
"A"<=>"B" "A"<=>NULL NULL<=>"A" "A"<=>"B" "A"<=>NULL NULL<=>"A"
0 0 0 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 t1 (id int, value int);
create table t2 (id int, value int); create table t2 (id int, value int);
insert into t1 values (1,null); 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; 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 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; 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 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 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); ...@@ -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'); 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; 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 gender dist_count percentage
F 3 60.00 F 3 60.00000
M 1 20.00 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; 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 gender dist_count percentage
M 1 20.00 M 1 20.00000
F 3 60.00 F 3 60.00000
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1 (ID1 int, ID2 int, ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID 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 ...@@ -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; select pk from t1 where key2 = 1 and key1 = 1;
pk pk
26 26
27
select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1; select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1;
pk pk
26 26
27
drop table t1; drop table t1;
create table t1 ( create table t1 (
pk int primary key auto_increment, pk int primary key auto_increment,
......
...@@ -56,7 +56,7 @@ pk1 pk2 ...@@ -56,7 +56,7 @@ pk1 pk2
95 59 95 59
explain select * from t1 where badkey=1 and key1=10; explain select * from t1 where badkey=1 and key1=10;
id select_type table type possible_keys key key_len ref rows Extra 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; explain select * from t1 where pk1 < 7500 and key1 = 10;
id select_type table type possible_keys key key_len ref rows Extra 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 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 ...@@ -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 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; explain select * from t1 where pktail3bad=1 and key1=10;
id select_type table type possible_keys key key_len ref rows Extra 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; explain select * from t1 where pktail4bad=1 and key1=10;
id select_type table type possible_keys key key_len ref rows Extra 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; explain select * from t1 where pktail5bad=1 and key1=10;
id select_type table type possible_keys key key_len ref rows Extra 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; 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 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 1 SIMPLE t1 index_merge key1,key2 key1,key2 4,4 NULL 1 Using intersect(key1,key2); Using where; Using index
......
...@@ -380,26 +380,6 @@ delete from mysql.db where user='joe'; ...@@ -380,26 +380,6 @@ delete from mysql.db where user='joe';
delete from mysql.tables_priv where user='joe'; delete from mysql.tables_priv where user='joe';
delete from mysql.columns_priv where user='joe'; delete from mysql.columns_priv where user='joe';
flush privileges; flush privileges;
create procedure px5 ()
begin
declare v int;
declare c cursor for select version from
information_schema.tables where table_schema <> 'information_schema';
open c;
fetch c into v;
select v;
close c;
end;//
call px5()//
v
9
call px5()//
v
9
select sql_mode from information_schema.ROUTINES;
sql_mode
drop procedure px5;
create table t1 (a int not null auto_increment,b int, primary key (a)); create table t1 (a int not null auto_increment,b int, primary key (a));
insert into t1 values (1,1),(NULL,3),(NULL,4); insert into t1 values (1,1),(NULL,3),(NULL,4);
select AUTO_INCREMENT from information_schema.tables where table_name = 't1'; select AUTO_INCREMENT from information_schema.tables where table_name = 't1';
......
...@@ -41,8 +41,8 @@ lock tables t1 write; ...@@ -41,8 +41,8 @@ lock tables t1 write;
check table t2; check table t2;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t2 check error Table 't2' was not locked with LOCK TABLES test.t2 check error Table 't2' was not locked with LOCK TABLES
insert into t1 select nr from t1; insert into t1 select index1,nr from t1;
ERROR HY000: Table 't1' was not locked with LOCK TABLES ERROR 42000: INSERT command denied to user 'root'@'localhost' for column 'index1' in table 't1'
unlock tables; unlock tables;
lock tables t1 write, t1 as t1_alias read; lock tables t1 write, t1 as t1_alias read;
insert into t1 select index1,nr from t1 as t1_alias; insert into t1 select index1,nr from t1 as t1_alias;
......
...@@ -2,7 +2,7 @@ drop table if exists t1,t2; ...@@ -2,7 +2,7 @@ drop table if exists t1,t2;
select 1, 1.0, -1, "hello", NULL; 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 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 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 -1 8 2 2 N 32897 0 63
def hello 253 5 5 N 1 31 8 def hello 253 5 5 N 1 31 8
def NULL 6 0 0 Y 32896 0 63 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 ...@@ -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 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 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 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 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 j j 10 10 0 Y 128 0 63
def test t1 t1 k k 7 19 0 N 1249 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); ...@@ -19,13 +19,13 @@ INSERT INTO t1 VALUES (1), (2);
</database> </database>
</mysqldump> </mysqldump>
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a decimal(240, 20)); CREATE TABLE t1 (a decimal(64, 20));
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
("0987654321098765432109876543210987654321"); ("0987654321098765432109876543210987654321");
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`a` decimal(240,20) default NULL `a` decimal(64,20) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `t1` VALUES ('1234567890123456789012345678901234567890.00000000000000000000'),('0987654321098765432109876543210987654321.00000000000000000000'); INSERT INTO `t1` VALUES ('1234567890123456789012345678901234567890.00000000000000000000'),('987654321098765432109876543210987654321.00000000000000000000');
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a double); CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES ('-9e999999'); INSERT INTO t1 VALUES ('-9e999999');
......
...@@ -164,48 +164,48 @@ product country_id year sum(profit) ...@@ -164,48 +164,48 @@ product country_id year sum(profit)
NULL NULL NULL 7785 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; 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(*) prod year 1+1 sum(profit)/count(*)
Calculator:1 :1999: 2 50.00 Calculator:1 :1999: 2 50.00000
Calculator:1 :2000: 2 75.00 Calculator:1 :2000: 2 75.00000
Calculator:1 NULL 2 62.50 Calculator:1 NULL 2 62.50000
Calculator:2 :2000: 2 75.00 Calculator:2 :2000: 2 75.00000
Calculator:2 NULL 2 75.00 Calculator:2 NULL 2 75.00000
Computer:1 :1999: 2 1350.00 Computer:1 :1999: 2 1350.00000
Computer:1 :2000: 2 1500.00 Computer:1 :2000: 2 1500.00000
Computer:1 NULL 2 1400.00 Computer:1 NULL 2 1400.00000
Computer:2 :2000: 2 1350.00 Computer:2 :2000: 2 1350.00000
Computer:2 NULL 2 1350.00 Computer:2 NULL 2 1350.00000
Phone:3 :2003: 2 10.00 Phone:3 :2003: 2 10.00000
Phone:3 NULL 2 10.00 Phone:3 NULL 2 10.00000
TV:1 :1999: 2 125.00 TV:1 :1999: 2 125.00000
TV:1 :2000: 2 150.00 TV:1 :2000: 2 150.00000
TV:1 NULL 2 133.33 TV:1 NULL 2 133.33333
TV:2 :2000: 2 100.00 TV:2 :2000: 2 100.00000
TV:2 NULL 2 100.00 TV:2 NULL 2 100.00000
NULL NULL 2 519.00 NULL NULL 2 519.00000
select product, sum(profit)/count(*) from t1 group by product with rollup; select product, sum(profit)/count(*) from t1 group by product with rollup;
product sum(profit)/count(*) product sum(profit)/count(*)
Calculator 68.75 Calculator 68.75000
Computer 1380.00 Computer 1380.00000
Phone 10.00 Phone 10.00000
TV 120.00 TV 120.00000
NULL 519.00 NULL 519.00000
select left(product,4) as prod, sum(profit)/count(*) from t1 group by prod with rollup; select left(product,4) as prod, sum(profit)/count(*) from t1 group by prod with rollup;
prod sum(profit)/count(*) prod sum(profit)/count(*)
Calc 68.75 Calc 68.75000
Comp 1380.00 Comp 1380.00000
Phon 10.00 Phon 10.00000
TV 120.00 TV 120.00000
NULL 519.00 NULL 519.00000
select concat(product,':',country_id), 1+1, sum(profit)/count(*) from t1 group by concat(product,':',country_id) with rollup; 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(*) concat(product,':',country_id) 1+1 sum(profit)/count(*)
Calculator:1 2 62.50 Calculator:1 2 62.50000
Calculator:2 2 75.00 Calculator:2 2 75.00000
Computer:1 2 1400.00 Computer:1 2 1400.00000
Computer:2 2 1350.00 Computer:2 2 1350.00000
Phone:3 2 10.00 Phone:3 2 10.00000
TV:1 2 133.33 TV:1 2 133.33333
TV:2 2 100.00 TV:2 2 100.00000
NULL 2 519.00 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; 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) product country year sum(profit)
Calculator India 2000 150 Calculator India 2000 150
......
...@@ -293,7 +293,7 @@ t2 MyISAM 9 Fixed 0 0 0 64424509439 1024 0 NULL # # # latin1_swedish_ci NULL ...@@ -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%'' '; prepare stmt4 from ' show table status from test like ''t9%'' ';
execute stmt4; 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 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'' '; prepare stmt4 from ' show status like ''Threads_running'' ';
execute stmt4; execute stmt4;
Variable_name Value 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 ...@@ -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 'c5' at row 1
Warning 1265 Data truncated for column 'c6' 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 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 Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ; execute my_select ;
c1 1 c1 1
...@@ -2724,6 +2725,7 @@ Warning 1265 Data truncated for column 'c4' at row 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 'c5' at row 1
Warning 1265 Data truncated for column 'c6' 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 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 Warning 1264 Out of range value adjusted for column 'c12' at row 1
execute my_select ; execute my_select ;
c1 -1 c1 -1
......
...@@ -14,6 +14,8 @@ row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)) ...@@ -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')); 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')) row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a'))
1 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)); 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)) row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3))
1 1
......
...@@ -84,27 +84,27 @@ slave-bin.000001 229 User var 2 272 @`i2`=-12345678901234 ...@@ -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 272 User var 2 315 @`i3`=0
slave-bin.000001 315 User var 2 358 @`i4`=-1 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 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 470 User var 2 509 @`r1`=12.5
slave-bin.000001 513 User var 2 556 @`r2`=-12.5 slave-bin.000001 509 User var 2 548 @`r2`=-12.5
slave-bin.000001 556 Query 1 654 use `test`; insert into t1 values (@r1), (@r2) slave-bin.000001 548 Query 1 646 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 646 User var 2 695 @`s1`=_latin1 0x5468697320697320612074657374 COLLATE latin1_swedish_ci
slave-bin.000001 703 User var 2 738 @`s2`=_latin1 "" COLLATE latin1_swedish_ci slave-bin.000001 695 User var 2 730 @`s2`=_latin1 "" COLLATE latin1_swedish_ci
slave-bin.000001 738 User var 2 780 @`s3`=_latin1 0x61626327646566 COLLATE latin1_swedish_ci slave-bin.000001 730 User var 2 772 @`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 772 User var 2 814 @`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 814 User var 2 856 @`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 856 Query 1 975 use `test`; insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5)
slave-bin.000001 983 User var 2 1009 @`n1`=NULL slave-bin.000001 975 User var 2 1001 @`n1`=NULL
slave-bin.000001 1009 Query 1 1100 use `test`; insert into t1 values (@n1) slave-bin.000001 1001 Query 1 1092 use `test`; insert into t1 values (@n1)
slave-bin.000001 1100 User var 2 1126 @`n2`=NULL slave-bin.000001 1092 User var 2 1118 @`n2`=NULL
slave-bin.000001 1126 Query 1 1217 use `test`; insert into t1 values (@n2) slave-bin.000001 1118 Query 1 1209 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 1209 Query 1 1326 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 1326 User var 2 1368 @`a`=2
slave-bin.000001 1376 Query 1 1477 use `test`; insert into t1 values (@a+(@b:=@a+1)) slave-bin.000001 1368 Query 1 1469 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 1469 User var 2 1506 @`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 1506 Query 1 1639 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 1639 User var 2 1681 @`a`=5
slave-bin.000001 1689 Query 1 1784 use `test`; insert into t1 values (@a),(@a) slave-bin.000001 1681 Query 1 1776 use `test`; insert into t1 values (@a),(@a)
slave-bin.000001 1784 User var 2 1809 @`a`=NULL slave-bin.000001 1776 User var 2 1801 @`a`=NULL
slave-bin.000001 1809 Query 1 1911 use `test`; insert into t1 values (@a),(@a),(@a*5) slave-bin.000001 1801 Query 1 1903 use `test`; insert into t1 values (@a),(@a),(@a*5)
drop table t1; drop table t1;
stop slave; stop slave;
...@@ -1672,7 +1672,7 @@ fld1 count(*) ...@@ -1672,7 +1672,7 @@ fld1 count(*)
158402 4181 158402 4181
select sum(Period)/count(*) from t1; select sum(Period)/count(*) from t1;
sum(Period)/count(*) 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; 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 companynr count sum diff func
37 12543 309394878010 0.0000 464091 37 12543 309394878010 0.0000 464091
...@@ -2109,7 +2109,7 @@ select @b; ...@@ -2109,7 +2109,7 @@ select @b;
aaaa aaaa
select @c; select @c;
@c @c
6.26 6.260
create table t1 (a int not null auto_increment primary key); create table t1 (a int not null auto_increment primary key);
insert into t1 values (); insert into t1 values ();
insert into t1 values (); insert into t1 values ();
......
...@@ -120,15 +120,8 @@ ERROR 42000: End-label bar without match ...@@ -120,15 +120,8 @@ ERROR 42000: End-label bar without match
create procedure foo() create procedure foo()
return 42| return 42|
ERROR 42000: RETURN is only allowed in a FUNCTION ERROR 42000: RETURN is only allowed in a FUNCTION
create function foo() returns int
begin
declare x int;
select max(c) into x from test.t;
return x;
end|
ERROR 0A000: Statements like SELECT, INSERT, UPDATE (and others) are not allowed in a FUNCTION
create procedure p(x int) create procedure p(x int)
insert into test.t1 values (x)| set @x = x|
create function f(x int) returns int create function f(x int) returns int
return x+42| return x+42|
call p()| call p()|
...@@ -336,10 +329,6 @@ ERROR 42S22: Unknown column 'valname' in 'order clause' ...@@ -336,10 +329,6 @@ ERROR 42S22: Unknown column 'valname' in 'order clause'
drop procedure bug1965| drop procedure bug1965|
select 1 into a| select 1 into a|
ERROR 42000: Undeclared variable: a ERROR 42000: Undeclared variable: a
create function bug1654()
returns int
return (select sum(t.data) from test.t2 t)|
ERROR 0A000: Statements like SELECT, INSERT, UPDATE (and others) are not allowed in a FUNCTION
drop table if exists t3| drop table if exists t3|
create table t3 (column_1_0 int)| create table t3 (column_1_0 int)|
create procedure bug1653() create procedure bug1653()
...@@ -354,7 +343,7 @@ drop table t3| ...@@ -354,7 +343,7 @@ drop table t3|
create procedure bug2259() create procedure bug2259()
begin begin
declare v1 int; declare v1 int;
declare c1 cursor for select s1 from t10; declare c1 cursor for select s1 from t1;
fetch c1 into v1; fetch c1 into v1;
end| end|
call bug2259()| call bug2259()|
...@@ -458,7 +447,9 @@ create procedure bug3294() ...@@ -458,7 +447,9 @@ create procedure bug3294()
begin begin
declare continue handler for sqlexception drop table t5; declare continue handler for sqlexception drop table t5;
drop table t5; drop table t5;
drop table t5;
end| end|
create table t5 (x int)|
call bug3294()| call bug3294()|
ERROR 42S02: Unknown table 't5' ERROR 42S02: Unknown table 't5'
drop procedure bug3294| drop procedure bug3294|
......
...@@ -693,7 +693,7 @@ drop procedure if exists create_select| ...@@ -693,7 +693,7 @@ drop procedure if exists create_select|
create procedure create_select(x char(16), y int) create procedure create_select(x char(16), y int)
begin begin
insert into test.t1 values (x, y); insert into test.t1 values (x, y);
create table test.t3 select * from test.t1; create temporary table test.t3 select * from test.t1;
insert into test.t3 values (concat(x, "2"), y+2); insert into test.t3 values (concat(x, "2"), y+2);
end| end|
drop table if exists t3| drop table if exists t3|
...@@ -775,11 +775,11 @@ drop procedure if exists hndlr1| ...@@ -775,11 +775,11 @@ drop procedure if exists hndlr1|
create procedure hndlr1(val int) create procedure hndlr1(val int)
begin begin
declare x int default 0; declare x int default 0;
declare foo condition for 1146; declare foo condition for 1136;
declare bar condition for sqlstate '42S98'; # Just for testing syntax declare bar condition for sqlstate '42S98'; # Just for testing syntax
declare zip condition for sqlstate value '42S99'; # Just for testing syntax declare zip condition for sqlstate value '42S99'; # Just for testing syntax
declare continue handler for foo set x = 1; declare continue handler for foo set x = 1;
insert into test.t666 values ("hndlr1", val); # Non-existing table insert into test.t1 values ("hndlr1", val, 2); # Too many values
if (x) then if (x) then
insert into test.t1 values ("hndlr1", val); # This instead then insert into test.t1 values ("hndlr1", val); # This instead then
end if; end if;
...@@ -795,8 +795,8 @@ create procedure hndlr2(val int) ...@@ -795,8 +795,8 @@ create procedure hndlr2(val int)
begin begin
declare x int default 0; declare x int default 0;
begin begin
declare exit handler for sqlstate '42S02' set x = 1; declare exit handler for sqlstate '21S01' set x = 1;
insert into test.t666 values ("hndlr2", val); # Non-existing table insert into test.t1 values ("hndlr2", val, 2); # Too many values
end; end;
insert into test.t1 values ("hndlr2", x); insert into test.t1 values ("hndlr2", x);
end| end|
...@@ -820,7 +820,7 @@ if val < 10 then ...@@ -820,7 +820,7 @@ if val < 10 then
begin begin
declare y int; declare y int;
set y = val + 10; set y = val + 10;
insert into test.t666 values ("hndlr3", y); # Non-existing table insert into test.t1 values ("hndlr3", y, 2); # Too many values
if x then if x then
insert into test.t1 values ("hndlr3", y); insert into test.t1 values ("hndlr3", y);
end if; end if;
...@@ -1239,18 +1239,6 @@ call bug2227(9)| ...@@ -1239,18 +1239,6 @@ call bug2227(9)|
1.3 x y 42 z 1.3 x y 42 z
1.3 9 2.6 42 zzz 1.3 9 2.6 42 zzz
drop procedure bug2227| drop procedure bug2227|
drop procedure if exists bug2614|
create procedure bug2614()
begin
drop table if exists t3;
create table t3 (id int default '0' not null);
insert into t3 select 12;
insert into t3 select * from t3;
end|
call bug2614()|
call bug2614()|
drop table t3|
drop procedure bug2614|
drop function if exists bug2674| drop function if exists bug2674|
create function bug2674() returns int create function bug2674() returns int
return @@sort_buffer_size| return @@sort_buffer_size|
...@@ -1551,7 +1539,7 @@ drop procedure if exists bug2460_2| ...@@ -1551,7 +1539,7 @@ drop procedure if exists bug2460_2|
create procedure bug2460_2() create procedure bug2460_2()
begin begin
drop table if exists t3; drop table if exists t3;
create table t3 (s1 int); create temporary table t3 (s1 int);
insert into t3 select 1 union select 1; insert into t3 select 1 union select 1;
end| end|
call bug2460_2()| call bug2460_2()|
...@@ -1681,22 +1669,6 @@ call bug4726()| ...@@ -1681,22 +1669,6 @@ call bug4726()|
call bug4726()| call bug4726()|
drop procedure bug4726| drop procedure bug4726|
drop table t3| drop table t3|
drop table if exists t3|
create table t3 (s1 int)|
insert into t3 values (3), (4)|
drop procedure if exists bug4318|
create procedure bug4318()
handler t3 read next|
handler t3 open|
call bug4318()|
s1
3
call bug4318()|
s1
4
handler t3 close|
drop procedure bug4318|
drop table t3|
drop procedure if exists bug4902| drop procedure if exists bug4902|
create procedure bug4902() create procedure bug4902()
begin begin
...@@ -2302,22 +2274,110 @@ show procedure status like 'bar'| ...@@ -2302,22 +2274,110 @@ show procedure status like 'bar'|
Db Name Type Definer Modified Created Security_type Comment Db Name Type Definer Modified Created Security_type Comment
test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER 3333333333 test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER 3333333333
drop procedure bar| drop procedure bar|
drop table t1; drop procedure if exists p1|
drop table t2; create procedure p1 ()
drop procedure if exists p1; select (select s1 from t3) from t3|
create procedure p1 () select (select s1 from t1) from t1; create table t3 (s1 int)|
create table t1 (s1 int); call p1()|
call p1(); (select s1 from t3)
(select s1 from t1) insert into t3 values (1)|
insert into t1 values (1); call p1()|
call p1(); (select s1 from t3)
(select s1 from t1)
1 1
drop procedure p1; drop procedure p1|
drop table t1; drop table t3|
drop function if exists foo; drop function if exists foo|
create function `foo` () returns int return 5; create function `foo` () returns int
select `foo` (); return 5|
select `foo` ()|
`foo` () `foo` ()
5 5
drop function `foo`; drop function `foo`|
drop function if exists t1max|
Warnings:
Note 1305 FUNCTION t1max does not exist
create function t1max() returns int
begin
declare x int;
select max(data) into x from t1;
return x;
end|
insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)|
select t1max()|
t1max()
5
drop function t1max|
drop table if exists t3|
create table t3 (
v char(16) not null primary key,
c int unsigned not null
)|
create function getcount(s char(16)) returns int
begin
declare x int;
select count(*) into x from t3 where v = s;
if x = 0 then
insert into t3 values (s, 1);
else
update t3 set c = c+1 where v = s;
end if;
return x;
end|
select * from t1 where data = getcount("bar")|
id data
zap 1
select * from t3|
v c
bar 4
select getcount("zip")|
getcount("zip")
0
select getcount("zip")|
getcount("zip")
1
select * from t3|
v c
bar 4
zip 2
select getcount(id) from t1 where data = 3|
getcount(id)
0
select getcount(id) from t1 where data = 5|
getcount(id)
1
select * from t3|
v c
bar 4
zip 3
foo 1
drop table t3|
drop function getcount|
drop function if exists bug5240|
create function bug5240 () returns int
begin
declare x int;
declare c cursor for select data from t1 limit 1;
open c;
fetch c into x;
close c;
return x;
end|
delete from t1|
insert into t1 values ("answer", 42)|
select id, bug5240() from t1|
id bug5240()
42 42
drop function bug5240|
drop function if exists bug5278|
create function bug5278 () returns char
begin
SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');
return 'okay';
end|
select bug5278()|
ERROR 42000: Can't find any matching row in the user table
select bug5278()|
ERROR 42000: Can't find any matching row in the user table
drop function bug5278|
drop table t1;
drop table t2;
...@@ -614,7 +614,6 @@ Warning 1264 Out of range value adjusted for column 'col1' at row 1 ...@@ -614,7 +614,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 '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 '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
Warning 1264 Out of range value adjusted for column 'col2' at row 2
UPDATE IGNORE t1 SET col2=1/NULL where col1=0; UPDATE IGNORE t1 SET col2=1/NULL where col1=0;
SELECT * FROM t1; SELECT * FROM t1;
col1 col2 col1 col2
...@@ -639,6 +638,7 @@ INSERT INTO t1 VALUES(-9223372036854775808,0),(0,0),(9223372036854775807,1844674 ...@@ -639,6 +638,7 @@ INSERT INTO t1 VALUES(-9223372036854775808,0),(0,0),(9223372036854775807,1844674
INSERT INTO t1 VALUES('-9223372036854775808','0'),('9223372036854775807','18446744073709551615'); INSERT INTO t1 VALUES('-9223372036854775808','0'),('9223372036854775807','18446744073709551615');
INSERT INTO t1 VALUES(-9223372036854774000.0,0.0),(9223372036854775700.0,1844674407370954000.0); INSERT INTO t1 VALUES(-9223372036854774000.0,0.0),(9223372036854775700.0,1844674407370954000.0);
INSERT INTO t1 (col1) VALUES(-9223372036854775809); 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 (col1) VALUES(9223372036854775808);
INSERT INTO t1 (col2) VALUES(-1); INSERT INTO t1 (col2) VALUES(-1);
INSERT INTO t1 (col2) VALUES(18446744073709551616); INSERT INTO t1 (col2) VALUES(18446744073709551616);
...@@ -678,6 +678,7 @@ Error 1365 Division by 0 ...@@ -678,6 +678,7 @@ Error 1365 Division by 0
Error 1365 Division by 0 Error 1365 Division by 0
INSERT IGNORE INTO t1 VALUES(-9223372036854775809,-1),(9223372036854775808,18446744073709551616); INSERT IGNORE INTO t1 VALUES(-9223372036854775809,-1),(9223372036854775808,18446744073709551616);
Warnings: 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 Warning 1264 Out of range value adjusted for column 'col2' at row 2
INSERT IGNORE INTO t1 VALUES('-9223372036854775809','-1'),('9223372036854775808','18446744073709551616'); INSERT IGNORE INTO t1 VALUES('-9223372036854775809','-1'),('9223372036854775808','18446744073709551616');
Warnings: Warnings:
...@@ -699,9 +700,8 @@ col1 col2 ...@@ -699,9 +700,8 @@ col1 col2
9223372036854775807 18446744073709551615 9223372036854775807 18446744073709551615
-9223372036854775808 0 -9223372036854775808 0
9223372036854775807 18446744073709551615 9223372036854775807 18446744073709551615
-9223372036854773760 0 -9223372036854774000 0
9223372036854775807 1844674407370953984 9223372036854775700 1844674407370954000
-9223372036854775808 NULL
-9223372036854775808 NULL -9223372036854775808 NULL
NULL 18446744073709551615 NULL 18446744073709551615
2 NULL 2 NULL
...@@ -715,12 +715,17 @@ NULL NULL ...@@ -715,12 +715,17 @@ NULL NULL
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (col1 NUMERIC(4,2)); CREATE TABLE t1 (col1 NUMERIC(4,2));
INSERT INTO t1 VALUES (10.55),(10.5555),(0),(-10.55),(-10.5555),(11),(1e+01); 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'); INSERT INTO t1 VALUES ('10.55'),('10.5555'),('-10.55'),('-10.5555'),('11'),('1e+01');
Warnings: Warnings:
Note 1265 Data truncated for column 'col1' at row 2 Note 1265 Data truncated for column 'col1' at row 2
Note 1265 Data truncated for column 'col1' at row 4 Note 1265 Data truncated for column 'col1' at row 4
INSERT INTO t1 VALUES (101.55); INSERT INTO t1 VALUES (101.55);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES (101); INSERT INTO t1 VALUES (101);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES (-101.55); INSERT INTO t1 VALUES (-101.55);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1 ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES (1010.55); INSERT INTO t1 VALUES (1010.55);
...@@ -728,7 +733,9 @@ ERROR 22003: Out of range value adjusted for column 'col1' at row 1 ...@@ -728,7 +733,9 @@ ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES (1010); INSERT INTO t1 VALUES (1010);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1 ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES ('101.55'); INSERT INTO t1 VALUES ('101.55');
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES ('101'); INSERT INTO t1 VALUES ('101');
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES ('-101.55'); INSERT INTO t1 VALUES ('-101.55');
ERROR 22003: Out of range value adjusted for column 'col1' at row 1 ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 VALUES ('-1010.55'); INSERT INTO t1 VALUES ('-1010.55');
...@@ -744,14 +751,15 @@ ERROR 22012: Division by 0 ...@@ -744,14 +751,15 @@ ERROR 22012: Division by 0
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0; UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
ERROR 22012: Division by 0 ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES (''); 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'); 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'); 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'); INSERT IGNORE INTO t1 (col1) VALUES ('2a');
Warnings: 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); INSERT IGNORE INTO t1 values (1/0);
Warnings: Warnings:
Error 1365 Division by 0 Error 1365 Division by 0
...@@ -778,22 +786,19 @@ NULL ...@@ -778,22 +786,19 @@ NULL
11.00 11.00
10.00 10.00
10.55 10.55
10.55 10.56
-10.55
-10.55 -10.55
-10.56
11.00 11.00
10.00 10.00
101.55 1.00
101.00
101.55
101.00
2.00 2.00
NULL NULL
999.99 99.99
-99.99 -99.99
999.99 99.99
-99.99 -99.99
999.99 99.99
-99.99 -99.99
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (col1 FLOAT, col2 FLOAT UNSIGNED); 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 ...@@ -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 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 Using index
2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 Using index 2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 Using index
Warnings: 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'); CREATE TABLE t3 (a int(11) default '0');
INSERT INTO t3 VALUES (1),(2),(3); 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; 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 ...@@ -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 1 PRIMARY t1 index NULL s1 5 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
Warnings: 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; 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 5 NULL 3 Using index 1 PRIMARY t1 index NULL s1 5 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
Warnings: 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; 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 5 NULL 3 Using index 1 PRIMARY t1 index NULL s1 5 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
Warnings: 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; 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL s1 5 NULL 3 Using index 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 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 1 Using index; Using where
Warnings: 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; drop table t1,t2;
create table t2 (a int, b int); create table t2 (a int, b int);
create table t3 (a int); create table t3 (a int);
......
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 ( CREATE TABLE t1 (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
gender CHAR(1), gender CHAR(1),
......
...@@ -156,6 +156,9 @@ insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0"); ...@@ -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 ("-.1"),("+.1"),(".1");
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001"); insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11"); 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"); insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
Warnings: 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 1
...@@ -164,7 +167,7 @@ Warning 1264 Out of range value adjusted for column 'a' at row 3 ...@@ -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"); insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
Warnings: 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 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 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"); insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings: Warnings:
...@@ -172,24 +175,24 @@ Note 1265 Data truncated for column 'a' at row 3 ...@@ -172,24 +175,24 @@ Note 1265 Data truncated for column 'a' at row 3
select * from t1; select * from t1;
a a
0.00 0.00
-0.00 0.00
+0.00 0.00
01.00 1.00
+01.00 1.00
-01.00 -1.00
-0.10 -0.10
+0.10
0.10 0.10
000000001.00 0.10
+00000001.00 1.00
-00000001.00 1.00
111111111.11 -1.00
111111111.11 99999999.99
99999999.99
-11111111.11 -11111111.11
-99999999.99 -99999999.99
999999999.99 99999999.99
999999999.99 99999999.99
999999999.99 99999999.99
0.00 0.00
-99999999.99 -99999999.99
123.40 123.40
...@@ -222,7 +225,7 @@ Warning 1264 Out of range value adjusted for column 'a' at row 3 ...@@ -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"); insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
Warnings: 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 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 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"); insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings: Warnings:
...@@ -231,15 +234,15 @@ select * from t1; ...@@ -231,15 +234,15 @@ select * from t1;
a a
0.00 0.00
0.00 0.00
+0.00 0.00
01.00 1.00
+01.00 1.00
0.00 0.00
0.00 0.00
+0.10
0.10 0.10
00000001.00 0.10
+0000001.00 1.00
1.00
0.00 0.00
99999999.99 99999999.99
99999999.99 99999999.99
...@@ -280,7 +283,7 @@ Warning 1264 Out of range value adjusted for column 'a' at row 3 ...@@ -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"); insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
Warnings: 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 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 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"); insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings: Warnings:
...@@ -319,6 +322,9 @@ insert into t1 values (0.0),("-0.0"),(+0.0),(01.0),(+01.0),(-01.0); ...@@ -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 (-.1),(+.1),(.1);
insert into t1 values (00000000000001),(+0000000000001),(-0000000000001); insert into t1 values (00000000000001),(+0000000000001),(-0000000000001);
insert into t1 values (+111111111.11),(111111111.11),(-11111111.11); 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); insert into t1 values (-111111111.11),(+1111111111.11),(1111111111.11);
Warnings: 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 1
...@@ -327,12 +333,15 @@ Warning 1264 Out of range value adjusted for column 'a' at row 3 ...@@ -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); insert into t1 values (1e+100),(1e-100),(-1e+100);
Warnings: 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 1
Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 3 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); 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; select * from t1;
a a
0.00 0.00
-0.00 0.00
0.00 0.00
1.00 1.00
1.00 1.00
...@@ -343,13 +352,13 @@ a ...@@ -343,13 +352,13 @@ a
1.00 1.00
1.00 1.00
-1.00 -1.00
111111111.11 99999999.99
111111111.11 99999999.99
-11111111.11 -11111111.11
-99999999.99 -99999999.99
999999999.99 99999999.99
999999999.99 99999999.99
999999999.99 99999999.99
0.00 0.00
-99999999.99 -99999999.99
123.40 123.40
...@@ -362,16 +371,17 @@ create table t1 (a decimal); ...@@ -362,16 +371,17 @@ create table t1 (a decimal);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+12345678901'),(99999999999999); insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+12345678901'),(99999999999999);
Warnings: 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 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 Warning 1264 Out of range value adjusted for column 'a' at row 7
select * from t1; select * from t1;
a a
-9999999999 -9999999999
-1 -1
+1 1
01 1
+0000000001 1
12345678901 9999999999
99999999999 9999999999
drop table t1; drop table t1;
create table t1 (a decimal unsigned); create table t1 (a decimal unsigned);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999); 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 ...@@ -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 Warning 1264 Out of range value adjusted for column 'a' at row 7
select * from t1; select * from t1;
a a
0 9999999999
0 9999999999
+1 1
01 1
+000000001 1
1234567890 1234567890
9999999999 9999999999
drop table t1; drop table t1;
...@@ -397,8 +407,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2 ...@@ -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 Warning 1264 Out of range value adjusted for column 'a' at row 7
select * from t1; select * from t1;
a a
0000000000 9999999999
0000000000 9999999999
0000000001 0000000001
0000000001 0000000001
0000000001 0000000001
...@@ -413,8 +423,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2 ...@@ -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 Warning 1264 Out of range value adjusted for column 'a' at row 7
select * from t1; select * from t1;
a a
0000000000 9999999999
0000000000 9999999999
0000000001 0000000001
0000000001 0000000001
0000000001 0000000001
...@@ -424,19 +434,17 @@ drop table t1; ...@@ -424,19 +434,17 @@ drop table t1;
create table t1(a decimal(10,0)); create table t1(a decimal(10,0));
insert into t1 values ("1e4294967295"); insert into t1 values ("1e4294967295");
Warnings: Warnings:
Warning 1265 Data truncated for column 'a' at row 1
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 1
select * from t1; select * from t1;
a a
99999999999 9999999999
delete from t1; delete from t1;
insert into t1 values("1e4294967297"); insert into t1 values("1e4294967297");
Warnings: Warnings:
Warning 1265 Data truncated for column 'a' at row 1
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 1
select * from t1; select * from t1;
a a
99999999999 9999999999
drop table t1; drop table t1;
CREATE TABLE t1 (a_dec DECIMAL(-1,0)); 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 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)); ...@@ -448,7 +456,7 @@ CREATE TABLE t1 (a_dec DECIMAL(0,11));
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a_dec` decimal(12,11) default NULL `a_dec` decimal(11,11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
create table t1(a decimal(7,3)); create table t1(a decimal(7,3));
...@@ -456,64 +464,64 @@ insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000 ...@@ -456,64 +464,64 @@ insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000
select * from t1; select * from t1;
a a
1.000 1.000
+1.000 1.000
-1.000 -1.000
00001.000 1.000
+0001.000 1.000
-0001.000 -1.000
10.000
10.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
-100.000 -100.000
00100.000
+0100.000
-0100.000
1000.000 1000.000
+1000.000 1000.000
-1000.000 -1000.000
01000.000 1000.000
+1000.000 1000.000
-1000.000 -1000.000
10000.000 9999.999
10000.000 9999.999
-9999.999 -9999.999
10000.000 9999.999
10000.000 9999.999
-9999.999 -9999.999
99999.999 9999.999
99999.999 9999.999
-9999.999 -9999.999
99999.999 9999.999
99999.999 9999.999
-9999.999 -9999.999
99999.999 9999.999
99999.999 9999.999
-9999.999 -9999.999
99999.999 9999.999
99999.999 9999.999
-9999.999 -9999.999
99999.999 9999.999
99999.999 9999.999
-9999.999 -9999.999
99999.999 9999.999
99999.999 9999.999
-9999.999 -9999.999
99999.999 9999.999
99999.999 9999.999
-9999.999 -9999.999
99999.999 9999.999
99999.999 9999.999
-9999.999 -9999.999
99999.999 9999.999
99999.999 9999.999
-9999.999 -9999.999
99999.999 9999.999
99999.999 9999.999
-9999.999 -9999.999
drop table t1; drop table t1;
create table t1(a decimal(7,3) unsigned); create table t1(a decimal(7,3) unsigned);
...@@ -521,22 +529,22 @@ insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000 ...@@ -521,22 +529,22 @@ insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000
select * from t1; select * from t1;
a a
1.000 1.000
+1.000 1.000
0.000 0.000
0001.000 1.000
+001.000 1.000
0.000 0.000
10.000 10.000
+10.000 10.000
0.000 0.000
0010.000 10.000
+010.000 10.000
0.000 0.000
100.000 100.000
+100.000 100.000
0.000 0.000
0100.000 100.000
+100.000 100.000
0.000 0.000
1000.000 1000.000
1000.000 1000.000
......
...@@ -66,7 +66,7 @@ select a from t1 order by a; ...@@ -66,7 +66,7 @@ select a from t1 order by a;
a a
-0.010 -0.010
-0.002 -0.002
-0.000 0.000
0.000 0.000
1.000 1.000
select min(a) from t1; select min(a) from t1;
...@@ -119,7 +119,7 @@ select a from t1 order by a; ...@@ -119,7 +119,7 @@ select a from t1 order by a;
a a
-0.010 -0.010
-0.002 -0.002
-0.000 0.000
0.000 0.000
1.000 1.000
select min(a) from t1; select min(a) from t1;
...@@ -142,6 +142,9 @@ create table t1 (c20 char); ...@@ -142,6 +142,9 @@ create table t1 (c20 char);
insert into t1 values (5000.0); insert into t1 values (5000.0);
Warnings: Warnings:
Warning 1265 Data truncated for column 'c20' at row 1 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; drop table t1;
create table t1 (f float(54)); create table t1 (f float(54));
ERROR 42000: Incorrect column specifier for column 'f' ERROR 42000: Incorrect column specifier for column 'f'
......
This diff is collapsed.
...@@ -87,6 +87,8 @@ DROP INDEX test ON t1; ...@@ -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 (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 (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); 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); 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: Warnings:
Warning 1264 Out of range value adjusted for column 'utiny' at row 1 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 ...@@ -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 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 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 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 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 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 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 ...@@ -174,7 +176,7 @@ Warning 1265 Data truncated for column 'new_field' at row 7
select * from t2; select * from t2;
auto string mediumblob_col new_field auto string mediumblob_col new_field
1 2 2 ne 1 2 2 ne
2 0.33 ne 2 0.33333333 ne
3 -1 -1 ne 3 -1 -1 ne
4 -429496729 -4294967295 ne 4 -429496729 -4294967295 ne
5 4294967295 4294967295 ne 5 4294967295 4294967295 ne
...@@ -268,7 +270,7 @@ drop table t2; ...@@ -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; 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; show full columns from t2;
Field Type Collation Null Key Default Extra Privileges Comment 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 t1 bigint(1) NULL NO 0 select,insert,update,references
t2 varchar(1) latin1_swedish_ci NO 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 t3 varchar(256) latin1_swedish_ci NO select,insert,update,references
......
...@@ -565,7 +565,7 @@ a ...@@ -565,7 +565,7 @@ a
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( 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 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; 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); 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; ...@@ -788,11 +788,11 @@ create table t3 select * from t2 union select * from t1;
select * from t3; select * from t3;
d d
1.234567800 1.234567800
100000000.0 100000000.000000000
show create table t3; show create table t3;
Table Create Table Table Create Table
t3 CREATE TABLE `t3` ( t3 CREATE TABLE `t3` (
`d` decimal(10,9) default NULL `d` decimal(19,9) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1,t2,t3; drop table t1,t2,t3;
create table t1 select 1 union select -1; create table t1 select 1 union select -1;
......
...@@ -500,14 +500,15 @@ t1 CREATE TABLE `t1` ( ...@@ -500,14 +500,15 @@ t1 CREATE TABLE `t1` (
`c5` bigint(20) default NULL `c5` bigint(20) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
set @arg00= 8, @arg01= 8.8, @arg02= 'a string'; 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; create table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3, @arg03 as c4;
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` bigint(20) default NULL, `c1` bigint(20) default NULL,
`c2` double default NULL, `c2` decimal(64,30) default NULL,
`c3` longtext `c3` longtext,
`c4` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8; SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8;
......
...@@ -448,7 +448,7 @@ create view v1 as select a+1 from t1; ...@@ -448,7 +448,7 @@ create view v1 as select a+1 from t1;
create table t2 select * from v1; create table t2 select * from v1;
show columns from t2; show columns from t2;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a+1 bigint(17) YES NULL a+1 bigint(12) YES NULL
select * from t2; select * from t2;
a+1 a+1
2 2
...@@ -889,10 +889,6 @@ ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function ...@@ -889,10 +889,6 @@ ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function
drop view v1; drop view v1;
create view v1 (a,a) as select 'a','a'; create view v1 (a,a) as select 'a','a';
ERROR 42S21: Duplicate column name 'a' ERROR 42S21: Duplicate column name 'a'
create procedure p1 () begin declare v int; create view v1 as select v; end;//
call p1();
ERROR HY000: View's SELECT contains a variable or parameter
drop procedure p1;
create table t1 (col1 int,col2 char(22)); create table t1 (col1 int,col2 char(22));
insert into t1 values(5,'Hello, world of views'); insert into t1 values(5,'Hello, world of views');
create view v1 as select * from t1; create view v1 as select * from t1;
......
...@@ -58,7 +58,10 @@ CREATE TABLE t1 SELECT ...@@ -58,7 +58,10 @@ CREATE TABLE t1 SELECT
CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6, 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 ELSE 1.0 END AS c7,
CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8, 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; SHOW CREATE TABLE t1;
DROP TABLE t1; DROP TABLE t1;
......
...@@ -11,10 +11,12 @@ drop table if exists t1,t2; ...@@ -11,10 +11,12 @@ drop table if exists t1,t2;
# First some simple tests # 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<=>NULL,NULL<=>0;
select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0; select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0;
select "A"<=>"B","A"<=>NULL,NULL<=>"A"; 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 # Test with tables
......
...@@ -189,23 +189,27 @@ delete from mysql.tables_priv where user='joe'; ...@@ -189,23 +189,27 @@ delete from mysql.tables_priv where user='joe';
delete from mysql.columns_priv where user='joe'; delete from mysql.columns_priv where user='joe';
flush privileges; flush privileges;
delimiter //; # QQ This results in NULLs instead of the version numbers when
create procedure px5 () # QQ a LOCK TABLES is in effect when selecting from
begin # QQ information_schema.tables. Until this bug has been fixed,
declare v int; # QQ this test is disabled /pem
declare c cursor for select version from #delimiter //;
information_schema.tables where table_schema <> 'information_schema'; #create procedure px5 ()
open c; #begin
fetch c into v; #declare v int;
select v; #declare c cursor for select version from
close c; #information_schema.tables where table_schema <> 'information_schema';
end;// #open c;
#fetch c into v;
call px5()// #select v;
call px5()// #close c;
delimiter ;// #end;//
select sql_mode from information_schema.ROUTINES; #
drop procedure px5; #call px5()//
#call px5()//
#delimiter ;//
#select sql_mode from information_schema.ROUTINES;
#drop procedure px5;
create table t1 (a int not null auto_increment,b int, primary key (a)); create table t1 (a int not null auto_increment,b int, primary key (a));
insert into t1 values (1,1),(NULL,3),(NULL,4); insert into t1 values (1,1),(NULL,3),(NULL,4);
......
...@@ -53,8 +53,8 @@ check table t1; ...@@ -53,8 +53,8 @@ check table t1;
# Check error message # Check error message
lock tables t1 write; lock tables t1 write;
check table t2; check table t2;
--error 1100 --error 1143
insert into t1 select nr from t1; insert into t1 select index1,nr from t1;
unlock tables; unlock tables;
lock tables t1 write, t1 as t1_alias read; lock tables t1 write, t1 as t1_alias read;
insert into t1 select index1,nr from t1 as t1_alias; insert into t1 select index1,nr from t1 as t1_alias;
......
...@@ -14,7 +14,7 @@ DROP TABLE t1; ...@@ -14,7 +14,7 @@ DROP TABLE t1;
# Bug #2005 # Bug #2005
# #
CREATE TABLE t1 (a decimal(240, 20)); CREATE TABLE t1 (a decimal(64, 20));
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
("0987654321098765432109876543210987654321"); ("0987654321098765432109876543210987654321");
--exec $MYSQL_DUMP --compact test t1 --exec $MYSQL_DUMP --compact test t1
......
...@@ -163,18 +163,9 @@ end loop bar| ...@@ -163,18 +163,9 @@ end loop bar|
create procedure foo() create procedure foo()
return 42| return 42|
# Doesn't allow queries in FUNCTIONs (for now :-( )
--error 1314
create function foo() returns int
begin
declare x int;
select max(c) into x from test.t;
return x;
end|
# Wrong number of arguments # Wrong number of arguments
create procedure p(x int) create procedure p(x int)
insert into test.t1 values (x)| set @x = x|
create function f(x int) returns int create function f(x int) returns int
return x+42| return x+42|
...@@ -439,14 +430,6 @@ drop procedure bug1965| ...@@ -439,14 +430,6 @@ drop procedure bug1965|
--error 1327 --error 1327
select 1 into a| select 1 into a|
#
# BUG#1654
#
--error 1314
create function bug1654()
returns int
return (select sum(t.data) from test.t2 t)|
# #
# BUG#1653 # BUG#1653
# #
...@@ -475,7 +458,7 @@ drop table t3| ...@@ -475,7 +458,7 @@ drop table t3|
create procedure bug2259() create procedure bug2259()
begin begin
declare v1 int; declare v1 int;
declare c1 cursor for select s1 from t10; declare c1 cursor for select s1 from t1;
fetch c1 into v1; fetch c1 into v1;
end| end|
...@@ -628,8 +611,10 @@ create procedure bug3294() ...@@ -628,8 +611,10 @@ create procedure bug3294()
begin begin
declare continue handler for sqlexception drop table t5; declare continue handler for sqlexception drop table t5;
drop table t5; drop table t5;
drop table t5;
end| end|
create table t5 (x int)|
--error 1051 --error 1051
call bug3294()| call bug3294()|
drop procedure bug3294| drop procedure bug3294|
......
...@@ -859,7 +859,7 @@ drop procedure if exists create_select| ...@@ -859,7 +859,7 @@ drop procedure if exists create_select|
create procedure create_select(x char(16), y int) create procedure create_select(x char(16), y int)
begin begin
insert into test.t1 values (x, y); insert into test.t1 values (x, y);
create table test.t3 select * from test.t1; create temporary table test.t3 select * from test.t1;
insert into test.t3 values (concat(x, "2"), y+2); insert into test.t3 values (concat(x, "2"), y+2);
end| end|
...@@ -970,12 +970,12 @@ drop procedure if exists hndlr1| ...@@ -970,12 +970,12 @@ drop procedure if exists hndlr1|
create procedure hndlr1(val int) create procedure hndlr1(val int)
begin begin
declare x int default 0; declare x int default 0;
declare foo condition for 1146; declare foo condition for 1136;
declare bar condition for sqlstate '42S98'; # Just for testing syntax declare bar condition for sqlstate '42S98'; # Just for testing syntax
declare zip condition for sqlstate value '42S99'; # Just for testing syntax declare zip condition for sqlstate value '42S99'; # Just for testing syntax
declare continue handler for foo set x = 1; declare continue handler for foo set x = 1;
insert into test.t666 values ("hndlr1", val); # Non-existing table insert into test.t1 values ("hndlr1", val, 2); # Too many values
if (x) then if (x) then
insert into test.t1 values ("hndlr1", val); # This instead then insert into test.t1 values ("hndlr1", val); # This instead then
end if; end if;
...@@ -994,9 +994,9 @@ begin ...@@ -994,9 +994,9 @@ begin
declare x int default 0; declare x int default 0;
begin begin
declare exit handler for sqlstate '42S02' set x = 1; declare exit handler for sqlstate '21S01' set x = 1;
insert into test.t666 values ("hndlr2", val); # Non-existing table insert into test.t1 values ("hndlr2", val, 2); # Too many values
end; end;
insert into test.t1 values ("hndlr2", x); insert into test.t1 values ("hndlr2", x);
...@@ -1027,7 +1027,7 @@ begin ...@@ -1027,7 +1027,7 @@ begin
declare y int; declare y int;
set y = val + 10; set y = val + 10;
insert into test.t666 values ("hndlr3", y); # Non-existing table insert into test.t1 values ("hndlr3", y, 2); # Too many values
if x then if x then
insert into test.t1 values ("hndlr3", y); insert into test.t1 values ("hndlr3", y);
end if; end if;
...@@ -1517,23 +1517,30 @@ drop procedure bug2227| ...@@ -1517,23 +1517,30 @@ drop procedure bug2227|
# #
# BUG#2614 # BUG#2614
# #
--disable_warnings # QQ The second insert doesn't work with temporary tables (it was an
drop procedure if exists bug2614| # QQ ordinary table before we changed the locking scheme). It results
--enable_warnings # QQ in an error: 1137: Can't reopen table: 't3'
create procedure bug2614() # QQ which is a known limit with temporary tables.
begin # QQ For this reason we can't run this test any more (i.e., if we modify
drop table if exists t3; # QQ it, it's no longer a test case for the bug), but we keep it here
create table t3 (id int default '0' not null); # QQ anyway, for tracability.
insert into t3 select 12; #--disable_warnings
insert into t3 select * from t3; #drop procedure if exists bug2614|
end| #--enable_warnings
#create procedure bug2614()
--disable_warnings #begin
call bug2614()| # drop table if exists t3;
--enable_warnings # create temporary table t3 (id int default '0' not null);
call bug2614()| # insert into t3 select 12;
drop table t3| # insert into t3 select * from t3;
drop procedure bug2614| #end|
#
#--disable_warnings
#call bug2614()|
#--enable_warnings
#call bug2614()|
#drop table t3|
#drop procedure bug2614|
# #
# BUG#2674 # BUG#2674
...@@ -1912,7 +1919,7 @@ drop procedure if exists bug2460_2| ...@@ -1912,7 +1919,7 @@ drop procedure if exists bug2460_2|
create procedure bug2460_2() create procedure bug2460_2()
begin begin
drop table if exists t3; drop table if exists t3;
create table t3 (s1 int); create temporary table t3 (s1 int);
insert into t3 select 1 union select 1; insert into t3 select 1 union select 1;
end| end|
...@@ -2093,27 +2100,28 @@ drop table t3| ...@@ -2093,27 +2100,28 @@ drop table t3|
# #
# BUG#4318 # BUG#4318
# #
--disable_warnings #QQ Don't know if HANDLER commands can work with SPs, or at all...
drop table if exists t3| #--disable_warnings
--enable_warnings #drop table if exists t3|
#--enable_warnings
create table t3 (s1 int)| #
insert into t3 values (3), (4)| #create table t3 (s1 int)|
#insert into t3 values (3), (4)|
--disable_warnings #
drop procedure if exists bug4318| #--disable_warnings
--enable_warnings #drop procedure if exists bug4318|
create procedure bug4318() #--enable_warnings
handler t3 read next| #create procedure bug4318()
# handler t3 read next|
handler t3 open| #
# Expect no results, as tables are closed, but there shouldn't be any errors #handler t3 open|
call bug4318()| ## Expect no results, as tables are closed, but there shouldn't be any errors
call bug4318()| #call bug4318()|
handler t3 close| #call bug4318()|
#handler t3 close|
drop procedure bug4318| #
drop table t3| #drop procedure bug4318|
#drop table t3|
# #
# BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error # BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error
...@@ -2712,30 +2720,136 @@ show create procedure bar| ...@@ -2712,30 +2720,136 @@ show create procedure bar|
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' --replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
show procedure status like 'bar'| show procedure status like 'bar'|
drop procedure bar| drop procedure bar|
delimiter ;|
drop table t1;
drop table t2;
# #
# rexecution # rexecution
# #
--disable_warnings --disable_warnings
drop procedure if exists p1; drop procedure if exists p1|
--enable_warnings --enable_warnings
create procedure p1 () select (select s1 from t1) from t1; create procedure p1 ()
create table t1 (s1 int); select (select s1 from t3) from t3|
call p1();
insert into t1 values (1); create table t3 (s1 int)|
call p1();
drop procedure p1; call p1()|
drop table t1; insert into t3 values (1)|
call p1()|
drop procedure p1|
drop table t3|
# #
# backticks # backticks
# #
--disable_warnings --disable_warnings
drop function if exists foo; drop function if exists foo|
--enable_warnings --enable_warnings
create function `foo` () returns int return 5; create function `foo` () returns int
select `foo` (); return 5|
drop function `foo`; select `foo` ()|
drop function `foo`|
#
# Implicit LOCK/UNLOCK TABLES for table access in functions
#
--disable_warning
drop function if exists t1max|
--enable_warnings
create function t1max() returns int
begin
declare x int;
select max(data) into x from t1;
return x;
end|
insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)|
select t1max()|
drop function t1max|
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 (
v char(16) not null primary key,
c int unsigned not null
)|
create function getcount(s char(16)) returns int
begin
declare x int;
select count(*) into x from t3 where v = s;
if x = 0 then
insert into t3 values (s, 1);
else
update t3 set c = c+1 where v = s;
end if;
return x;
end|
select * from t1 where data = getcount("bar")|
select * from t3|
select getcount("zip")|
select getcount("zip")|
select * from t3|
select getcount(id) from t1 where data = 3|
select getcount(id) from t1 where data = 5|
select * from t3|
drop table t3|
drop function getcount|
#
# Former BUG#1654
# QQ Currently crashes
#
#create function bug1654() returns int
# return (select sum(t1.data) from test.t1 t)|
#
#select bug1654()|
#
# BUG#5240: Stored procedure crash if function has cursor declaration
#
--disable_warnings
drop function if exists bug5240|
--enable_warnings
create function bug5240 () returns int
begin
declare x int;
declare c cursor for select data from t1 limit 1;
open c;
fetch c into x;
close c;
return x;
end|
delete from t1|
insert into t1 values ("answer", 42)|
# QQ BUG: This returns the wrong result, id=42 instead of "answer".
select id, bug5240() from t1|
drop function bug5240|
#
# BUG#5278: Stored procedure packets out of order if SET PASSWORD.
#
--disable_warnings
drop function if exists bug5278|
--enable_warnings
create function bug5278 () returns char
begin
SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');
return 'okay';
end|
--error 1133
select bug5278()|
--error 1133
select bug5278()|
drop function bug5278|
delimiter ;|
drop table t1;
drop table t2;
...@@ -686,9 +686,7 @@ INSERT INTO t1 VALUES(-9223372036854775808,0),(0,0),(9223372036854775807,1844674 ...@@ -686,9 +686,7 @@ INSERT INTO t1 VALUES(-9223372036854775808,0),(0,0),(9223372036854775807,1844674
INSERT INTO t1 VALUES('-9223372036854775808','0'),('9223372036854775807','18446744073709551615'); INSERT INTO t1 VALUES('-9223372036854775808','0'),('9223372036854775807','18446744073709551615');
INSERT INTO t1 VALUES(-9223372036854774000.0,0.0),(9223372036854775700.0,1844674407370954000.0); 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 -- error 1264
# for Field_longlong::store()
INSERT INTO t1 (col1) VALUES(-9223372036854775809); INSERT INTO t1 (col1) VALUES(-9223372036854775809);
INSERT INTO t1 (col1) VALUES(9223372036854775808); INSERT INTO t1 (col1) VALUES(9223372036854775808);
INSERT INTO t1 (col2) VALUES(-1); INSERT INTO t1 (col2) VALUES(-1);
...@@ -747,7 +745,9 @@ INSERT INTO t1 VALUES ('10.55'),('10.5555'),('-10.55'),('-10.5555'),('11'),('1e+ ...@@ -747,7 +745,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 -- The 2 following inserts should generate a warning, but doesn't yet
-- because NUMERIC works like DECIMAL -- because NUMERIC works like DECIMAL
--error 1264
INSERT INTO t1 VALUES (101.55); INSERT INTO t1 VALUES (101.55);
--error 1264
INSERT INTO t1 VALUES (101); INSERT INTO t1 VALUES (101);
--error 1264 --error 1264
INSERT INTO t1 VALUES (-101.55); INSERT INTO t1 VALUES (-101.55);
...@@ -757,7 +757,9 @@ INSERT INTO t1 VALUES (1010.55); ...@@ -757,7 +757,9 @@ INSERT INTO t1 VALUES (1010.55);
INSERT INTO t1 VALUES (1010); INSERT INTO t1 VALUES (1010);
-- The 2 following inserts should generate a warning, but doesn't yet -- The 2 following inserts should generate a warning, but doesn't yet
-- because NUMERIC works like DECIMAL -- because NUMERIC works like DECIMAL
--error 1264
INSERT INTO t1 VALUES ('101.55'); INSERT INTO t1 VALUES ('101.55');
--error 1264
INSERT INTO t1 VALUES ('101'); INSERT INTO t1 VALUES ('101');
--error 1264 --error 1264
INSERT INTO t1 VALUES ('-101.55'); INSERT INTO t1 VALUES ('-101.55');
...@@ -773,11 +775,13 @@ UPDATE t1 SET col1 =col1 * 50000 WHERE col1 =11; ...@@ -773,11 +775,13 @@ UPDATE t1 SET col1 =col1 * 50000 WHERE col1 =11;
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0; UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
--error 1365 --error 1365
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0; UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
--error 1265 #--error 1265
--error 1366
INSERT INTO t1 (col1) VALUES (''); INSERT INTO t1 (col1) VALUES ('');
--error 1265 #--error 1265
--error 1366
INSERT INTO t1 (col1) VALUES ('a59b'); INSERT INTO t1 (col1) VALUES ('a59b');
--error 1265 #--error 1265
INSERT INTO t1 (col1) VALUES ('1a'); INSERT INTO t1 (col1) VALUES ('1a');
INSERT IGNORE INTO t1 (col1) VALUES ('2a'); INSERT IGNORE INTO t1 (col1) VALUES ('2a');
INSERT IGNORE INTO t1 values (1/0); INSERT IGNORE INTO t1 values (1/0);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Various tests for SUM(DISTINCT ...) # Various tests for SUM(DISTINCT ...)
# #
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1, t2;
--enable_warnings --enable_warnings
CREATE TABLE t1 ( CREATE TABLE t1 (
......
...@@ -84,6 +84,7 @@ drop table t1; ...@@ -84,6 +84,7 @@ drop table t1;
# #
create table t1 (c20 char); create table t1 (c20 char);
insert into t1 values (5000.0); insert into t1 values (5000.0);
insert into t1 values (0.5e4);
drop table t1; drop table t1;
# Errors # Errors
......
This diff is collapsed.
...@@ -368,8 +368,8 @@ show create table t1; ...@@ -368,8 +368,8 @@ show create table t1;
drop table t1; drop table t1;
# #
# What types and widths have variables? # What types and widths have variables?
set @arg00= 8, @arg01= 8.8, @arg02= 'a string'; 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; create table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3, @arg03 as c4;
show create table t1; show create table t1;
drop table t1; drop table t1;
......
...@@ -863,12 +863,15 @@ create view v1 (a,a) as select 'a','a'; ...@@ -863,12 +863,15 @@ create view v1 (a,a) as select 'a','a';
# #
# SP variables inside view test # SP variables inside view test
# #
delimiter //; # QQ This can't be tested with the new table locking for functions,
create procedure p1 () begin declare v int; create view v1 as select v; end;// # QQ since views created in an SP can't be used within the same SP
delimiter ;// # QQ (just as for tables). Instead it fails with error 1146.
-- error 1351 #delimiter //;
call p1(); #create procedure p1 () begin declare v int; create view v1 as select v; end;//
drop procedure p1; #delimiter ;//
#-- error 1351
#call p1();
#drop procedure p1;
# #
# updatablity should be transitive # updatablity should be transitive
......
...@@ -58,7 +58,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ ...@@ -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 \ log_event.h sql_repl.h slave.h \
stacktrace.h sql_sort.h sql_cache.h set_var.h \ stacktrace.h sql_sort.h sql_cache.h set_var.h \
spatial.h gstream.h client_settings.h tzfile.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 \ sp_head.h sp_pcontext.h sp_rcontext.h sp.h sp_cache.h \
parse_file.h sql_view.h sql_trigger.h \ parse_file.h sql_view.h sql_trigger.h \
examples/ha_example.h examples/ha_archive.h \ examples/ha_example.h examples/ha_archive.h \
...@@ -95,7 +95,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \ ...@@ -95,7 +95,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
stacktrace.c repl_failsafe.h repl_failsafe.cc \ stacktrace.c repl_failsafe.h repl_failsafe.cc \
sql_olap.cc sql_view.cc \ sql_olap.cc sql_view.cc \
gstream.cc spatial.cc sql_help.cc protocol_cursor.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_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \
sp_cache.cc parse_file.cc sql_trigger.cc \ sp_cache.cc parse_file.cc sql_trigger.cc \
examples/ha_example.cc examples/ha_archive.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) ...@@ -586,6 +586,9 @@ void field_conv(Field *to,Field *from)
!(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) && !(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) &&
to->real_type() != FIELD_TYPE_ENUM && to->real_type() != FIELD_TYPE_ENUM &&
to->real_type() != FIELD_TYPE_SET && 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() && from->charset() == to->charset() &&
to->table->s->db_low_byte_first == from->table->s->db_low_byte_first) to->table->s->db_low_byte_first == from->table->s->db_low_byte_first)
{ // Identical fields { // Identical fields
...@@ -623,6 +626,11 @@ void field_conv(Field *to,Field *from) ...@@ -623,6 +626,11 @@ void field_conv(Field *to,Field *from)
} }
else if (from->result_type() == REAL_RESULT) else if (from->result_type() == REAL_RESULT)
to->store(from->val_real()); to->store(from->val_real());
else if (from->result_type() == DECIMAL_RESULT)
{
my_decimal buff;
to->store_decimal(from->val_decimal(&buff));
}
else else
to->store(from->val_int()); to->store(from->val_int());
} }
...@@ -703,6 +703,22 @@ static void make_sortkey(register SORTPARAM *param, ...@@ -703,6 +703,22 @@ static void make_sortkey(register SORTPARAM *param,
#endif #endif
break; 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: case REAL_RESULT:
{ {
double value= item->val_real(); double value= item->val_real();
...@@ -1212,6 +1228,12 @@ sortlength(SORT_FIELD *sortorder, uint s_length, bool *multi_byte_charset) ...@@ -1212,6 +1228,12 @@ sortlength(SORT_FIELD *sortorder, uint s_length, bool *multi_byte_charset)
sortorder->length=4; sortorder->length=4;
#endif #endif
break; 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: case REAL_RESULT:
sortorder->length=sizeof(double); sortorder->length=sizeof(double);
break; break;
......
...@@ -2159,6 +2159,8 @@ get_innobase_type_from_mysql_type( ...@@ -2159,6 +2159,8 @@ get_innobase_type_from_mysql_type(
} else { } else {
return(DATA_MYSQL); return(DATA_MYSQL);
} }
case FIELD_TYPE_NEWDECIMAL:
return(DATA_BINARY);
case FIELD_TYPE_LONG: case FIELD_TYPE_LONG:
case FIELD_TYPE_LONGLONG: case FIELD_TYPE_LONGLONG:
case FIELD_TYPE_TINY: case FIELD_TYPE_TINY:
......
...@@ -727,7 +727,7 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) ...@@ -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))) 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), my_snprintf(buf, sizeof(buf),
"Failed to flush to index file (errno: %d)", error); "Failed to flush to index file (errno: %d)", error);
errmsg= buf; errmsg= buf;
......
This diff is collapsed.
This diff is collapsed.
...@@ -28,11 +28,21 @@ Item_buff *new_Item_buff(Item *item) ...@@ -28,11 +28,21 @@ Item_buff *new_Item_buff(Item *item)
if (item->type() == Item::FIELD_ITEM && if (item->type() == Item::FIELD_ITEM &&
!(((Item_field *) item)->field->flags & BLOB_FLAG)) !(((Item_field *) item)->field->flags & BLOB_FLAG))
return new Item_field_buff((Item_field *) item); 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); 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); return new Item_int_buff((Item_field *) item);
return new Item_real_buff(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() {} Item_buff::~Item_buff() {}
...@@ -107,6 +117,27 @@ bool Item_field_buff::cmp(void) ...@@ -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 ** Instansiate templates
*****************************************************************************/ *****************************************************************************/
......
This diff is collapsed.
...@@ -67,6 +67,7 @@ public: ...@@ -67,6 +67,7 @@ public:
int compare_string(); // compare args[0] & args[1] int compare_string(); // compare args[0] & args[1]
int compare_binary_string(); // compare args[0] & args[1] int compare_binary_string(); // compare args[0] & args[1]
int compare_real(); // compare args[0] & args[1] int compare_real(); // compare args[0] & args[1]
int compare_decimal(); // compare args[0] & args[1]
int compare_int_signed(); // compare args[0] & args[1] int compare_int_signed(); // compare args[0] & args[1]
int compare_int_signed_unsigned(); int compare_int_signed_unsigned();
int compare_int_unsigned_signed(); int compare_int_unsigned_signed();
...@@ -75,11 +76,12 @@ public: ...@@ -75,11 +76,12 @@ public:
int compare_e_string(); // compare args[0] & args[1] int compare_e_string(); // compare args[0] & args[1]
int compare_e_binary_string(); // compare args[0] & args[1] int compare_e_binary_string(); // compare args[0] & args[1]
int compare_e_real(); // compare args[0] & args[1] int compare_e_real(); // compare args[0] & args[1]
int compare_e_decimal(); // compare args[0] & args[1]
int compare_e_int(); // compare args[0] & args[1] int compare_e_int(); // compare args[0] & args[1]
int compare_e_int_diff_signedness(); int compare_e_int_diff_signedness();
int compare_e_row(); // compare args[0] & args[1] int compare_e_row(); // compare args[0] & args[1]
static arg_cmp_func comparator_matrix [4][2]; static arg_cmp_func comparator_matrix [5][2];
friend class Item_func; friend class Item_func;
}; };
...@@ -269,7 +271,7 @@ public: ...@@ -269,7 +271,7 @@ public:
class Item_func_not_all :public Item_func_not class Item_func_not_all :public Item_func_not
{ {
/* allow to check presence od values in max/min optimisation */ /* allow to check presence of values in max/min optimization */
Item_sum_hybrid *test_sum_item; Item_sum_hybrid *test_sum_item;
Item_maxmin_subselect *test_sub_item; Item_maxmin_subselect *test_sub_item;
...@@ -421,10 +423,18 @@ public: ...@@ -421,10 +423,18 @@ public:
}; };
struct interval_range
{
Item_result type;
double dbl;
my_decimal dec;
};
class Item_func_interval :public Item_int_func class Item_func_interval :public Item_int_func
{ {
Item_row *row; Item_row *row;
double *intervals; my_bool use_decimal_comparison;
interval_range *intervals;
public: public:
Item_func_interval(Item_row *a) Item_func_interval(Item_row *a)
:Item_int_func(a),row(a),intervals(0) :Item_int_func(a),row(a),intervals(0)
...@@ -437,24 +447,43 @@ public: ...@@ -437,24 +447,43 @@ public:
}; };
class Item_func_ifnull :public Item_func class Item_func_coalesce :public Item_func
{ {
protected:
enum Item_result cached_result_type; enum Item_result cached_result_type;
Item_func_coalesce(Item *a, Item *b)
:Item_func(a, b), cached_result_type(INT_RESULT)
{}
public:
Item_func_coalesce(List<Item> &list)
:Item_func(list),cached_result_type(INT_RESULT)
{}
double val_real();
longlong val_int();
String *val_str(String *);
my_decimal *val_decimal(my_decimal *);
void fix_length_and_dec();
enum Item_result result_type () const { return cached_result_type; }
const char *func_name() const { return "coalesce"; }
table_map not_null_tables() const { return 0; }
};
class Item_func_ifnull :public Item_func_coalesce
{
protected:
enum_field_types cached_field_type; enum_field_types cached_field_type;
bool field_type_defined; bool field_type_defined;
public: public:
Item_func_ifnull(Item *a,Item *b) Item_func_ifnull(Item *a, Item *b) :Item_func_coalesce(a,b) {}
:Item_func(a,b), cached_result_type(INT_RESULT)
{}
double val_real(); double val_real();
longlong val_int(); longlong val_int();
String *val_str(String *str); String *val_str(String *str);
enum Item_result result_type () const { return cached_result_type; } my_decimal *val_decimal(my_decimal *);
enum_field_types field_type() const; enum_field_types field_type() const;
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "ifnull"; } const char *func_name() const { return "ifnull"; }
Field *tmp_table_field(TABLE *table); Field *tmp_table_field(TABLE *table);
table_map not_null_tables() const { return 0; }
}; };
...@@ -468,6 +497,7 @@ public: ...@@ -468,6 +497,7 @@ public:
double val_real(); double val_real();
longlong val_int(); longlong val_int();
String *val_str(String *str); String *val_str(String *str);
my_decimal *val_decimal(my_decimal *);
enum Item_result result_type () const { return cached_result_type; } enum Item_result result_type () const { return cached_result_type; }
bool fix_fields(THD *thd,struct st_table_list *tlist, Item **ref) bool fix_fields(THD *thd,struct st_table_list *tlist, Item **ref)
{ {
...@@ -491,6 +521,7 @@ public: ...@@ -491,6 +521,7 @@ public:
double val_real(); double val_real();
longlong val_int(); longlong val_int();
String *val_str(String *str); String *val_str(String *str);
my_decimal *val_decimal(my_decimal *);
enum Item_result result_type () const { return cached_result_type; } enum Item_result result_type () const { return cached_result_type; }
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "nullif"; } const char *func_name() const { return "nullif"; }
...@@ -500,23 +531,6 @@ public: ...@@ -500,23 +531,6 @@ public:
}; };
class Item_func_coalesce :public Item_func
{
enum Item_result cached_result_type;
public:
Item_func_coalesce(List<Item> &list)
:Item_func(list),cached_result_type(INT_RESULT)
{}
double val_real();
longlong val_int();
String *val_str(String *);
void fix_length_and_dec();
enum Item_result result_type () const { return cached_result_type; }
const char *func_name() const { return "coalesce"; }
table_map not_null_tables() const { return 0; }
};
class Item_func_case :public Item_func class Item_func_case :public Item_func
{ {
int first_expr_num, else_expr_num; int first_expr_num, else_expr_num;
...@@ -529,7 +543,7 @@ public: ...@@ -529,7 +543,7 @@ public:
Item_func_case(List<Item> &list, Item *first_expr_arg, Item *else_expr_arg) Item_func_case(List<Item> &list, Item *first_expr_arg, Item *else_expr_arg)
:Item_func(), first_expr_num(-1), else_expr_num(-1), :Item_func(), first_expr_num(-1), else_expr_num(-1),
cached_result_type(INT_RESULT) cached_result_type(INT_RESULT)
{ {
ncases= list.elements; ncases= list.elements;
if (first_expr_arg) if (first_expr_arg)
{ {
...@@ -546,6 +560,7 @@ public: ...@@ -546,6 +560,7 @@ public:
double val_real(); double val_real();
longlong val_int(); longlong val_int();
String *val_str(String *); String *val_str(String *);
my_decimal *val_decimal(my_decimal *);
void fix_length_and_dec(); void fix_length_and_dec();
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
enum Item_result result_type () const { return cached_result_type; } enum Item_result result_type () const { return cached_result_type; }
...@@ -586,7 +601,7 @@ public: ...@@ -586,7 +601,7 @@ public:
class in_string :public in_vector class in_string :public in_vector
{ {
char buff[80]; char buff[STRING_BUFFER_USUAL_SIZE];
String tmp; String tmp;
public: public:
in_string(uint elements,qsort2_cmp cmp_func, CHARSET_INFO *cs); in_string(uint elements,qsort2_cmp cmp_func, CHARSET_INFO *cs);
...@@ -613,6 +628,16 @@ public: ...@@ -613,6 +628,16 @@ public:
byte *get_value(Item *item); byte *get_value(Item *item);
}; };
class in_decimal :public in_vector
{
my_decimal val;
public:
in_decimal(uint elements);
void set(uint pos, Item *item);
byte *get_value(Item *item);
};
/* /*
** Classes for easy comparing of non const items ** Classes for easy comparing of non const items
*/ */
...@@ -627,7 +652,7 @@ public: ...@@ -627,7 +652,7 @@ public:
virtual int cmp(Item *item)= 0; virtual int cmp(Item *item)= 0;
// for optimized IN with row // for optimized IN with row
virtual int compare(cmp_item *item)= 0; virtual int compare(cmp_item *item)= 0;
static cmp_item* get_comparator(Item *); static cmp_item* get_comparator(Item_result type, CHARSET_INFO *cs);
virtual cmp_item *make_same()= 0; virtual cmp_item *make_same()= 0;
virtual void store_value_by_template(cmp_item *tmpl, Item *item) virtual void store_value_by_template(cmp_item *tmpl, Item *item)
{ {
...@@ -648,7 +673,7 @@ public: ...@@ -648,7 +673,7 @@ public:
class cmp_item_sort_string :public cmp_item_string class cmp_item_sort_string :public cmp_item_string
{ {
protected: protected:
char value_buff[80]; char value_buff[STRING_BUFFER_USUAL_SIZE];
String value; String value;
public: public:
cmp_item_sort_string(CHARSET_INFO *cs): cmp_item_sort_string(CHARSET_INFO *cs):
...@@ -660,7 +685,7 @@ public: ...@@ -660,7 +685,7 @@ public:
} }
int cmp(Item *arg) int cmp(Item *arg)
{ {
char buff[80]; char buff[STRING_BUFFER_USUAL_SIZE];
String tmp(buff, sizeof(buff), cmp_charset), *res; String tmp(buff, sizeof(buff), cmp_charset), *res;
if (!(res= arg->val_str(&tmp))) if (!(res= arg->val_str(&tmp)))
return 1; /* Can't be right */ return 1; /* Can't be right */
...@@ -714,6 +739,18 @@ public: ...@@ -714,6 +739,18 @@ public:
cmp_item *make_same(); cmp_item *make_same();
}; };
class cmp_item_decimal :public cmp_item
{
my_decimal value;
public:
void store_value(Item *item);
int cmp(Item *arg);
int compare(cmp_item *c);
cmp_item *make_same();
};
class cmp_item_row :public cmp_item class cmp_item_row :public cmp_item
{ {
cmp_item **comparators; cmp_item **comparators;
...@@ -996,26 +1033,26 @@ public: ...@@ -996,26 +1033,26 @@ public:
/* /*
The class Item_equal is used to represent conjuctions of equality The class Item_equal is used to represent conjunctions of equality
predicates of the form field1 = field2, and field=const in where predicates of the form field1 = field2, and field=const in where
conditions and on expressions. conditions and on expressions.
All equality predicates of the form field1=field2 contained in a All equality predicates of the form field1=field2 contained in a
conjuction are substituted for a sequence of items of this class. conjunction are substituted for a sequence of items of this class.
An item of this class Item_equal(f1,f2,...fk) respresents a An item of this class Item_equal(f1,f2,...fk) represents a
multiple equality f1=f2=...=fk. multiple equality f1=f2=...=fk.
If a conjuction contains predicates f1=f2 and f2=f3, a new item of If a conjunction contains predicates f1=f2 and f2=f3, a new item of
this class is created Item_equal(f1,f2,f3) representing the multiple this class is created Item_equal(f1,f2,f3) representing the multiple
equality f1=f2=f3 that substitutes the above equality predicates in equality f1=f2=f3 that substitutes the above equality predicates in
the conjuction. the conjunction.
A conjuction of the predicates f2=f1 and f3=f1 and f3=f2 will be A conjunction of the predicates f2=f1 and f3=f1 and f3=f2 will be
substituted for the item representing the same multiple equality substituted for the item representing the same multiple equality
f1=f2=f3. f1=f2=f3.
An item Item_equal(f1,f2) can appear instead of a conjuction of An item Item_equal(f1,f2) can appear instead of a conjunction of
f2=f1 and f1=f2, or instead of just the predicate f1=f2. f2=f1 and f1=f2, or instead of just the predicate f1=f2.
An item of the class Item_equal inherites equalities from outer An item of the class Item_equal inherits equalities from outer
conjunctive levels. conjunctive levels.
Suppose we have a where condition of the following form: Suppose we have a where condition of the following form:
...@@ -1026,7 +1063,7 @@ public: ...@@ -1026,7 +1063,7 @@ public:
f1=f3 will be substituted for Item_equal(f1,f2,f3,f4,f5); f1=f3 will be substituted for Item_equal(f1,f2,f3,f4,f5);
An object of the class Item_equal can contain an optional constant An object of the class Item_equal can contain an optional constant
item c. Thenit represents a multiple equality of the form item c. Then it represents a multiple equality of the form
c=f1=...=fk. c=f1=...=fk.
Objects of the class Item_equal are used for the following: Objects of the class Item_equal are used for the following:
...@@ -1044,7 +1081,7 @@ public: ...@@ -1044,7 +1081,7 @@ public:
3. An object Item_equal(t1.f1,...,tk.fk) is used to optimize the 3. An object Item_equal(t1.f1,...,tk.fk) is used to optimize the
selected execution plan for the query: if table ti is accessed selected execution plan for the query: if table ti is accessed
before the table tj then in any predicate P in the where condition before the table tj then in any predicate P in the where condition
the occurence of tj.fj is substituted for ti.fi. This can allow the occurrence of tj.fj is substituted for ti.fi. This can allow
an evaluation of the predicate at an earlier step. an evaluation of the predicate at an earlier step.
When feature 1 is supported they say that join transitive closure When feature 1 is supported they say that join transitive closure
...@@ -1175,7 +1212,7 @@ public: ...@@ -1175,7 +1212,7 @@ public:
/* /*
XOR is Item_cond, not an Item_int_func bevause we could like to XOR is Item_cond, not an Item_int_func because we could like to
optimize (a XOR b) later on. It's low prio, though optimize (a XOR b) later on. It's low prio, though
*/ */
...@@ -1192,7 +1229,7 @@ public: ...@@ -1192,7 +1229,7 @@ public:
}; };
/* Some usefull inline functions */ /* Some useful inline functions */
inline Item *and_conds(Item *a, Item *b) inline Item *and_conds(Item *a, Item *b)
{ {
......
...@@ -289,7 +289,7 @@ Item *create_func_period_diff(Item* a, Item *b) ...@@ -289,7 +289,7 @@ Item *create_func_period_diff(Item* a, Item *b)
Item *create_func_pi(void) 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) Item *create_func_pow(Item* a, Item *b)
...@@ -454,7 +454,7 @@ Item *create_load_file(Item* a) ...@@ -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) CHARSET_INFO *cs)
{ {
Item *res; Item *res;
...@@ -467,6 +467,9 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len, ...@@ -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_DATE: res= new Item_date_typecast(a); break;
case ITEM_CAST_TIME: res= new Item_time_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_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: case ITEM_CAST_CHAR:
res= new Item_char_typecast(a, len, cs ? cs : res= new Item_char_typecast(a, len, cs ? cs :
current_thd->variables.collation_connection); current_thd->variables.collation_connection);
......
...@@ -28,7 +28,8 @@ Item *create_func_bit_length(Item* a); ...@@ -28,7 +28,8 @@ Item *create_func_bit_length(Item* a);
Item *create_func_coercibility(Item* a); Item *create_func_coercibility(Item* a);
Item *create_func_ceiling(Item* a); Item *create_func_ceiling(Item* a);
Item *create_func_char_length(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_connection_id(void);
Item *create_func_conv(Item* a, Item *b, Item *c); Item *create_func_conv(Item* a, Item *b, Item *c);
Item *create_func_cos(Item* a); 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, ...@@ -100,10 +100,9 @@ void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array,
(item->used_tables() && item->type() != REF_ITEM)) (item->used_tables() && item->type() != REF_ITEM))
{ {
uint el= fields.elements; 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); Item *new_item= new Item_ref(ref_pointer_array + el, 0, (*arg)->name);
fields.push_front(*arg); fields.push_front(*arg);
ref_pointer_array[el]= *arg;
thd->change_item_tree(arg, new_item); thd->change_item_tree(arg, new_item);
} }
} }
......
...@@ -56,6 +56,11 @@ public: ...@@ -56,6 +56,11 @@ public:
illegal_method_call((const char*)"val_str"); illegal_method_call((const char*)"val_str");
return 0; 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); bool fix_fields(THD *thd, TABLE_LIST *tables, Item **ref);
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields); void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
table_map used_tables() const { return used_tables_cache; }; table_map used_tables() const { return used_tables_cache; };
......
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.
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.
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