• <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, 評論 - 8, 引用 - 0
            數據加載中……

            Windows上的MySQL UDF開發

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

            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)

            畫蛇添足的作下簡要中文說明。

            抱歉,這并不是一個bug。下面我粘貼一個以前為某個客戶做的簡例,假設你有了
            VC++,源碼分發,并且有一個正常運行的MySQL服務器。

            我將創建一個UDF它將一個名字:
            注意:例子非常簡陋,目的是讓你了解該如何處理手頭的UDF。

            - 打開 mysqld.dsw 工作區。
            - 添加新項目到這個工作區
            - Project name: my_udf // 項目名稱:my_udf
            - 選擇 Win32 Dynamic-Link Library // Win32動態連接庫
            - 點擊 OK
            - 選擇 An Empty DLL project // 一個空DLL項目
            - 點擊 Finish
            - 點擊 OK
            - 添加新文件 my_udf.cpp 到項目中:
            #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;
            // 調用此UDF將返回 my name
            }
            - 按 Ctrl+N 來創建一個新文件。
            - 選擇 text 類型
            - File name: my_udf.def file://文件名:my_udf.def
            - 按照下邊的內容編輯文件。
            LIBRARY UDF_EXAMPLE
            DESCRIPTION 'Example Using UDF with VC++'
            VERSION 1.0
            EXPORTS
            my_name

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

            - 復制 my_udf.dll 到環境變量path定義過的目錄
            比如 \winnt\system32 。

            - 打開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!歡迎大家來MySQL板交流UDF設計經驗!我的電子郵件是HeartIcy@163.com,
            手機13706410308。同時,我們MySQL板準備開始系統化持續性翻譯MySQL文檔,
            希望大家多多支持共同完成這一項目。

            HeartIcy
            2003年5月17日于中國濟南

            posted on 2006-04-06 12:02 編程之道 閱讀(306) 評論(0)  編輯 收藏 引用 所屬分類: C/C++數據庫

            天天躁日日躁狠狠久久| 国产精品伦理久久久久久| 久久婷婷人人澡人人爽人人爱| 亚洲国产成人精品久久久国产成人一区二区三区综 | 久久久久亚洲AV无码观看| 性高湖久久久久久久久AAAAA| 亚洲精品乱码久久久久久| 777米奇久久最新地址| 久久天天躁狠狠躁夜夜2020老熟妇| 国产成年无码久久久免费| 久久99精品国产一区二区三区| 人妻无码久久精品| 高清免费久久午夜精品| 97精品国产97久久久久久免费| 久久99国产精品99久久| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 欧洲成人午夜精品无码区久久| 久久精品国产影库免费看| 无码人妻久久一区二区三区蜜桃| 97久久精品无码一区二区| 欧美粉嫩小泬久久久久久久| 国产精品美女久久久久网| 久久久一本精品99久久精品88| 久久99国产精品99久久| 久久精品国产亚洲αv忘忧草| 91精品国产高清久久久久久91| 久久国产乱子伦免费精品| 久久亚洲AV无码精品色午夜 | 亚洲欧美国产日韩综合久久| 国产91久久综合| 99久久精品免费看国产一区二区三区 | 久久久91精品国产一区二区三区 | 久久亚洲熟女cc98cm| 亚洲精品无码专区久久同性男| 亚洲一区二区三区日本久久九| 国产V亚洲V天堂无码久久久| 久久亚洲精品成人av无码网站| 亚洲AV无一区二区三区久久| 亚洲国产欧洲综合997久久| 久久精品国产99国产精品亚洲| 日本WV一本一道久久香蕉|