Bug #30311 ERROR 2013 (HY000): Lost connection to MySQL server during query
Submitted: 8 Aug 2007 14:55 Modified: 6 Jan 2008 10:20
Reporter: Aurélie de LUCA Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.32-Debian_7etch1-log OS:Linux
Assigned to: Assigned Account CPU Architecture:Any

[8 Aug 2007 14:55] Aurélie de LUCA
Description:
Hello, 

I have write an UDF whose code functions when I call it in a program main, but which turns over the error when I call it in MySQL : 

ERROR 2013 (HY000): Lost connection to MySQL server during query.

I looked at bugs preceding, but my database is in MyISAM and I have all the rights root.

You have the UDF code which is composed of a C code, of a wrapper and of a C++ code below:

C code :

my_bool fingerprint_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
  if (args->arg_count != 2 || args->arg_type[0] != STRING_RESULT && args->arg_type[1] != STRING_RESULT)
  {
    strcpy(message,"Usage: FunctionName (InputFileName,FPTType)");
    return 1;
  }
 return 0;
}

void fingerprint_deinit(UDF_INIT *initid)
{}

char *fingerprint(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *length, char *is_null, char *error)
{
  //char *b = malloc(2*sizeof(char));
  //b = result;
  char *molfile = args->args[0];
  char *output;
  char *e = args->args[1];

  result = conversionfpt(molfile,e);
  output = strdup(result);
  *length=strlen(output);

  return output;

}

wrapper :

char *conversionfpt(char *molfile, char *type);

C++ code :

char *conversionfpt(char * molfile, char *type)
{
  int i;
  string f;
  string mode(type);
  char *e;
  istringstream ist(molfile);
  OBMol mol;
  OBConversion conv;
  OBFingerprint *fingerprint;
  vector < unsigned int >vfp;

  fingerprint = OBFingerprint::FindFingerprint ("FP2");

  conv.Read (&mol, &ist);

  fingerprint->GetFingerprint (&mol, vfp);

  char b[(vfp.size () * sizeof(unsigned int))];
 
  for (i = 0; i< vfp.size(); i++) sprintf(&b[i],"%ld",vfp[i]);
  e = strdup(b);

  return e;
}

Thank you for your help.

Aurélie

How to repeat:
aureliedeluca@gmail.com
[8 Aug 2007 15:56] MySQL Verification Team
Thank you for the bug report. The version reported is pretty older, could
you please test with the latest released version 5.0.45. Thanks in advance.
[9 Aug 2007 12:54] Aurélie de LUCA
Hello, 

It is impossible for me to install version 5.0.45 because the person responsible for computer equipement is on holiday. I make only development. I tested all the day install version 5.0.45 but I could not arrive, and I must regulate this problem of UDF at all costs. I notice that I could install another UDF with version 5.0.32 and I did not have this type of problem. 

How to make it, please, without installing the 5.0.45? 

Thank you in advance.
[9 Aug 2007 17:43] Sergei Golubchik
Well, if it works with another UDF, than the problem could be in your UDF.
Try to find where a crash happens. For example make mysqld to dump core and look at the core dump. Or add debug printf()'s to your UDF.
[9 Aug 2007 20:16] Aurélie de LUCA
Hello,

I have to listen to you, and I tried to install 5.0.45, but today I cannot use my FindMySQL.cmake any more. I have the following error, it does not find mysqlclient. However it is well to install since I reinstalled my starting version. I however specify the way to him or to find it, but it does not find the bookshop which definite args for example. Must I install something of other?

Thank you in advance.

PS: By using a file.sql and a request bash, I could install my UDF.
[9 Aug 2007 21:42] Aurélie de LUCA
I have found what install in order to make function my FoundMySQL.cmake. I needed the mysql++ package. 

Thank you for all.

Aurélie
[10 Aug 2007 9:25] Sveta Smirnova
Thank you for the feedback.

Does last comment mean bug is not repeatble if you use mysql++?
[10 Aug 2007 9:51] Aurélie de LUCA
No, I badly expressed myself. The bug disappears if I use a file.sql to add my UDF in the table mysql. I can then use my UDF without problems in my tables. 
I don't understand, because they are the same orders as that typed in mysql but all sets in a file.sql that I send to mysql by a request of the type:

mysql -u root -p mysql < file.mysql

Aurélie
[10 Aug 2007 12:32] Sveta Smirnova
Thank you for the feedback.

Please provide file file.sql
[10 Sep 2007 23: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".
[8 Oct 2007 18:55] Aurélie de LUCA
SQL request

Attachment: mychem.sql (application/octet-stream, text), 2.70 KiB.

[8 Oct 2007 19:00] Aurélie de LUCA
Hello,

Excuse me, I had a problem to connect me. But I have sent my file file.sql that you can download in Files.

Cheers.

Aurélie
[6 Dec 2007 10:20] Sveta Smirnova
Thank you for the feedback.

Please also provide your error log file with records made in time when you get Lost connection error.
[7 Jan 2008 0: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".