[MCOL-1570] Wrong data when inserting NULL into DECIMAL column with non-default precision Created: 2018-07-19  Updated: 2023-10-26  Resolved: 2018-10-02

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

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

Linux CentOS 7.5


Issue Links:
Duplicate
duplicates MCOL-1322 data corruption when setting NUMERIC ... Closed

 Description   

When creating a table with DECIMAL columns and a specific precision, then using mcsapi to insert NULL will end up with incorrect data. Create to following table:

CREATE TABLE `t1` (
  `c1` decimal(10,0) DEFAULT NULL,
  `c2` decimal(9,0) DEFAULT NULL,
  `c3` decimal(16,0) DEFAULT NULL
) ENGINE=Columnstore

Compile and run this program, which should insert INTO into all columns in the table above:

#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->setNull(0);
      bulk->setNull(1);
      bulk->setNull(2);
      bulk->writeRow();
      bulk->commit();
   } catch (mcsapi::ColumnStoreError &e) {
      std::cout << "Error caught: " << e.what() << std::endl;
   }
   delete bulk;
   delete driver;
 
   return 0;
   }

MariaDB [test]> select * from t1;
+------+------+---------+
| c1   | c2   | c3      |
+------+------+---------+
| NULL | 0    | 8388608 |
+------+------+---------+
1 row in set (0.11 sec)



 Comments   
Comment by Andrew Hutchings (Inactive) [ 2018-10-02 ]

Closed as duplicate of MCOL-1322

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