Comment 3 for bug 1436963

Revision history for this message
Weishiun Tsai (wei-shiun-tsai) wrote :

Verified on the v0307 build installed on a workstation. This problem has been fixed.

With the line in qaTmudfTest.cpp remains as info.out().setLong(2, -3333); the execution returns error 11252, as a numeric unsigned output can't take a negative value -3333:

>>create schema mytest;

--- SQL operation complete.
>>set schema mytest;

--- SQL operation complete.
>>
>>create library qaTmudfLib file '<mydir>/qaTmudfTest.so';

--- SQL operation complete.
>>
>>create table mytable (
+>c1 numeric(9,2),
+>c2 numeric(9,2) unsigned
+>);

--- SQL operation complete.
>>
>>insert into mytable values (-11.11, 22.22);

--- 1 row(s) inserted.
>>
>>create table_mapping function qaTmudfGeneral()
+>returns (
+>o1 char(50),
+>o2 char(50),
+>o3 numeric(9,2) unsigned
+>)
+>external name 'QA_TMUDF'
+>language cpp
+>library qaTmudfLib;

--- SQL operation complete.
>>
>>select * from mytable;

C1 C2
------------ -----------

      -11.11 22.22

--- 1 row(s) selected.
>>
>>select * from UDF(qaTmudfGeneral(TABLE(select * from mytable)));

*** ERROR[11252] Trying to assign a negative value to an INT UNSIGNED type (SQLSTATE 38900)

--- 0 row(s) selected.
>>
>>drop schema mytest cascade;

--- SQL operation complete.

---------------------------------------------------------------------------------------------------------------

With the line in qaTmudfTest.cpp changed to info.out().setLong(2, 3333); the execution output indicates that the input data type for column c2 is now correctly mapped to TypeInfo::NUMERIC_UNSIGNED

>>create schema mytest;

--- SQL operation complete.
>>set schema mytest;

--- SQL operation complete.
>>
>>create library qaTmudfLib file '<mydir>/qaTmudfTest.so';

--- SQL operation complete.
>>
>>create table mytable (
+>c1 numeric(9,2),
+>c2 numeric(9,2) unsigned
+>);

--- SQL operation complete.
>>
>>insert into mytable values (-11.11, 22.22);

--- 1 row(s) inserted.
>>
>>create table_mapping function qaTmudfGeneral()
+>returns (
+>o1 char(50),
+>o2 char(50),
+>o3 numeric(9,2) unsigned
+>)
+>external name 'QA_TMUDF'
+>language cpp
+>library qaTmudfLib;

--- SQL operation complete.
>>
>>select * from mytable;

C1 C2
------------ -----------

      -11.11 22.22

--- 1 row(s) selected.
>>
>>select * from UDF(qaTmudfGeneral(TABLE(select * from mytable)));

O1 O2 O3
-------------------------------------------------- -------------------------------------------------- -----------

c[1]: TypeInfo::NUMERIC c[2]: TypeInfo::NUMERIC_UNSIGNED 33.33

--- 1 row(s) selected.
>>
>>drop schema mytest cascade;

--- SQL operation complete.