[MDEV-12520] ConnectSE truncating data on DECIMAL column Created: 2017-04-18  Updated: 2020-08-25  Resolved: 2017-05-09

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Connect
Affects Version/s: 10.1.19
Fix Version/s: 10.1.25, 10.0.31, 10.2.7

Type: Bug Priority: Major
Reporter: Will Fong Assignee: Olivier Bertrand
Resolution: Fixed Votes: 1
Labels: connect-engine

Issue Links:
Duplicate
is duplicated by MDEV-12614 Connect Crash with DECIMAL column Closed

 Description   

The Connect engine is doing some strange things for a DECIMAL column.

It starts off normal:

MariaDB [test]> CREATE TABLE connect14007 ( id INT PRIMARY KEY AUTO_INCREMENT, foo DECIMAL(18,3));
Query OK, 0 rows affected (0.02 sec)
 
MariaDB [test]> CREATE TABLE connect14007j ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=connect14007 CONNECTION='jdbc:mysql://localhost/test?user=root';
Query OK, 0 rows affected (0.02 sec)
 
MariaDB [test]> INSERT INTO connect14007 ( foo ) VALUES ( 1234567890.123 );
Query OK, 1 row affected (0.09 sec)
 
MariaDB [test]> SELECT 'MariaDB', foo FROM connect14007 UNION ALL SELECT 'Connect', foo FROM connect14007j;
+---------+----------------+
| MariaDB | foo            |
+---------+----------------+
| MariaDB | 1234567890.123 |
| Connect | 1234567890.123 |
+---------+----------------+
2 rows in set (0.01 sec)
 
MariaDB [test]> 

Until we add one more number (10x):

MariaDB [test]> INSERT INTO connect14007 ( foo ) VALUES ( 12345678901.123 );
Query OK, 1 row affected (0.00 sec)
 
MariaDB [test]> SELECT 'MariaDB', foo FROM connect14007 UNION ALL SELECT 'Connect', foo FROM connect14007j;
+---------+-----------------+
| MariaDB | foo             |
+---------+-----------------+
| MariaDB |  1234567890.123 |
| MariaDB | 12345678901.123 |
| Connect |  1234567890.123 |
| Connect | 12345678901.123 |
+---------+-----------------+
4 rows in set, 1 warning (0.00 sec)
 
MariaDB [test]> SHOW WARNINGS;
+-------+------+------------------------------------------+
| Level | Code | Message                                  |
+-------+------+------------------------------------------+
| Note  | 1265 | Data truncated for column 'foo' at row 2 |
+-------+------+------------------------------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> 

We can do this three more times:

MariaDB [test]> SELECT 'MariaDB', foo FROM connect14007 UNION ALL SELECT 'Connect', foo FROM connect14007j;
+---------+--------------------+
| MariaDB | foo                |
+---------+--------------------+
| MariaDB |     1234567890.123 |
| MariaDB |    12345678901.123 |
| MariaDB |   123456789012.123 |
| MariaDB |  1234567890123.123 |
| MariaDB | 12345678901234.123 |
| Connect |     1234567890.123 |
| Connect |    12345678901.123 |
| Connect |   123456789012.123 |
| Connect |  1234567890123.123 |
| Connect | 12345678901234.123 |
+---------+--------------------+
10 rows in set, 4 warnings (0.01 sec)
 
MariaDB [test]> show warnings;
+-------+------+------------------------------------------+
| Level | Code | Message                                  |
+-------+------+------------------------------------------+
| Note  | 1265 | Data truncated for column 'foo' at row 2 |
| Note  | 1265 | Data truncated for column 'foo' at row 3 |
| Note  | 1265 | Data truncated for column 'foo' at row 4 |
| Note  | 1265 | Data truncated for column 'foo' at row 5 |
+-------+------+------------------------------------------+
4 rows in set (0.00 sec)
 
MariaDB [test]>  

And the fifth one somehow changes the decimal value:

MariaDB [test]> INSERT INTO connect14007 ( foo ) VALUES ( 123456789012345.123 );
Query OK, 1 row affected (0.00 sec)
 
MariaDB [test]> SELECT 'MariaDB', foo FROM connect14007 UNION ALL SELECT 'Connect', foo FROM connect14007j;
+---------+---------------------+
| MariaDB | foo                 |
+---------+---------------------+
| MariaDB |      1234567890.123 |
| MariaDB |     12345678901.123 |
| MariaDB |    123456789012.123 |
| MariaDB |   1234567890123.123 |
| MariaDB |  12345678901234.123 |
| MariaDB | 123456789012345.123 |
| Connect |      1234567890.123 |
| Connect |     12345678901.123 |
| Connect |    123456789012.123 |
| Connect |   1234567890123.123 |
| Connect |  12345678901234.123 |
| Connect | 123456789012345.125 |
+---------+---------------------+
12 rows in set, 4 warnings (0.00 sec)
 
MariaDB [test]> SHOW WARNINGS;
+-------+------+------------------------------------------+
| Level | Code | Message                                  |
+-------+------+------------------------------------------+
| Note  | 1265 | Data truncated for column 'foo' at row 2 |
| Note  | 1265 | Data truncated for column 'foo' at row 3 |
| Note  | 1265 | Data truncated for column 'foo' at row 4 |
| Note  | 1265 | Data truncated for column 'foo' at row 5 |
+-------+------+------------------------------------------+
4 rows in set (0.00 sec)
 
MariaDB [test]> 



 Comments   
Comment by Will Fong [ 2017-05-01 ]

Hi bertrandop, Will we be able to get this into 10.2 line? Thanks!

Comment by Alvin Richards (Inactive) [ 2017-05-01 ]

bertrandop I'm trying to track down the git commit for this change, can't find it via 'git log'.

Comment by Olivier Bertrand [ 2017-05-01 ]

I pushed the fix quite recently. It will appear only when new versions will be issued providing the fixed CONNECT is correctly included in them

Comment by Alvin Richards (Inactive) [ 2017-05-01 ]

These are the last two commits on 10.1, not clear if either of these fixes this issue. I search for MDEV-12520 in the git log and did not find anything.

Author: Olivier Bertrand
Date: Thu Mar 2 12:12:53 2017 +0100

Update version number and date
modified: storage/connect/ha_connect.cc

Add conditional SE exception support
modified: storage/connect/json.cpp
modified: storage/connect/plgdbutl.cpp

Change %p in %x in some sprintf functions.
This to avoid some compiler warnings.
modified: storage/connect/tabwmi.cpp
modified: storage/connect/tabxml.cpp
modified: storage/connect/value.h

Author: Olivier Bertrand
Date: Fri Feb 24 23:21:20 2017 +0100

Fix crashing when joining two JDBC tables..
Was in close (the virtual machine could have been detached.
modified: storage/connect/jdbconn.cpp

commit ac78927aefa2bd0d869d999839480d69086a9882
Author: Igor Babaev <igor@askmonty.org>
Date: Fri Feb 24 00:10:08 2017 -0800

Fixed bug mdev-7992.

'Not exists' optimization can be used for nested outer joins
only if IS NULL predicate from the WHERE condition is activated.
So we have to check that all guards that wrap this predicate

Comment by Olivier Bertrand [ 2017-05-09 ]

No these are not the fix I have done. Unfortunately, the 10.1 version released last week seem to have forgotten the recent changes to CONNECT.

Comment by Valerii Kravchuk [ 2017-06-16 ]

What about the 10.2? I do not see 10.2.x in the fixed versions. may I assume we get this fix in 10.2.7 after some merge (from 10.1.25)?

Comment by Olivier Bertrand [ 2017-06-16 ]

I hope so. The fix was done end of april. Did you check it is not included in version 10.2.6?

Generated at Thu Feb 08 07:58:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.