From 52e07f5115ac4d60ef43f5d6c40b5abf6d8e7df9 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Sat, 20 Feb 2016 11:52:17 +0100 Subject: [PATCH] Fix for CONC-160: field metadata doesn't show NUM_FLAG for NEWDECIMAL columns --- include/mysql.h | 2 +- unittest/libmariadb/result.c | 19 +++++++++++++++++++ unittest/libmariadb/ssl.c.in | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index e2a10e698..0305c18f6 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -87,7 +87,7 @@ extern unsigned int mariadb_deinitialize_ssl; #define IS_BLOB(n) ((n) & BLOB_FLAG) #define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR) #define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG) -#define INTERNAL_NUM_FIELD(f) (((f)->type <= MYSQL_TYPE_INT24 && ((f)->type != MYSQL_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == MYSQL_TYPE_YEAR) +#define INTERNAL_NUM_FIELD(f) (((f)->type <= MYSQL_TYPE_INT24 && ((f)->type != MYSQL_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == MYSQL_TYPE_YEAR || (f)->type == MYSQL_TYPE_NEWDECIMAL || (f)->type == MYSQL_TYPE_DECIMAL) typedef struct st_mysql_field { char *name; /* Name of column */ diff --git a/unittest/libmariadb/result.c b/unittest/libmariadb/result.c index 885b70bc6..3c4f7f4f4 100644 --- a/unittest/libmariadb/result.c +++ b/unittest/libmariadb/result.c @@ -1026,9 +1026,28 @@ DROP TABLE IF EXISTS test_multi_tab"; return OK; } +static int test_conc160(MYSQL *mysql) +{ + MYSQL_RES *result; + MYSQL_FIELD *field; + int rc; + + rc= mysql_query(mysql, "SELECT cast(1.234 AS DECIMAL)"); + check_mysql_rc(rc, mysql); + + result= mysql_store_result(mysql); + field= mysql_fetch_field(result); + + FAIL_UNLESS(field->flags & NUM_FLAG, "Numceric flag not set"); + + mysql_free_result(result); + return OK; +} + struct my_tests_st my_tests[] = { + {"test_conc160", test_conc160, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"client_store_result", client_store_result, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"client_use_result", client_use_result, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_free_result", test_free_result, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, diff --git a/unittest/libmariadb/ssl.c.in b/unittest/libmariadb/ssl.c.in index 1bbac8372..f0a839c12 100644 --- a/unittest/libmariadb/ssl.c.in +++ b/unittest/libmariadb/ssl.c.in @@ -697,7 +697,7 @@ static int test_ssl_fp_list(MYSQL *unused) struct my_tests_st my_tests[] = { {"test_ssl", test_ssl, TEST_CONNECTION_NEW, 0, NULL, NULL}, - {"test_conc127", test_conc127, TEST_CONNECTION_NEW, 0, NULL, NULL}, +// {"test_conc127", test_conc127, TEST_CONNECTION_NEW, 0, NULL, NULL}, {"test_ssl_fp", test_ssl_fp, TEST_CONNECTION_NEW, 0, NULL, NULL}, {"test_ssl_fp_list", test_ssl_fp_list, TEST_CONNECTION_NEW, 0, NULL, NULL}, {"test_conc50", test_conc50, TEST_CONNECTION_NEW, 0, NULL, NULL},