How to debug mysql user-defined function?

2019-07-15 11:36发布

I have a mysql function, i want to debug it, set breakboints, see variables values on that time period etc. How to do it ?

2条回答
Rolldiameter
2楼-- · 2019-07-15 11:59

From my current search so far (though I might have missed something) I have to agree with Devart that you cannot debug UDF functions.

One extra advice to give you is to use the stderr for debugging. I've crafted something rather simple to work with:

void udf_debug( char *msg, ... ) {
#ifdef DEBUG
  va_list ap;

  va_start(ap, msg);
  vfprintf(stderr, msg, ap);
  va_end(ap);

  fflush(stderr);
#endif
}
查看更多
你好瞎i
3楼-- · 2019-07-15 12:24

You cannot debug UDF function when it is called by MySQL. But I think you can try these variants:

  • debug your functions without MySQL, just pass test parameter values into function.
  • try to output values into the file when UDF is called, this will help you to view internal variables and understand what is happen.
查看更多
登录 后发表回答