Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
-
linux+otl_v4+mariadb-connector-odbc-3.0.8-ga+mariadb-10.2.12
Description
MADB_SetIrdRecord in ma_desc.c:
switch (Field->type) {
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
Record->FixedPrecScale= SQL_FALSE;
Record->NumPrecRadix= 10;
Record->Precision= (SQLSMALLINT)Field->length - 2;
Record->Scale= Field->decimals;
if field type is MYSQL_TYPE_DECIMAL, the precision is Field->length-2, so field type decimal(1,0) will return precision=2-2=0, which makes otl buffer offset wrong.
Test Case:
TABLE:
MariaDB [test]> show create table t1;
----------------------------------------------------------------------------------------------------------------------------------+
Table | Create Table |
----------------------------------------------------------------------------------------------------------------------------------+
t1 | CREATE TABLE `t1` ( `f1` decimal(9,0) DEFAULT NULL, `f2` decimal(1,0) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
----------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
DATA:
MariaDB [test]> select * from t1;
----------+
f1 | f2 |
----------+
100 | 1 |
100 | 2 |
100 | 3 |
----------+
3 rows in set (0.00 sec)
use otl to select f1,f2 from t1,result is wrong if otl_stream first param array_size is 1000:
f1=100,f2=1
f1=100,f2=0
f1=100,f2=0
result is corrent, if otl_stream first param array_size is 1
f1=100,f2=1
f1=100,f2=2
f1=100,f2=3
Test Code:
#include <iostream>
using namespace std;
#include "otl.h"
otl_connect db;
int main()
{
otl_connect::otl_initialize();
try
{
db.rlogon("DSN=mdb_test");
string sql = "select f1,f2 from test.t1";
otl_nocommit_stream select(1000, sql.c_str(), db);
//otl_nocommit_stream select(1, sql.c_str(), db);
while(!select.eof())
}catch(otl_exception& p)
{ cerr<<p.msg<<endl; cerr<<p.stm_text<<endl; cerr<<p.var_info<<endl; } db.logoff();
}