• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 47, 文章 - 10, 評(píng)論 - 8, 引用 - 0
            數(shù)據(jù)加載中……

            Windows上的MySQL UDF開(kāi)發(fā)

            終于發(fā)現(xiàn)了篇不錯(cuò)的Mysql開(kāi)發(fā)的文章
            曾以為Windows版本的MySQL存在不能使用UDF的BUG諸提交了一個(gè)bug報(bào)告。不過(guò)
            似乎發(fā)現(xiàn)是我搞錯(cuò)了,MySQL的技術(shù)支持人員給了非常完美的解答,同大家分享
            一下。下邊是原文回復(fù) :)

            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 will create a UDF that returns a name:

            Note: the sample is ugly, but the purpose here is to show you how
            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/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:
            \winnt\system32 for example.

            - Start the mysql client and issue:

            C:\mysql-udf\bin>mysql -uroot -p
            Enter password:
            Welcome to the MySQL monitor. Commands end with ; or \g.
            Your MySQL connection id is 2 to server version: 3.23.52-max-nt

            Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

            mysql> CREATE FUNCTION my_name RETURNS STRING SONAME "my_udf.dll";
            Query OK, 0 rows affected (0.08 sec)

            mysql> select my_name();

            mysql> drop function my_name;
            Query OK, 0 rows affected (0.00 sec)

            畫蛇添足的作下簡(jiǎn)要中文說(shuō)明。

            抱歉,這并不是一個(gè)bug。下面我粘貼一個(gè)以前為某個(gè)客戶做的簡(jiǎn)例,假設(shè)你有了
            VC++,源碼分發(fā),并且有一個(gè)正常運(yùn)行的MySQL服務(wù)器。

            我將創(chuàng)建一個(gè)UDF它將一個(gè)名字:
            注意:例子非常簡(jiǎn)陋,目的是讓你了解該如何處理手頭的UDF。

            - 打開(kāi) mysqld.dsw 工作區(qū)。
            - 添加新項(xiàng)目到這個(gè)工作區(qū)
            - Project name: my_udf // 項(xiàng)目名稱:my_udf
            - 選擇 Win32 Dynamic-Link Library // Win32動(dòng)態(tài)連接庫(kù)
            - 點(diǎn)擊 OK
            - 選擇 An Empty DLL project // 一個(gè)空DLL項(xiàng)目
            - 點(diǎn)擊 Finish
            - 點(diǎn)擊 OK
            - 添加新文件 my_udf.cpp 到項(xiàng)目中:
            #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);
            // 兼容C
            }

            char *my_name(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
            char *error)
            {
            char * me = "my name";

            return me;
            // 調(diào)用此UDF將返回 my name
            }
            - 按 Ctrl+N 來(lái)創(chuàng)建一個(gè)新文件。
            - 選擇 text 類型
            - File name: my_udf.def file://文件名:my_udf.def
            - 按照下邊的內(nèi)容編輯文件。
            LIBRARY UDF_EXAMPLE
            DESCRIPTION 'Example Using UDF with VC++'
            VERSION 1.0
            EXPORTS
            my_name

            - 右擊my_udf項(xiàng)目并選擇Settings
            - 點(diǎn) C/C++ 選項(xiàng)卡
            - 選擇 General
            - 添加宏 HAVE_DLOPE 到預(yù)處理器定義
            - 選擇 Preprocessor
            - 添加頭文件路徑: Additional Include directories
            例如: ../include
            - 按 F7 去編譯成 DLL.

            - 復(fù)制 my_udf.dll 到環(huán)境變量path定義過(guò)的目錄
            比如 \winnt\system32 。

            - 打開(kāi)mysql客戶端

            C:\mysql-udf\bin>mysql -uroot -p
            Enter password:
            Welcome to the MySQL monitor. Commands end with ; or \g.
            Your MySQL connection id is 2 to server version: 3.23.52-max-nt

            Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

            mysql> CREATE FUNCTION my_name RETURNS STRING SONAME "my_udf.dll";
            Query OK, 0 rows affected (0.08 sec)

            mysql> select my_name();

            mysql> drop function my_name;
            Query OK, 0 rows affected (0.00 sec)


            ok!歡迎大家來(lái)MySQL板交流UDF設(shè)計(jì)經(jīng)驗(yàn)!我的電子郵件是HeartIcy@163.com,
            手機(jī)13706410308。同時(shí),我們MySQL板準(zhǔn)備開(kāi)始系統(tǒng)化持續(xù)性翻譯MySQL文檔,
            希望大家多多支持共同完成這一項(xiàng)目。

            HeartIcy
            2003年5月17日于中國(guó)濟(jì)南

            posted on 2006-04-06 12:02 編程之道 閱讀(305) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C/C++數(shù)據(jù)庫(kù)

            色成年激情久久综合| 香蕉久久影院| 久久天天躁夜夜躁狠狠躁2022 | 久久99精品国产麻豆| 欧美久久综合九色综合| 韩国三级中文字幕hd久久精品 | 久久五月精品中文字幕| 精品久久一区二区三区| 久久久无码精品亚洲日韩蜜臀浪潮| 久久久久久久91精品免费观看| 手机看片久久高清国产日韩| 久久久91人妻无码精品蜜桃HD| 国产三级观看久久| 青青久久精品国产免费看| 久久精品国产一区二区 | 精品久久久久久国产| 久久亚洲国产欧洲精品一 | 国产L精品国产亚洲区久久 | 精品人妻伦九区久久AAA片69| 国产成人无码精品久久久久免费| 亚洲嫩草影院久久精品| 久久久国产精品| 国产精品久久久久久五月尺| 婷婷伊人久久大香线蕉AV| 久久66热人妻偷产精品9| 久久国产精品99久久久久久老狼 | 精品免费tv久久久久久久| 精品久久久久久无码免费| 精品久久久久久无码不卡| 囯产极品美女高潮无套久久久| 99久久精品日本一区二区免费| 99久久精品国产毛片| 久久男人AV资源网站| 77777亚洲午夜久久多喷| 77777亚洲午夜久久多喷| 亚洲а∨天堂久久精品| 97久久久精品综合88久久| 国产精品久久久久久久久免费| 91精品国产91久久久久久蜜臀| 久久久久亚洲AV成人网人人软件 | 久久综合久久性久99毛片|