Changeset 7943 in project


Ignore:
Timestamp:
01/26/08 20:49:29 (12 years ago)
Author:
Kon Lovett
Message:

Chgd fetch row body to handle binary blob/string.

Location:
release/3/mysql
Files:
2 deleted
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • release/3/mysql/tags/1.31/mysql-tests-body.scm

    r7930 r7943  
    4949(newline)
    5050(print "The rows can be enumerated one-per-line, like this:")
    51 (mysql-foreach-row *conn* (lambda (row row-idx)
    52   (display (conc row-idx ": " (row "Database") "\n"))))
     51(mysql-row-for-each
     52  *conn*
     53  (lambda (row row-idx)
     54    (display (conc row-idx ": " (row "Database") "\n"))))
    5355
    5456(newline)
    5557(display "Or they can just be comma-separated, like so:")
    56 (mysql-foreach-row *conn* (lambda (row row-idx)
    57   (display (conc (row "Database")
    58                  (if (< row-idx (mysql-num-rows *conn*)) ", " "\n")))))
     58(mysql-row-for-each
     59  *conn*
     60  (lambda (row row-idx)
     61    (display (conc (row "Database")
     62                   (if (< row-idx (mysql-num-rows *conn*)) ", " "\n")))))
    5963
    6064(mysql-print-and-query *conn* "DROP DATABASE IF EXISTS mysql_egg_test")
     
    8084(newline)
    8185(mysql-print-and-query *conn* "SELECT testboolnn, testbool FROM test1")
    82 (mysql-foreach-row *conn* (lambda (row idx)
     86(mysql-row-for-each
     87  *conn*
     88  (lambda (row idx)
     89    (print "Row " idx " lengths: " (mysql-fetch-lengths *conn*))))
     90
     91(newline)
     92(mysql-print-and-query *conn* "SELECT testboolnn, testbool FROM test1")
     93(mysql-row-for-each *conn* (lambda (row idx)
    8394  (display (conc "row " idx ": testboolnn=" (row "testboolnn")
    8495                 ", testbool="
     
    94105       (map (lambda (f) (cons f (row f))) names)))) )
    95106
    96 (newline)
    97 (mysql-print-and-query *conn* "SELECT testboolnn, testbool FROM test1")
    98 (mysql-row-for-each
    99   *conn*
    100   (lambda (row idx)
    101     (print "Row " idx " lengths: " (mysql-fetch-lengths *conn*))))
    102 
    103107;; Finished
    104108(newline)
  • release/3/mysql/tags/1.31/mysql.html

    r7902 r7943  
    158158<h3>Version</h3>
    159159<ul>
    160 <li>1.3 Additional functions [Kon Lovett].</li>
    161 <li>1.2 Fix for ticket #297 [Mario Domenech Goulart].</li>
     160<li>1.31 Additional functions &amp; special handling of binary column. [Kon Lovett]</li>
     161<li>1.3 Additional functions. [Kon Lovett]</li>
     162<li>1.2 Fix for ticket #297. [Mario Domenech Goulart]</li>
    162163<li>1.1 Cross-platform compilation fixes, et al.</li>
    163164<li>1.0 Initial release</li></ul></div>
     
    172173<div class="section">
    173174<h3>Documentation</h3>
    174 <p>The MySQL egg provides (most of) the functions offered by the MySQL C API (the <tt>foreign-mysql-*</tt> functions). It also maps those to a set of slightly more convenient Scheme functions (the <tt>mysql-*</tt> functions). Finally, a few extra functions are provided for easy of use.</p>
     175<p>The MySQL egg provides (most of) the functions offered by the MySQL C API (the <tt>foreign-mysql-*</tt> functions). It also provides a set of slightly more convenient Scheme functions (the <tt>mysql-*</tt> functions). Finally, a few extra functions are provided for easy of use.</p>
    175176<p>Only the most often used MySQL functions are described in this document. If you really want to see the full listing, consult the <a href="mysql-mole.html">mole documentation</a>.</p>
    176177<p>Please send bug reports and suggestions to <a href="mailto:toby@butzon.com">toby@butzon.com</a>.</p>
    177178<div class="subsection">
     179<h4>Exceptions</h4>
     180<p>Conditions of the kind <code>(exn mysql)</code> are signaled for error situations.<table class="symbol-table">Properties
     181<tr>
     182<td class="symbol">location</td>
     183<td>Where the error occured - usually a procedure name.</td></tr>
     184<tr>
     185<td class="symbol">arguments</td>
     186<td>Values that contributed to the error.</td></tr>
     187<tr>
     188<td class="symbol">message</td>
     189<td>Error message.</td></tr></table></p></div>
     190<div class="subsection">
    178191<h4>Connections</h4>
    179192<dt class="definition"><strong>procedure:</strong> (mysql-connect [KEYWORDS])</dt>
    180193<dd>
    181194<p>Connect to a MySQL server.</p>
    182 <p>Returns a MySQL connection object suitable for passing to the other MySQL functions. This object is referred to as <tt>DB</tt> when passed by all the other MySQL functions. Returns <tt>#f</tt> when the connection fails.</p>
     195<p>Returns a MySQL connection object suitable for passing to the other MySQL functions. This object is referred to as <tt>CONN</tt> when passed by all the other MySQL functions. Signals an exception when the connection fails.</p>
    183196<p>Any number of the following <tt>KEYWORDS</tt> may be included:
    184197<ul>
    185 <li>host</li>
    186 <li>user</li>
    187 <li>passwd</li>
    188 <li>db</li>
    189 <li>port</li>
    190 <li>unix-socket</li>
    191 <li>client-flag</li></ul></p>
     198<li><tt>host</tt></li>
     199<li><tt>user</tt></li>
     200<li><tt>passwd</tt></li>
     201<li><tt>db</tt></li>
     202<li><tt>port</tt></li>
     203<li><tt>unix-socket</tt></li>
     204<li><tt>client-flag</tt></li>
     205<li><tt>ssl</tt> - A <code>mysql-ssl</code> record object.</li>
     206<li><tt>options</tt> - An association list of <code>(&lt;mysql-option&gt; . &lt;object&gt;)</code>.</li></ul></p>
    192207<p>Note that default values are available for all of these arguments. (Consult the <a href="http://dev.mysql.com/doc/mysql/en/c.html">MySQL C API</a> for details on how these defaults are determined.)</p></dd>
    193 <dt class="definition"><strong>procedure:</strong> (mysql-close DB)</dt>
    194 <dd>
    195 <p>Closes the connection to <tt>DB</tt>. This frees any remaining MySQL resources from memory, but invalidates the MySQL connection object (<tt>DB</tt>) so that it may no longer be used.</p></dd></div>
    196 <div class="subsection">
    197 <h4>Basic Operations</h4>
    198 <dt class="definition"><strong>procedure:</strong> (mysql-query DB SQL-STRING)</dt>
    199 <dd>
    200 <p>Executes <tt>SQL-STRING</tt> on the MySQL server and stores the result in memory. Generates an error (calls <tt>error</tt>) if the query fails.</p></dd>
    201 <dt class="definition"><strong>procedure:</strong> (mysql-fetch-row DB)</dt>
     208<dt class="definition"><strong>procedure:</strong> (mysql-connection? OBJECT)</dt>
     209<dd>
     210<p>Is the <tt>OBJECT</tt> a <code>mysql-connection</code>? Referred to as a <tt>CONN</tt>.</p></dd>
     211<dt class="definition"><strong>procedure:</strong> (mysql-close CONN)</dt>
     212<dd>
     213<p>Closes the connection to <tt>CONN</tt>. This frees any remaining MySQL resources from memory, but invalidates the MySQL connection object (<tt>CONN</tt>) so that it may no longer be used.</p></dd>
     214<div class="subsubsection">
     215<h5>Connect Parameter Constructors</h5>
     216<dt class="definition"><strong>procedure:</strong> (make-mysql-options OPTION-FLAG OPTION-VALUE ...)</dt>
     217<dd>
     218<p>Returns an object suitable as the <tt>options</tt> parameter for <code>mysql-connect</code>.</p>
     219<p>The type of the <tt>OPTION-VALUE</tt> is dependent on the <tt>OPTION-FLAG</tt>.</p></dd>
     220<dt class="definition"><strong>procedure:</strong> (make-mysql-ssl [KEYWORD ...])</dt>
     221<dd>
     222<p>Returns a <code>mysql-ssl</code> record.</p>
     223<p>Any number of the following <tt>KEYWORD ...</tt> may be included:
     224<ul>
     225<li><tt>key</tt> - pathname of key file.</li>
     226<li><tt>certificate</tt> - pathname of certificate file.</li>
     227<li><tt>certificate-authority</tt> - pathname of certificate authority file.</li>
     228<li><tt>trusted-certificates</tt> - pathname of trusted certificates directory.</li>
     229<li><tt>ciphers</tt> - See <a href="http://www.openssl.org/docs/apps/ciphers.html">OpenSSL Ciphers Man Page</a></li></ul></p></dd>
     230<dt class="definition"><strong>procedure:</strong> (mysql-ssl? OBJECT)</dt>
     231<dd>
     232<p>Is the <tt>OBJECT</tt> an <code>mysql-ssl</code> record?</p></dd>
     233<dt class="definition"><strong>procedure:</strong> (mysql-ssl-key-pathname MYSQL-SSL)</dt>
     234<dd>
     235<p>Returns a <code>string</code>.</p></dd>
     236<dt class="definition"><strong>procedure:</strong> (mysql-ssl-certificate-pathname MYSQL-SSL)</dt>
     237<dd>
     238<p>Returns a <code>string</code>.</p></dd>
     239<dt class="definition"><strong>procedure:</strong> (mysql-ssl-certificate-authority-pathname MYSQL-SSL)</dt>
     240<dd>
     241<p>Returns a <code>string</code>.</p></dd>
     242<dt class="definition"><strong>procedure:</strong> (mysql-ssl-trusted-certificates-pathname MYSQL-SSL)</dt>
     243<dd>
     244<p>Returns a <code>string</code>.</p></dd>
     245<dt class="definition"><strong>procedure:</strong> (mysql-ssl-ciphers MYSQL-SSL)</dt>
     246<dd>
     247<p>Returns a <code>string</code>.</p></dd></div></div>
     248<div class="subsection">
     249<h4>Basic Query Operations</h4>
     250<dt class="definition"><strong>procedure:</strong> (mysql-query CONN SQL-STRING)</dt>
     251<dd>
     252<p>Executes <tt>SQL-STRING</tt> on the MySQL server and stores the result in memory. Signals an exception if the query fails.</p></dd>
     253<dt class="definition"><strong>procedure:</strong> (mysql-fetch-row CONN)</dt>
    202254<dd>
    203255<p>Fetches a row from the result set returned by the most recent call to <tt>mysql-query</tt>. If the last query failed, or if there are no more rows left in the result set, returns <tt>#f</tt>; otherwise returns a row object.</p><a name='rowobj'></a>
    204256<p>A row object is defined as a function that takes a single argument. If the argument is a number, the function returns the value of the field for which that number is the index, or <tt>#f</tt> if the index is out of range. Otherwise, the argument must be a symbol or string, in which case the function returns the value of the field for which that string (or symbol converted into a string) is the field/column name. If no such field exists, returns <tt>#f</tt>.</p></dd>
    205 <dt class="definition"><strong>procedure:</strong> (mysql-rewind DB)</dt>
     257<dt class="definition"><strong>procedure:</strong> (mysql-field-count CONN)</dt>
     258<dd>
     259<p>Returns the number of columns for the most recent query.</p></dd>
     260<dt class="definition"><strong>procedure:</strong> (mysql-fetch-lengths CONN)</dt>
     261<dd>
     262<p>Returns a <code>u32vector</code> of the lengths of the columns of the current row.</p></dd>
     263<dt class="definition"><strong>procedure:</strong> (mysql-rewind CONN)</dt>
    206264<dd>
    207265<p>Rewinds the result set; that is, resets the pointer used by <tt>mysql-fetch-row</tt> so that the next call to it will return the first row of the result set. If there is no current result set, does nothing.</p></dd>
    208 <dt class="definition"><strong>procedure:</strong> (mysql-num-rows DB)</dt>
    209 <dd>
    210 <p>Returns the number of rows in the current result set. If no result set exists, returns <tt>#f</tt>.</p></dd></div>
     266<dt class="definition"><strong>procedure:</strong> (mysql-num-rows CONN)</dt>
     267<dd>
     268<p>Returns the number of rows in the current result set. If no result set exists, returns <tt>#f</tt>.</p></dd>
     269<dt class="definition"><strong>procedure:</strong> (mysql-num-fields CONN)</dt>
     270<dd>
     271<p>Returns the number of fields in the current result set. If no result set exists, returns <tt>#f</tt>.</p></dd>
     272<dt class="definition"><strong>procedure:</strong> (mysql-affected-rows CONN)</dt>
     273<dd>
     274<p>Returns the number of rows affected by the current query.</p></dd></div>
    211275<div class="subsection">
    212276<h4>Row Mapping</h4>
    213 <dt class="definition"><strong>procedure:</strong> (mysql-row-fold DB PROC INIT)</dt>
     277<dt class="definition"><strong>procedure:</strong> (mysql-row-fold CONN PROC INIT)</dt>
    214278<dd>
    215279<p>Iterates over the entire result set (regardless of any rows that may have already been returned by <tt>mysql-fetch-row</tt>), calling <tt>PROC</tt> on each row.</p>
    216280<p>Returns the final accumulated value.</p>
    217 <p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows DB)</tt>, and the current accumulated value (initially <tt>INIT</tt>).</p>
     281<p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows CONN)</tt>, and the current accumulated value (initially <tt>INIT</tt>).</p>
    218282<p><tt>PROC</tt> must return a value.</p></dd>
    219 <dt class="definition"><strong>procedure:</strong> (mysql-row-for-each DB PROC)</dt>
     283<dt class="definition"><strong>procedure:</strong> (mysql-row-for-each CONN PROC)</dt>
    220284<dd>
    221285<p>Iterates over the entire result set (regardless of any rows that may have already been returned by <tt>mysql-fetch-row</tt>), calling <tt>PROC</tt> on each row.</p>
    222 <p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, and the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows DB)</tt>.</p></dd>
    223 <dt class="definition"><strong>procedure:</strong> (mysql-row-map DB PROC)</dt>
     286<p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, and the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows CONN)</tt>.</p></dd>
     287<dt class="definition"><strong>procedure:</strong> (mysql-row-map CONN PROC)</dt>
    224288<dd>
    225289<p>Iterates over the entire result set (regardless of any rows that may have already been returned by <tt>mysql-fetch-row</tt>), calling <tt>PROC</tt> on each row.</p>
    226290<p>Returns the list of results of the <tt>PROC</tt> invocations.</p>
    227 <p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, and the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows DB)</tt>.</p>
     291<p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, and the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows CONN)</tt>.</p>
    228292<p><tt>PROC</tt> must return a value.</p></dd>
    229 <dt class="definition"><strong>procedure:</strong> (mysql-query-fold DB QUERY PROC INIT)</dt>
     293<dt class="definition"><strong>procedure:</strong> (mysql-query-fold CONN QUERY PROC INIT)</dt>
    230294<dd>
    231295<p>Combines <tt>mysql-query</tt> and <tt>mysql-row-fold</tt>.</p></dd>
    232 <dt class="definition"><strong>procedure:</strong> (mysql-query-for-each DB QUERY PROC)</dt>
     296<dt class="definition"><strong>procedure:</strong> (mysql-query-for-each CONN QUERY PROC)</dt>
    233297<dd>
    234298<p>Combines <tt>mysql-query</tt> and <tt>mysql-row-for-each</tt>.</p></dd>
    235 <dt class="definition"><strong>procedure:</strong> (mysql-query-map DB QUERY PROC)</dt>
     299<dt class="definition"><strong>procedure:</strong> (mysql-query-map CONN QUERY PROC)</dt>
    236300<dd>
    237301<p>Combines <tt>mysql-query</tt> and <tt>mysql-row-map</tt>.</p></dd>
    238 <dt class="definition"><strong>procedure:</strong> (mysql-foreach-row DB BODY)</dt>
     302<dt class="definition"><strong>procedure:</strong> (mysql-foreach-row CONN BODY)</dt>
    239303<dd>
    240304<p>Synonym for <code>mysql-row-for-each</code>.</p></dd>
    241 <dt class="definition"><strong>procedure:</strong> (mysql-query-foreach DB QUERY BODY)</dt>
     305<dt class="definition"><strong>procedure:</strong> (mysql-query-foreach CONN QUERY BODY)</dt>
    242306<dd>
    243307<p>Synonym for <code>mysql-query-for-each</code>.</p></dd></div>
    244308<div class="subsection">
    245 <h4>Field Access</h4>
     309<h4>MYSQL_FIELD Access</h4>
     310<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field CONN)</dt>
     311<dd>
     312<p>Returns a <code>mysql-field-ptr</code> to the next field, or <code>#f</code>.</p></dd>
     313<dt class="definition"><strong>procedure:</strong> (mysql-fetch-fields CONN)</dt>
     314<dd>
     315<p>Returns a <code>mysql-field-ptr</code> to the first field, or <code>#f</code>.</p></dd>
     316<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-direct CONN MYSQL-FIELD-NUMBER)</dt>
     317<dd>
     318<p>Returns a <code>mysql-field-ptr</code> to a specific field, or <code>#f</code>.</p></dd>
     319<dt class="definition"><strong>procedure:</strong> (mysql-field-slots MYSQL-FIELD-POINTER MYSQL-FIELD-GETTER ...)</dt>
     320<dd>
     321<p>Returns a list of MYSQL_FIELD entry values, from each <tt>MYSQL-FIELD-GETTER</tt>.</p>
     322<p><tt>MYSQL-FIELD-POINTER</tt> is a pointer to a MYSQL_FIELD, or <code>#f</code>. <tt>MYSQL-FIELD-GETTER</tt> is a <code>mysql-field-*</code> reference function.</p></dd>
     323<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-slot-direct CONN FIELD-NUMBER MYSQL-FIELD-GETTER)</dt>
     324<dd>
     325<p>Returns a field slot value. Combines <code>mysql-fetch-field-direct</code> and <code>mysql-field-slots</code>.</p></dd>
     326<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-slot CONN MYSQL-FIELD-GETTER)</dt>
     327<dd>
     328<p>Returns a field slot value. Combines <code>mysql-fetch-field</code> and <code>mysql-field-slots</code>.</p></dd>
     329<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-slots-direct CONN FIELD-NUMBER MYSQL-FIELD-GETTER ...)</dt>
     330<dd>
     331<p>Returns a list of field slot values. Combines <code>mysql-fetch-field-direct</code> and <code>mysql-field-slots</code>.</p></dd>
     332<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-slots CONN MYSQL-FIELD-GETTER ...)</dt>
     333<dd>
     334<p>Returns a list of field slot values. Combines <code>mysql-fetch-field</code> and <code>mysql-field-slots</code>.</p></dd>
    246335<div class="subsubsection">
    247 <h5>Field Set Access</h5>
    248 <dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-items DB MYSQL-FIELD-GETTER ...)</dt>
    249 <dd>
    250 <p>Returns a list of lists of MYSQL_FIELD entry values, a list for each <tt>MYSQL-FIELD-GETTER</tt>.</p>
    251 <p><tt>MYSQL-FIELD-GETTER</tt> is a <code>mysql-field-*</code> reference function.</p></dd>
    252 <dt class="definition"><strong>procedure:</strong> (*mysql-fetch-field-item MYSQL-FIELD-POINTER FIELD-COUNT MYSQL-FIELD-GETTER)</dt>
    253 <dd>
    254 <p>Returns a <tt>FIELD-COUNT</tt> length list of MYSQL_FIELD entry (object).</p>
    255 <p><tt>MYSQL-FIELD-POINTER</tt> is a pointer to a vector of MYSQL_FIELD. <tt>FIELD-COUNT</tt> is the number of entries in the vector. <tt>MYSQL-FIELD-GETTER</tt> is a <code>mysql-field-*</code> reference function.</p></dd></div>
    256 <div class="subsubsection">
    257 <h5>Field Entry Access</h5>
     336<h5>Slot Getters</h5>
    258337<dt class="definition"><strong>procedure:</strong> (mysql-field-org-name MYSQL-FIELD-POINTER)</dt>
    259338<dd>
     
    270349<dt class="definition"><strong>procedure:</strong> (mysql-field-db MYSQL-FIELD-POINTER)</dt>
    271350<dd>
    272 <p>Returns <code>pointer -&gt; ?</code>.</p></dd>
     351<p>Returns <code>string</code>.</p></dd>
    273352<dt class="definition"><strong>procedure:</strong> (mysql-field-catalog MYSQL-FIELD-POINTER)</dt>
    274353<dd>
    275 <p>Returns <code>pointer -&gt; ?</code>.</p></dd>
     354<p>Returns <code>string</code>.</p></dd>
    276355<dt class="definition"><strong>procedure:</strong> (mysql-field-def MYSQL-FIELD-POINTER)</dt>
    277356<dd>
    278 <p>Returns <code>pointer -&gt; ?</code>.</p></dd>
     357<p>Returns <code>string</code>.</p></dd>
    279358<dt class="definition"><strong>procedure:</strong> (mysql-field-table MYSQL-FIELD-POINTER)</dt>
    280359<dd>
    281 <p>Returns <code>pointer -&gt; ?</code>.</p></dd>
     360<p>Returns <code>string</code>.</p></dd>
    282361<dt class="definition"><strong>procedure:</strong> (mysql-field-type MYSQL-FIELD-POINTER)</dt>
    283362<dd>
     
    320399<p>Returns <code>unsigned-integer</code>.</p></dd></div></div>
    321400<div class="subsection">
    322 <h4>Enumeration Values</h4><table class="symbol-table">enum enum_mysql_set_option
     401<h4>Field Flag Testing</h4>
     402<dt class="definition"><strong>procedure:</strong> (mysql-field-flags-on? MYSQL-FIELD-POINTER MYSQL-FIELD-FLAG ...)</dt>
     403<dd>
     404<p>Does the field, <tt>MYSQL-FIELD-POINTER</tt>, have all of the <tt>MYSQL-FIELD-FLAG ...</tt> set?</p></dd>
     405<dt class="definition"><strong>procedure:</strong> (mysql-field-flags-off? MYSQL-FIELD-POINTER MYSQL-FIELD-FLAG ...)</dt>
     406<dd>
     407<p>Does the field, <tt>MYSQL-FIELD-POINTER</tt>, have all of the <tt>MYSQL-FIELD-FLAG ...</tt> not set?</p></dd>
     408<dt class="definition"><strong>procedure:</strong> (mysql-field-primary-key? MYSQL-FIELD-POINTER)</dt>
     409<dd>
     410<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, a primary key?</p></dd>
     411<dt class="definition"><strong>procedure:</strong> (mysql-field-not-null? MYSQL-FIELD-POINTER)</dt>
     412<dd>
     413<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, not null?</p></dd>
     414<dt class="definition"><strong>procedure:</strong> (mysql-field-binary? MYSQL-FIELD-POINTER)</dt>
     415<dd>
     416<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, binary?</p></dd>
     417<dt class="definition"><strong>procedure:</strong> (mysql-field-numeric? MYSQL-FIELD-POINTER)</dt>
     418<dd>
     419<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, numeric?</p></dd></div>
     420<div class="subsection">
     421<h4>Field Type Testing</h4>
     422<dt class="definition"><strong>procedure:</strong> (mysql-field-type-any? MYSQL-FIELD-POINTER MYSQL-TYPE ...)</dt>
     423<dd>
     424<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type any of <tt>MYSQL-TYPE ...</tt>?</p></dd>
     425<dt class="definition"><strong>procedure:</strong> (mysql-field-type=? MYSQL-FIELD-POINTER MYSQL-TYPE)</dt>
     426<dd>
     427<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, <tt>MYSQL-TYPE</tt>?</p></dd>
     428<dt class="definition"><strong>procedure:</strong> (mysql-field-type-clock? MYSQL-FIELD-POINTER)</dt>
     429<dd>
     430<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type time or date related?</p></dd>
     431<dt class="definition"><strong>procedure:</strong> (mysql-field-type-number? MYSQL-FIELD-POINTER)</dt>
     432<dd>
     433<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type a number?</p></dd>
     434<dt class="definition"><strong>procedure:</strong> (mysql-field-type-blob? MYSQL-FIELD-POINTER)</dt>
     435<dd>
     436<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type some kind of blob?</p></dd>
     437<dt class="definition"><strong>procedure:</strong> (mysql-field-type-string? MYSQL-FIELD-POINTER)</dt>
     438<dd>
     439<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type some kind of string?</p></dd>
     440<dt class="definition"><strong>procedure:</strong> (mysql-field-type-magnitude? MYSQL-FIELD-POINTER)</dt>
     441<dd>
     442<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type some kind of number?</p></dd>
     443<dt class="definition"><strong>procedure:</strong> (mysql-field-type-binary? MYSQL-FIELD-POINTER)</dt>
     444<dd>
     445<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type some kind of binary string or blob?</p></dd>
     446<dt class="definition"><strong>procedure:</strong> (mysql-field-type-text? MYSQL-FIELD-POINTER)</dt>
     447<dd>
     448<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type some kind of non-binary string or blob?</p></dd></div>
     449<div class="subsection">
     450<h4>Character Set Access</h4>
     451<dt class="definition"><strong>procedure:</strong> (mysql-set-character-set CONN CHARACTER-SET-NAME)</dt>
     452<dd>
     453<p>Sets the current character set.</p></dd>
     454<dt class="definition"><strong>procedure:</strong> (mysql-character-set-name CONN)</dt>
     455<dd>
     456<p>Returns a <tt>string</tt>.</p></dd>
     457<dt class="definition"><strong>procedure:</strong> (mysql-get-character-set-info CONN)</dt>
     458<dd>
     459<p>Returns a <tt>MY-CHARSET-INFO-POINTER</tt>.</p></dd>
     460<div class="subsubsection">
     461<h5>Slot Getters</h5>
     462<dt class="definition"><strong>procedure:</strong> (my-charset-info-name MY-CHARSET-INFO-POINTER)</dt>
     463<dd>
     464<p>Return a <code>string</code>.</p></dd>
     465<dt class="definition"><strong>procedure:</strong> (my-charset-info-csname MY-CHARSET-INFO-POINTER)</dt>
     466<dd>
     467<p>Return a <code>string</code>.</p></dd>
     468<dt class="definition"><strong>procedure:</strong> (my-charset-info-comment MY-CHARSET-INFO-POINTER)</dt>
     469<dd>
     470<p>Return a <code>string</code>.</p></dd>
     471<dt class="definition"><strong>procedure:</strong> (my-charset-info-dir MY-CHARSET-INFO-POINTER)</dt>
     472<dd>
     473<p>Return a <code>string</code>.</p></dd>
     474<dt class="definition"><strong>procedure:</strong> (my-charset-info-mbminlen MY-CHARSET-INFO-POINTER)</dt>
     475<dd>
     476<p>Return a <code>number</code>.</p></dd>
     477<dt class="definition"><strong>procedure:</strong> (my-charset-info-mbmaxlen MY-CHARSET-INFO-POINTER)</dt>
     478<dd>
     479<p>Return a <code>number</code>.</p></dd></div></div>
     480<div class="subsection">
     481<h4>Miscellaneous Procedures</h4>
     482<dt class="definition"><strong>procedure:</strong> (mysql-change-user CONN [KEYWORD ...])</dt>
     483<dd>
     484<p>Changes the user identity.</p>
     485<p>Any number of the following <tt>KEYWORD ...</tt> may be included:
     486<ul>
     487<li><tt>user</tt></li>
     488<li><tt>passwd</tt></li>
     489<li><tt>db</tt></li></ul></p></dd>
     490<dt class="definition"><strong>procedure:</strong> (mysql-debug DEBUG)</dt>
     491<dd>
     492<p>.</p></dd>
     493<dt class="definition"><strong>procedure:</strong> (mysql-dump-debug-info CONN)</dt>
     494<dd>
     495<p>.</p></dd>
     496<dt class="definition"><strong>procedure:</strong> (mysql-errno CONN)</dt>
     497<dd>
     498<p>.</p></dd>
     499<dt class="definition"><strong>procedure:</strong> (mysql-error CONN)</dt>
     500<dd>
     501<p>Returns a string describing the last mysql error, or #f if no error has occurred.</p></dd>
     502<dt class="definition"><strong>procedure:</strong> (mysql-escape-string CONN SQL)</dt>
     503<dd>
     504<p>Returns an escape encoded form of the <tt>SQL</tt> string.</p></dd>
     505<dt class="definition"><strong>procedure:</strong> (mysql-free-result CONN)</dt>
     506<dd>
     507<p>.</p></dd>
     508<dt class="definition"><strong>procedure:</strong> (mysql-get-client-info)</dt>
     509<dd>
     510<p>.</p></dd>
     511<dt class="definition"><strong>procedure:</strong> (mysql-get-client-version)</dt>
     512<dd>
     513<p>.</p></dd>
     514<dt class="definition"><strong>procedure:</strong> (mysql-get-host-info CONN)</dt>
     515<dd>
     516<p>.</p></dd>
     517<dt class="definition"><strong>procedure:</strong> (mysql-get-proto-info CONN)</dt>
     518<dd>
     519<p>.</p></dd>
     520<dt class="definition"><strong>procedure:</strong> (mysql-get-server-info CONN)</dt>
     521<dd>
     522<p>.</p></dd>
     523<dt class="definition"><strong>procedure:</strong> (mysql-get-server-version CONN)</dt>
     524<dd>
     525<p>.</p></dd>
     526<dt class="definition"><strong>procedure:</strong> (mysql-info CONN)</dt>
     527<dd>
     528<p>.</p></dd>
     529<dt class="definition"><strong>procedure:</strong> (mysql-insert-id CONN)</dt>
     530<dd>
     531<p>.</p></dd>
     532<dt class="definition"><strong>procedure:</strong> (mysql-kill CONN PID)</dt>
     533<dd>
     534<p>.</p></dd>
     535<dt class="definition"><strong>procedure:</strong> (mysql-list-dbs CONN LIKE)</dt>
     536<dd>
     537<p>.</p></dd>
     538<dt class="definition"><strong>procedure:</strong> (mysql-list-fields CONN TABLE WILD)</dt>
     539<dd>
     540<p>.</p></dd>
     541<dt class="definition"><strong>procedure:</strong> (mysql-list-processes CONN)</dt>
     542<dd>
     543<p>.</p></dd>
     544<dt class="definition"><strong>procedure:</strong> (mysql-list-tables CONN WILD)</dt>
     545<dd>
     546<p>.</p></dd>
     547<dt class="definition"><strong>procedure:</strong> (mysql-num-fields CONN)</dt>
     548<dd>
     549<p>.</p></dd>
     550<dt class="definition"><strong>procedure:</strong> (mysql-num-rows CONN)</dt>
     551<dd>
     552<p>.</p></dd>
     553<dt class="definition"><strong>procedure:</strong> (mysql-ping CONN)</dt>
     554<dd>
     555<p>.</p></dd>
     556<dt class="definition"><strong>procedure:</strong> (mysql-select-db CONN DB)</dt>
     557<dd>
     558<p>Returns <code>#t</code> if the select was successful, signals exception otherwise.</p></dd>
     559<dt class="definition"><strong>procedure:</strong> (mysql-stat CONN)</dt>
     560<dd>
     561<p>.</p></dd>
     562<dt class="definition"><strong>procedure:</strong> (mysql-store-result CONN)</dt>
     563<dd>
     564<p>.</p></dd>
     565<dt class="definition"><strong>procedure:</strong> (mysql-thread-id CONN)</dt>
     566<dd>
     567<p>.</p></dd></div>
     568<div class="subsection">
     569<h4>Enumerations &amp; Flags</h4>
     570<div class="subsubsection">
     571<h5>Client Flags</h5>
     572<p><table class="symbol-table">Symbolic Value
     573<tr>
     574<td class="symbol">client-compress</td>
     575<td>CLIENT_COMPRESS</td></tr>
     576<tr>
     577<td class="symbol">client-found-rows</td>
     578<td>CLIENT_FOUND_ROWS</td></tr>
     579<tr>
     580<td class="symbol">client-ignore-sigpipe</td>
     581<td>CLIENT_IGNORE_SIGPIPE</td></tr>
     582<tr>
     583<td class="symbol">client-ignore-space</td>
     584<td>CLIENT_IGNORE_SPACE</td></tr>
     585<tr>
     586<td class="symbol">client-interactive</td>
     587<td>CLIENT_INTERACTIVE</td></tr>
     588<tr>
     589<td class="symbol">client-local-files</td>
     590<td>CLIENT_LOCAL_FILES</td></tr>
     591<tr>
     592<td class="symbol">client-multi-results</td>
     593<td>CLIENT_MULTI_RESULTS</td></tr>
     594<tr>
     595<td class="symbol">client-multi-statements</td>
     596<td>CLIENT_MULTI_STATEMENTS</td></tr>
     597<tr>
     598<td class="symbol">client-no-schema</td>
     599<td>CLIENT_NO_SCHEMA</td></tr>
     600<tr>
     601<td class="symbol">client-odbc</td>
     602<td>CLIENT_ODBC</td></tr>
     603<tr>
     604<td class="symbol">client-ssl</td>
     605<td>CLIENT_SSL</td></tr></table></p>
     606<dt class="definition"><strong>procedure:</strong> (mysql-client-flags-value SYMBOL ...)</dt>
     607<dd>
     608<p>Returns the or'ed value of the <tt>SYMBOL ...</tt> values.</p></dd>
     609<dt class="definition"><strong>procedure:</strong> (mysql-client-flags-symbol NUMBER)</dt>
     610<dd>
     611<p>Returns the symbol for the <tt>NUMBER</tt>.</p></dd></div>
     612<div class="subsubsection">
     613<h5>enum enum_mysql_set_option</h5>
     614<p><table class="symbol-table">Symbolic Value
    323615<tr>
    324616<td class="symbol">mysql-option-multi-statements-on</td>
    325 <td></td></tr>
     617<td>MYSQL_OPTION_MULTI_STATEMENTS_ON</td></tr>
    326618<tr>
    327619<td class="symbol">mysql-option-multi-statements-off</td>
    328 <td></td></tr></table><table class="symbol-table">enum mysql_option
     620<td>MYSQL_OPTION_MULTI_STATEMENTS_OFF</td></tr></table></p>
     621<dt class="definition"><strong>procedure:</strong> (mysql-server-option-value SYMBOL ...)</dt>
     622<dd>
     623<p>Returns the or'ed value of the <tt>SYMBOL ...</tt> values.</p></dd>
     624<dt class="definition"><strong>procedure:</strong> (mysql-server-option-symbol NUMBER)</dt>
     625<dd>
     626<p>Returns the symbol for the <tt>NUMBER</tt>.</p></dd></div>
     627<div class="subsubsection">
     628<h5>enum mysql_option</h5>
     629<p><table class="symbol-table">Symbolic Value
    329630<tr>
    330631<td class="symbol">mysql-opt-connect-timeout</td>
    331 <td></td></tr>
     632<td>MYSQL_OPT_CONNECT_TIMEOUT</td></tr>
    332633<tr>
    333634<td class="symbol">mysql-opt-compress</td>
    334 <td></td></tr>
     635<td>MYSQL_OPT_COMPRESS</td></tr>
    335636<tr>
    336637<td class="symbol">mysql-opt-named-pipe</td>
    337 <td></td></tr>
     638<td>MYSQL_OPT_NAMED_PIPE</td></tr>
    338639<tr>
    339640<td class="symbol">mysql-init-command</td>
    340 <td></td></tr>
     641<td>MYSQL_INIT_COMMAND</td></tr>
    341642<tr>
    342643<td class="symbol">mysql-read-default-file</td>
    343 <td></td></tr>
     644<td>MYSQL_READ_DEFAULT_FILE</td></tr>
    344645<tr>
    345646<td class="symbol">mysql-read-default-group</td>
    346 <td></td></tr>
     647<td>MYSQL_READ_DEFAULT_GROUP</td></tr>
    347648<tr>
    348649<td class="symbol">mysql-set-charset-dir</td>
    349 <td></td></tr>
     650<td>MYSQL_SET_CHARSET_DIR</td></tr>
    350651<tr>
    351652<td class="symbol">mysql-set-charset-name</td>
    352 <td></td></tr>
     653<td>MYSQL_SET_CHARSET_NAME</td></tr>
    353654<tr>
    354655<td class="symbol">mysql-opt-local-infile</td>
    355 <td></td></tr>
     656<td>MYSQL_OPT_LOCAL_INFILE</td></tr>
    356657<tr>
    357658<td class="symbol">mysql-opt-protocol</td>
    358 <td></td></tr>
     659<td>MYSQL_OPT_PROTOCOL</td></tr>
    359660<tr>
    360661<td class="symbol">mysql-shared-memory-base-name</td>
    361 <td></td></tr>
     662<td>MYSQL_SHARED_MEMORY_BASE_NAME</td></tr>
    362663<tr>
    363664<td class="symbol">mysql-opt-read-timeout</td>
    364 <td></td></tr>
     665<td>MYSQL_OPT_READ_TIMEOUT</td></tr>
    365666<tr>
    366667<td class="symbol">mysql-opt-write-timeout</td>
    367 <td></td></tr>
     668<td>MYSQL_OPT_WRITE_TIMEOUT</td></tr>
    368669<tr>
    369670<td class="symbol">mysql-opt-use-result</td>
    370 <td></td></tr>
     671<td>MYSQL_OPT_USE_RESULT</td></tr>
    371672<tr>
    372673<td class="symbol">mysql-opt-use-remote-connection</td>
    373 <td></td></tr>
     674<td>MYSQL_OPT_USE_REMOTE_CONNECTION</td></tr>
    374675<tr>
    375676<td class="symbol">mysql-opt-use-embedded-connection</td>
    376 <td></td></tr>
     677<td>MYSQL_OPT_USE_EMBEDDED_CONNECTION</td></tr>
    377678<tr>
    378679<td class="symbol">mysql-opt-guess-connection</td>
    379 <td></td></tr>
     680<td>MYSQL_OPT_GUESS_CONNECTION</td></tr>
    380681<tr>
    381682<td class="symbol">mysql-set-client-ip</td>
    382 <td></td></tr>
     683<td>MYSQL_SET_CLIENT_IP</td></tr>
    383684<tr>
    384685<td class="symbol">mysql-secure-auth</td>
    385 <td></td></tr>
     686<td>MYSQL_SECURE_AUTH</td></tr>
    386687<tr>
    387688<td class="symbol">mysql-report-data-truncation</td>
    388 <td></td></tr></table><table class="symbol-table">enum enum_field_types
     689<td>MYSQL_REPORT_DATA_TRUNCATION</td></tr></table></p>
     690<dt class="definition"><strong>procedure:</strong> (mysql-option-value SYMBOL ...)</dt>
     691<dd>
     692<p>Returns the or'ed value of the <tt>SYMBOL ...</tt> values.</p></dd>
     693<dt class="definition"><strong>procedure:</strong> (mysql-option-symbol NUMBER)</dt>
     694<dd>
     695<p>Returns the symbol for the <tt>NUMBER</tt>.</p></dd></div>
     696<div class="subsubsection">
     697<h5>enum enum_field_types</h5>
     698<p><table class="symbol-table">Symbolic Value
    389699<tr>
    390700<td class="symbol">mysql-type-decimal</td>
    391 <td></td></tr>
     701<td>MYSQL_TYPE_DECIMAL</td></tr>
    392702<tr>
    393703<td class="symbol">mysql-type-tiny</td>
    394 <td></td></tr>
     704<td>MYSQL_TYPE_TINY</td></tr>
    395705<tr>
    396706<td class="symbol">mysql-type-short</td>
    397 <td></td></tr>
     707<td>MYSQL_TYPE_SHORT</td></tr>
    398708<tr>
    399709<td class="symbol">mysql-type-long</td>
    400 <td></td></tr>
     710<td>MYSQL_TYPE_LONG</td></tr>
    401711<tr>
    402712<td class="symbol">mysql-type-float</td>
    403 <td></td></tr>
     713<td>MYSQL_TYPE_FLOAT</td></tr>
    404714<tr>
    405715<td class="symbol">mysql-type-double</td>
    406 <td></td></tr>
     716<td>MYSQL_TYPE_DOUBLE</td></tr>
    407717<tr>
    408718<td class="symbol">mysql-type-null</td>
    409 <td></td></tr>
     719<td>MYSQL_TYPE_NULL</td></tr>
    410720<tr>
    411721<td class="symbol">mysql-type-timestamp</td>
    412 <td></td></tr>
     722<td>MYSQL_TYPE_TIMESTAMP</td></tr>
    413723<tr>
    414724<td class="symbol">mysql-type-longlong</td>
    415 <td></td></tr>
     725<td>MYSQL_TYPE_LONGLONG</td></tr>
    416726<tr>
    417727<td class="symbol">mysql-type-int24</td>
    418 <td></td></tr>
     728<td>MYSQL_TYPE_INT24</td></tr>
    419729<tr>
    420730<td class="symbol">mysql-type-date</td>
    421 <td></td></tr>
     731<td>MYSQL_TYPE_DATE</td></tr>
    422732<tr>
    423733<td class="symbol">mysql-type-time</td>
    424 <td></td></tr>
     734<td>MYSQL_TYPE_TIME</td></tr>
    425735<tr>
    426736<td class="symbol">mysql-type-datetime</td>
    427 <td></td></tr>
     737<td>MYSQL_TYPE_DATETIME</td></tr>
    428738<tr>
    429739<td class="symbol">mysql-type-year</td>
    430 <td></td></tr>
     740<td>MYSQL_TYPE_YEAR</td></tr>
    431741<tr>
    432742<td class="symbol">mysql-type-newdate</td>
    433 <td></td></tr>
     743<td>MYSQL_TYPE_NEWDATE</td></tr>
    434744<tr>
    435745<td class="symbol">mysql-type-varchar</td>
    436 <td></td></tr>
     746<td>MYSQL_TYPE_VARCHAR</td></tr>
    437747<tr>
    438748<td class="symbol">mysql-type-bit</td>
    439 <td></td></tr>
     749<td>MYSQL_TYPE_BIT</td></tr>
    440750<tr>
    441751<td class="symbol">mysql-type-newdecimal</td>
    442 <td></td></tr>
     752<td>MYSQL_TYPE_NEWDECIMAL</td></tr>
    443753<tr>
    444754<td class="symbol">mysql-type-enum</td>
    445 <td></td></tr>
     755<td>MYSQL_TYPE_ENUM</td></tr>
    446756<tr>
    447757<td class="symbol">mysql-type-set</td>
    448 <td></td></tr>
     758<td>MYSQL_TYPE_SET</td></tr>
    449759<tr>
    450760<td class="symbol">mysql-type-tiny-blob</td>
    451 <td></td></tr>
     761<td>MYSQL_TYPE_TINY_BLOB</td></tr>
    452762<tr>
    453763<td class="symbol">mysql-type-medium-blob</td>
    454 <td></td></tr>
     764<td>MYSQL_TYPE_MEDIUM_BLOB</td></tr>
    455765<tr>
    456766<td class="symbol">mysql-type-long-blob</td>
    457 <td></td></tr>
     767<td>MYSQL_TYPE_LONG_BLOB</td></tr>
    458768<tr>
    459769<td class="symbol">mysql-type-blob</td>
    460 <td></td></tr>
     770<td>MYSQL_TYPE_BLOB</td></tr>
    461771<tr>
    462772<td class="symbol">mysql-type-var-string</td>
    463 <td></td></tr>
     773<td>MYSQL_TYPE_VAR_STRING</td></tr>
    464774<tr>
    465775<td class="symbol">mysql-type-string</td>
    466 <td></td></tr>
     776<td>MYSQL_TYPE_STRING</td></tr>
    467777<tr>
    468778<td class="symbol">mysql-type-geometry</td>
    469 <td></td></tr></table></div></div>
     779<td>MYSQL_TYPE_GEOMETRY</td></tr></table></p>
     780<dt class="definition"><strong>procedure:</strong> (mysql-type-value SYMBOL ...)</dt>
     781<dd>
     782<p>Returns the or'ed value of the <tt>SYMBOL ...</tt> values.</p></dd>
     783<dt class="definition"><strong>procedure:</strong> (mysql-type-symbol NUMBER)</dt>
     784<dd>
     785<p>Returns the symbol for the <tt>NUMBER</tt>.</p></dd></div>
     786<div class="subsubsection">
     787<h5>MYSQL_FIELD.flags Flags</h5>
     788<p><table class="symbol-table">Symbolic Value
     789<tr>
     790<td class="symbol">not-null-flag</td>
     791<td>NOT-NULL-FLAG</td></tr>
     792<tr>
     793<td class="symbol">pri-key-flag</td>
     794<td>PRI-KEY-FLAG</td></tr>
     795<tr>
     796<td class="symbol">unique-key-flag</td>
     797<td>UNIQUE-KEY-FLAG</td></tr>
     798<tr>
     799<td class="symbol">multiple-key-flag</td>
     800<td>MULTIPLE-KEY-FLAG</td></tr>
     801<tr>
     802<td class="symbol">unsigned-flag</td>
     803<td>UNSIGNED-FLAG</td></tr>
     804<tr>
     805<td class="symbol">zerofill-flag</td>
     806<td>ZEROFILL-FLAG</td></tr>
     807<tr>
     808<td class="symbol">binary-flag</td>
     809<td>BINARY-FLAG</td></tr>
     810<tr>
     811<td class="symbol">auto-increment-flag</td>
     812<td>AUTO-INCREMENT-FLAG</td></tr>
     813<tr>
     814<td class="symbol">no-default-value-flag</td>
     815<td>NO-DEFAULT-VALUE-FLAG</td></tr></table></p>
     816<dt class="definition"><strong>procedure:</strong> (mysql-field-flags-value SYMBOL ...)</dt>
     817<dd>
     818<p>Returns the or'ed value of the <tt>SYMBOL ...</tt> values.</p></dd>
     819<dt class="definition"><strong>procedure:</strong> (mysql-field-flags-symbol NUMBER)</dt>
     820<dd>
     821<p>Returns the symbol for the <tt>NUMBER</tt>.</p></dd></div></div></div>
    470822<div class="section">
    471823<h3>Examples</h3>
     
    476828(let [(db (mysql-connect host: &quot;mysql.example.com&quot; user: &quot;example&quot;
    477829                         passwd: &quot;secret&quot;))]
    478   (if (not db) (error (conc &quot;MySQL connection failed: &quot; (mysql-error db))))
    479830  (mysql-query db &quot;SHOW DATABASES&quot;)
    480831  (do [(row (mysql-fetch-row db) (mysql-fetch-row db))]
     
    487838(let [(db (mysql-connect host: &quot;mysql.example.com&quot; user: &quot;example&quot;
    488839                         passwd: &quot;secret&quot;))]
    489   (if (not db) (error (conc &quot;MySQL connection failed: &quot; (mysql-error db))))
    490840  (mysql-query-foreach db &quot;SHOW DATABASES&quot;
    491841                       (lambda (row idx)
     
    494844<div class="section">
    495845<h3>Data Type Conversion</h3>
    496 <p>All MySQL result data (except NULL) are returned as Scheme strings. The NULL value is represented by <tt>#f</tt>. Booleans are expressed as Scheme strings <tt>&quot;1&quot;</tt> and <tt>&quot;0&quot;</tt>. All remaining types, including numeric types and strings are returned as Scheme strings.</p></div>
     846<p>All MySQL result data (except NULL) are returned as Scheme strings.</p>
     847<p>The NULL value is represented by <tt>#f</tt>.</p>
     848<p>Booleans are expressed as the Scheme strings <tt>&quot;1&quot;</tt> and <tt>&quot;0&quot;</tt>.</p>
     849<p>All remaining types, including numeric types, blobs, and strings are returned as Scheme strings.</p></div>
    497850<div class="section">
    498851<h3>Bugs</h3>
     852<p>No prepared statement support.</p>
    499853<p>This is alpha quality software. Only very basic functionality has been tested so far. I look forward to providing a more complete test suite (and probably a slew of bugfixes) with the next release.</p>
    500 <p>Does not return native types.</p>
    501854<p><tt>mysql-escape-string</tt> is broken when it's used for binary data.</p>
    502 <p>Not yet sure how to handle <tt>unsigned long *</tt> for <tt>foreign-mysql-fetch-lengths</tt>.</p>
    503 <p><tt>foreign-mysql-get-charset-info</tt> isn't yet supported.</p>
    504855<p>I need to nail down the supported libmysqlclient versions. Right now there are some functions I've put off because they may or may not be supported in my target range. We'll see, soon...</p></div>
    505856<div class="section">
  • release/3/mysql/tags/1.31/mysql.scm

    r7942 r7943  
    119119  (bound-to-procedure
    120120    mysql-error
    121     mysql-field-binary? )
     121    mysql-field-type-binary? )
    122122  (export
    123123    ;; direct api
     
    835835
    836836;-----------------------------------------------------------------------
     837; Foreign function definitions for mysqlaux functions.
     838;
     839
     840#>
     841static int
     842mysqlaux_field_index (MYSQL_RES *result, const char *name, unsigned int num_fields)
     843{
     844  MYSQL_FIELD *fields = mysql_fetch_fields (result);
     845  unsigned int i;
     846
     847  for (i = 0; i < num_fields; i++) {
     848    if (0 == strcasecmp (name, fields[i].name)) {
     849      return (i);
     850    }
     851  }
     852
     853  return (-1);
     854}
     855
     856static char *
     857mysqlaux_fetch_column_data_direct (MYSQL_RES *result, MYSQL_ROW row, unsigned int fldidx, int *binflg)
     858{
     859  MYSQL_FIELD *fields = mysql_fetch_fields (result);
     860
     861  switch (fields[fldidx].type) {
     862    case MYSQL_TYPE_VARCHAR:
     863    case MYSQL_TYPE_TINY_BLOB:
     864    case MYSQL_TYPE_MEDIUM_BLOB:
     865    case MYSQL_TYPE_LONG_BLOB:
     866    case MYSQL_TYPE_BLOB:
     867    case MYSQL_TYPE_VAR_STRING:
     868    case MYSQL_TYPE_STRING:
     869      *binflg = 1;
     870      break;
     871    default:
     872      *binflg = 0;
     873      break;
     874  }
     875  *binflg &= (63 == fields[fldidx].charsetnr);
     876
     877  return (((MYSQL_ROW)row)[fldidx]);
     878}
     879<#
     880
     881(define foreign-mysqlaux-field-index
     882  (foreign-lambda int "mysqlaux_field_index" mysql-res-ptr nonnull-c-string unsigned-integer) )
     883
     884(define foreign-mysqlaux-fetch-column-data-direct
     885  (foreign-lambda c-pointer "mysqlaux_fetch_column_data_direct"
     886                            mysql-res-ptr mysql-row
     887                            unsigned-integer
     888                            (nonnull-c-pointer int)) )
     889
     890;-----------------------------------------------------------------------
    837891; Foreign function definitions from MySQL C API.
    838892;
     
    11651219  (foreign-lambda integer "mysql_next_result" mysql-ptr))
    11661220
    1167 ;-----------------------------------------------------------------------
    1168 ; Foreign function definitions for mysqlaux functions.
    1169 ;
    1170 
    1171 #>
    1172 static int
    1173 mysqlaux_field_index (MYSQL *mysql, MYSQL_RES *result, const char *name)
    1174 {
    1175   unsigned int num_fields = mysql_field_count(mysql);
    1176   MYSQL_FIELD *fields = mysql_fetch_fields(result);
    1177   unsigned int i;
    1178 
    1179   for (i = 0; i < num_fields; i++) {
    1180     if (0 == strcasecmp (name, fields[i].name)) {
    1181       return (i);
    1182     }
    1183   }
    1184 
    1185   return (-1);
    1186 }
    1187 <#
    1188 
    1189 ; int mysqlaux_field_index (MYSQL *mysql, MYSQL_RES *result, const char *name)
    1190 (define foreign-mysqlaux-field-index
    1191   (foreign-lambda int "mysqlaux_field_index" mysql-ptr mysql-res-ptr nonnull-c-string) )
    1192 
    1193 ; char *mysqlaux_fetch_column_direct(MYSQL_ROW, unsigned int);
    1194 (define foreign-mysqlaux-fetch-column-direct
    1195   (foreign-lambda* c-pointer ((mysql-row row) (unsigned-integer idx))
    1196     "return (((MYSQL_ROW)row)[idx]);") )
    1197 
    1198 ;
    1199 (define (%mysql-get-field-index connptr resptr field)
    1200   (if (number? field)
    1201       field
    1202       (foreign-mysqlaux-field-index connptr resptr (->string field)) ) )
    1203 
    12041221;=======================================================================
    12051222; Provided Scheme API.
     
    12161233      "") )
    12171234
    1218 (define foreign-char-pointer->string
    1219   (foreign-lambda* c-string ((nonnull-c-pointer chrptr))
    1220     "return ((char *) chrptr);") )
    1221 
    12221235(define (foreign-unsigned-long-pointer->u32vector ulptr cnt)
    12231236  (let* ([siz (* cnt UNSIGNED-LONG-SIZE)]
     
    12261239    (blob->u32vector/shared store) ) )
    12271240
    1228 (define foreign-char-pointer->string
     1241(define char-pointer->string
    12291242  (foreign-lambda* c-string ((c-pointer chrptr))
    12301243    "return ((char *) chrptr);") )
    12311244
    1232 (define (foreign-binary-char-pointer->string chrptr size)
     1245(define (binary-char-pointer->string chrptr size)
    12331246  (let ([blob (make-blob size)])
    12341247    (move-memory! chrptr blob size)
    12351248    (blob->string blob) ) )
     1249
     1250(define (%mysql-get-field-index resptr field fldcnt)
     1251  (let ([fldidx (if (number? field)
     1252                    field
     1253                    (foreign-mysqlaux-field-index resptr
     1254                                                  (->string field) fldcnt))])
     1255    (and (<= 0 fldidx) (< fldidx fldcnt)
     1256         fldidx ) ) )
    12361257
    12371258;-----------------------------------------------------------------------
     
    14621483      "    (void) mysql_real_escape_string (mysql, *((char **) to), from, length);\n"
    14631484      "}")
    1464      (location escstr)
     1485     #$escstr
    14651486     str (string-length str))
    14661487    escstr ) )
     
    15091530           [fldlens (%mysql-fetch-lengths resptr fldcnt)])
    15101531      (lambda (field)
    1511         (let ([fldidx (%mysql-get-field-index connptr resptr field)])
    1512           (and (<= 0 fldidx) (< fldidx fldcnt)
    1513                (let ([chrptr (foreign-mysqlaux-fetch-column-direct resptr fldidx)])
    1514                   (if (mysql-field-binary? (foreign-mysql-fetch-field-direct resptr fldidx))
    1515                       (foreign-binary-char-pointer->string
    1516                        chrptr (u32vector-ref fldlens fldidx))
    1517                       (foreign-char-pointer->string chrptr) ) ) ) ) ) ) ) )
     1532        (and-let* ([fldidx (%mysql-get-field-index resptr field fldcnt)])
     1533          (let-location ([binary-flag bool])
     1534            (and-let* ([datptr (foreign-mysqlaux-fetch-column-data-direct resptr row fldidx #$binary-flag)])
     1535              (if binary-flag
     1536                  (binary-char-pointer->string datptr (u32vector-ref fldlens fldidx))
     1537                  (char-pointer->string datptr) ) ) ) ) ) ) ) )
    15181538
    15191539(define (mysql-field-count conn)
     
    17221742
    17231743(define (mysql-field-flags-mask flags)
    1724   (apply mysql-field-flags-value flags) )
     1744  (apply bitwise-ior flags) )
    17251745
    17261746;;
     
    17351755;;
    17361756
    1737 (define (mysql-field-type-any? fldptr types)
     1757(define (mysql-field-type-any? fldptr . types)
    17381758  (memv (mysql-field-type fldptr) types) )
    17391759
     
    17621782                        mysql-type-newdate mysql-type-year)])
    17631783    (lambda (fldptr)
    1764       (mysql-field-type-any? fldptr numtypes) ) ) )
     1784      (apply mysql-field-type-any? fldptr numtypes) ) ) )
    17651785
    17661786; note - not the same as the "IS_NUM" macro.
     
    17711791                        mysql-type-newdecimal)])
    17721792    (lambda (fldptr)
    1773       (mysql-field-type-any? fldptr numtypes) ) ) )
     1793      (apply mysql-field-type-any? fldptr numtypes) ) ) )
    17741794
    17751795(define mysql-field-type-blob?
     
    17771797                         mysql-type-long-blob mysql-type-blob)])
    17781798    (lambda (fldptr)
    1779       (mysql-field-type-any? fldptr blobtypes) ) ) )
     1799      (apply mysql-field-type-any? fldptr blobtypes) ) ) )
    17801800
    17811801(define mysql-field-type-string?
     
    17831803                        mysql-type-string)])
    17841804    (lambda (fldptr)
    1785       (mysql-field-type-any? fldptr numtypes) ) ) )
     1805      (apply mysql-field-type-any? fldptr numtypes) ) ) )
    17861806
    17871807;;
     
    17921812    (lambda (fldptr)
    17931813      (or (mysql-field-type-number? fldptr)
    1794           (mysql-field-type-any? fldptr magtypes) ) ) ) )
     1814          (apply mysql-field-type-any? fldptr magtypes) ) ) ) )
    17951815
    17961816(define (mysql-field-type-binary? fldptr)
     
    18331853; returns a field pointer or #f.
    18341854(define (mysql-fetch-field-specific conn field)
    1835   (and-let* ([resptr (mysql-connection-result conn)])
    1836     (let ([fldidx (%mysql-get-field-index (mysql-connection-ptr conn) resptr field)]
    1837           [fldcnt (foreign-mysql-num-fields resptr)])
    1838       (and (<= 0 fldcnt) (< fldidx fldcnt)
    1839            (foreign-mysql-fetch-field-direct resptr fldidx) ) ) ) )
    1840 
    1841 #|
    1842 ;-----------------------------------------------------------------------
    1843 ; The MySQL row field value string form conversion
    1844 ;
    1845 
    1846 (define (chrbuf2obj-string->number _ x) (string->number x))
    1847 (define (chrbuf2obj-string->blob _ x) (string->blob x))
    1848 (define (chrbuf2obj-identity _ x) (identity x))
    1849 
    1850 (define *character-buffer->object*
    1851   `(
    1852         (((,mysql-field-type=? ,mysql-type-null))
    1853                   (,chrbuf2obj-identity))
    1854 
    1855         (((,mysql-field-type=? ,mysql-type-bit))
    1856                   (,chrbuf2obj-identity))
    1857         (((,mysql-field-type=? ,mysql-type-enum))
    1858                   (,chrbuf2obj-identity))
    1859         (((,mysql-field-type=? ,mysql-type-set))
    1860                   (,chrbuf2obj-identity))
    1861         (((,mysql-field-type=? ,mysql-type-geometry))
    1862                   (,chrbuf2obj-identity))
    1863 
    1864         (((,mysql-field-type=? ,mysql-type-decimal))
    1865                         (,chrbuf2obj-string->number))
    1866         (((,mysql-field-type=? ,mysql-type-tiny))
    1867                         (,chrbuf2obj-string->number))
    1868         (((,mysql-field-type=? ,mysql-type-short))
    1869                         (,chrbuf2obj-string->number))
    1870         (((,mysql-field-type=? ,mysql-type-long))
    1871                         (,chrbuf2obj-string->number))
    1872         (((,mysql-field-type=? ,mysql-type-float))
    1873                         (,chrbuf2obj-string->number))
    1874         (((,mysql-field-type=? ,mysql-type-double))
    1875                         (,chrbuf2obj-string->number))
    1876         (((,mysql-field-type=? ,mysql-type-longlong))
    1877                         (,chrbuf2obj-string->number))
    1878         (((,mysql-field-type=? ,mysql-type-int24))
    1879                         (,chrbuf2obj-string->number))
    1880         (((,mysql-field-type=? ,mysql-type-newdecimal))
    1881                         (,chrbuf2obj-string->number))
    1882 
    1883         (((,mysql-field-type=? ,mysql-type-timestamp))
    1884                   (,chrbuf2obj-identity))
    1885         (((,mysql-field-type=? ,mysql-type-date))
    1886                   (,chrbuf2obj-identity))
    1887         (((,mysql-field-type=? ,mysql-type-time))
    1888                   (,chrbuf2obj-identity))
    1889         (((,mysql-field-type=? ,mysql-type-datetime))
    1890                   (,chrbuf2obj-identity))
    1891         (((,mysql-field-type=? ,mysql-type-year))
    1892                   (,chrbuf2obj-identity))
    1893         (((,mysql-field-type=? ,mysql-type-newdate))
    1894                   (,chrbuf2obj-identity))
    1895 
    1896         (((,mysql-field-type=? ,mysql-type-tiny-blob) (,mysql-field-binary?))
    1897                   (,chrbuf2obj-string->blob))
    1898         (((,mysql-field-type=? ,mysql-type-medium-blob) (,mysql-field-binary?))
    1899                   (,chrbuf2obj-string->blob))
    1900         (((,mysql-field-type=? ,mysql-type-long-blob) (,mysql-field-binary?))
    1901                   (,chrbuf2obj-string->blob))
    1902         (((,mysql-field-type=? ,mysql-type-blob) (,mysql-field-binary?))
    1903                   (,chrbuf2obj-string->blob))
    1904 
    1905         (((,mysql-field-type=? ,mysql-type-varchar) (,mysql-field-binary?))
    1906                   (,chrbuf2obj-string->blob))
    1907     (((,mysql-field-type=? ,mysql-type-var-string) (,mysql-field-binary?))
    1908                   (,chrbuf2obj-string->blob))
    1909         (((,mysql-field-type=? ,mysql-type-string) (,mysql-field-binary?))
    1910                   (,chrbuf2obj-string->blob))
    1911 
    1912         (((,mysql-field-type=? ,mysql-type-tiny-blob))
    1913                         (,chrbuf2obj-identity))
    1914         (((,mysql-field-type=? ,mysql-type-medium-blob))
    1915                         (,chrbuf2obj-identity))
    1916         (((,mysql-field-type=? ,mysql-type-long-blob))
    1917                         (,chrbuf2obj-identity))
    1918         (((,mysql-field-type=? ,mysql-type-blob))
    1919                         (,chrbuf2obj-identity))
    1920 
    1921         (((,mysql-field-type=? ,mysql-type-varchar))
    1922                         (,chrbuf2obj-identity))
    1923         (((,mysql-field-type=? ,mysql-type-var-string))
    1924                         (,chrbuf2obj-identity))
    1925         (((,mysql-field-type=? ,mysql-type-string))
    1926                         (,chrbuf2obj-identity))
    1927   ) )
    1928 
    1929 (define (call-with-template obj def)
    1930   (apply (car def) obj (cdr def)) )
    1931 
    1932 (define (test-with-templates obj defs)
    1933   (every (cut call-with-template obj <>) defs) )
    1934 
    1935 ; returns field object value for the string form.
    1936 (define (mysql-field-string-form->object fldptr str)
    1937   (let ([def (find (lambda (def) (test-with-templates fldptr (first def)))
    1938                    *character-buffer->object*)])
    1939     (if def
    1940         (call-with-template fldptr (append (second def) `(,str)))
    1941         (signal-mysql-condition 'mysql-field-string-form->object
    1942                                 "unknown field type") ) ) )
    1943 
    1944 ; returns list of field object value for the specified row.
    1945 (define (mysql-row-string-form->object rowprc . field-ids)
    1946   (map (lambda (fld-id)
    1947          (let ([fldptr (mysql-fetch-field-specific conn fld-id)])
    1948            (if fldptr
    1949                (mysql-field-string-form->object fldptr (rowprc fld-id))
    1950                (signal-mysql-condition 'mysql-row-string-form->object
    1951                                        "no such field") ) ) )
    1952        field-ids) )
    1953 |#
     1855  (and-let* ([resptr (mysql-connection-result conn)]
     1856             [fldidx (%mysql-get-field-index resptr field (foreign-mysql-num-fields resptr))])
     1857    (foreign-mysql-fetch-field-direct resptr fldidx) ) )
  • release/3/mysql/trunk/mysql-tests-body.scm

    r7930 r7943  
    4949(newline)
    5050(print "The rows can be enumerated one-per-line, like this:")
    51 (mysql-foreach-row *conn* (lambda (row row-idx)
    52   (display (conc row-idx ": " (row "Database") "\n"))))
     51(mysql-row-for-each
     52  *conn*
     53  (lambda (row row-idx)
     54    (display (conc row-idx ": " (row "Database") "\n"))))
    5355
    5456(newline)
    5557(display "Or they can just be comma-separated, like so:")
    56 (mysql-foreach-row *conn* (lambda (row row-idx)
    57   (display (conc (row "Database")
    58                  (if (< row-idx (mysql-num-rows *conn*)) ", " "\n")))))
     58(mysql-row-for-each
     59  *conn*
     60  (lambda (row row-idx)
     61    (display (conc (row "Database")
     62                   (if (< row-idx (mysql-num-rows *conn*)) ", " "\n")))))
    5963
    6064(mysql-print-and-query *conn* "DROP DATABASE IF EXISTS mysql_egg_test")
     
    8084(newline)
    8185(mysql-print-and-query *conn* "SELECT testboolnn, testbool FROM test1")
    82 (mysql-foreach-row *conn* (lambda (row idx)
     86(mysql-row-for-each
     87  *conn*
     88  (lambda (row idx)
     89    (print "Row " idx " lengths: " (mysql-fetch-lengths *conn*))))
     90
     91(newline)
     92(mysql-print-and-query *conn* "SELECT testboolnn, testbool FROM test1")
     93(mysql-row-for-each *conn* (lambda (row idx)
    8394  (display (conc "row " idx ": testboolnn=" (row "testboolnn")
    8495                 ", testbool="
     
    94105       (map (lambda (f) (cons f (row f))) names)))) )
    95106
    96 (newline)
    97 (mysql-print-and-query *conn* "SELECT testboolnn, testbool FROM test1")
    98 (mysql-row-for-each
    99   *conn*
    100   (lambda (row idx)
    101     (print "Row " idx " lengths: " (mysql-fetch-lengths *conn*))))
    102 
    103107;; Finished
    104108(newline)
  • release/3/mysql/trunk/mysql.html

    r7902 r7943  
    158158<h3>Version</h3>
    159159<ul>
    160 <li>1.3 Additional functions [Kon Lovett].</li>
    161 <li>1.2 Fix for ticket #297 [Mario Domenech Goulart].</li>
     160<li>1.31 Additional functions &amp; special handling of binary column. [Kon Lovett]</li>
     161<li>1.3 Additional functions. [Kon Lovett]</li>
     162<li>1.2 Fix for ticket #297. [Mario Domenech Goulart]</li>
    162163<li>1.1 Cross-platform compilation fixes, et al.</li>
    163164<li>1.0 Initial release</li></ul></div>
     
    172173<div class="section">
    173174<h3>Documentation</h3>
    174 <p>The MySQL egg provides (most of) the functions offered by the MySQL C API (the <tt>foreign-mysql-*</tt> functions). It also maps those to a set of slightly more convenient Scheme functions (the <tt>mysql-*</tt> functions). Finally, a few extra functions are provided for easy of use.</p>
     175<p>The MySQL egg provides (most of) the functions offered by the MySQL C API (the <tt>foreign-mysql-*</tt> functions). It also provides a set of slightly more convenient Scheme functions (the <tt>mysql-*</tt> functions). Finally, a few extra functions are provided for easy of use.</p>
    175176<p>Only the most often used MySQL functions are described in this document. If you really want to see the full listing, consult the <a href="mysql-mole.html">mole documentation</a>.</p>
    176177<p>Please send bug reports and suggestions to <a href="mailto:toby@butzon.com">toby@butzon.com</a>.</p>
    177178<div class="subsection">
     179<h4>Exceptions</h4>
     180<p>Conditions of the kind <code>(exn mysql)</code> are signaled for error situations.<table class="symbol-table">Properties
     181<tr>
     182<td class="symbol">location</td>
     183<td>Where the error occured - usually a procedure name.</td></tr>
     184<tr>
     185<td class="symbol">arguments</td>
     186<td>Values that contributed to the error.</td></tr>
     187<tr>
     188<td class="symbol">message</td>
     189<td>Error message.</td></tr></table></p></div>
     190<div class="subsection">
    178191<h4>Connections</h4>
    179192<dt class="definition"><strong>procedure:</strong> (mysql-connect [KEYWORDS])</dt>
    180193<dd>
    181194<p>Connect to a MySQL server.</p>
    182 <p>Returns a MySQL connection object suitable for passing to the other MySQL functions. This object is referred to as <tt>DB</tt> when passed by all the other MySQL functions. Returns <tt>#f</tt> when the connection fails.</p>
     195<p>Returns a MySQL connection object suitable for passing to the other MySQL functions. This object is referred to as <tt>CONN</tt> when passed by all the other MySQL functions. Signals an exception when the connection fails.</p>
    183196<p>Any number of the following <tt>KEYWORDS</tt> may be included:
    184197<ul>
    185 <li>host</li>
    186 <li>user</li>
    187 <li>passwd</li>
    188 <li>db</li>
    189 <li>port</li>
    190 <li>unix-socket</li>
    191 <li>client-flag</li></ul></p>
     198<li><tt>host</tt></li>
     199<li><tt>user</tt></li>
     200<li><tt>passwd</tt></li>
     201<li><tt>db</tt></li>
     202<li><tt>port</tt></li>
     203<li><tt>unix-socket</tt></li>
     204<li><tt>client-flag</tt></li>
     205<li><tt>ssl</tt> - A <code>mysql-ssl</code> record object.</li>
     206<li><tt>options</tt> - An association list of <code>(&lt;mysql-option&gt; . &lt;object&gt;)</code>.</li></ul></p>
    192207<p>Note that default values are available for all of these arguments. (Consult the <a href="http://dev.mysql.com/doc/mysql/en/c.html">MySQL C API</a> for details on how these defaults are determined.)</p></dd>
    193 <dt class="definition"><strong>procedure:</strong> (mysql-close DB)</dt>
    194 <dd>
    195 <p>Closes the connection to <tt>DB</tt>. This frees any remaining MySQL resources from memory, but invalidates the MySQL connection object (<tt>DB</tt>) so that it may no longer be used.</p></dd></div>
    196 <div class="subsection">
    197 <h4>Basic Operations</h4>
    198 <dt class="definition"><strong>procedure:</strong> (mysql-query DB SQL-STRING)</dt>
    199 <dd>
    200 <p>Executes <tt>SQL-STRING</tt> on the MySQL server and stores the result in memory. Generates an error (calls <tt>error</tt>) if the query fails.</p></dd>
    201 <dt class="definition"><strong>procedure:</strong> (mysql-fetch-row DB)</dt>
     208<dt class="definition"><strong>procedure:</strong> (mysql-connection? OBJECT)</dt>
     209<dd>
     210<p>Is the <tt>OBJECT</tt> a <code>mysql-connection</code>? Referred to as a <tt>CONN</tt>.</p></dd>
     211<dt class="definition"><strong>procedure:</strong> (mysql-close CONN)</dt>
     212<dd>
     213<p>Closes the connection to <tt>CONN</tt>. This frees any remaining MySQL resources from memory, but invalidates the MySQL connection object (<tt>CONN</tt>) so that it may no longer be used.</p></dd>
     214<div class="subsubsection">
     215<h5>Connect Parameter Constructors</h5>
     216<dt class="definition"><strong>procedure:</strong> (make-mysql-options OPTION-FLAG OPTION-VALUE ...)</dt>
     217<dd>
     218<p>Returns an object suitable as the <tt>options</tt> parameter for <code>mysql-connect</code>.</p>
     219<p>The type of the <tt>OPTION-VALUE</tt> is dependent on the <tt>OPTION-FLAG</tt>.</p></dd>
     220<dt class="definition"><strong>procedure:</strong> (make-mysql-ssl [KEYWORD ...])</dt>
     221<dd>
     222<p>Returns a <code>mysql-ssl</code> record.</p>
     223<p>Any number of the following <tt>KEYWORD ...</tt> may be included:
     224<ul>
     225<li><tt>key</tt> - pathname of key file.</li>
     226<li><tt>certificate</tt> - pathname of certificate file.</li>
     227<li><tt>certificate-authority</tt> - pathname of certificate authority file.</li>
     228<li><tt>trusted-certificates</tt> - pathname of trusted certificates directory.</li>
     229<li><tt>ciphers</tt> - See <a href="http://www.openssl.org/docs/apps/ciphers.html">OpenSSL Ciphers Man Page</a></li></ul></p></dd>
     230<dt class="definition"><strong>procedure:</strong> (mysql-ssl? OBJECT)</dt>
     231<dd>
     232<p>Is the <tt>OBJECT</tt> an <code>mysql-ssl</code> record?</p></dd>
     233<dt class="definition"><strong>procedure:</strong> (mysql-ssl-key-pathname MYSQL-SSL)</dt>
     234<dd>
     235<p>Returns a <code>string</code>.</p></dd>
     236<dt class="definition"><strong>procedure:</strong> (mysql-ssl-certificate-pathname MYSQL-SSL)</dt>
     237<dd>
     238<p>Returns a <code>string</code>.</p></dd>
     239<dt class="definition"><strong>procedure:</strong> (mysql-ssl-certificate-authority-pathname MYSQL-SSL)</dt>
     240<dd>
     241<p>Returns a <code>string</code>.</p></dd>
     242<dt class="definition"><strong>procedure:</strong> (mysql-ssl-trusted-certificates-pathname MYSQL-SSL)</dt>
     243<dd>
     244<p>Returns a <code>string</code>.</p></dd>
     245<dt class="definition"><strong>procedure:</strong> (mysql-ssl-ciphers MYSQL-SSL)</dt>
     246<dd>
     247<p>Returns a <code>string</code>.</p></dd></div></div>
     248<div class="subsection">
     249<h4>Basic Query Operations</h4>
     250<dt class="definition"><strong>procedure:</strong> (mysql-query CONN SQL-STRING)</dt>
     251<dd>
     252<p>Executes <tt>SQL-STRING</tt> on the MySQL server and stores the result in memory. Signals an exception if the query fails.</p></dd>
     253<dt class="definition"><strong>procedure:</strong> (mysql-fetch-row CONN)</dt>
    202254<dd>
    203255<p>Fetches a row from the result set returned by the most recent call to <tt>mysql-query</tt>. If the last query failed, or if there are no more rows left in the result set, returns <tt>#f</tt>; otherwise returns a row object.</p><a name='rowobj'></a>
    204256<p>A row object is defined as a function that takes a single argument. If the argument is a number, the function returns the value of the field for which that number is the index, or <tt>#f</tt> if the index is out of range. Otherwise, the argument must be a symbol or string, in which case the function returns the value of the field for which that string (or symbol converted into a string) is the field/column name. If no such field exists, returns <tt>#f</tt>.</p></dd>
    205 <dt class="definition"><strong>procedure:</strong> (mysql-rewind DB)</dt>
     257<dt class="definition"><strong>procedure:</strong> (mysql-field-count CONN)</dt>
     258<dd>
     259<p>Returns the number of columns for the most recent query.</p></dd>
     260<dt class="definition"><strong>procedure:</strong> (mysql-fetch-lengths CONN)</dt>
     261<dd>
     262<p>Returns a <code>u32vector</code> of the lengths of the columns of the current row.</p></dd>
     263<dt class="definition"><strong>procedure:</strong> (mysql-rewind CONN)</dt>
    206264<dd>
    207265<p>Rewinds the result set; that is, resets the pointer used by <tt>mysql-fetch-row</tt> so that the next call to it will return the first row of the result set. If there is no current result set, does nothing.</p></dd>
    208 <dt class="definition"><strong>procedure:</strong> (mysql-num-rows DB)</dt>
    209 <dd>
    210 <p>Returns the number of rows in the current result set. If no result set exists, returns <tt>#f</tt>.</p></dd></div>
     266<dt class="definition"><strong>procedure:</strong> (mysql-num-rows CONN)</dt>
     267<dd>
     268<p>Returns the number of rows in the current result set. If no result set exists, returns <tt>#f</tt>.</p></dd>
     269<dt class="definition"><strong>procedure:</strong> (mysql-num-fields CONN)</dt>
     270<dd>
     271<p>Returns the number of fields in the current result set. If no result set exists, returns <tt>#f</tt>.</p></dd>
     272<dt class="definition"><strong>procedure:</strong> (mysql-affected-rows CONN)</dt>
     273<dd>
     274<p>Returns the number of rows affected by the current query.</p></dd></div>
    211275<div class="subsection">
    212276<h4>Row Mapping</h4>
    213 <dt class="definition"><strong>procedure:</strong> (mysql-row-fold DB PROC INIT)</dt>
     277<dt class="definition"><strong>procedure:</strong> (mysql-row-fold CONN PROC INIT)</dt>
    214278<dd>
    215279<p>Iterates over the entire result set (regardless of any rows that may have already been returned by <tt>mysql-fetch-row</tt>), calling <tt>PROC</tt> on each row.</p>
    216280<p>Returns the final accumulated value.</p>
    217 <p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows DB)</tt>, and the current accumulated value (initially <tt>INIT</tt>).</p>
     281<p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows CONN)</tt>, and the current accumulated value (initially <tt>INIT</tt>).</p>
    218282<p><tt>PROC</tt> must return a value.</p></dd>
    219 <dt class="definition"><strong>procedure:</strong> (mysql-row-for-each DB PROC)</dt>
     283<dt class="definition"><strong>procedure:</strong> (mysql-row-for-each CONN PROC)</dt>
    220284<dd>
    221285<p>Iterates over the entire result set (regardless of any rows that may have already been returned by <tt>mysql-fetch-row</tt>), calling <tt>PROC</tt> on each row.</p>
    222 <p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, and the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows DB)</tt>.</p></dd>
    223 <dt class="definition"><strong>procedure:</strong> (mysql-row-map DB PROC)</dt>
     286<p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, and the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows CONN)</tt>.</p></dd>
     287<dt class="definition"><strong>procedure:</strong> (mysql-row-map CONN PROC)</dt>
    224288<dd>
    225289<p>Iterates over the entire result set (regardless of any rows that may have already been returned by <tt>mysql-fetch-row</tt>), calling <tt>PROC</tt> on each row.</p>
    226290<p>Returns the list of results of the <tt>PROC</tt> invocations.</p>
    227 <p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, and the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows DB)</tt>.</p>
     291<p><tt>PROC</tt> must take three arguments: the row (as <a href="#rowobj">described</a>) for <tt>mysql-fetch-row</tt>, and the index of that row in the result set, starting with <tt>1</tt> and ending with <tt>(mysql-num-rows CONN)</tt>.</p>
    228292<p><tt>PROC</tt> must return a value.</p></dd>
    229 <dt class="definition"><strong>procedure:</strong> (mysql-query-fold DB QUERY PROC INIT)</dt>
     293<dt class="definition"><strong>procedure:</strong> (mysql-query-fold CONN QUERY PROC INIT)</dt>
    230294<dd>
    231295<p>Combines <tt>mysql-query</tt> and <tt>mysql-row-fold</tt>.</p></dd>
    232 <dt class="definition"><strong>procedure:</strong> (mysql-query-for-each DB QUERY PROC)</dt>
     296<dt class="definition"><strong>procedure:</strong> (mysql-query-for-each CONN QUERY PROC)</dt>
    233297<dd>
    234298<p>Combines <tt>mysql-query</tt> and <tt>mysql-row-for-each</tt>.</p></dd>
    235 <dt class="definition"><strong>procedure:</strong> (mysql-query-map DB QUERY PROC)</dt>
     299<dt class="definition"><strong>procedure:</strong> (mysql-query-map CONN QUERY PROC)</dt>
    236300<dd>
    237301<p>Combines <tt>mysql-query</tt> and <tt>mysql-row-map</tt>.</p></dd>
    238 <dt class="definition"><strong>procedure:</strong> (mysql-foreach-row DB BODY)</dt>
     302<dt class="definition"><strong>procedure:</strong> (mysql-foreach-row CONN BODY)</dt>
    239303<dd>
    240304<p>Synonym for <code>mysql-row-for-each</code>.</p></dd>
    241 <dt class="definition"><strong>procedure:</strong> (mysql-query-foreach DB QUERY BODY)</dt>
     305<dt class="definition"><strong>procedure:</strong> (mysql-query-foreach CONN QUERY BODY)</dt>
    242306<dd>
    243307<p>Synonym for <code>mysql-query-for-each</code>.</p></dd></div>
    244308<div class="subsection">
    245 <h4>Field Access</h4>
     309<h4>MYSQL_FIELD Access</h4>
     310<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field CONN)</dt>
     311<dd>
     312<p>Returns a <code>mysql-field-ptr</code> to the next field, or <code>#f</code>.</p></dd>
     313<dt class="definition"><strong>procedure:</strong> (mysql-fetch-fields CONN)</dt>
     314<dd>
     315<p>Returns a <code>mysql-field-ptr</code> to the first field, or <code>#f</code>.</p></dd>
     316<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-direct CONN MYSQL-FIELD-NUMBER)</dt>
     317<dd>
     318<p>Returns a <code>mysql-field-ptr</code> to a specific field, or <code>#f</code>.</p></dd>
     319<dt class="definition"><strong>procedure:</strong> (mysql-field-slots MYSQL-FIELD-POINTER MYSQL-FIELD-GETTER ...)</dt>
     320<dd>
     321<p>Returns a list of MYSQL_FIELD entry values, from each <tt>MYSQL-FIELD-GETTER</tt>.</p>
     322<p><tt>MYSQL-FIELD-POINTER</tt> is a pointer to a MYSQL_FIELD, or <code>#f</code>. <tt>MYSQL-FIELD-GETTER</tt> is a <code>mysql-field-*</code> reference function.</p></dd>
     323<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-slot-direct CONN FIELD-NUMBER MYSQL-FIELD-GETTER)</dt>
     324<dd>
     325<p>Returns a field slot value. Combines <code>mysql-fetch-field-direct</code> and <code>mysql-field-slots</code>.</p></dd>
     326<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-slot CONN MYSQL-FIELD-GETTER)</dt>
     327<dd>
     328<p>Returns a field slot value. Combines <code>mysql-fetch-field</code> and <code>mysql-field-slots</code>.</p></dd>
     329<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-slots-direct CONN FIELD-NUMBER MYSQL-FIELD-GETTER ...)</dt>
     330<dd>
     331<p>Returns a list of field slot values. Combines <code>mysql-fetch-field-direct</code> and <code>mysql-field-slots</code>.</p></dd>
     332<dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-slots CONN MYSQL-FIELD-GETTER ...)</dt>
     333<dd>
     334<p>Returns a list of field slot values. Combines <code>mysql-fetch-field</code> and <code>mysql-field-slots</code>.</p></dd>
    246335<div class="subsubsection">
    247 <h5>Field Set Access</h5>
    248 <dt class="definition"><strong>procedure:</strong> (mysql-fetch-field-items DB MYSQL-FIELD-GETTER ...)</dt>
    249 <dd>
    250 <p>Returns a list of lists of MYSQL_FIELD entry values, a list for each <tt>MYSQL-FIELD-GETTER</tt>.</p>
    251 <p><tt>MYSQL-FIELD-GETTER</tt> is a <code>mysql-field-*</code> reference function.</p></dd>
    252 <dt class="definition"><strong>procedure:</strong> (*mysql-fetch-field-item MYSQL-FIELD-POINTER FIELD-COUNT MYSQL-FIELD-GETTER)</dt>
    253 <dd>
    254 <p>Returns a <tt>FIELD-COUNT</tt> length list of MYSQL_FIELD entry (object).</p>
    255 <p><tt>MYSQL-FIELD-POINTER</tt> is a pointer to a vector of MYSQL_FIELD. <tt>FIELD-COUNT</tt> is the number of entries in the vector. <tt>MYSQL-FIELD-GETTER</tt> is a <code>mysql-field-*</code> reference function.</p></dd></div>
    256 <div class="subsubsection">
    257 <h5>Field Entry Access</h5>
     336<h5>Slot Getters</h5>
    258337<dt class="definition"><strong>procedure:</strong> (mysql-field-org-name MYSQL-FIELD-POINTER)</dt>
    259338<dd>
     
    270349<dt class="definition"><strong>procedure:</strong> (mysql-field-db MYSQL-FIELD-POINTER)</dt>
    271350<dd>
    272 <p>Returns <code>pointer -&gt; ?</code>.</p></dd>
     351<p>Returns <code>string</code>.</p></dd>
    273352<dt class="definition"><strong>procedure:</strong> (mysql-field-catalog MYSQL-FIELD-POINTER)</dt>
    274353<dd>
    275 <p>Returns <code>pointer -&gt; ?</code>.</p></dd>
     354<p>Returns <code>string</code>.</p></dd>
    276355<dt class="definition"><strong>procedure:</strong> (mysql-field-def MYSQL-FIELD-POINTER)</dt>
    277356<dd>
    278 <p>Returns <code>pointer -&gt; ?</code>.</p></dd>
     357<p>Returns <code>string</code>.</p></dd>
    279358<dt class="definition"><strong>procedure:</strong> (mysql-field-table MYSQL-FIELD-POINTER)</dt>
    280359<dd>
    281 <p>Returns <code>pointer -&gt; ?</code>.</p></dd>
     360<p>Returns <code>string</code>.</p></dd>
    282361<dt class="definition"><strong>procedure:</strong> (mysql-field-type MYSQL-FIELD-POINTER)</dt>
    283362<dd>
     
    320399<p>Returns <code>unsigned-integer</code>.</p></dd></div></div>
    321400<div class="subsection">
    322 <h4>Enumeration Values</h4><table class="symbol-table">enum enum_mysql_set_option
     401<h4>Field Flag Testing</h4>
     402<dt class="definition"><strong>procedure:</strong> (mysql-field-flags-on? MYSQL-FIELD-POINTER MYSQL-FIELD-FLAG ...)</dt>
     403<dd>
     404<p>Does the field, <tt>MYSQL-FIELD-POINTER</tt>, have all of the <tt>MYSQL-FIELD-FLAG ...</tt> set?</p></dd>
     405<dt class="definition"><strong>procedure:</strong> (mysql-field-flags-off? MYSQL-FIELD-POINTER MYSQL-FIELD-FLAG ...)</dt>
     406<dd>
     407<p>Does the field, <tt>MYSQL-FIELD-POINTER</tt>, have all of the <tt>MYSQL-FIELD-FLAG ...</tt> not set?</p></dd>
     408<dt class="definition"><strong>procedure:</strong> (mysql-field-primary-key? MYSQL-FIELD-POINTER)</dt>
     409<dd>
     410<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, a primary key?</p></dd>
     411<dt class="definition"><strong>procedure:</strong> (mysql-field-not-null? MYSQL-FIELD-POINTER)</dt>
     412<dd>
     413<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, not null?</p></dd>
     414<dt class="definition"><strong>procedure:</strong> (mysql-field-binary? MYSQL-FIELD-POINTER)</dt>
     415<dd>
     416<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, binary?</p></dd>
     417<dt class="definition"><strong>procedure:</strong> (mysql-field-numeric? MYSQL-FIELD-POINTER)</dt>
     418<dd>
     419<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, numeric?</p></dd></div>
     420<div class="subsection">
     421<h4>Field Type Testing</h4>
     422<dt class="definition"><strong>procedure:</strong> (mysql-field-type-any? MYSQL-FIELD-POINTER MYSQL-TYPE ...)</dt>
     423<dd>
     424<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type any of <tt>MYSQL-TYPE ...</tt>?</p></dd>
     425<dt class="definition"><strong>procedure:</strong> (mysql-field-type=? MYSQL-FIELD-POINTER MYSQL-TYPE)</dt>
     426<dd>
     427<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, <tt>MYSQL-TYPE</tt>?</p></dd>
     428<dt class="definition"><strong>procedure:</strong> (mysql-field-type-clock? MYSQL-FIELD-POINTER)</dt>
     429<dd>
     430<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type time or date related?</p></dd>
     431<dt class="definition"><strong>procedure:</strong> (mysql-field-type-number? MYSQL-FIELD-POINTER)</dt>
     432<dd>
     433<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type a number?</p></dd>
     434<dt class="definition"><strong>procedure:</strong> (mysql-field-type-blob? MYSQL-FIELD-POINTER)</dt>
     435<dd>
     436<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type some kind of blob?</p></dd>
     437<dt class="definition"><strong>procedure:</strong> (mysql-field-type-string? MYSQL-FIELD-POINTER)</dt>
     438<dd>
     439<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type some kind of string?</p></dd>
     440<dt class="definition"><strong>procedure:</strong> (mysql-field-type-magnitude? MYSQL-FIELD-POINTER)</dt>
     441<dd>
     442<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type some kind of number?</p></dd>
     443<dt class="definition"><strong>procedure:</strong> (mysql-field-type-binary? MYSQL-FIELD-POINTER)</dt>
     444<dd>
     445<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type some kind of binary string or blob?</p></dd>
     446<dt class="definition"><strong>procedure:</strong> (mysql-field-type-text? MYSQL-FIELD-POINTER)</dt>
     447<dd>
     448<p>Is the field, <tt>MYSQL-FIELD-POINTER</tt>, type some kind of non-binary string or blob?</p></dd></div>
     449<div class="subsection">
     450<h4>Character Set Access</h4>
     451<dt class="definition"><strong>procedure:</strong> (mysql-set-character-set CONN CHARACTER-SET-NAME)</dt>
     452<dd>
     453<p>Sets the current character set.</p></dd>
     454<dt class="definition"><strong>procedure:</strong> (mysql-character-set-name CONN)</dt>
     455<dd>
     456<p>Returns a <tt>string</tt>.</p></dd>
     457<dt class="definition"><strong>procedure:</strong> (mysql-get-character-set-info CONN)</dt>
     458<dd>
     459<p>Returns a <tt>MY-CHARSET-INFO-POINTER</tt>.</p></dd>
     460<div class="subsubsection">
     461<h5>Slot Getters</h5>
     462<dt class="definition"><strong>procedure:</strong> (my-charset-info-name MY-CHARSET-INFO-POINTER)</dt>
     463<dd>
     464<p>Return a <code>string</code>.</p></dd>
     465<dt class="definition"><strong>procedure:</strong> (my-charset-info-csname MY-CHARSET-INFO-POINTER)</dt>
     466<dd>
     467<p>Return a <code>string</code>.</p></dd>
     468<dt class="definition"><strong>procedure:</strong> (my-charset-info-comment MY-CHARSET-INFO-POINTER)</dt>
     469<dd>
     470<p>Return a <code>string</code>.</p></dd>
     471<dt class="definition"><strong>procedure:</strong> (my-charset-info-dir MY-CHARSET-INFO-POINTER)</dt>
     472<dd>
     473<p>Return a <code>string</code>.</p></dd>
     474<dt class="definition"><strong>procedure:</strong> (my-charset-info-mbminlen MY-CHARSET-INFO-POINTER)</dt>
     475<dd>
     476<p>Return a <code>number</code>.</p></dd>
     477<dt class="definition"><strong>procedure:</strong> (my-charset-info-mbmaxlen MY-CHARSET-INFO-POINTER)</dt>
     478<dd>
     479<p>Return a <code>number</code>.</p></dd></div></div>
     480<div class="subsection">
     481<h4>Miscellaneous Procedures</h4>
     482<dt class="definition"><strong>procedure:</strong> (mysql-change-user CONN [KEYWORD ...])</dt>
     483<dd>
     484<p>Changes the user identity.</p>
     485<p>Any number of the following <tt>KEYWORD ...</tt> may be included:
     486<ul>
     487<li><tt>user</tt></li>
     488<li><tt>passwd</tt></li>
     489<li><tt>db</tt></li></ul></p></dd>
     490<dt class="definition"><strong>procedure:</strong> (mysql-debug DEBUG)</dt>
     491<dd>
     492<p>.</p></dd>
     493<dt class="definition"><strong>procedure:</strong> (mysql-dump-debug-info CONN)</dt>
     494<dd>
     495<p>.</p></dd>
     496<dt class="definition"><strong>procedure:</strong> (mysql-errno CONN)</dt>
     497<dd>
     498<p>.</p></dd>
     499<dt class="definition"><strong>procedure:</strong> (mysql-error CONN)</dt>
     500<dd>
     501<p>Returns a string describing the last mysql error, or #f if no error has occurred.</p></dd>
     502<dt class="definition"><strong>procedure:</strong> (mysql-escape-string CONN SQL)</dt>
     503<dd>
     504<p>Returns an escape encoded form of the <tt>SQL</tt> string.</p></dd>
     505<dt class="definition"><strong>procedure:</strong> (mysql-free-result CONN)</dt>
     506<dd>
     507<p>.</p></dd>
     508<dt class="definition"><strong>procedure:</strong> (mysql-get-client-info)</dt>
     509<dd>
     510<p>.</p></dd>
     511<dt class="definition"><strong>procedure:</strong> (mysql-get-client-version)</dt>
     512<dd>
     513<p>.</p></dd>
     514<dt class="definition"><strong>procedure:</strong> (mysql-get-host-info CONN)</dt>
     515<dd>
     516<p>.</p></dd>
     517<dt class="definition"><strong>procedure:</strong> (mysql-get-proto-info CONN)</dt>
     518<dd>
     519<p>.</p></dd>
     520<dt class="definition"><strong>procedure:</strong> (mysql-get-server-info CONN)</dt>
     521<dd>
     522<p>.</p></dd>
     523<dt class="definition"><strong>procedure:</strong> (mysql-get-server-version CONN)</dt>
     524<dd>
     525<p>.</p></dd>
     526<dt class="definition"><strong>procedure:</strong> (mysql-info CONN)</dt>
     527<dd>
     528<p>.</p></dd>
     529<dt class="definition"><strong>procedure:</strong> (mysql-insert-id CONN)</dt>
     530<dd>
     531<p>.</p></dd>
     532<dt class="definition"><strong>procedure:</strong> (mysql-kill CONN PID)</dt>
     533<dd>
     534<p>.</p></dd>
     535<dt class="definition"><strong>procedure:</strong> (mysql-list-dbs CONN LIKE)</dt>
     536<dd>
     537<p>.</p></dd>
     538<dt class="definition"><strong>procedure:</strong> (mysql-list-fields CONN TABLE WILD)</dt>
     539<dd>
     540<p>.</p></dd>
     541<dt class="definition"><strong>procedure:</strong> (mysql-list-processes CONN)</dt>
     542<dd>
     543<p>.</p></dd>
     544<dt class="definition"><strong>procedure:</strong> (mysql-list-tables CONN WILD)</dt>
     545<dd>
     546<p>.</p></dd>
     547<dt class="definition"><strong>procedure:</strong> (mysql-num-fields CONN)</dt>
     548<dd>
     549<p>.</p></dd>
     550<dt class="definition"><strong>procedure:</strong> (mysql-num-rows CONN)</dt>
     551<dd>
     552<p>.</p></dd>
     553<dt class="definition"><strong>procedure:</strong> (mysql-ping CONN)</dt>
     554<dd>
     555<p>.</p></dd>
     556<dt class="definition"><strong>procedure:</strong> (mysql-select-db CONN DB)</dt>
     557<dd>
     558<p>Returns <code>#t</code> if the select was successful, signals exception otherwise.</p></dd>
     559<dt class="definition"><strong>procedure:</strong> (mysql-stat CONN)</dt>
     560<dd>
     561<p>.</p></dd>
     562<dt class="definition"><strong>procedure:</strong> (mysql-store-result CONN)</dt>
     563<dd>
     564<p>.</p></dd>
     565<dt class="definition"><strong>procedure:</strong> (mysql-thread-id CONN)</dt>
     566<dd>
     567<p>.</p></dd></div>
     568<div class="subsection">
     569<h4>Enumerations &amp; Flags</h4>
     570<div class="subsubsection">
     571<h5>Client Flags</h5>
     572<p><table class="symbol-table">Symbolic Value
     573<tr>
     574<td class="symbol">client-compress</td>
     575<td>CLIENT_COMPRESS</td></tr>
     576<tr>
     577<td class="symbol">client-found-rows</td>
     578<td>CLIENT_FOUND_ROWS</td></tr>
     579<tr>
     580<td class="symbol">client-ignore-sigpipe</td>
     581<td>CLIENT_IGNORE_SIGPIPE</td></tr>
     582<tr>
     583<td class="symbol">client-ignore-space</td>
     584<td>CLIENT_IGNORE_SPACE</td></tr>
     585<tr>
     586<td class="symbol">client-interactive</td>
     587<td>CLIENT_INTERACTIVE</td></tr>
     588<tr>
     589<td class="symbol">client-local-files</td>
     590<td>CLIENT_LOCAL_FILES</td></tr>
     591<tr>
     592<td class="symbol">client-multi-results</td>
     593<td>CLIENT_MULTI_RESULTS</td></tr>
     594<tr>
     595<td class="symbol">client-multi-statements</td>
     596<td>CLIENT_MULTI_STATEMENTS</td></tr>
     597<tr>
     598<td class="symbol">client-no-schema</td>
     599<td>CLIENT_NO_SCHEMA</td></tr>
     600<tr>
     601<td class="symbol">client-odbc</td>
     602<td>CLIENT_ODBC</td></tr>
     603<tr>
     604<td class="symbol">client-ssl</td>
     605<td>CLIENT_SSL</td></tr></table></p>
     606<dt class="definition"><strong>procedure:</strong> (mysql-client-flags-value SYMBOL ...)</dt>
     607<dd>
     608<p>Returns the or'ed value of the <tt>SYMBOL ...</tt> values.</p></dd>
     609<dt class="definition"><strong>procedure:</strong> (mysql-client-flags-symbol NUMBER)</dt>
     610<dd>
     611<p>Returns the symbol for the <tt>NUMBER</tt>.</p></dd></div>
     612<div class="subsubsection">
     613<h5>enum enum_mysql_set_option</h5>
     614<p><table class="symbol-table">Symbolic Value
    323615<tr>
    324616<td class="symbol">mysql-option-multi-statements-on</td>
    325 <td></td></tr>
     617<td>MYSQL_OPTION_MULTI_STATEMENTS_ON</td></tr>
    326618<tr>
    327619<td class="symbol">mysql-option-multi-statements-off</td>
    328 <td></td></tr></table><table class="symbol-table">enum mysql_option
     620<td>MYSQL_OPTION_MULTI_STATEMENTS_OFF</td></tr></table></p>
     621<dt class="definition"><strong>procedure:</strong> (mysql-server-option-value SYMBOL ...)</dt>
     622<dd>
     623<p>Returns the or'ed value of the <tt>SYMBOL ...</tt> values.</p></dd>
     624<dt class="definition"><strong>procedure:</strong> (mysql-server-option-symbol NUMBER)</dt>
     625<dd>
     626<p>Returns the symbol for the <tt>NUMBER</tt>.</p></dd></div>
     627<div class="subsubsection">
     628<h5>enum mysql_option</h5>
     629<p><table class="symbol-table">Symbolic Value
    329630<tr>
    330631<td class="symbol">mysql-opt-connect-timeout</td>
    331 <td></td></tr>
     632<td>MYSQL_OPT_CONNECT_TIMEOUT</td></tr>
    332633<tr>
    333634<td class="symbol">mysql-opt-compress</td>
    334 <td></td></tr>
     635<td>MYSQL_OPT_COMPRESS</td></tr>
    335636<tr>
    336637<td class="symbol">mysql-opt-named-pipe</td>
    337 <td></td></tr>
     638<td>MYSQL_OPT_NAMED_PIPE</td></tr>
    338639<tr>
    339640<td class="symbol">mysql-init-command</td>
    340 <td></td></tr>
     641<td>MYSQL_INIT_COMMAND</td></tr>
    341642<tr>
    342643<td class="symbol">mysql-read-default-file</td>
    343 <td></td></tr>
     644<td>MYSQL_READ_DEFAULT_FILE</td></tr>
    344645<tr>
    345646<td class="symbol">mysql-read-default-group</td>
    346 <td></td></tr>
     647<td>MYSQL_READ_DEFAULT_GROUP</td></tr>
    347648<tr>
    348649<td class="symbol">mysql-set-charset-dir</td>
    349 <td></td></tr>
     650<td>MYSQL_SET_CHARSET_DIR</td></tr>
    350651<tr>
    351652<td class="symbol">mysql-set-charset-name</td>
    352 <td></td></tr>
     653<td>MYSQL_SET_CHARSET_NAME</td></tr>
    353654<tr>
    354655<td class="symbol">mysql-opt-local-infile</td>
    355 <td></td></tr>
     656<td>MYSQL_OPT_LOCAL_INFILE</td></tr>
    356657<tr>
    357658<td class="symbol">mysql-opt-protocol</td>
    358 <td></td></tr>
     659<td>MYSQL_OPT_PROTOCOL</td></tr>
    359660<tr>
    360661<td class="symbol">mysql-shared-memory-base-name</td>
    361 <td></td></tr>
     662<td>MYSQL_SHARED_MEMORY_BASE_NAME</td></tr>
    362663<tr>
    363664<td class="symbol">mysql-opt-read-timeout</td>
    364 <td></td></tr>
     665<td>MYSQL_OPT_READ_TIMEOUT</td></tr>
    365666<tr>
    366667<td class="symbol">mysql-opt-write-timeout</td>
    367 <td></td></tr>
     668<td>MYSQL_OPT_WRITE_TIMEOUT</td></tr>
    368669<tr>
    369670<td class="symbol">mysql-opt-use-result</td>
    370 <td></td></tr>
     671<td>MYSQL_OPT_USE_RESULT</td></tr>
    371672<tr>
    372673<td class="symbol">mysql-opt-use-remote-connection</td>
    373 <td></td></tr>
     674<td>MYSQL_OPT_USE_REMOTE_CONNECTION</td></tr>
    374675<tr>
    375676<td class="symbol">mysql-opt-use-embedded-connection</td>
    376 <td></td></tr>
     677<td>MYSQL_OPT_USE_EMBEDDED_CONNECTION</td></tr>
    377678<tr>
    378679<td class="symbol">mysql-opt-guess-connection</td>
    379 <td></td></tr>
     680<td>MYSQL_OPT_GUESS_CONNECTION</td></tr>
    380681<tr>
    381682<td class="symbol">mysql-set-client-ip</td>
    382 <td></td></tr>
     683<td>MYSQL_SET_CLIENT_IP</td></tr>
    383684<tr>
    384685<td class="symbol">mysql-secure-auth</td>
    385 <td></td></tr>
     686<td>MYSQL_SECURE_AUTH</td></tr>
    386687<tr>
    387688<td class="symbol">mysql-report-data-truncation</td>
    388 <td></td></tr></table><table class="symbol-table">enum enum_field_types
     689<td>MYSQL_REPORT_DATA_TRUNCATION</td></tr></table></p>
     690<dt class="definition"><strong>procedure:</strong> (mysql-option-value SYMBOL ...)</dt>
     691<dd>
     692<p>Returns the or'ed value of the <tt>SYMBOL ...</tt> values.</p></dd>
     693<dt class="definition"><strong>procedure:</strong> (mysql-option-symbol NUMBER)</dt>
     694<dd>
     695<p>Returns the symbol for the <tt>NUMBER</tt>.</p></dd></div>
     696<div class="subsubsection">
     697<h5>enum enum_field_types</h5>
     698<p><table class="symbol-table">Symbolic Value
    389699<tr>
    390700<td class="symbol">mysql-type-decimal</td>
    391 <td></td></tr>
     701<td>MYSQL_TYPE_DECIMAL</td></tr>
    392702<tr>
    393703<td class="symbol">mysql-type-tiny</td>
    394 <td></td></tr>
     704<td>MYSQL_TYPE_TINY</td></tr>
    395705<tr>
    396706<td class="symbol">mysql-type-short</td>
    397 <td></td></tr>
     707<td>MYSQL_TYPE_SHORT</td></tr>
    398708<tr>
    399709<td class="symbol">mysql-type-long</td>
    400 <td></td></tr>
     710<td>MYSQL_TYPE_LONG</td></tr>
    401711<tr>
    402712<td class="symbol">mysql-type-float</td>
    403 <td></td></tr>
     713<td>MYSQL_TYPE_FLOAT</td></tr>
    404714<tr>
    405715<td class="symbol">mysql-type-double</td>
    406 <td></td></tr>
     716<td>MYSQL_TYPE_DOUBLE</td></tr>
    407717<tr>
    408718<td class="symbol">mysql-type-null</td>
    409 <td></td></tr>
     719<td>MYSQL_TYPE_NULL</td></tr>
    410720<tr>
    411721<td class="symbol">mysql-type-timestamp</td>
    412 <td></td></tr>
     722<td>MYSQL_TYPE_TIMESTAMP</td></tr>
    413723<tr>
    414724<td class="symbol">mysql-type-longlong</td>
    415 <td></td></tr>
     725<td>MYSQL_TYPE_LONGLONG</td></tr>
    416726<tr>
    417727<td class="symbol">mysql-type-int24</td>
    418 <td></td></tr>
     728<td>MYSQL_TYPE_INT24</td></tr>
    419729<tr>
    420730<td class="symbol">mysql-type-date</td>
    421 <td></td></tr>
     731<td>MYSQL_TYPE_DATE</td></tr>
    422732<tr>
    423733<td class="symbol">mysql-type-time</td>
    424 <td></td></tr>
     734<td>MYSQL_TYPE_TIME</td></tr>
    425735<tr>
    426736<td class="symbol">mysql-type-datetime</td>
    427 <td></td></tr>
     737<td>MYSQL_TYPE_DATETIME</td></tr>
    428738<tr>
    429739<td class="symbol">mysql-type-year</td>
    430 <td></td></tr>
     740<td>MYSQL_TYPE_YEAR</td></tr>
    431741<tr>
    432742<td class="symbol">mysql-type-newdate</td>
    433 <td></td></tr>
     743<td>MYSQL_TYPE_NEWDATE</td></tr>
    434744<tr>
    435745<td class="symbol">mysql-type-varchar</td>
    436 <td></td></tr>
     746<td>MYSQL_TYPE_VARCHAR</td></tr>
    437747<tr>
    438748<td class="symbol">mysql-type-bit</td>
    439 <td></td></tr>
     749<td>MYSQL_TYPE_BIT</td></tr>
    440750<tr>
    441751<td class="symbol">mysql-type-newdecimal</td>
    442 <td></td></tr>
     752<td>MYSQL_TYPE_NEWDECIMAL</td></tr>
    443753<tr>
    444754<td class="symbol">mysql-type-enum</td>
    445 <td></td></tr>
     755<td>MYSQL_TYPE_ENUM</td></tr>
    446756<tr>
    447757<td class="symbol">mysql-type-set</td>
    448 <td></td></tr>
     758<td>MYSQL_TYPE_SET</td></tr>
    449759<tr>
    450760<td class="symbol">mysql-type-tiny-blob</td>
    451 <td></td></tr>
     761<td>MYSQL_TYPE_TINY_BLOB</td></tr>
    452762<tr>
    453763<td class="symbol">mysql-type-medium-blob</td>
    454 <td></td></tr>
     764<td>MYSQL_TYPE_MEDIUM_BLOB</td></tr>
    455765<tr>
    456766<td class="symbol">mysql-type-long-blob</td>
    457 <td></td></tr>
     767<td>MYSQL_TYPE_LONG_BLOB</td></tr>
    458768<tr>
    459769<td class="symbol">mysql-type-blob</td>
    460 <td></td></tr>
     770<td>MYSQL_TYPE_BLOB</td></tr>
    461771<tr>
    462772<td class="symbol">mysql-type-var-string</td>
    463 <td></td></tr>
     773<td>MYSQL_TYPE_VAR_STRING</td></tr>
    464774<tr>
    465775<td class="symbol">mysql-type-string</td>
    466 <td></td></tr>
     776<td>MYSQL_TYPE_STRING</td></tr>
    467777<tr>
    468778<td class="symbol">mysql-type-geometry</td>
    469 <td></td></tr></table></div></div>
     779<td>MYSQL_TYPE_GEOMETRY</td></tr></table></p>
     780<dt class="definition"><strong>procedure:</strong> (mysql-type-value SYMBOL ...)</dt>
     781<dd>
     782<p>Returns the or'ed value of the <tt>SYMBOL ...</tt> values.</p></dd>
     783<dt class="definition"><strong>procedure:</strong> (mysql-type-symbol NUMBER)</dt>
     784<dd>
     785<p>Returns the symbol for the <tt>NUMBER</tt>.</p></dd></div>
     786<div class="subsubsection">
     787<h5>MYSQL_FIELD.flags Flags</h5>
     788<p><table class="symbol-table">Symbolic Value
     789<tr>
     790<td class="symbol">not-null-flag</td>
     791<td>NOT-NULL-FLAG</td></tr>
     792<tr>
     793<td class="symbol">pri-key-flag</td>
     794<td>PRI-KEY-FLAG</td></tr>
     795<tr>
     796<td class="symbol">unique-key-flag</td>
     797<td>UNIQUE-KEY-FLAG</td></tr>
     798<tr>
     799<td class="symbol">multiple-key-flag</td>
     800<td>MULTIPLE-KEY-FLAG</td></tr>
     801<tr>
     802<td class="symbol">unsigned-flag</td>
     803<td>UNSIGNED-FLAG</td></tr>
     804<tr>
     805<td class="symbol">zerofill-flag</td>
     806<td>ZEROFILL-FLAG</td></tr>
     807<tr>
     808<td class="symbol">binary-flag</td>
     809<td>BINARY-FLAG</td></tr>
     810<tr>
     811<td class="symbol">auto-increment-flag</td>
     812<td>AUTO-INCREMENT-FLAG</td></tr>
     813<tr>
     814<td class="symbol">no-default-value-flag</td>
     815<td>NO-DEFAULT-VALUE-FLAG</td></tr></table></p>
     816<dt class="definition"><strong>procedure:</strong> (mysql-field-flags-value SYMBOL ...)</dt>
     817<dd>
     818<p>Returns the or'ed value of the <tt>SYMBOL ...</tt> values.</p></dd>
     819<dt class="definition"><strong>procedure:</strong> (mysql-field-flags-symbol NUMBER)</dt>
     820<dd>
     821<p>Returns the symbol for the <tt>NUMBER</tt>.</p></dd></div></div></div>
    470822<div class="section">
    471823<h3>Examples</h3>
     
    476828(let [(db (mysql-connect host: &quot;mysql.example.com&quot; user: &quot;example&quot;
    477829                         passwd: &quot;secret&quot;))]
    478   (if (not db) (error (conc &quot;MySQL connection failed: &quot; (mysql-error db))))
    479830  (mysql-query db &quot;SHOW DATABASES&quot;)
    480831  (do [(row (mysql-fetch-row db) (mysql-fetch-row db))]
     
    487838(let [(db (mysql-connect host: &quot;mysql.example.com&quot; user: &quot;example&quot;
    488839                         passwd: &quot;secret&quot;))]
    489   (if (not db) (error (conc &quot;MySQL connection failed: &quot; (mysql-error db))))
    490840  (mysql-query-foreach db &quot;SHOW DATABASES&quot;
    491841                       (lambda (row idx)
     
    494844<div class="section">
    495845<h3>Data Type Conversion</h3>
    496 <p>All MySQL result data (except NULL) are returned as Scheme strings. The NULL value is represented by <tt>#f</tt>. Booleans are expressed as Scheme strings <tt>&quot;1&quot;</tt> and <tt>&quot;0&quot;</tt>. All remaining types, including numeric types and strings are returned as Scheme strings.</p></div>
     846<p>All MySQL result data (except NULL) are returned as Scheme strings.</p>
     847<p>The NULL value is represented by <tt>#f</tt>.</p>
     848<p>Booleans are expressed as the Scheme strings <tt>&quot;1&quot;</tt> and <tt>&quot;0&quot;</tt>.</p>
     849<p>All remaining types, including numeric types, blobs, and strings are returned as Scheme strings.</p></div>
    497850<div class="section">
    498851<h3>Bugs</h3>
     852<p>No prepared statement support.</p>
    499853<p>This is alpha quality software. Only very basic functionality has been tested so far. I look forward to providing a more complete test suite (and probably a slew of bugfixes) with the next release.</p>
    500 <p>Does not return native types.</p>
    501854<p><tt>mysql-escape-string</tt> is broken when it's used for binary data.</p>
    502 <p>Not yet sure how to handle <tt>unsigned long *</tt> for <tt>foreign-mysql-fetch-lengths</tt>.</p>
    503 <p><tt>foreign-mysql-get-charset-info</tt> isn't yet supported.</p>
    504855<p>I need to nail down the supported libmysqlclient versions. Right now there are some functions I've put off because they may or may not be supported in my target range. We'll see, soon...</p></div>
    505856<div class="section">
  • release/3/mysql/trunk/mysql.scm

    r7942 r7943  
    119119  (bound-to-procedure
    120120    mysql-error
    121     mysql-field-binary? )
     121    mysql-field-type-binary? )
    122122  (export
    123123    ;; direct api
     
    835835
    836836;-----------------------------------------------------------------------
     837; Foreign function definitions for mysqlaux functions.
     838;
     839
     840#>
     841static int
     842mysqlaux_field_index (MYSQL_RES *result, const char *name, unsigned int num_fields)
     843{
     844  MYSQL_FIELD *fields = mysql_fetch_fields (result);
     845  unsigned int i;
     846
     847  for (i = 0; i < num_fields; i++) {
     848    if (0 == strcasecmp (name, fields[i].name)) {
     849      return (i);
     850    }
     851  }
     852
     853  return (-1);
     854}
     855
     856static char *
     857mysqlaux_fetch_column_data_direct (MYSQL_RES *result, MYSQL_ROW row, unsigned int fldidx, int *binflg)
     858{
     859  MYSQL_FIELD *fields = mysql_fetch_fields (result);
     860
     861  switch (fields[fldidx].type) {
     862    case MYSQL_TYPE_VARCHAR:
     863    case MYSQL_TYPE_TINY_BLOB:
     864    case MYSQL_TYPE_MEDIUM_BLOB:
     865    case MYSQL_TYPE_LONG_BLOB:
     866    case MYSQL_TYPE_BLOB:
     867    case MYSQL_TYPE_VAR_STRING:
     868    case MYSQL_TYPE_STRING:
     869      *binflg = 1;
     870      break;
     871    default:
     872      *binflg = 0;
     873      break;
     874  }
     875  *binflg &= (63 == fields[fldidx].charsetnr);
     876
     877  return (((MYSQL_ROW)row)[fldidx]);
     878}
     879<#
     880
     881(define foreign-mysqlaux-field-index
     882  (foreign-lambda int "mysqlaux_field_index" mysql-res-ptr nonnull-c-string unsigned-integer) )
     883
     884(define foreign-mysqlaux-fetch-column-data-direct
     885  (foreign-lambda c-pointer "mysqlaux_fetch_column_data_direct"
     886                            mysql-res-ptr mysql-row
     887                            unsigned-integer
     888                            (nonnull-c-pointer int)) )
     889
     890;-----------------------------------------------------------------------
    837891; Foreign function definitions from MySQL C API.
    838892;
     
    11651219  (foreign-lambda integer "mysql_next_result" mysql-ptr))
    11661220
    1167 ;-----------------------------------------------------------------------
    1168 ; Foreign function definitions for mysqlaux functions.
    1169 ;
    1170 
    1171 #>
    1172 static int
    1173 mysqlaux_field_index (MYSQL *mysql, MYSQL_RES *result, const char *name)
    1174 {
    1175   unsigned int num_fields = mysql_field_count(mysql);
    1176   MYSQL_FIELD *fields = mysql_fetch_fields(result);
    1177   unsigned int i;
    1178 
    1179   for (i = 0; i < num_fields; i++) {
    1180     if (0 == strcasecmp (name, fields[i].name)) {
    1181       return (i);
    1182     }
    1183   }
    1184 
    1185   return (-1);
    1186 }
    1187 <#
    1188 
    1189 ; int mysqlaux_field_index (MYSQL *mysql, MYSQL_RES *result, const char *name)
    1190 (define foreign-mysqlaux-field-index
    1191   (foreign-lambda int "mysqlaux_field_index" mysql-ptr mysql-res-ptr nonnull-c-string) )
    1192 
    1193 ; char *mysqlaux_fetch_column_direct(MYSQL_ROW, unsigned int);
    1194 (define foreign-mysqlaux-fetch-column-direct
    1195   (foreign-lambda* c-pointer ((mysql-row row) (unsigned-integer idx))
    1196     "return (((MYSQL_ROW)row)[idx]);") )
    1197 
    1198 ;
    1199 (define (%mysql-get-field-index connptr resptr field)
    1200   (if (number? field)
    1201       field
    1202       (foreign-mysqlaux-field-index connptr resptr (->string field)) ) )
    1203 
    12041221;=======================================================================
    12051222; Provided Scheme API.
     
    12161233      "") )
    12171234
    1218 (define foreign-char-pointer->string
    1219   (foreign-lambda* c-string ((nonnull-c-pointer chrptr))
    1220     "return ((char *) chrptr);") )
    1221 
    12221235(define (foreign-unsigned-long-pointer->u32vector ulptr cnt)
    12231236  (let* ([siz (* cnt UNSIGNED-LONG-SIZE)]
     
    12261239    (blob->u32vector/shared store) ) )
    12271240
    1228 (define foreign-char-pointer->string
     1241(define char-pointer->string
    12291242  (foreign-lambda* c-string ((c-pointer chrptr))
    12301243    "return ((char *) chrptr);") )
    12311244
    1232 (define (foreign-binary-char-pointer->string chrptr size)
     1245(define (binary-char-pointer->string chrptr size)
    12331246  (let ([blob (make-blob size)])
    12341247    (move-memory! chrptr blob size)
    12351248    (blob->string blob) ) )
     1249
     1250(define (%mysql-get-field-index resptr field fldcnt)
     1251  (let ([fldidx (if (number? field)
     1252                    field
     1253                    (foreign-mysqlaux-field-index resptr
     1254                                                  (->string field) fldcnt))])
     1255    (and (<= 0 fldidx) (< fldidx fldcnt)
     1256         fldidx ) ) )
    12361257
    12371258;-----------------------------------------------------------------------
     
    14621483      "    (void) mysql_real_escape_string (mysql, *((char **) to), from, length);\n"
    14631484      "}")
    1464      (location escstr)
     1485     #$escstr
    14651486     str (string-length str))
    14661487    escstr ) )
     
    15091530           [fldlens (%mysql-fetch-lengths resptr fldcnt)])
    15101531      (lambda (field)
    1511         (let ([fldidx (%mysql-get-field-index connptr resptr field)])
    1512           (and (<= 0 fldidx) (< fldidx fldcnt)
    1513                (let ([chrptr (foreign-mysqlaux-fetch-column-direct resptr fldidx)])
    1514                   (if (mysql-field-binary? (foreign-mysql-fetch-field-direct resptr fldidx))
    1515                       (foreign-binary-char-pointer->string
    1516                        chrptr (u32vector-ref fldlens fldidx))
    1517                       (foreign-char-pointer->string chrptr) ) ) ) ) ) ) ) )
     1532        (and-let* ([fldidx (%mysql-get-field-index resptr field fldcnt)])
     1533          (let-location ([binary-flag bool])
     1534            (and-let* ([datptr (foreign-mysqlaux-fetch-column-data-direct resptr row fldidx #$binary-flag)])
     1535              (if binary-flag
     1536                  (binary-char-pointer->string datptr (u32vector-ref fldlens fldidx))
     1537                  (char-pointer->string datptr) ) ) ) ) ) ) ) )
    15181538
    15191539(define (mysql-field-count conn)
     
    17221742
    17231743(define (mysql-field-flags-mask flags)
    1724   (apply mysql-field-flags-value flags) )
     1744  (apply bitwise-ior flags) )
    17251745
    17261746;;
     
    17351755;;
    17361756
    1737 (define (mysql-field-type-any? fldptr types)
     1757(define (mysql-field-type-any? fldptr . types)
    17381758  (memv (mysql-field-type fldptr) types) )
    17391759
     
    17621782                        mysql-type-newdate mysql-type-year)])
    17631783    (lambda (fldptr)
    1764       (mysql-field-type-any? fldptr numtypes) ) ) )
     1784      (apply mysql-field-type-any? fldptr numtypes) ) ) )
    17651785
    17661786; note - not the same as the "IS_NUM" macro.
     
    17711791                        mysql-type-newdecimal)])
    17721792    (lambda (fldptr)
    1773       (mysql-field-type-any? fldptr numtypes) ) ) )
     1793      (apply mysql-field-type-any? fldptr numtypes) ) ) )
    17741794
    17751795(define mysql-field-type-blob?
     
    17771797                         mysql-type-long-blob mysql-type-blob)])
    17781798    (lambda (fldptr)
    1779       (mysql-field-type-any? fldptr blobtypes) ) ) )
     1799      (apply mysql-field-type-any? fldptr blobtypes) ) ) )
    17801800
    17811801(define mysql-field-type-string?
     
    17831803                        mysql-type-string)])
    17841804    (lambda (fldptr)
    1785       (mysql-field-type-any? fldptr numtypes) ) ) )
     1805      (apply mysql-field-type-any? fldptr numtypes) ) ) )
    17861806
    17871807;;
     
    17921812    (lambda (fldptr)
    17931813      (or (mysql-field-type-number? fldptr)
    1794           (mysql-field-type-any? fldptr magtypes) ) ) ) )
     1814          (apply mysql-field-type-any? fldptr magtypes) ) ) ) )
    17951815
    17961816(define (mysql-field-type-binary? fldptr)
     
    18331853; returns a field pointer or #f.
    18341854(define (mysql-fetch-field-specific conn field)
    1835   (and-let* ([resptr (mysql-connection-result conn)])
    1836     (let ([fldidx (%mysql-get-field-index (mysql-connection-ptr conn) resptr field)]
    1837           [fldcnt (foreign-mysql-num-fields resptr)])
    1838       (and (<= 0 fldcnt) (< fldidx fldcnt)
    1839            (foreign-mysql-fetch-field-direct resptr fldidx) ) ) ) )
    1840 
    1841 #|
    1842 ;-----------------------------------------------------------------------
    1843 ; The MySQL row field value string form conversion
    1844 ;
    1845 
    1846 (define (chrbuf2obj-string->number _ x) (string->number x))
    1847 (define (chrbuf2obj-string->blob _ x) (string->blob x))
    1848 (define (chrbuf2obj-identity _ x) (identity x))
    1849 
    1850 (define *character-buffer->object*
    1851   `(
    1852         (((,mysql-field-type=? ,mysql-type-null))
    1853                   (,chrbuf2obj-identity))
    1854 
    1855         (((,mysql-field-type=? ,mysql-type-bit))
    1856                   (,chrbuf2obj-identity))
    1857         (((,mysql-field-type=? ,mysql-type-enum))
    1858                   (,chrbuf2obj-identity))
    1859         (((,mysql-field-type=? ,mysql-type-set))
    1860                   (,chrbuf2obj-identity))
    1861         (((,mysql-field-type=? ,mysql-type-geometry))
    1862                   (,chrbuf2obj-identity))
    1863 
    1864         (((,mysql-field-type=? ,mysql-type-decimal))
    1865                         (,chrbuf2obj-string->number))
    1866         (((,mysql-field-type=? ,mysql-type-tiny))
    1867                         (,chrbuf2obj-string->number))
    1868         (((,mysql-field-type=? ,mysql-type-short))
    1869                         (,chrbuf2obj-string->number))
    1870         (((,mysql-field-type=? ,mysql-type-long))
    1871                         (,chrbuf2obj-string->number))
    1872         (((,mysql-field-type=? ,mysql-type-float))
    1873                         (,chrbuf2obj-string->number))
    1874         (((,mysql-field-type=? ,mysql-type-double))
    1875                         (,chrbuf2obj-string->number))
    1876         (((,mysql-field-type=? ,mysql-type-longlong))
    1877                         (,chrbuf2obj-string->number))
    1878         (((,mysql-field-type=? ,mysql-type-int24))
    1879                         (,chrbuf2obj-string->number))
    1880         (((,mysql-field-type=? ,mysql-type-newdecimal))
    1881                         (,chrbuf2obj-string->number))
    1882 
    1883         (((,mysql-field-type=? ,mysql-type-timestamp))
    1884                   (,chrbuf2obj-identity))
    1885         (((,mysql-field-type=? ,mysql-type-date))
    1886                   (,chrbuf2obj-identity))
    1887         (((,mysql-field-type=? ,mysql-type-time))
    1888                   (,chrbuf2obj-identity))
    1889         (((,mysql-field-type=? ,mysql-type-datetime))
    1890                   (,chrbuf2obj-identity))
    1891         (((,mysql-field-type=? ,mysql-type-year))
    1892                   (,chrbuf2obj-identity))
    1893         (((,mysql-field-type=? ,mysql-type-newdate))
    1894                   (,chrbuf2obj-identity))
    1895 
    1896         (((,mysql-field-type=? ,mysql-type-tiny-blob) (,mysql-field-binary?))
    1897                   (,chrbuf2obj-string->blob))
    1898         (((,mysql-field-type=? ,mysql-type-medium-blob) (,mysql-field-binary?))
    1899                   (,chrbuf2obj-string->blob))
    1900         (((,mysql-field-type=? ,mysql-type-long-blob) (,mysql-field-binary?))
    1901                   (,chrbuf2obj-string->blob))
    1902         (((,mysql-field-type=? ,mysql-type-blob) (,mysql-field-binary?))
    1903                   (,chrbuf2obj-string->blob))
    1904 
    1905         (((,mysql-field-type=? ,mysql-type-varchar) (,mysql-field-binary?))
    1906                   (,chrbuf2obj-string->blob))
    1907     (((,mysql-field-type=? ,mysql-type-var-string) (,mysql-field-binary?))
    1908                   (,chrbuf2obj-string->blob))
    1909         (((,mysql-field-type=? ,mysql-type-string) (,mysql-field-binary?))
    1910                   (,chrbuf2obj-string->blob))
    1911 
    1912         (((,mysql-field-type=? ,mysql-type-tiny-blob))
    1913                         (,chrbuf2obj-identity))
    1914         (((,mysql-field-type=? ,mysql-type-medium-blob))
    1915                         (,chrbuf2obj-identity))
    1916         (((,mysql-field-type=? ,mysql-type-long-blob))
    1917                         (,chrbuf2obj-identity))
    1918         (((,mysql-field-type=? ,mysql-type-blob))
    1919                         (,chrbuf2obj-identity))
    1920 
    1921         (((,mysql-field-type=? ,mysql-type-varchar))
    1922                         (,chrbuf2obj-identity))
    1923         (((,mysql-field-type=? ,mysql-type-var-string))
    1924                         (,chrbuf2obj-identity))
    1925         (((,mysql-field-type=? ,mysql-type-string))
    1926                         (,chrbuf2obj-identity))
    1927   ) )
    1928 
    1929 (define (call-with-template obj def)
    1930   (apply (car def) obj (cdr def)) )
    1931 
    1932 (define (test-with-templates obj defs)
    1933   (every (cut call-with-template obj <>) defs) )
    1934 
    1935 ; returns field object value for the string form.
    1936 (define (mysql-field-string-form->object fldptr str)
    1937   (let ([def (find (lambda (def) (test-with-templates fldptr (first def)))
    1938                    *character-buffer->object*)])
    1939     (if def
    1940         (call-with-template fldptr (append (second def) `(,str)))
    1941         (signal-mysql-condition 'mysql-field-string-form->object
    1942                                 "unknown field type") ) ) )
    1943 
    1944 ; returns list of field object value for the specified row.
    1945 (define (mysql-row-string-form->object rowprc . field-ids)
    1946   (map (lambda (fld-id)
    1947          (let ([fldptr (mysql-fetch-field-specific conn fld-id)])
    1948            (if fldptr
    1949                (mysql-field-string-form->object fldptr (rowprc fld-id))
    1950                (signal-mysql-condition 'mysql-row-string-form->object
    1951                                        "no such field") ) ) )
    1952        field-ids) )
    1953 |#
     1855  (and-let* ([resptr (mysql-connection-result conn)]
     1856             [fldidx (%mysql-get-field-index resptr field (foreign-mysql-num-fields resptr))])
     1857    (foreign-mysql-fetch-field-direct resptr fldidx) ) )
Note: See TracChangeset for help on using the changeset viewer.