<< previous page   --   table of contents   --   next page >>
| | | | | | | |
  • Return to Table of Contents
  • Table of Contents

    1. General Information
    2. MySQL Installation
    3. Tutorial Introduction
    4. Database Administration
    5. MySQL Optimisation
    6. MySQL Language Reference
    7. MySQL Table Types
    8. MySQL APIs
    9. Extending MySQL

    Chapter 9:  Extending MySQL 623 memcpy(result, "result string", 13); *length = 13; The result bu er that is passed to the calc function is 255 byte big.  If your result ts in this, you don't have to worry about memory allocation for results. If your string function needs to return a string longer than 255 bytes, you must allocate the space for it with  malloc()  in your  xxx_init()  function or your  xxx()  function and free it in your xxx_deinit() function.  You can store the allocated memory in the ptr slot in the UDF_INIT structure for reuse by future xxx() calls.  See Section 9.2.2.1 [UDF calling], page 619. To indicate a return value of NULL in the main function, set is_null to 1: *is_null = 1; To indicate an error return in the main function, set the error parameter to 1: *error = 1; If xxx() sets *error to 1 for any row, the function value is NULL for the current row and for any subsequent rows processed by the statement in which XXX() was invoked.  (xxx() will not even be called for subsequent rows.)   Note:  in MySQL versions prior to 3.22.10, you should set both *error and *is_null: *error = 1; *is_null = 1; 9.2.2.5  Compiling and Installing User-de nable Functions Files implementing UDFs must be compiled and installed on the host where the server runs. This process is described below for the example UDF le `udf_example.cc' that is included in the MySQL source distribution.  This le contains the following functions:    metaphon()  returns a metaphon string of the string argument.  This is something like a soundex string, but it's more tuned for English.    myfunc_double()  returns the sum of the ASCII values of the characters in its argu- ments, divided by the sum of the length of its arguments.    myfunc_int() returns the sum of the length of its arguments.    sequence([const int])  returns an sequence starting from the given number or 1 if no number has been given.    lookup() returns the IP number for a hostname.    reverse_lookup()  returns  the  hostname  for  an  IP  number.   The  function  may  be called with a string "xxx.xxx.xxx.xxx" or four numbers. A dynamically loadable le should be compiled as a sharable object le, using a command something like this: shell> gcc -shared -o udf_example.so myfunc.cc You can easily nd out the correct compiler options for your system by running this com- mand in the `sql' directory of your MySQL source tree:
     

    Customer Support CentreMySQL Reference Manual

    Web Hosting Services
    UNIX WEB HOSTING
    MERCHANT ACCOUNTS
    DEDICATED SERVERS
    E-COMMERCE HOSTING
    SUPPORT & FAQ's
    TERMS OF USE
    Domain Services
    DOMAIN
    REGISTRATION
    MANAGE
    YOUR ACCOUNT
    SUPPORT & FAQ's
    TERMS OF USE
    Corporate Info
    ABOUT US
    OUR NETWORK
    CONTACT US
    SITE MAP
    Copyright © 2002 Dyntex Group, Inc. All Rights Reserved
  • Return to Table of Contents
  • Back to top

  • Web Hosting: Manuals & FAQ's

    1. Unix-Based Web Hosting
    2. Unix Dedicated Servers
    3. Windows Dedicated Servers
    4. CuteFTP User’s Guide
    5. CuteHTML User’s Guide
    6. WS_FTP Pro User's Guide
    7. Miva Order User's Guide
    8. Miva Merchant User's Guide