Bug #79826 MySql invalid argument reading
Submitted: 3 Jan 2016 8:41 Modified: 28 Sep 2018 12:08
Reporter: yazan Houshieh Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S3 (Non-critical)
Version: 5.6.27 OS:Ubuntu
Assigned to: CPU Architecture:Any

[3 Jan 2016 8:41] yazan Houshieh
Description:

0
down vote
favorite
I am trying to write a udf were it read a long char* and do some operations on it, however my problem goes like this assume I have 2 strings in the DB first length is 614 and second is 613, i.e. first string length larger than the seconds. When I just retrieve those using the following code, it gives as an output two 614 strings with the second filled by the last char of the first.

my_bool dtest_init(UDF_INIT *initid, UDF_ARGS *args, char *message){
   return 0;
}

void dtest_deinit(UDF_INIT *initid){}

char* dtest(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error){
      return (args->args[0]);
} 

Sample 1:

57782753942348770558462424518365017219873030159893088335555614928921188344108959217524053308810653421421319418817377422752662160124993625129780431855975607991439146909250667938766259384513244404575786366888016969165329910829448323076371961520441981281951910639340439644317408905318840547666530467308889800019605225695961989228395472974660195564433310139610550440046877196427184157471167783336528527122329464974550734757380541796494598129335131297308994124713506054339366053040068103211013093498896904743988388982224973160278160818060583157224476796381096840573001138344577304870424803994698588347321784517455356638
Sample 2

7051377515424639451375816302260341038313898460584177231439542454261450397034935119361197682040287872744001337536358165841858051050781647035501740332215023788825177394225981073148439527491830747652087779012788762322656539919292633830534512839567172188357970683464256293770776183927260671981399447251210188264290726619459723447036331721060865620694564166547995498432242514685012717792349704568602147050832830132150817699014620168719260933405427173518070877563894758197684364320818875634146885146624359553705891799083515215267673893252538886497906674604572382440104513212860703010861818553948367170475951603419617410
Output is : first sample as it is. second sample with char 8 added. (8 is the last of the first)

NOTE : if I assumed I have first length 615 and second 613, 2 chars will be added to the second string, which are last two of the first.

How to repeat:
the problem is repeated when ever i have a longer string ahead of a shorter one in the database
[27 Aug 2018 12:38] MySQL Verification Team
Hi,

Straight away, I can notice two problems with your example.

First of all, since you have long strings in the arguments, you did not initialise your UDF properly.

Second, your declaration of the UDF is missing and is possibly not suitable, but we can not evaluate that , since you have not published it.

Last, but not least, our UDF interface is not maintained very frequently, since it was invented when we did not have stored routines, so why don't you just use a stored function instead ........
[28 Sep 2018 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".