[MCOL-1563] Data corruption when inserting out-of-bounds data Created: 2018-07-14  Updated: 2023-10-26  Resolved: 2019-01-21

Status: Closed
Project: MariaDB ColumnStore
Component/s: None
Affects Version/s: 1.1.5
Fix Version/s: 1.1.7

Type: Bug Priority: Major
Reporter: Anders Karlsson Assignee: Andrew Hutchings (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux CentOS 7.5


Attachments: HTML File 1563    
Sprint: 2018-21, 2019-01

 Description   

The issues seems related to unsigned smallint and inserting through mcsapi

MariaDB> create table test.t1(smallint_t SMALLINT, usmallint_t SMALLINT UNSIGNED) engine=columnstore;

Then load data using this simple c++ program

#include <libmcsapi/mcsapi.h>
#include <iostream>
 
int main(int argc, char *argv[])
   {
   mcsapi::ColumnStoreDriver* driver = nullptr;
   mcsapi::ColumnStoreBulkInsert* bulk = nullptr;
 
   try {
      driver = new mcsapi::ColumnStoreDriver();
      bulk = driver->createBulkInsert("test", "t1", 0, 0);
 
      bulk->setColumn(0, (int16_t) INT16_MAX);
      bulk->setColumn(1, (uint16_t) UINT16_MAX);
      bulk->writeRow();
      bulk->commit();
   } catch (mcsapi::ColumnStoreError &e) {
      std::cout << "Error caught: " << e.what() << std::endl;
   }
   delete bulk;
   delete driver;
 
   return 0;
   }

Back to the MySQL command prompt, the data now looks corrupt:

MariaDB> select * from test.t1;
ERROR 1815 (HY000): Internal error: An unexpected condition within the query caused an internal processing error within InfiniDB. Please check the log files for more details. Additional Information: error in BatchPrimitiveProces



 Comments   
Comment by Andrew Hutchings (Inactive) [ 2018-12-19 ]

For QA: test case added to API regression suite called mcol1563.

Comment by Zdravelina Sokolovska (Inactive) [ 2019-01-14 ]

checked with mariadb-columnstore-api-1.1.7-1.x86_64 , fail to build the given code in #1563

  1. # g++ -o cpcp cpcp.cpp
    In file included from /usr/include/libmcsapi/mcsapi.h:28:0,
    from cpcp.cpp:1:
    /usr/include/libmcsapi/mcsapi_types.h:38:34: error: expected ‘)’ before ‘year’
    ColumnStoreDateTime(uint32_t year, uint32_t month, uint32_t day, uint32_t hour = 0, uint32_t minute = 0, uint32_t second = 0, uint32_t microsecond = 0);
    ^
    In file included from /usr/include/libmcsapi/mcsapi.h:28:0,
    from cpcp.cpp:1:
    .......................
Comment by Andrew Hutchings (Inactive) [ 2019-01-21 ]

You appear to have include issues and a linking issue in your test.

Comment by Andrew Hutchings (Inactive) [ 2019-01-21 ]

Closing as regression suite nightly runs confirms this is fixed.

Comment by Zdravelina Sokolovska (Inactive) [ 2019-01-22 ]

with the compiled script with source mariadb-columnstore-api dev branch develop-1.1, tag columnstore-1.1.6-47-g7ee34ce

MariaDB [(none)]> create table test.t1(smallint_t SMALLINT, usmallint_t SMALLINT UNSIGNED) engine=columnstore;
Query OK, 0 rows affected (0.11 sec)
 
MariaDB [(none)]> select * from test.t1 ;
Empty set (0.10 sec)
 
MariaDB [(none)]> show create table  test.t1 ;
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                               |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `smallint_t` smallint(6) DEFAULT NULL,
  `usmallint_t` smallint(5) unsigned DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=latin1 |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
 

[root@ ~]# ./1563

Jan 22 21:05:10 pm1 ExeMgr[11806]: 10.323528 |14961|0|0| D 16 CAL0041: Start SQL statement: select * from test.t1; ||
Jan 22 21:05:10 pm1 ExeMgr[11806]: 10.332866 |14961|0|0| D 16 CAL0042: End SQL statement

an 22 21:06:16 pm1 ProcessMonitor[11044]: 16.144774 |0|0|0| I 18 CAL0000: MSG RECEIVED: Get Calpont Software Info
Jan 22 21:06:16 pm1 ProcessMonitor[11044]: 16.144896 |0|0|0| I 18 CAL0000: GETSOFTWAREINFO: ACK back to ProcMgr with 1.1.71

 
 
 
MariaDB [(none)]> select * from test.t1 ;
+------------+-------------+
| smallint_t | usmallint_t |
+------------+-------------+
|      32767 |       65533 |
+------------+-------------+
1 row in set (0.06 sec)

note: it's inserted value 65533 in usmallint_t instead of
the uint16_t ,UINT16_MAX 65535
but in the column store KB the 65533 is given as max one
SMALLINT 2-bytes A small integer. Signed: -32,766 to 32,767. Unsigned: 0 to 65,533.

Generated at Thu Feb 08 02:29:41 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.