- added commands --query_vertical and --query_horisontal to client/mysqltest.cc

- get my_strtod to return inf
- get Field_float::store(double) and Field_double::store(float) to set null for 
nan value 
(as extra serg's recomendations to fix for patch on 
 Bug #2082 'mysqldump converts "inf" to null')
parent b0979952
......@@ -216,6 +216,7 @@ Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
Q_ENABLE_INFO, Q_DISABLE_INFO,
Q_EXEC, Q_DELIMITER,
Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORISONTAL_RESULTS,
Q_QUERY_VERTICAL, Q_QUERY_HORISONTAL,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
......@@ -291,6 +292,8 @@ const char *command_names[]=
"delimiter",
"vertical_results",
"horisontal_results",
"query_vertical",
"query_horisontal",
0
};
......@@ -2586,6 +2589,28 @@ int main(int argc, char **argv)
if (q->query == q->query_buf)
q->query= q->first_argument;
/* fall through */
case Q_QUERY_VERTICAL:
case Q_QUERY_HORISONTAL:
{
my_bool old_display_result_vertically= display_result_vertically;
if (!q->query[q->first_word_len])
{
/* This happens when we use 'query_..' on it's own line */
q_send_flag=1;
break;
}
/* fix up query pointer if this is * first iteration for this line */
if (q->query == q->query_buf)
q->query += q->first_word_len + 1;
switch(q->type)
{
case Q_QUERY_VERTICAL: display_result_vertically= TRUE; break;
case Q_QUERY_HORISONTAL: display_result_vertically= FALSE; break;
}
error |= run_query(&cur_con->mysql, q, QUERY_REAP|QUERY_SEND);
display_result_vertically= old_display_result_vertically;
break;
}
case Q_QUERY:
case Q_REAP:
{
......
......@@ -169,6 +169,7 @@ set @value= "1e+1111111111a";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
Warnings:
Warning 1265 Data truncated for column 'f_double ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double ' at row 1
Warning 1265 Data truncated for column 'f_float ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float ' at row 1
Warning 1265 Data truncated for column 'f_double_7_2 ' at row 1
......@@ -176,6 +177,7 @@ Warning 1264 Data truncated, out of range for column 'f_double_7_2 ' at row 1
Warning 1265 Data truncated for column 'f_float_4_3 ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_4_3 ' at row 1
Warning 1265 Data truncated for column 'f_double_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double_u ' at row 1
Warning 1265 Data truncated for column 'f_float_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_u ' at row 1
Warning 1265 Data truncated for column 'f_double_15_1_u ' at row 1
......@@ -197,6 +199,7 @@ set @value= "-1e+1111111111a";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
Warnings:
Warning 1265 Data truncated for column 'f_double ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double ' at row 1
Warning 1265 Data truncated for column 'f_float ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float ' at row 1
Warning 1265 Data truncated for column 'f_double_7_2 ' at row 1
......@@ -225,15 +228,17 @@ f_float_3_1_u 0.0
set @value= 1e+1111111111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
Warnings:
Warning 1264 Data truncated, out of range for column 'f_double ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double_7_2 ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_4_3 ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double_15_1_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_3_1_u ' at row 1
select * from t1 where `number `=last_insert_id();
number 6
original_value 1.7976931348623e+308
original_value inf
f_double 1.79769313486232e+308
f_float 3.40282e+38
f_double_7_2 99999.99
......@@ -245,6 +250,7 @@ f_float_3_1_u 99.9
set @value= -1e+1111111111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
Warnings:
Warning 1264 Data truncated, out of range for column 'f_double ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double_7_2 ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_4_3 ' at row 1
......@@ -254,7 +260,7 @@ Warning 1264 Data truncated, out of range for column 'f_double_15_1_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_3_1_u ' at row 1
select * from t1 where `number `=last_insert_id();
number 7
original_value -1.7976931348623e+308
original_value -inf
f_double -1.79769313486232e+308
f_float -3.40282e+38
f_double_7_2 -99999.99
......
......@@ -46,6 +46,8 @@ UNLOCK TABLES;
DROP TABLE t1;
CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES (-9e999999);
Warnings:
Warning 1264 Data truncated, out of range for column 'a' at row 1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
......
......@@ -90,7 +90,8 @@ drop database mysqltest;
#
# Test of wrong values for float data (bug #2082)
#
#
use test;
create table t1(
`number ` int auto_increment primary key,
......@@ -107,68 +108,46 @@ create table t1(
set @value= "aa";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
vertical_results;
select * from t1 where `number `=last_insert_id();
horisontal_results;
--query_vertical select * from t1 where `number `=last_insert_id()
set @value= "1aa";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
vertical_results;
select * from t1 where `number `=last_insert_id();
horisontal_results;
--query_vertical select * from t1 where `number `=last_insert_id()
set @value= "aa1";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
vertical_results;
select * from t1 where `number `=last_insert_id();
horisontal_results;
--query_vertical select * from t1 where `number `=last_insert_id()
set @value= "1e+1111111111a";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
vertical_results;
select * from t1 where `number `=last_insert_id();
horisontal_results;
--query_vertical select * from t1 where `number `=last_insert_id()
set @value= "-1e+1111111111a";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
vertical_results;
select * from t1 where `number `=last_insert_id();
horisontal_results;
--query_vertical select * from t1 where `number `=last_insert_id()
set @value= 1e+1111111111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
vertical_results;
select * from t1 where `number `=last_insert_id();
horisontal_results;
--query_vertical select * from t1 where `number `=last_insert_id()
set @value= -1e+1111111111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
vertical_results;
select * from t1 where `number `=last_insert_id();
horisontal_results;
--query_vertical select * from t1 where `number `=last_insert_id()
set @value= 1e+111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
vertical_results;
select * from t1 where `number `=last_insert_id();
horisontal_results;
--query_vertical select * from t1 where `number `=last_insert_id()
set @value= -1e+111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
vertical_results;
select * from t1 where `number `=last_insert_id();
horisontal_results;
--query_vertical select * from t1 where `number `=last_insert_id()
set @value= 1;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
vertical_results;
select * from t1 where `number `=last_insert_id();
horisontal_results;
--query_vertical select * from t1 where `number `=last_insert_id()
set @value= -1;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
vertical_results;
select * from t1 where `number `=last_insert_id();
horisontal_results;
--query_vertical select * from t1 where `number `=last_insert_id()
drop table t1;
......@@ -2291,7 +2291,14 @@ int Field_float::store(double nr)
float j;
int error= 0;
if (isnan(nr) || unsigned_flag && nr < 0)
if (isnan(nr))
{
j= 0;
set_null();
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (unsigned_flag && nr < 0)
{
j= 0;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
......@@ -2581,7 +2588,14 @@ int Field_double::store(double nr)
{
int error= 0;
if (isnan(nr) || unsigned_flag && nr < 0)
if (isnan(nr))
{
nr= 0;
set_null();
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
error= 1;
}
else if (unsigned_flag && nr < 0)
{
nr= 0;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
......
......@@ -93,7 +93,7 @@ double my_strtod(const char *str, char **end)
if (neg)
result= 0.0;
else
result= DBL_MAX;
result= DBL_MAX*10;
goto done;
}
while (exp >= 100)
......@@ -113,9 +113,6 @@ done:
if (end)
*end = (char *)str;
if (isinf(result))
result=DBL_MAX;
return negative ? -result : result;
}
......
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