MySQL UDF development on Windows

Source: Internet
Author: User
Tags mysql client
A bug report has been submitted for a bug in Windows version of MySQL that does not use UDF. But
It seems to me that I made a mistake, and the MySQL technical support staff gave me the perfect solution to share
A moment. Below is the original reply:)
Sorry this isn ' t a bug.
Below I pasted a sample I did sometime ago for another user:
Ok. Assuming you have VC and the source distribution and a server
Running
I'll create a UDF that returns a name:
Note:the sample is ugly, but the purpose here
To handle the UDF.
-Open the MYSQLD.DSW workspace.
-ADD New project to the workspace
-Project NAME:MY_UDF
-Select Win32 Dynamic-link Library
-Click OK
-Select an Empty DLL project
-Click Finish
-Click OK
-Add A new file called My_udf.cpp to the project:
#include <stdlib.h>
#include <winsock.h>
#include <mysql.h>
extern "C" {
Char *my_name (udf_init *initid, Udf_args *args, Char *is_null,
Char *error);
}
Char *my_name (udf_init *initid, Udf_args *args, Char *is_null,
Char *error)
{
char * me = "my Name";
return me;
}
-Type Ctrl N for to create a new file.
-Select Text Type
-File Name:my_udf.def
-Edit the above file with the below contents:
LIBRARY Udf_example
DESCRIPTION ' Example Using UDF with VC '
VERSION 1.0
Exports
My_name
-Right Click the MY_UDF project and select Settings
-Click The/C tab
-Select General in the Category Combo
-ADD the macro have_dlopen to the preprocessor definition
-Select preprocessor in the Category Combo
-ADD the Include path to the text box:additional include directories
e.g:.. /include
-Press F7 for to build the DLL.
-Copy the My_udf.dll to the Environment path directory:
Winntsystem32 for example.
-Start The MySQL client and issue:
C:mysql-udfin>mysql-uroot-p
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.