UDF: UDF with 33 parameters cores tdm_udrserv in ../udrserv/UdrFFDC.cpp

Bug #1420938 reported by Weishiun Tsai
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Trafodion
Fix Released
High
Suresh Subbiah

Bug Description

UDF only allows a maximum of 32 parameters (input+output). The following example defined a UDF with 33 parameters (32 input + 1 output). At the execution time, it did return a message 'LM Assertion: Parameters more than 32 are not allowed.
at FILE: ../langman/LmRoutineCSql.cpp LINE: 840', but it also cored tdm_udrserv in ../udrserv/UdrFFDC.cpp. Instead of crashing tdm_udrserv, SQL should just return a proper error message at the registration time or the execution time.

This is seen on the v0210 build installed on a workstation.

To reproduce this problem:

(1) Download the attached tar file and untar it to get the 4 files in there. Put the 4 files in any directory <mydir>
(2) Run build.sh from <mydir> to build the UDF so file.
(3) Change the line ‘create library qa_udf_lib file '<mydir>/myudf.so'; in mytest.sql and fill in <mydir>
(4) From sqlci, obey mytest.sql

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

Here is the execution output:

>>obey mytest.sql;
>>create schema mytest;

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

--- SQL operation complete.
>>
>>create library qa_udf_lib file '<mydir>/myudf.so';

--- SQL operation complete.
>>
>>create function QA_UDF_33_PARAMETERS
+>(I1 int, I2 int, I3 int, I4 int, I5 int, I6 int, I7 int, I8 int, I9 int,
+>I10 int, I11 int, I12 int, I13 int, I14 int, I15 int, I16 int, I17 int,
+>I18 int, I19 int, I20 int, I21 int, I22 int, I23 int, I24 int, I25 int,
+>I26 int, I27 int, I28 int, I29 int, I30 int, I31 int, I32 int)
+>returns (O int)
+>language c
+>parameter style sql
+>external name 'qa_udf_33_parameters'
+>library qa_udf_lib
+>deterministic
+>state area size 1024
+>allow any parallelism
+>no sql;

--- SQL operation complete.
>>
>>values(QA_UDF_33_PARAMETERS(
+>1,1,1,1,1,1,1,1,1,1,
+>1,1,1,1,1,1,1,1,1,1,
+>1,1,1,1,1,1,1,1,1,1,
+>1,1));
LM Assertion: Parameters more than 32 are not allowed.
at FILE: ../langman/LmRoutineCSql.cpp LINE: 840

*** ERROR[2034] $Z0001NI:60: Operating system error 201 while communicating with server process $Z0002EK:63.

*** ERROR[8904] SQL did not receive a reply from MXUDR, possibly caused by internal errors when executing user-defined routines.

--- 0 row(s) selected.
>>
>>drop function QA_UDF_33_PARAMETERS;

--- SQL operation complete.
>>drop library qa_udf_lib cascade;

--- SQL operation complete.
>>drop schema mytest cascade;

--- SQL operation complete.

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

Here is the stack of the core file:

(gdb) bt
#0 0x00000039e28328a5 in raise () from /lib64/libc.so.6
#1 0x00000039e2834085 in abort () from /lib64/libc.so.6
#2 0x0000000000423689 in comTFDS (
    msg1=0x43ad50 "Trafodion UDR Server Internal Error",
    msg2=<value optimized out>,
    msg3=0x7fffffff8f20 "Error occurred in source file ../langman/LmRoutineCSql.cpp on line 840",
    msg4=0x7fffffff8720 "User routine being processed : TRAFODION.MYTEST.QA_UDF_33_PARAMETERS, Routine Type : UDF, Language Type : C, Error occurred outside the user routine code", msg5=0x43c977 "", dialOut=<value optimized out>,
    writeToSeaLog=1) at ../udrserv/UdrFFDC.cpp:188
#3 0x00000000004238f7 in makeTFDSCall (
    msg=0x7fffffff9370 "Language Manager internal error : Parameters more than 32 are not allowed.", file=<value optimized out>, line=<value optimized out>,
    dialOut=1, writeToSeaLog=1) at ../udrserv/UdrFFDC.cpp:216
#4 0x00007ffff79c0873 in lmAssert (
    file=0x7ffff79e553c "../langman/LmRoutineCSql.cpp", linenum=840,
    msg=0x7ffff79e5488 "Parameters more than 32 are not allowed.")
    at ../langman/LmAssert.cpp:56
#5 0x00007ffff79e1c58 in LmRoutineCSql::invokeRoutine (this=0x7fffea26d650,
    inputRow=0x7fffea22c480, outputRow=0x7fffea23e160, da=0x7fffea23c678)
    at ../langman/LmRoutineCSql.cpp:840
#6 0x0000000000415ebc in SPInfo::processOneRequestRow (this=0x7fffea26afb8,
    reqSqlBuf=<value optimized out>, replySqlBuf=0x7fffea23e100,
    numRowsProcessed=<value optimized out>) at ../udrserv/spinfo.cpp:1586
#7 0x00000000004164bf in SPInfo::work (this=0x7fffea26afb8)
    at ../udrserv/spinfo.cpp:1436
#8 0x0000000000432cda in UdrServerDataStream::actOnReceive (
    this=0x7fffea26bee8, conn=<value optimized out>)
    at ../udrserv/UdrStreams.cpp:134
#9 0x000000000042f08d in processARequest (UdrGlob=0x7fffea266040,
    msgStream=..., env=...) at ../udrserv/udrserv.cpp:698
#10 0x00000000004318ec in runServer (argc=2, argv=0x7fffffff9fb8)
    at ../udrserv/udrserv.cpp:509
#11 0x0000000000431b7f in main (argc=2, argv=0x7fffffff9fb8)
    at ../udrserv/udrserv.cpp:345

Tags: sql-exe
Revision history for this message
Weishiun Tsai (wei-shiun-tsai) wrote :
description: updated
Changed in trafodion:
assignee: nobody → Suresh Subbiah (suresh-subbiah)
status: New → In Progress
Revision history for this message
Suresh Subbiah (suresh-subbiah) wrote :

An error is raised during CREATE time for an UDF with more than 32 parameters now.

Changed in trafodion:
status: In Progress → Fix Committed
Revision history for this message
Weishiun Tsai (wei-shiun-tsai) wrote :

Verified on the v0330 build installed on a workstation. This problem is fixed. A proper 1550 error is returned at the registration time:

>>create schema mytest;

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

--- SQL operation complete.
>>
>>create library qa_udf_lib file '<mydir>/myudf.so';

--- SQL operation complete.
>>
>>create function QA_UDF_33_PARAMETERS
+>(I1 int, I2 int, I3 int, I4 int, I5 int, I6 int, I7 int, I8 int, I9 int,
+>I10 int, I11 int, I12 int, I13 int, I14 int, I15 int, I16 int, I17 int,
+>I18 int, I19 int, I20 int, I21 int, I22 int, I23 int, I24 int, I25 int,
+>I26 int, I27 int, I28 int, I29 int, I30 int, I31 int, I32 int)
+>returns (O int)
+>language c
+>parameter style sql
+>external name 'qa_udf_33_parameters'
+>library qa_udf_lib
+>deterministic
+>state area size 1024
+>allow any parallelism
+>no sql;

*** ERROR[1550] Failed to create UDF TRAFODION.MYTEST.QA_UDF_33_PARAMETERS with 33 parameters. A scalar UDF can have a maximum of 32 parameters.

--- SQL operation failed with errors.
>>
>>values(QA_UDF_33_PARAMETERS(
+>1,1,1,1,1,1,1,1,1,1,
+>1,1,1,1,1,1,1,1,1,1,
+>1,1,1,1,1,1,1,1,1,1,
+>1,1));

*** ERROR[4450] Function TRAFODION."_UDF_".QA_UDF_33_PARAMETERS is not a built-in function or registered user-defined function.

*** ERROR[8822] The statement was not prepared.

>>
>>drop function QA_UDF_33_PARAMETERS;

*** ERROR[1389] Object TRAFODION.MYTEST.QA_UDF_33_PARAMETERS does not exist in Trafodion.

--- SQL operation failed with errors.
>>drop library qa_udf_lib cascade;

--- SQL operation complete.
>>drop schema mytest cascade;

--- SQL operation complete.

Changed in trafodion:
status: Fix Committed → 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.