TMUDF: User defined error number for UDRException() not returned at run time

Bug #1430484 reported by Weishiun Tsai
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Trafodion
Fix Released
Medium
Hans Zeller

Bug Description

Throwing an UDRException() from a compile time interface, such as describeParamsAndColumns(), properly returns the user defined error number. However, doing so from the run time interface processData() somehow loses the error number. Only the error message is returned.

As shown here in the example, the TMUDF throws an UDRException() with the user defined error number 38001. But when executed, only the error message was propagated back.

void QATmudf::processData(UDRInvocationInfo &info, UDRPlanInfo &plan)
{
  throw UDRException(38001, "test exception in process data");
}

This is seen on the v0305 build installed on a workstation. To reproduce it:

(1) Download the attached tar file and untar it to get the 3 files in there. Put the files in any directory <mydir>
(2) Make sure that you have run ./sqenv.sh of your Trafodion instance first as building UDF needs $MY_SQROOT for the header files.
(3) Run build.sh from <mydir> to build the UDF so file.
(4) Change the line create library qaTmudfLib file '<mydir>/qaTMUdfTest.so'; in mytest.sql and fill in <mydir>
(5) From sqlci, obey mytest.sql

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

Here is the execution output:

>>log mytest.log clear;
>>drop schema mytest cascade;

*** ERROR[1003] Schema TRAFODION.MYTEST does not exist.

--- SQL operation failed with errors.
>>create schema mytest;

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

--- SQL operation complete.
>>
>>create library qaTmudfLib file '/designs/seaquest/wtsai/udf_bugs/udf_bug/qaTMUdfTest.so';

--- SQL operation complete.
>>
>>create table mytable (a int, b int);

--- SQL operation complete.
>>insert into mytable values (1,1),(2,2);

--- 2 row(s) inserted.
>>
>>create table_mapping function qa_tmudf()
+>external name 'QA_TMUDF'
+>language cpp
+>library qaTmudfLib;

--- SQL operation complete.
>>
>>select * from UDF(qa_tmudf(TABLE(select * from mytable)));

*** ERROR[11249] User-defined function QA_TMUDF completed with an error with SQLSTATE . Details: test exception in process data.

*** ERROR[2037] $Z0001XI:172: A message from process $Z00029T:175 was incorrectly formatted and could not be processed.

*** ERROR[8906] An invalid or corrupt MXUDR reply could not be processed, possibly due to memory corruption in MXUDR while executing user-defined routines or an internal error in SQL.

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

--- SQL operation complete.
>>
>>exit;

End of MXCI Session

Tags: sql-exe
Revision history for this message
Weishiun Tsai (wei-shiun-tsai) wrote :
summary: - TMUDR: User defined error number for UDRException() not returned at run
+ TMUDF: User defined error number for UDRException() not returned at run
time
Changed in trafodion:
assignee: nobody → Hans Zeller (hans-zeller)
Revision history for this message
Hans Zeller (hans-zeller) wrote :

With my latest change this testcase works now. Unfortunately I didn't validate the problem earlier, so I'm not sure what the cause or the fix are.

Changed in trafodion:
status: New → In Progress
Revision history for this message
Hans Zeller (hans-zeller) wrote :

I hopefully fixed the two extra errors 2037 and 8906 as well, that problem was a missing "break" in a switch statement.

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

Verified on the v0324 build installed on a workstation. This problem is now fixed:

>>create schema mytest;

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

--- SQL operation complete.
>>
>>create library qaTmudfLib file '/designs/seaquest/wtsai/udf_bugs/udf_bug_LP1430484/qaTMUdfTest.so';

--- SQL operation complete.
>>
>>create table mytable (a int, b int);

--- SQL operation complete.
>>insert into mytable values (1,1),(2,2);

--- 2 row(s) inserted.
>>
>>create table_mapping function qa_tmudf()
+>external name 'QA_TMUDF'
+>language cpp
+>library qaTmudfLib;

--- SQL operation complete.
>>
>>select * from UDF(qa_tmudf(TABLE(select * from mytable)));

*** ERROR[11252] test exception in process data (SQLSTATE 38001)

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

--- SQL operation complete.

Changed in trafodion:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.