Author: paul
Date: 2007-02-14 16:42:16 +0100 (Wed, 14 Feb 2007)
New Revision: 4949
Log:
r16226@frost: paul | 2007-02-14 09:32:12 -0600
C API binary protocol: Add a couple more how-to-fetch examples.
- DECIMAL values are returned as strings. How to fetch as number.
- BIT values are returned as bitstrings. How to coerce to integer
for easier handling.
Modified:
trunk/refman-4.1/apis-c.xml
trunk/refman-5.0/apis-c.xml
trunk/refman-5.1/apis-c.xml
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 4767c598-dc10-0410-bea0-d01b485662eb:/mysqldoc-local/mysqldoc/trunk:19804
7d8d2c4e-af1d-0410-ab9f-b038ce55645b:/mysqldoc-local/mysqldoc:16183
b5ec3a16-e900-0410-9ad2-d183a3acac99:/mysqldoc-local/mysqldoc/trunk:14218
bf112a9c-6c03-0410-a055-ad865cd57414:/mysqldoc-local/mysqldoc/trunk:14562
+ 4767c598-dc10-0410-bea0-d01b485662eb:/mysqldoc-local/mysqldoc/trunk:19804
7d8d2c4e-af1d-0410-ab9f-b038ce55645b:/mysqldoc-local/mysqldoc:16226
b5ec3a16-e900-0410-9ad2-d183a3acac99:/mysqldoc-local/mysqldoc/trunk:14218
bf112a9c-6c03-0410-a055-ad865cd57414:/mysqldoc-local/mysqldoc/trunk:14562
Modified: trunk/refman-4.1/apis-c.xml
===================================================================
--- trunk/refman-4.1/apis-c.xml 2007-02-14 15:35:13 UTC (rev 4948)
+++ trunk/refman-4.1/apis-c.xml 2007-02-14 15:42:16 UTC (rev 4949)
Changed blocks: 2, Lines Added: 43, Lines Deleted: 3; 2674 bytes
@@ -8454,9 +8454,7 @@
SQL types of received values, the corresponding type code that
such values have in result set metadata, and the recommended C
language data types to bind to the <literal>MYSQL_BIND</literal>
- structure to receive the SQL values without conversion. Note that
- <literal>DECIMAL</literal> values are returned as strings, which
- is why the corresponding C type is <literal>char[]</literal>.
+ structure to receive the SQL values without conversion.
</para>
<informaltable>
@@ -8615,6 +8613,48 @@
</para>
</listitem>
+ <listitem>
+ <para>
+ <literal>DECIMAL</literal> values are returned as strings,
+ which is why the corresponding C type is
+ <literal>char[]</literal>. <literal>DECIMAL</literal> values
+ returned by the server correspond to the string representation
+ of the original server-side value. For example,
+ <literal>12.345</literal> is returned to the client as
+ <literal>'12.345'</literal>. If you specify
+ <literal>MYSQL_TYPE_NEWDECIMAL</literal> and bind a string
+ buffer to the <literal>MYSQL_BIND</literal> structure,
+ <literal>mysql_stmt_fetch()</literal> stores the value in the
+ buffer without conversion. If instead you specify a numeric
+ variable and type code, <literal>mysql_stmt_fetch()</literal>
+ converts the string-format <literal>DECIMAL</literal> value to
+ numeric form.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ For the <literal>MYSQL_TYPE_BIT</literal> type code,
+ <literal>BIT</literal> values are returned into a string
+ buffer (thus, the corresponding C type is
+ <literal>char[]</literal> here, too). The value represents a
+ bit string that requires interpretation on the client side. To
+ return the value as a type that is easier to deal with, you
+ can use a query of the following form that uses <literal>+
+ 0</literal> to cause the value to be cast to integer:
+ </para>
+
+<programlisting>
+SELECT bit_col + 0 FROM t
+</programlisting>
+
+ <para>
+ To retrieve the value, bind an integer variable large enough
+ to hold the value and specify the appropriate corresponding
+ integer type code.
+ </para>
+ </listitem>
+
</itemizedlist>
<para>
Modified: trunk/refman-5.0/apis-c.xml
===================================================================
--- trunk/refman-5.0/apis-c.xml 2007-02-14 15:35:13 UTC (rev 4948)
+++ trunk/refman-5.0/apis-c.xml 2007-02-14 15:42:16 UTC (rev 4949)
Changed blocks: 4, Lines Added: 48, Lines Deleted: 8; 3609 bytes
@@ -8570,9 +8570,7 @@
SQL types of received values, the corresponding type code that
such values have in result set metadata, and the recommended C
language data types to bind to the <literal>MYSQL_BIND</literal>
- structure to receive the SQL values without conversion. Note that
- <literal>DECIMAL</literal> values are returned as strings, which
- is why the corresponding C type is <literal>char[]</literal>.
+ structure to receive the SQL values without conversion.
</para>
<informaltable>
@@ -8587,11 +8585,6 @@
<entry><emphasis role="bold">Output Variable C Type</emphasis></entry>
</row>
<row>
- <entry><literal>BIT</literal></entry>
- <entry><literal>MYSQL_TYPE_BIT</literal></entry>
- <entry><literal>unsigned long long int</literal></entry>
- </row>
- <row>
<entry><literal>TINYINT</literal></entry>
<entry><literal>MYSQL_TYPE_TINY</literal></entry>
<entry><literal>signed char</literal></entry>
@@ -8686,6 +8679,11 @@
<entry><literal>MYSQL_TYPE_LONG_BLOB</literal></entry>
<entry><literal>char[]</literal></entry>
</row>
+ <row>
+ <entry><literal>BIT</literal></entry>
+ <entry><literal>MYSQL_TYPE_BIT</literal></entry>
+ <entry><literal>char[]</literal></entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
@@ -8741,6 +8739,48 @@
</para>
</listitem>
+ <listitem>
+ <para>
+ <literal>DECIMAL</literal> values are returned as strings,
+ which is why the corresponding C type is
+ <literal>char[]</literal>. <literal>DECIMAL</literal> values
+ returned by the server correspond to the string representation
+ of the original server-side value. For example,
+ <literal>12.345</literal> is returned to the client as
+ <literal>'12.345'</literal>. If you specify
+ <literal>MYSQL_TYPE_NEWDECIMAL</literal> and bind a string
+ buffer to the <literal>MYSQL_BIND</literal> structure,
+ <literal>mysql_stmt_fetch()</literal> stores the value in the
+ buffer without conversion. If instead you specify a numeric
+ variable and type code, <literal>mysql_stmt_fetch()</literal>
+ converts the string-format <literal>DECIMAL</literal> value to
+ numeric form.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ For the <literal>MYSQL_TYPE_BIT</literal> type code,
+ <literal>BIT</literal> values are returned into a string
+ buffer (thus, the corresponding C type is
+ <literal>char[]</literal> here, too). The value represents a
+ bit string that requires interpretation on the client side. To
+ return the value as a type that is easier to deal with, you
+ can use a query of the following form that uses <literal>+
+ 0</literal> to cause the value to be cast to integer:
+ </para>
+
+<programlisting>
+SELECT bit_col + 0 FROM t
+</programlisting>
+
+ <para>
+ To retrieve the value, bind an integer variable large enough
+ to hold the value and specify the appropriate corresponding
+ integer type code.
+ </para>
+ </listitem>
+
</itemizedlist>
<para>
Modified: trunk/refman-5.1/apis-c.xml
===================================================================
--- trunk/refman-5.1/apis-c.xml 2007-02-14 15:35:13 UTC (rev 4948)
+++ trunk/refman-5.1/apis-c.xml 2007-02-14 15:42:16 UTC (rev 4949)
Changed blocks: 4, Lines Added: 48, Lines Deleted: 8; 3609 bytes
@@ -8688,9 +8688,7 @@
SQL types of received values, the corresponding type code that
such values have in result set metadata, and the recommended C
language data types to bind to the <literal>MYSQL_BIND</literal>
- structure to receive the SQL values without conversion. Note that
- <literal>DECIMAL</literal> values are returned as strings, which
- is why the corresponding C type is <literal>char[]</literal>.
+ structure to receive the SQL values without conversion.
</para>
<informaltable>
@@ -8705,11 +8703,6 @@
<entry><emphasis role="bold">Output Variable C Type</emphasis></entry>
</row>
<row>
- <entry><literal>BIT</literal></entry>
- <entry><literal>MYSQL_TYPE_BIT</literal></entry>
- <entry><literal>unsigned long long int</literal></entry>
- </row>
- <row>
<entry><literal>TINYINT</literal></entry>
<entry><literal>MYSQL_TYPE_TINY</literal></entry>
<entry><literal>signed char</literal></entry>
@@ -8804,6 +8797,11 @@
<entry><literal>MYSQL_TYPE_LONG_BLOB</literal></entry>
<entry><literal>char[]</literal></entry>
</row>
+ <row>
+ <entry><literal>BIT</literal></entry>
+ <entry><literal>MYSQL_TYPE_BIT</literal></entry>
+ <entry><literal>char[]</literal></entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
@@ -8859,6 +8857,48 @@
</para>
</listitem>
+ <listitem>
+ <para>
+ <literal>DECIMAL</literal> values are returned as strings,
+ which is why the corresponding C type is
+ <literal>char[]</literal>. <literal>DECIMAL</literal> values
+ returned by the server correspond to the string representation
+ of the original server-side value. For example,
+ <literal>12.345</literal> is returned to the client as
+ <literal>'12.345'</literal>. If you specify
+ <literal>MYSQL_TYPE_NEWDECIMAL</literal> and bind a string
+ buffer to the <literal>MYSQL_BIND</literal> structure,
+ <literal>mysql_stmt_fetch()</literal> stores the value in the
+ buffer without conversion. If instead you specify a numeric
+ variable and type code, <literal>mysql_stmt_fetch()</literal>
+ converts the string-format <literal>DECIMAL</literal> value to
+ numeric form.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ For the <literal>MYSQL_TYPE_BIT</literal> type code,
+ <literal>BIT</literal> values are returned into a string
+ buffer (thus, the corresponding C type is
+ <literal>char[]</literal> here, too). The value represents a
+ bit string that requires interpretation on the client side. To
+ return the value as a type that is easier to deal with, you
+ can use a query of the following form that uses <literal>+
+ 0</literal> to cause the value to be cast to integer:
+ </para>
+
+<programlisting>
+SELECT bit_col + 0 FROM t
+</programlisting>
+
+ <para>
+ To retrieve the value, bind an integer variable large enough
+ to hold the value and specify the appropriate corresponding
+ integer type code.
+ </para>
+ </listitem>
+
</itemizedlist>
<para>
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r4949 - in trunk: . refman-4.1 refman-5.0 refman-5.1 | paul | 14 Feb |