MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:paul Date:January 10 2008 3:30pm
Subject:svn commit - mysqldoc@docsrva: r9548 - in trunk: . refman-5.1 refman-6.0
View as plain text  
Author: paul
Date: 2008-01-10 16:30:41 +0100 (Thu, 10 Jan 2008)
New Revision: 9548

Log:
 r28572@frost:  paul | 2008-01-10 09:24:33 -0600
 "Adding a new native function" modifications, part 2:
 Revisions that apply to 5.1.13 and up.
 (Bug#32480)


Modified:
   trunk/refman-5.1/extending-mysql.xml
   trunk/refman-6.0/extending-mysql.xml

Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 4767c598-dc10-0410-bea0-d01b485662eb:/mysqldoc-local/mysqldoc/trunk:34807
7d8d2c4e-af1d-0410-ab9f-b038ce55645b:/mysqldoc-local/mysqldoc:28571
b5ec3a16-e900-0410-9ad2-d183a3acac99:/mysqldoc-local/mysqldoc/trunk:14218
bf112a9c-6c03-0410-a055-ad865cd57414:/mysqldoc-local/mysqldoc/trunk:23202
   + 4767c598-dc10-0410-bea0-d01b485662eb:/mysqldoc-local/mysqldoc/trunk:34807
7d8d2c4e-af1d-0410-ab9f-b038ce55645b:/mysqldoc-local/mysqldoc:28572
b5ec3a16-e900-0410-9ad2-d183a3acac99:/mysqldoc-local/mysqldoc/trunk:14218
bf112a9c-6c03-0410-a055-ad865cd57414:/mysqldoc-local/mysqldoc/trunk:23202


Modified: trunk/refman-5.1/extending-mysql.xml
===================================================================
--- trunk/refman-5.1/extending-mysql.xml	2008-01-10 15:30:30 UTC (rev 9547)
+++ trunk/refman-5.1/extending-mysql.xml	2008-01-10 15:30:41 UTC (rev 9548)
Changed blocks: 1, Lines Added: 49, Lines Deleted: 27; 4430 bytes

@@ -4428,47 +4428,69 @@
 
       <para>
         To add a new native function, follow these steps to modify
-        source files in the <filename>sql</filename> directory:
+        source files in the <filename>sql</filename> directory. For
+        MySQL 5.1, the first two steps apply only as of 5.1.13. For
+        older versions, see the instructions in the corresponding
+        section of the MySQL 5.0 manual
+        (<xref linkend="refman-5.0:adding-native-function"/>).
       </para>
 
       <orderedlist>
 
         <listitem>
           <para>
-            Add one line to <filename>lex.h</filename> that defines the
-            function name in the <literal>sql_functions[]</literal>
-            array.
+            Create a subclass for the function in
+            <filename>item_create.cc</filename>:
           </para>
+
+          <itemizedlist>
+
+            <listitem>
+              <para>
+                If the function takes a fixed number of arguments,
+                create a subclass of
+                <function>Create_func_arg0</function>,
+                <function>Create_func_arg1</function>,
+                <function>Create_func_arg2</function>, or
+                <function>Create_func_arg3</function>, respectively,
+                depending on whether the function takes zero, one, two,
+                or three arguments. For examples, see the subclasses for
+                <function>Create_func_uuid</function>,
+                <function>Create_func_abs</function>,
+                <function>Create_func_pow</function>, or
+                <function>Create_func_lpad</function>.
+              </para>
+            </listitem>
+
+            <listitem>
+              <para>
+                If the function takes a variable number of arguments,
+                create a subclass of
+                <function>Create_native_func</function>. For an example,
+                see <function>Create_func_concat</function>.
+              </para>
+            </listitem>
+
+          </itemizedlist>
         </listitem>
 
         <listitem>
           <para>
-            If the function prototype is simple (just takes zero, one,
-            two, or three arguments), add a line to the
-            <literal>sql_functions[]</literal> array in
-            <filename>lex.h</filename> that specifies
-            <literal>SYM(FUNC_ARG<replaceable>N</replaceable>)</literal>
-            as the second argument (where <replaceable>N</replaceable>
-            is the number of arguments the function takes). Also, add a
-            function in <filename>item_create.cc</filename> that creates
-            a function object. Look at <literal>"ABS"</literal> and
-            <literal>create_funcs_abs()</literal> for an example of
-            this.
+            To provide a name by which the function can be referred to
+            in SQL statements, register the name in
+            <filename>item_create.cc</filename> by adding a line to this
+            array:
           </para>
 
+<programlisting>
+static Native_func_registry func_array[]
+</programlisting>
+
           <para>
-            If the function prototype is not simple (for example, if it
-            takes a variable number of arguments), you should make two
-            changes to <filename>sql_yacc.yy</filename>. One is a line
-            that indicates the preprocessor symbol that
-            <command>yacc</command> should define; this should be added
-            at the beginning of the file. The other is an
-            <quote>item</quote> to be added to the
-            <literal>simple_expr</literal> parsing rule that defines the
-            function parameters. You will need an item for each syntax
-            with which the function can be called. For an example that
-            shows how this this is done, check all occurrences of
-            <literal>ATAN</literal> in <filename>sql_yacc.yy</filename>.
+            You can register several names for the same function. For
+            example, see the lines for <literal>"LCASE"</literal> and
+            <literal>"LOWER"</literal>, which are aliases for
+            <function>Create_func_lcase</function>.
           </para>
         </listitem>
 


Modified: trunk/refman-6.0/extending-mysql.xml
===================================================================
--- trunk/refman-6.0/extending-mysql.xml	2008-01-10 15:30:30 UTC (rev 9547)
+++ trunk/refman-6.0/extending-mysql.xml	2008-01-10 15:30:41 UTC (rev 9548)
Changed blocks: 1, Lines Added: 44, Lines Deleted: 26; 3945 bytes

@@ -4410,40 +4410,58 @@
 
         <listitem>
           <para>
-            Add one line to <filename>lex.h</filename> that defines the
-            function name in the <literal>sql_functions[]</literal>
-            array.
+            Create a subclass for the function in
+            <filename>item_create.cc</filename>:
           </para>
+
+          <itemizedlist>
+
+            <listitem>
+              <para>
+                If the function takes a fixed number of arguments,
+                create a subclass of
+                <function>Create_func_arg0</function>,
+                <function>Create_func_arg1</function>,
+                <function>Create_func_arg2</function>, or
+                <function>Create_func_arg3</function>, respectively,
+                depending on whether the function takes zero, one, two,
+                or three arguments. For examples, see the subclasses for
+                <function>Create_func_uuid</function>,
+                <function>Create_func_abs</function>,
+                <function>Create_func_pow</function>, or
+                <function>Create_func_lpad</function>.
+              </para>
+            </listitem>
+
+            <listitem>
+              <para>
+                If the function takes a variable number of arguments,
+                create a subclass of
+                <function>Create_native_func</function>. For an example,
+                see <function>Create_func_concat</function>.
+              </para>
+            </listitem>
+
+          </itemizedlist>
         </listitem>
 
         <listitem>
           <para>
-            If the function prototype is simple (just takes zero, one,
-            two, or three arguments), add a line to the
-            <literal>sql_functions[]</literal> array in
-            <filename>lex.h</filename> that specifies
-            <literal>SYM(FUNC_ARG<replaceable>N</replaceable>)</literal>
-            as the second argument (where <replaceable>N</replaceable>
-            is the number of arguments the function takes). Also, add a
-            function in <filename>item_create.cc</filename> that creates
-            a function object. Look at <literal>"ABS"</literal> and
-            <literal>create_funcs_abs()</literal> for an example of
-            this.
+            To provide a name by which the function can be referred to
+            in SQL statements, register the name in
+            <filename>item_create.cc</filename> by adding a line to this
+            array:
           </para>
 
+<programlisting>
+static Native_func_registry func_array[]
+</programlisting>
+
           <para>
-            If the function prototype is not simple (for example, if it
-            takes a variable number of arguments), you should make two
-            changes to <filename>sql_yacc.yy</filename>. One is a line
-            that indicates the preprocessor symbol that
-            <command>yacc</command> should define; this should be added
-            at the beginning of the file. The other is an
-            <quote>item</quote> to be added to the
-            <literal>simple_expr</literal> parsing rule that defines the
-            function parameters. You will need an item for each syntax
-            with which the function can be called. For an example that
-            shows how this this is done, check all occurrences of
-            <literal>ATAN</literal> in <filename>sql_yacc.yy</filename>.
+            You can register several names for the same function. For
+            example, see the lines for <literal>"LCASE"</literal> and
+            <literal>"LOWER"</literal>, which are aliases for
+            <function>Create_func_lcase</function>.
           </para>
         </listitem>
 


Thread
svn commit - mysqldoc@docsrva: r9548 - in trunk: . refman-5.1 refman-6.0paul10 Jan