Bug #43489 NDBAPI Cannot Store Values To SMALLINT/TINYINT Columns
Submitted: 9 Mar 2009 6:00 Modified: 26 Dec 2010 14:06
Reporter: Mikiya Okuno Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Cluster: NDB API Severity:S2 (Serious)
Version:mysql-5.1-telco-6.3 OS:Solaris (SPARC)
Assigned to: CPU Architecture:Any
Tags: mysql-5.1-telco-6.3.20

[9 Mar 2009 6:00] Mikiya Okuno
Description:
When using NDBAPI, it is not possible to store values using NdbObject::setValue() to SMALLINT/TINYINT column. It is possible to store values to INT column. It cannot repeatable on Intel platform, but only happens on SPARC/Solaris.

How to repeat:
1. Edit ndbapi_simple.cpp under storage/ndb/ndbapi-examples/ndbapi_simple directory, and modify line 150 (table definition) so that ATTR2 is defined as SMALLINT/TINYINT.

2. Compile it and run it.

3. Then, you'll see the following output:

ATTR1 ATTR2
  0     0
  1     0
  2     0
Detected that deleted tuple doesn't exist!
  4     0
  5     0
  6     0
  7     0
  8     0
  9     0

The output should be like following instead of the above:

ATTR1 ATTR2
  0    10
  1     1
  2    12
Detected that deleted tuple doesn't exist!
  4    14
  5     5
  6    16
  7     7
  8    18
  9     9

Suggested fix:
Please fix NdbObject class.
[9 Mar 2009 9:40] MySQL Verification Team
Casting explicitly fixed the problem.
myOperation->setValue("ATTR2", (Uint16)i);
[12 Mar 2009 7:52] MySQL Verification Team
Modified simple_ndbapi.cpp

Attachment: ndbapi_simple.cpp (text/plain), 9.13 KiB.

[12 Mar 2009 8:08] MySQL Verification Team
I retest using a table with SMALLINT column. The modifications of attached ndbapi_simple.cpp are listed below:

* setValue(const char*, const char*, int) is used instead of (const char*, Uint32).
* Add a buffer for int2store().
* Data is converted using int2store() in advance.
* Change the data type for i (a variable for loop) from int to uint16.

When I execute the program, the output is like the following:

ATTR1 ATTR2
  0    167772160
  1    16777216
  2    201326592
Detected that deleted tuple doesn't exist!
  4    234881024
  5    83886080
  6    268435456
  7    117440512
  8    301989888
  9    150994944

Instead of expected output:

ATTR1 ATTR2
  0    10
  1     1
  2    12
Detected that deleted tuple doesn't exist!
  4    14
  5     5
  6    16
  7     7
  8    18
  9     9

Why don't we add an interface like setValue(const char*, Uint16)?