Numeric errors, server crash with COLUMN_JSON() on DECIMAL with precision > 40

Description

Lines 4 through 11 of the following input have numeric errors in the JSON output. Line 12 crashes the server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 $ mysql -fN <<SQL SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.12345678901234567890123456789012345)); SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.123456789012345678901234567890123456)); SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.1234567890123456789012345678901234567)); SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.12345678901234567890123456789012345678)); SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.123456789012345678901234567890123456789)); SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.1234567890123456789012345678901234567890)); SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.12345678901234567890123456789012345678901)); SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.123456789012345678901234567890123456789012)); SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.1234567890123456789012345678901234567890123)); SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.12345678901234567890123456789012345678901234)); SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.123456789012345678901234567890123456789012345)); SELECT COLUMN_JSON(COLUMN_CREATE('x', 0.1234567890123456789012345678901234567890123467)); SQL {"x":0.12345678901234567890123456789012345} {"x":0.123456789012345678901234567890123456} {"x":0.1234567890123456789012345678901234567} {"x":0.12345678901234567890123456789012345670} {"x":0.123456789012345678901234567890123456700} {"x":0.1234567890123456789012345678901234567000} {"x":0.12345678901234567890123456789012345670000} {"x":0.123456789012345678901234567890123456700000} {"x":0.1234567890123456789012345678901234567000000} {"x":0.12345678901234567890123456789012345670000000} {"x":0.123456789012345678901234567890123456700000000} ERROR 2013 (HY000) at line 12: Lost connection to MySQL server during query /usr/local/bin/mysqld_safe: line 183: 2570 Abort trap: 6 ā€¦ 150701 09:15:49 mysqld_safe mysqld restarted

Lines 6 through 13 of the following input have numeric errors in the JSON output. Line 14 crashes the server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 fsb@yossy [~] šŸ‘ $ mysql -fN <<SQL > SELECT COLUMN_JSON(COLUMN_CREATE('x', 12345678901234567890123456789012345)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 123456789012345678901234567890123456)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 1234567890123456789012345678901234567)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 12345678901234567890123456789012345678)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 123456789012345678901234567890123456789)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 1234567890123456789012345678901234567890)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 12345678901234567890123456789012345678901)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 123456789012345678901234567890123456789012)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 1234567890123456789012345678901234567890123)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 12345678901234567890123456789012345678901234)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 123456789012345678901234567890123456789012345)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 1234567890123456789012345678901234567890123467)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 12345678901234567890123456789012345678901234678)); > SELECT COLUMN_JSON(COLUMN_CREATE('x', 123456789012345678901234567890123456789012346789)); > SQL {"x":12345678901234567890123456789012345} {"x":123456789012345678901234567890123456} {"x":1234567890123456789012345678901234567} {"x":12345678901234567890123456789012345678} {"x":123456789012345678901234567890123456789} {"x":0234567890123456789012345678901234567890} {"x":00345678901234567890123456789012345678901} {"x":000456789012345678901234567890123456789012} {"x":0000567890123456789012345678901234567890123} {"x":00000678901234567890123456789012345678901234} {"x":000000789012345678901234567890123456789012345} {"x":0000000001234567890123456789012345678901234567} {"x":00000000012345678901234567890123456789012345678} ERROR 2013 (HY000) at line 14: Lost connection to MySQL server during query /usr/local/bin/mysqld_safe: line 183: 2584 Abort trap: 6 ā€¦ 150701 09:16:00 mysqld_safe mysqld restarted

Note 1: JSON supports decimal number with arbitrary precision and scale.

Note 2: Apart from being numerically wrong, lines 6 through 13 of the output in the second test
are invalid JSON, which allows only numbers with magnitude less than one to begin with the digit 0.

Environment

Darwin yossy.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64

Status

Assignee

Oleksandr Byelkin

Reporter

TheF

Labels

None

External issue ID

None

External issue ID

None

Components

Sprint

None

Fix versions

Affects versions

10.0
10.1

Priority

Major