Skip to content

Commit

Permalink
MDEV-8401 COLUMN_CREATE(name, value as DOUBLE) results in string
Browse files Browse the repository at this point in the history
Double representation fixed (JSON is valid even with 'e' in the number)
  • Loading branch information
sanja-byelkin committed Dec 10, 2015
1 parent 7bf7fea commit d289ba8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
20 changes: 18 additions & 2 deletions mysql-test/r/dyncol.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -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
#
11 changes: 11 additions & 0 deletions mysql-test/t/dyncol.test
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,17 @@ 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 #
4 changes: 0 additions & 4 deletions mysys/ma_dyncol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d289ba8

Please sign in to comment.