Skip to content

Commit d289ba8

Browse files
committed
MDEV-8401 COLUMN_CREATE(name, value as DOUBLE) results in string
Double representation fixed (JSON is valid even with 'e' in the number)
1 parent 7bf7fea commit d289ba8

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

mysql-test/r/dyncol.result

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,10 +1693,10 @@ ERROR 22007: Illegal value used as argument of dynamic column function
16931693
#
16941694
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));
16951695
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"
1696-
{"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"}
1696+
{"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"}
16971697
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));
16981698
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))
1699-
{"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"}
1699+
{"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"}
17001700
#
17011701
# CHECK test
17021702
#
@@ -1820,5 +1820,21 @@ SELECT COLUMN_JSON(COLUMN_CREATE('a',1,'b','1'));
18201820
COLUMN_JSON(COLUMN_CREATE('a',1,'b','1'))
18211821
{"a":1,"b":"1"}
18221822
#
1823+
# MDEV-8401: COLUMN_CREATE(name, value as DOUBLE) results in string
1824+
#
1825+
SELECT COLUMN_JSON(
1826+
COLUMN_CREATE(
1827+
'one', 123.456,
1828+
'two', 123.456 as DOUBLE
1829+
)
1830+
);
1831+
COLUMN_JSON(
1832+
COLUMN_CREATE(
1833+
'one', 123.456,
1834+
'two', 123.456 as DOUBLE
1835+
)
1836+
)
1837+
{"one":123.456,"two":123.46}
1838+
#
18231839
# end of 10.0 tests
18241840
#

mysql-test/t/dyncol.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,17 @@ SELECT COLUMN_JSON(COLUMN_CREATE('a',0,'b','1'));
883883

884884
SELECT COLUMN_JSON(COLUMN_CREATE('a',1,'b','1'));
885885

886+
--echo #
887+
--echo # MDEV-8401: COLUMN_CREATE(name, value as DOUBLE) results in string
888+
--echo #
889+
SELECT COLUMN_JSON(
890+
COLUMN_CREATE(
891+
'one', 123.456,
892+
'two', 123.456 as DOUBLE
893+
)
894+
);
895+
896+
886897
--echo #
887898
--echo # end of 10.0 tests
888899
--echo #

mysys/ma_dyncol.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,11 +3840,7 @@ mariadb_dyncol_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val,
38403840
len= my_snprintf(buff, sizeof(buff), "%g", val->x.double_value);
38413841
if (dynstr_realloc(str, len + (quote ? 2 : 0)))
38423842
return ER_DYNCOL_RESOURCE;
3843-
if (quote)
3844-
str->str[str->length++]= quote;
38453843
dynstr_append_mem(str, buff, len);
3846-
if (quote)
3847-
str->str[str->length++]= quote;
38483844
break;
38493845
case DYN_COL_DYNCOL:
38503846
case DYN_COL_STRING:

0 commit comments

Comments
 (0)