summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2004-11-05 00:45:41 +0300
committerunknown <konstantin@mysql.com>2004-11-05 00:45:41 +0300
commitc7b5a8d7b14832b6257d6c410f7c6e8d37536617 (patch)
treeb8eba9b957bd9441a66782de21fc1532a5594958 /tests
parent7f3749c82ff55deb4f25626084b242ce6c2306e1 (diff)
downloadmariadb-git-c7b5a8d7b14832b6257d6c410f7c6e8d37536617.tar.gz
A test case for Bug#4172 "Floating point conversion looses precision
(prepared staements)": adding the test case to close the bug (the bug was fixed along with other conversion incompatibilities in 4.1.7) tests/client_test.c: A test case for Bug#4172: "Floating point conversion loses precision (prepared staements)" Fix memleak.
Diffstat (limited to 'tests')
-rw-r--r--tests/client_test.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/client_test.c b/tests/client_test.c
index 227f7e29ef2..004f076c6df 100644
--- a/tests/client_test.c
+++ b/tests/client_test.c
@@ -11082,12 +11082,77 @@ static void test_bug6096()
free(bind[i].buffer);
mysql_stmt_close(stmt);
mysql_free_result(query_result);
+ mysql_free_result(stmt_metadata);
stmt_text= "drop table t1";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
}
+static void test_bug4172()
+{
+ MYSQL_STMT *stmt;
+ MYSQL_BIND bind[3];
+ const char *stmt_text;
+ MYSQL_RES *res;
+ MYSQL_ROW row;
+ int rc;
+ char f[100], d[100], e[100];
+ long f_len, d_len, e_len;
+
+ myheader("test_bug4172");
+
+ mysql_query(mysql, "DROP TABLE IF EXISTS t1");
+ mysql_query(mysql, "CREATE TABLE t1 (f float, d double, e decimal(10,4))");
+ mysql_query(mysql, "INSERT INTO t1 VALUES (12345.1234, 123456.123456, "
+ "123456.1234)");
+
+ stmt= mysql_stmt_init(mysql);
+ stmt_text= "SELECT f, d, e FROM t1";
+
+ rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+ check_execute(stmt, rc);
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ bzero(bind, sizeof(bind));
+ bind[0].buffer_type= MYSQL_TYPE_STRING;
+ bind[0].buffer= f;
+ bind[0].buffer_length= sizeof(f);
+ bind[0].length= &f_len;
+ bind[1].buffer_type= MYSQL_TYPE_STRING;
+ bind[1].buffer= d;
+ bind[1].buffer_length= sizeof(d);
+ bind[1].length= &d_len;
+ bind[2].buffer_type= MYSQL_TYPE_STRING;
+ bind[2].buffer= e;
+ bind[2].buffer_length= sizeof(e);
+ bind[2].length= &e_len;
+
+ mysql_stmt_bind_result(stmt, bind);
+
+ mysql_stmt_store_result(stmt);
+ rc= mysql_stmt_fetch(stmt);
+ check_execute(stmt, rc);
+
+ rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
+ myquery(rc);
+ res= mysql_store_result(mysql);
+ row= mysql_fetch_row(res);
+
+ printf("Binary protocol: float=%s, double=%s, decimal(10,4)=%s\n",
+ f, d, e);
+ printf("Text protocol: float=%s, double=%s, decimal(10,4)=%s\n",
+ row[0], row[1], row[2]);
+
+ DIE_UNLESS(!strcmp(f, row[0]) && !strcmp(d, row[1]) && !strcmp(e, row[2]));
+
+ mysql_free_result(res);
+ mysql_stmt_close(stmt);
+}
+
+
+
/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -11404,6 +11469,8 @@ int main(int argc, char **argv)
test_bug6046(); /* NATURAL JOIN transformation works in PS */
test_bug6081(); /* test of mysql_create_db()/mysql_rm_db() */
test_bug6096(); /* max_length for numeric columns */
+ test_bug4172(); /* floating point conversions in libmysql */
+
/*
XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST
DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH.