Commit d6307b76 authored by serg@serg.mylan's avatar serg@serg.mylan

compare a decimal value with a string not a double, as we want to test for an *exact* match

parent 6f806352
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
/*************************************************************************** /***************************************************************************
This is a test sample to test the new features in MySQL client-server This is a test sample to test the new features in MySQL client-server
protocol protocol
Main author: venu ( venu@mysql.com ) Main author: venu ( venu@mysql.com )
...@@ -6553,7 +6553,7 @@ static void test_decimal_bug() ...@@ -6553,7 +6553,7 @@ static void test_decimal_bug()
{ {
MYSQL_STMT *stmt; MYSQL_STMT *stmt;
MYSQL_BIND bind[1]; MYSQL_BIND bind[1];
double data; char data[30];
int rc; int rc;
my_bool is_null; my_bool is_null;
...@@ -6573,9 +6573,9 @@ static void test_decimal_bug() ...@@ -6573,9 +6573,9 @@ static void test_decimal_bug()
stmt = mysql_simple_prepare(mysql,"select c1 from test_decimal_bug where c1= ?"); stmt = mysql_simple_prepare(mysql,"select c1 from test_decimal_bug where c1= ?");
mystmt_init(stmt); mystmt_init(stmt);
bind[0].buffer_type= MYSQL_TYPE_DOUBLE; bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (char *)&data; bind[0].buffer= (char *)data;
bind[0].buffer_length= 0; bind[0].buffer_length= 25;
bind[0].is_null= &is_null; bind[0].is_null= &is_null;
bind[0].length= 0; bind[0].length= 0;
...@@ -6583,36 +6583,36 @@ static void test_decimal_bug() ...@@ -6583,36 +6583,36 @@ static void test_decimal_bug()
rc = mysql_bind_param(stmt, bind); rc = mysql_bind_param(stmt, bind);
mystmt(stmt,rc); mystmt(stmt,rc);
data= 8.0; strcpy(data, "8.0");
rc = mysql_execute(stmt); rc = mysql_execute(stmt);
mystmt(stmt,rc); mystmt(stmt,rc);
data=0; data[0]=0;
rc = mysql_bind_result(stmt, bind); rc = mysql_bind_result(stmt, bind);
mystmt(stmt,rc); mystmt(stmt,rc);
rc = mysql_fetch(stmt); rc = mysql_fetch(stmt);
mystmt(stmt,rc); mystmt(stmt,rc);
fprintf(stdout, "\n data: %g", data); fprintf(stdout, "\n data: %s", data);
assert(data == 8.0); assert(strcmp(data, "8.00")==0);
rc = mysql_fetch(stmt); rc = mysql_fetch(stmt);
assert(rc == MYSQL_NO_DATA); assert(rc == MYSQL_NO_DATA);
data= 5.61; strcpy(data, "5.61");
rc = mysql_execute(stmt); rc = mysql_execute(stmt);
mystmt(stmt,rc); mystmt(stmt,rc);
data=0; data[0]=0;
rc = mysql_bind_result(stmt, bind); rc = mysql_bind_result(stmt, bind);
mystmt(stmt,rc); mystmt(stmt,rc);
rc = mysql_fetch(stmt); rc = mysql_fetch(stmt);
mystmt(stmt,rc); mystmt(stmt,rc);
fprintf(stdout, "\n data: %g", data); fprintf(stdout, "\n data: %s", data);
assert(data == 5.61); assert(strcmp(data, "5.61")==0);
rc = mysql_fetch(stmt); rc = mysql_fetch(stmt);
assert(rc == MYSQL_NO_DATA); assert(rc == MYSQL_NO_DATA);
...@@ -6624,19 +6624,19 @@ static void test_decimal_bug() ...@@ -6624,19 +6624,19 @@ static void test_decimal_bug()
rc = mysql_fetch(stmt); rc = mysql_fetch(stmt);
assert(rc == MYSQL_NO_DATA); assert(rc == MYSQL_NO_DATA);
data= 10.22; is_null= 0; strcpy(data, "10.22"); is_null= 0;
rc = mysql_execute(stmt); rc = mysql_execute(stmt);
mystmt(stmt,rc); mystmt(stmt,rc);
data=0; data[0]=0;
rc = mysql_bind_result(stmt, bind); rc = mysql_bind_result(stmt, bind);
mystmt(stmt,rc); mystmt(stmt,rc);
rc = mysql_fetch(stmt); rc = mysql_fetch(stmt);
mystmt(stmt,rc); mystmt(stmt,rc);
fprintf(stdout, "\n data: %g", data); fprintf(stdout, "\n data: %s", data);
assert(data == 10.22); assert(strcmp(data, "10.22")==0);
rc = mysql_fetch(stmt); rc = mysql_fetch(stmt);
assert(rc == MYSQL_NO_DATA); assert(rc == MYSQL_NO_DATA);
...@@ -8256,7 +8256,7 @@ static void test_distinct() ...@@ -8256,7 +8256,7 @@ static void test_distinct()
rc= mysql_query(mysql, rc= mysql_query(mysql,
"insert into t1 values (1,1), (2, 2), (3,3), (4,4), (5,5),\ "insert into t1 values (1,1), (2, 2), (3,3), (4,4), (5,5),\
(1,10), (2, 20), (3,30), (4,40), (5,50)\;"); (1,10), (2, 20), (3,30), (4,40), (5,50);");
myquery(rc); myquery(rc);
for (i= 0; i < 3; i++) for (i= 0; i < 3; i++)
......
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