[Commits] 3833e69: MDEV-8401 COLUMN_CREATE(name, value as DOUBLE) results in string

OleksandrByelkin sanja at mariadb.com
Thu Dec 10 11:18:34 EET 2015


revision-id: 3833e69c75f7da2212038d2c82fb239189e34234 (mariadb-10.0.22-35-g3833e69)
parent(s): 50160216eab066de7a71dd8e355f0c5cb29c8789
committer: Oleksandr Byelkin
timestamp: 2015-12-10 10:18:34 +0100
message:

MDEV-8401 COLUMN_CREATE(name, value as DOUBLE) results in string

Double representation fixed (JSON is valid even with 'e' in the number)

---
 mysql-test/r/dyncol.result | 20 ++++++++++++++++++--
 mysql-test/t/dyncol.test   | 11 +++++++++++
 mysys/ma_dyncol.c          |  4 ----
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/mysql-test/r/dyncol.result b/mysql-test/r/dyncol.result
index 62e3b1c..fe66e8a 100644
--- a/mysql-test/r/dyncol.result
+++ b/mysql-test/r/dyncol.result
@@ -1693,10 +1693,10 @@ ERROR 22007: Illegal value used as argument of dynamic column function
 #
 select column_json(column_create("int", -1212 as int, "uint", 12334 as unsigned int, "decimal", "23.344" as decimal, "double", 1.23444e50 as double, "string", 'gdgd\\dhdjh"dhdhd' as char, "time", "0:45:49.000001" AS time, "datetime", "2011-04-05 0:45:49.000001" AS datetime, "date", "2011-04-05" AS date));
 column_json(column_create("int", -1212 as int, "uint", 12334 as unsigned int, "decimal", "23.344" as decimal, "double", 1.23444e50 as double, "string", 'gdgd\\dhdjh"dhdhd' as char, "time", "0:45:49.000001" AS time, "datetime", "2011-04-05 0:45:49.000001" 
-{"int":-1212,"date":"2011-04-05","time":"00:45:49.000001","uint":12334,"double":"1.2e50","string":"gdgd\\dhdjh\"dhdhd","decimal":23.344,"datetime":"2011-04-05 00:45:49.000001"}
+{"int":-1212,"date":"2011-04-05","time":"00:45:49.000001","uint":12334,"double":1.2e50,"string":"gdgd\\dhdjh\"dhdhd","decimal":23.344,"datetime":"2011-04-05 00:45:49.000001"}
 select column_json(column_create(1, -1212 as int, 2, 12334 as unsigned int, 3, "23.344" as decimal, 4, 1.23444e50 as double, 5, 'gdgd\\dhdjh"dhdhd' as char, 6, "0:45:49.000001" AS time, 7, "2011-04-05 0:45:49.000001" AS datetime, 8, "2011-04-05" AS date));
 column_json(column_create(1, -1212 as int, 2, 12334 as unsigned int, 3, "23.344" as decimal, 4, 1.23444e50 as double, 5, 'gdgd\\dhdjh"dhdhd' as char, 6, "0:45:49.000001" AS time, 7, "2011-04-05 0:45:49.000001" AS datetime, 8, "2011-04-05" AS date))
-{"1":-1212,"2":12334,"3":23.344,"4":"1.2e50","5":"gdgd\\dhdjh\"dhdhd","6":"00:45:49.000001","7":"2011-04-05 00:45:49.000001","8":"2011-04-05"}
+{"1":-1212,"2":12334,"3":23.344,"4":1.2e50,"5":"gdgd\\dhdjh\"dhdhd","6":"00:45:49.000001","7":"2011-04-05 00:45:49.000001","8":"2011-04-05"}
 #
 # CHECK test
 #
@@ -1820,5 +1820,21 @@ SELECT COLUMN_JSON(COLUMN_CREATE('a',1,'b','1'));
 COLUMN_JSON(COLUMN_CREATE('a',1,'b','1'))
 {"a":1,"b":"1"}
 #
+# MDEV-8401: COLUMN_CREATE(name, value as DOUBLE) results in string
+#
+SELECT COLUMN_JSON(
+COLUMN_CREATE(
+'one', 123.456,
+'two', 123.456 as DOUBLE
+)
+);
+COLUMN_JSON(
+COLUMN_CREATE(
+'one', 123.456,
+'two', 123.456 as DOUBLE
+)
+)
+{"one":123.456,"two":123.46}
+#
 # end of 10.0 tests
 #
diff --git a/mysql-test/t/dyncol.test b/mysql-test/t/dyncol.test
index ac55fec..ceebeb2 100644
--- a/mysql-test/t/dyncol.test
+++ b/mysql-test/t/dyncol.test
@@ -884,5 +884,16 @@ SELECT COLUMN_JSON(COLUMN_CREATE('a',0,'b','1'));
 SELECT COLUMN_JSON(COLUMN_CREATE('a',1,'b','1'));
 
 --echo #
+--echo # MDEV-8401: COLUMN_CREATE(name, value as DOUBLE) results in string
+--echo #
+SELECT COLUMN_JSON(
+    COLUMN_CREATE(
+        'one', 123.456,
+        'two', 123.456 as DOUBLE
+    )
+);
+
+
+--echo #
 --echo # end of 10.0 tests
 --echo #
diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c
index 7e47856..7dfaf29 100644
--- a/mysys/ma_dyncol.c
+++ b/mysys/ma_dyncol.c
@@ -3840,11 +3840,7 @@ mariadb_dyncol_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val,
       len= my_snprintf(buff, sizeof(buff), "%g", val->x.double_value);
       if (dynstr_realloc(str, len + (quote ? 2 : 0)))
         return ER_DYNCOL_RESOURCE;
-      if (quote)
-        str->str[str->length++]= quote;
       dynstr_append_mem(str, buff, len);
-      if (quote)
-        str->str[str->length++]= quote;
       break;
     case DYN_COL_DYNCOL:
     case DYN_COL_STRING:


More information about the commits mailing list