1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

Fix for CONC-177: Fixed length calculation for zerofill conversion from

float/double to string
This commit is contained in:
Georg Richter
2016-05-14 17:58:13 +02:00
parent 3823a0f7a9
commit ca68323c7b
2 changed files with 60 additions and 12 deletions

View File

@@ -4147,7 +4147,52 @@ static int test_conc167(MYSQL *mysql)
return OK;
}
static int test_conc177(MYSQL *mysql)
{
MYSQL_STMT *stmt;
int rc;
MYSQL_BIND bind[2];
char *stmt_str= "SELECT a,b FROM t1";
char buf1[128], buf2[128];
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
check_mysql_rc(rc, mysql);
rc= mysql_query(mysql, "CREATE TABLE t1 (a double zerofill default 8.8,b float zerofill default 8.8)");
check_mysql_rc(rc, mysql);
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (DEFAULT, DEFAULT)");
check_mysql_rc(rc, mysql);
stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, stmt_str, strlen(stmt_str));
check_stmt_rc(rc, stmt);
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
memset(bind, 0, 2 * sizeof(MYSQL_BIND));
bind[0].buffer= &buf1;
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer_length= 128;
bind[1].buffer= &buf2;
bind[1].buffer_type= MYSQL_TYPE_STRING;
bind[1].buffer_length= 128;
rc= mysql_stmt_bind_result(stmt, bind);
check_stmt_rc(rc, stmt);
rc= mysql_stmt_fetch(stmt);
mysql_stmt_close(stmt);
diag("buf1 %s\nbuf2 %s", buf1, buf2);
FAIL_IF(strcmp(buf1, "00000000000000000008.8"), "Expected 00000000000000000008.8");
FAIL_IF(strcmp(buf2, "0000000008.8"), "Expected 0000000008.8");
return OK;
}
struct my_tests_st my_tests[] = {
{"test_conc177", test_conc177, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc167", test_conc167, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc168", test_conc168, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc155", test_conc155, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},