Commit bbff8ade authored by msvensson@neptunus.(none)'s avatar msvensson@neptunus.(none)

Merge neptunus.(none):/home/msvensson/mysql/mysqltest_float_result/my51-mysqltest_float_result

into  neptunus.(none):/home/msvensson/mysql/mysql-5.1-new
parents 4fc2b926 5e31bff3
...@@ -3604,6 +3604,59 @@ static void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val) ...@@ -3604,6 +3604,59 @@ static void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val)
} }
/*
Append the result for one field to the dynamic string ds
*/
static void append_field(DYNAMIC_STRING *ds, uint col_idx, MYSQL_FIELD* field,
const char* val, ulonglong len, bool is_null)
{
char buf[256];
if (col_idx < max_replace_column && replace_column[col_idx])
{
val= replace_column[col_idx];
len= strlen(val);
}
else if (is_null)
{
val= "NULL";
len= 4;
}
#ifdef __WIN__
else if ((field->type == MYSQL_TYPE_DOUBLE ||
field->type == MYSQL_TYPE_FLOAT ) &&
field->decimals >= 31)
{
/* Convert 1.2e+018 to 1.2e+18 and 1.2e-018 to 1.2e-18 */
char *start= strchr(val, 'e');
if (start && strlen(start) >= 5 &&
(start[1] == '-' || start[1] == '+') && start[2] == '0')
{
start+=2; /* Now points at first '0' */
/* Move all chars after the first '0' one step left */
memmove(start, start + 1, strlen(start));
len--;
}
}
#endif
if (!display_result_vertically)
{
if (col_idx)
dynstr_append_mem(ds, "\t", 1);
replace_dynstr_append_mem(ds, val, (int)len);
}
else
{
dynstr_append(ds, field->name);
dynstr_append_mem(ds, "\t", 1);
replace_dynstr_append_mem(ds, val, (int)len);
dynstr_append_mem(ds, "\n", 1);
}
}
/* /*
Append all results to the dynamic string separated with '\t' Append all results to the dynamic string separated with '\t'
Values may be converted with 'replace_column' Values may be converted with 'replace_column'
...@@ -3613,41 +3666,16 @@ static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res) ...@@ -3613,41 +3666,16 @@ static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res)
{ {
MYSQL_ROW row; MYSQL_ROW row;
uint num_fields= mysql_num_fields(res); uint num_fields= mysql_num_fields(res);
MYSQL_FIELD *fields= !display_result_vertically ? 0 : mysql_fetch_fields(res); MYSQL_FIELD *fields= mysql_fetch_fields(res);
ulong *lengths; ulong *lengths;
while ((row = mysql_fetch_row(res))) while ((row = mysql_fetch_row(res)))
{ {
uint i; uint i;
lengths = mysql_fetch_lengths(res); lengths = mysql_fetch_lengths(res);
for (i = 0; i < num_fields; i++) for (i = 0; i < num_fields; i++)
{ append_field(ds, i, &fields[i],
const char *val= row[i]; (const char*)row[i], lengths[i], !row[i]);
ulonglong len= lengths[i];
if (i < max_replace_column && replace_column[i])
{
val= replace_column[i];
len= strlen(val);
}
if (!val)
{
val= "NULL";
len= 4;
}
if (!display_result_vertically)
{
if (i)
dynstr_append_mem(ds, "\t", 1);
replace_dynstr_append_mem(ds, val, (int)len);
}
else
{
dynstr_append(ds, fields[i].name);
dynstr_append_mem(ds, "\t", 1);
replace_dynstr_append_mem(ds, val, (int)len);
dynstr_append_mem(ds, "\n", 1);
}
}
if (!display_result_vertically) if (!display_result_vertically)
dynstr_append_mem(ds, "\n", 1); dynstr_append_mem(ds, "\n", 1);
} }
...@@ -3661,13 +3689,12 @@ static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res) ...@@ -3661,13 +3689,12 @@ static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res)
*/ */
static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt, static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
MYSQL_FIELD *field, uint num_fields) MYSQL_FIELD *fields, uint num_fields)
{ {
MYSQL_BIND *bind; MYSQL_BIND *bind;
my_bool *is_null; my_bool *is_null;
ulong *length; ulong *length;
ulonglong num_rows; uint i;
uint col_idx, row_idx;
/* Allocate array with bind structs, lengths and NULL flags */ /* Allocate array with bind structs, lengths and NULL flags */
bind= (MYSQL_BIND*) my_malloc(num_fields * sizeof(MYSQL_BIND), bind= (MYSQL_BIND*) my_malloc(num_fields * sizeof(MYSQL_BIND),
...@@ -3677,71 +3704,29 @@ static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt, ...@@ -3677,71 +3704,29 @@ static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
is_null= (my_bool*) my_malloc(num_fields * sizeof(my_bool), is_null= (my_bool*) my_malloc(num_fields * sizeof(my_bool),
MYF(MY_WME | MY_FAE)); MYF(MY_WME | MY_FAE));
for (col_idx= 0; col_idx < num_fields; col_idx++) /* Allocate data for the result of each field */
for (i= 0; i < num_fields; i++)
{ {
/* Allocate data for output */ uint max_length= fields[i].max_length + 1;
uint max_length= field[col_idx].max_length + 1; bind[i].buffer_type= MYSQL_TYPE_STRING;
char *str_data= (char *) my_malloc(max_length, MYF(MY_WME | MY_FAE)); bind[i].buffer= (char *)my_malloc(max_length, MYF(MY_WME | MY_FAE));
bind[i].buffer_length= max_length;
bind[col_idx].buffer_type= MYSQL_TYPE_STRING; bind[i].is_null= &is_null[i];
bind[col_idx].buffer= (char *)str_data; bind[i].length= &length[i];
bind[col_idx].buffer_length= max_length;
bind[col_idx].is_null= &is_null[col_idx];
bind[col_idx].length= &length[col_idx];
DBUG_PRINT("bind", ("col[%d]: buffer_type: %d, buffer_length: %d", DBUG_PRINT("bind", ("col[%d]: buffer_type: %d, buffer_length: %d",
col_idx, i, bind[i].buffer_type, bind[i].buffer_length));
bind[col_idx].buffer_type,
bind[col_idx].buffer_length));
} }
/* Fill in the data into the structures created above */
if (mysql_stmt_bind_result(stmt, bind)) if (mysql_stmt_bind_result(stmt, bind))
die("mysql_stmt_bind_result failed: %d: %s", die("mysql_stmt_bind_result failed: %d: %s",
mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
/* Read result from each row */ while (mysql_stmt_fetch(stmt) == 0)
num_rows= mysql_stmt_num_rows(stmt);
for (row_idx= 0; row_idx < num_rows; row_idx++)
{ {
if (mysql_stmt_fetch(stmt)) for (i= 0; i < num_fields; i++)
die("mysql_stmt_fetch failed: %d %s", append_field(ds, i, &fields[i], (const char *) bind[i].buffer,
mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); *bind[i].length, *bind[i].is_null);
/* Read result from each column */
for (col_idx= 0; col_idx < num_fields; col_idx++)
{
const char *val;
ulonglong len;
if (col_idx < max_replace_column && replace_column[col_idx])
{
val= replace_column[col_idx];
len= strlen(val);
}
else if (*bind[col_idx].is_null)
{
val= "NULL";
len= 4;
}
else
{
val= (const char *) bind[col_idx].buffer;
len= *bind[col_idx].length;
}
if (!display_result_vertically)
{
if (col_idx) /* No tab before first col */
dynstr_append_mem(ds, "\t", 1);
replace_dynstr_append_mem(ds, val, (int)len);
}
else
{
dynstr_append(ds, field[col_idx].name);
dynstr_append_mem(ds, "\t", 1);
replace_dynstr_append_mem(ds, val, (int)len);
dynstr_append_mem(ds, "\n", 1);
}
}
if (!display_result_vertically) if (!display_result_vertically)
dynstr_append_mem(ds, "\n", 1); dynstr_append_mem(ds, "\n", 1);
} }
...@@ -3752,10 +3737,10 @@ static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt, ...@@ -3752,10 +3737,10 @@ static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
free_replace_column(); free_replace_column();
for (col_idx= 0; col_idx < num_fields; col_idx++) for (i= 0; i < num_fields; i++)
{ {
/* Free data for output */ /* Free data for output */
my_free((gptr)bind[col_idx].buffer, MYF(MY_WME | MY_FAE)); my_free((gptr)bind[i].buffer, MYF(MY_WME | MY_FAE));
} }
/* Free array with bind structs, lengths and NULL flags */ /* Free array with bind structs, lengths and NULL flags */
my_free((gptr)bind , MYF(MY_WME | MY_FAE)); my_free((gptr)bind , MYF(MY_WME | MY_FAE));
......
...@@ -31,14 +31,14 @@ select * from t1; ...@@ -31,14 +31,14 @@ select * from t1;
f1 f2 f1 f2
10 10 10 10
100000 100000 100000 100000
1.23457e+9 1234567890 1.23457e+09 1234567890
1e+10 10000000000 1e+10 10000000000
1e+15 1e+15 1e+15 1e+15
1e+20 1e+20 1e+20 1e+20
3.40282e+38 1e+50 3.40282e+38 1e+50
3.40282e+38 1e+150 3.40282e+38 1e+150
-10 -10 -10 -10
1e-5 1e-5 1e-05 1e-05
1e-10 1e-10 1e-10 1e-10
1e-15 1e-15 1e-15 1e-15
1e-20 1e-20 1e-20 1e-20
......
...@@ -99,27 +99,22 @@ create table t1(number int auto_increment primary key, original_value varchar(50 ...@@ -99,27 +99,22 @@ create table t1(number int auto_increment primary key, original_value varchar(50
set @value= "aa"; set @value= "aa";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--replace_result e-0 e- e+0 e+
--query_vertical select * from t1 where number =last_insert_id() --query_vertical select * from t1 where number =last_insert_id()
set @value= "1aa"; set @value= "1aa";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--replace_result e-0 e- e+0 e+
--query_vertical select * from t1 where number =last_insert_id() --query_vertical select * from t1 where number =last_insert_id()
set @value= "aa1"; set @value= "aa1";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--replace_result e-0 e- e+0 e+
--query_vertical select * from t1 where number =last_insert_id() --query_vertical select * from t1 where number =last_insert_id()
set @value= "1e+1111111111a"; set @value= "1e+1111111111a";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--replace_result e-0 e- e+0 e+
--query_vertical select * from t1 where number =last_insert_id() --query_vertical select * from t1 where number =last_insert_id()
set @value= "-1e+1111111111a"; set @value= "-1e+1111111111a";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--replace_result e-0 e- e+0 e+
--query_vertical select * from t1 where number =last_insert_id() --query_vertical select * from t1 where number =last_insert_id()
--error 1367 --error 1367
...@@ -130,22 +125,18 @@ set @value= -1e+1111111111; ...@@ -130,22 +125,18 @@ set @value= -1e+1111111111;
set @value= 1e+111; set @value= 1e+111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--replace_result e-0 e- e+0 e+
--query_vertical select * from t1 where number =last_insert_id() --query_vertical select * from t1 where number =last_insert_id()
set @value= -1e+111; set @value= -1e+111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--replace_result e-0 e- e+0 e+
--query_vertical select * from t1 where number =last_insert_id() --query_vertical select * from t1 where number =last_insert_id()
set @value= 1; set @value= 1;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--replace_result e-0 e- e+0 e+
--query_vertical select * from t1 where number =last_insert_id() --query_vertical select * from t1 where number =last_insert_id()
set @value= -1; set @value= -1;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
--replace_result e-0 e- e+0 e+
--query_vertical select * from t1 where number =last_insert_id() --query_vertical select * from t1 where number =last_insert_id()
drop table t1; drop table t1;
......
...@@ -6,9 +6,7 @@ ...@@ -6,9 +6,7 @@
drop table if exists t1,t2; drop table if exists t1,t2;
--enable_warnings --enable_warnings
--replace_result e-0 e- e+0 e+
SELECT 10,10.0,10.,.1e+2,100.0e-1; SELECT 10,10.0,10.,.1e+2,100.0e-1;
--replace_result e-00 e-0
SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000; SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1; SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01; SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01;
...@@ -21,7 +19,6 @@ create table t1 (f1 float(24),f2 float(52)); ...@@ -21,7 +19,6 @@ create table t1 (f1 float(24),f2 float(52));
show full columns from t1; show full columns from t1;
insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150); insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150); insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);
--replace_result e-0 e- e+0 e+
select * from t1; select * from t1;
drop table t1; drop table t1;
......
...@@ -20,7 +20,6 @@ select @test, @`test`, @TEST, @`TEST`, @"teSt"; ...@@ -20,7 +20,6 @@ select @test, @`test`, @TEST, @`TEST`, @"teSt";
set @select=2,@t5=1.23456; set @select=2,@t5=1.23456;
select @`select`,@not_used; select @`select`,@not_used;
set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL; set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL;
--replace_result e-0 e- e+0 e+
select @test_int,@test_double,@test_string,@test_string2,@select; select @test_int,@test_double,@test_string,@test_string2,@select;
set @test_int="hello",@test_double="hello",@test_string="hello",@test_string2="hello"; set @test_int="hello",@test_double="hello",@test_string="hello",@test_string2="hello";
select @test_int,@test_double,@test_string,@test_string2; select @test_int,@test_double,@test_string,@test_string2;
......
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