Changeset 8193 in project


Ignore:
Timestamp:
02/06/08 07:49:55 (12 years ago)
Author:
Kon Lovett
Message:

Save.

Location:
release/3/mysql/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/3/mysql/trunk/mysql.html

    r7943 r8193  
    253253<dt class="definition"><strong>procedure:</strong> (mysql-fetch-row CONN)</dt>
    254254<dd>
    255 <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>
    256 <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>
     255<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 <code>#f</code>; otherwise returns a row object.</p><a name='rowobj'></a>
     256<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 <code>#f</code> 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 <code>#f</code>.</p></dd>
    257257<dt class="definition"><strong>procedure:</strong> (mysql-field-count CONN)</dt>
    258258<dd>
     
    266266<dt class="definition"><strong>procedure:</strong> (mysql-num-rows CONN)</dt>
    267267<dd>
    268 <p>Returns the number of rows in the current result set. If no result set exists, returns <tt>#f</tt>.</p></dd>
     268<p>Returns the number of rows in the current result set. If no result set exists, returns <code>#f</code>.</p></dd>
    269269<dt class="definition"><strong>procedure:</strong> (mysql-num-fields CONN)</dt>
    270270<dd>
    271 <p>Returns the number of fields in the current result set. If no result set exists, returns <tt>#f</tt>.</p></dd>
     271<p>Returns the number of fields in the current result set. If no result set exists, returns <code>#f</code>.</p></dd>
    272272<dt class="definition"><strong>procedure:</strong> (mysql-affected-rows CONN)</dt>
    273273<dd>
     
    826826<pre>(use mysql)
    827827
    828 (let [(db (mysql-connect host: &quot;mysql.example.com&quot; user: &quot;example&quot;
    829                          passwd: &quot;secret&quot;))]
     828(let ((db (mysql-connect host: &quot;mysql.example.com&quot; user: &quot;example&quot; passwd: &quot;secret&quot;)))
    830829  (mysql-query db &quot;SHOW DATABASES&quot;)
    831   (do [(row (mysql-fetch-row db) (mysql-fetch-row db))]
    832       [(not row)]
    833     (display (conc &quot;Row &quot; idx &quot;: &quot; (row &quot;Database&quot;) &quot;\n&quot;)))
    834   (mysql-close db))</pre></p>
     830  (do ((row (mysql-fetch-row db) (mysql-fetch-row db)))
     831      ((not row))
     832    (print &quot;Row &quot; idx &quot;: &quot; (row &quot;Database&quot;)) )
     833  (mysql-close db) )</pre></p>
    835834<p>A slightly more compact version that does the same thing:
    836835<pre>(use mysql)
    837836
    838 (let [(db (mysql-connect host: &quot;mysql.example.com&quot; user: &quot;example&quot;
    839                          passwd: &quot;secret&quot;))]
    840   (mysql-query-foreach db &quot;SHOW DATABASES&quot;
    841                        (lambda (row idx)
    842                          (display (conc &quot;Row &quot; idx &quot;: &quot; (row &quot;Database&quot;) &quot;\n&quot;))))
    843   (mysql-close db))</pre></p></div></div>
     837(let ((db (mysql-connect host: &quot;mysql.example.com&quot; user: &quot;example&quot; passwd: &quot;secret&quot;)))
     838  (mysql-query-for-each
     839   db &quot;SHOW DATABASES&quot; (lambda (row idx) (print &quot;Row &quot; idx &quot;: &quot; (row &quot;Database&quot;))))
     840  (mysql-close db) )</pre></p></div></div>
    844841<div class="section">
    845842<h3>Data Type Conversion</h3>
    846843<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>
     844<p>The NULL value is represented by <code>#f</code>.</p>
     845<p>Booleans are expressed as the Scheme strings <code>&quot;1&quot;</code> and <code>&quot;0&quot;</code>.</p>
    849846<p>All remaining types, including numeric types, blobs, and strings are returned as Scheme strings.</p></div>
    850847<div class="section">
  • release/3/mysql/trunk/mysql.scm

    r8192 r8193  
    88;; Author: Toby Butzon (toby@butzon.com)
    99;; Revisions:
    10 ;;  2005.08.04 Initial release.
    11 ;;  2007.01.20 Added -lz for Mac OS X compilation.
    12 ;;                (Thanks to Daniel Sadilek.)
    13 ;;              Changed #include <mysql/mysql.h> to #include <mysql.h>
    14 ;;                (Thanks to Kon Lovett and Daniel Sadilek.)
    15 ;;              Removed some misc. compilation warnings.
    16 ;;                (Thanks to Kon Lovett.)
    17 ;;              Added (error ...) calls instead of silently failing in
    18 ;;                mysql-connect.
    19 ;;                (Thanks to Daniel Sadilek.)
    20 ;;  2008.01.24 Use of SRFI-12 conditions instead of 'error'.
    21 ;;              MYSQL_FIELD support.
    22 ;;              MY_CHARSET_INFO support.
    23 ;;              More row mapping functions.
    24 ;;              Options support
    25 ;;              SSL support
    26 ;;              Removed deprecated procedures:
    27 ;;                mysql-create-db
    28 ;;                mysql-drop-db
    29 ;;                mysql-eof
    30 ;;                mysql-reload
    31 ;;              (Kon Lovett)
     10;;      2005.08.04 Initial release.
     11;;      2007.01.20 Added -lz for Mac OS X compilation.
     12;;                                                              (Thanks to Daniel Sadilek.)
     13;;                                                      Changed #include <mysql/mysql.h> to #include <mysql.h>
     14;;                                                              (Thanks to Kon Lovett and Daniel Sadilek.)
     15;;                                                      Removed some misc. compilation warnings.
     16;;                                                              (Thanks to Kon Lovett.)
     17;;                                                      Added (error ...) calls instead of silently failing in
     18;;                                                              mysql-connect.
     19;;                                                              (Thanks to Daniel Sadilek.)
     20;;      2008.01.24 Use of SRFI-12 conditions instead of 'error'.
     21;;                                                      MYSQL_FIELD support.
     22;;                                                      MY_CHARSET_INFO support.
     23;;                                                      More row mapping functions.
     24;;                                                      Options support
     25;;                                                      SSL support
     26;;                                                      Removed deprecated procedures:
     27;;                                                              mysql-create-db
     28;;                                                              mysql-drop-db
     29;;                                                              mysql-eof
     30;;                                                              mysql-reload
     31;;                                                      (Kon Lovett)
    3232;;
    3333;; This egg provides the MySQL C API via Chicken's foreign function
     
    4040;; documented in full on MySQL's website:
    4141;;
    42 ;;    http://dev.mysql.com/doc/mysql/en/c.html
     42;;              http://dev.mysql.com/doc/mysql/en/c.html
    4343;;
    4444;; Further, this egg provides a layer on top of the foreign API to
     
    8282
    8383(define-for-syntax (c-name->scheme-name str)
    84   (string-downcase (string-translate str "_" "-")) )
     84        (string-downcase (string-translate str "_" "-")) )
    8585
    8686(declare
    87   (usual-integrations)
    88   (generic)
    89   (no-procedure-checks-for-usual-bindings)
    90   (no-bound-checks)
    91   (inline)
    92   (unused
    93     my-charset-info-name-set!
    94     my-charset-info-csname-set!
    95     my-charset-info-comment-set!
    96     my-charset-info-dir-set!
    97     my-charset-info-mbminlen-set!
    98     my-charset-info-mbmaxlen-set!
     87        (usual-integrations)
     88        (generic)
     89        (no-procedure-checks-for-usual-bindings)
     90        (no-bound-checks)
     91        (inline)
     92        (unused
     93                my-charset-info-name-set!
     94                my-charset-info-csname-set!
     95                my-charset-info-comment-set!
     96                my-charset-info-dir-set!
     97                my-charset-info-mbminlen-set!
     98                my-charset-info-mbmaxlen-set!
    9999                mysql-field-db-set!
    100100                mysql-field-type-set!
     
    118118                mysql-field-max-length-set!
    119119                mysql-field-length-set! )
    120   (bound-to-procedure
    121     mysql-error
    122     mysql-errno
    123     #;%mysql-stmt-close )
    124   (export
    125     ;; direct api
    126     foreign-mysql-affected-rows
    127     foreign-mysql-change-user
    128     foreign-mysql-character-set-name
    129     foreign-mysql-close
    130     foreign-mysql-data-seek
    131     foreign-mysql-debug
    132     foreign-mysql-dump-debug-info
    133     foreign-mysql-errno
    134     foreign-mysql-error
    135     foreign-mysql-escape-string
    136     foreign-mysql-fetch-field
    137     foreign-mysql-fetch-fields
    138     foreign-mysql-fetch-field-direct
    139     foreign-mysql-fetch-lengths
    140     foreign-mysql-fetch-row
    141     foreign-mysql-field-count
    142     foreign-mysql-field-seek
    143     foreign-mysql-field-tell
    144     foreign-mysql-free-result
     120        (bound-to-procedure
     121                mysql-error
     122                mysql-errno
     123                #;%mysql-stmt-close )
     124        (export
     125                ;; direct api
     126                foreign-mysql-affected-rows
     127                foreign-mysql-change-user
     128                foreign-mysql-character-set-name
     129                foreign-mysql-close
     130                foreign-mysql-data-seek
     131                foreign-mysql-debug
     132                foreign-mysql-dump-debug-info
     133                foreign-mysql-errno
     134                foreign-mysql-error
     135                foreign-mysql-escape-string
     136                foreign-mysql-fetch-field
     137                foreign-mysql-fetch-fields
     138                foreign-mysql-fetch-field-direct
     139                foreign-mysql-fetch-lengths
     140                foreign-mysql-fetch-row
     141                foreign-mysql-field-count
     142                foreign-mysql-field-seek
     143                foreign-mysql-field-tell
     144                foreign-mysql-free-result
    145145                foreign-mysql-get-character-set-info
    146     foreign-mysql-get-client-info
    147     foreign-mysql-get-client-version
    148     foreign-mysql-get-host-info
     146                foreign-mysql-get-client-info
     147                foreign-mysql-get-client-version
     148                foreign-mysql-get-host-info
    149149                foreign-mysql-get-proto-info
    150     foreign-mysql-get-server-info
    151     foreign-mysql-get-server-version
    152     foreign-mysql-hex-string
    153     foreign-mysql-info
    154     foreign-mysql-init
    155     foreign-mysql-insert-id
    156     foreign-mysql-kill
    157     foreign-mysql-library-init
    158     foreign-mysql-library-end
    159     foreign-mysql-list-dbs
    160     foreign-mysql-list-fields
    161     foreign-mysql-list-processes
    162     foreign-mysql-list-tables
    163     foreign-mysql-num-fields
    164     foreign-mysql-num-rows
    165     foreign-mysql-options
    166     foreign-mysql-ping
    167     foreign-mysql-query
    168     foreign-mysql-real-connect
    169     foreign-mysql-real-escape-string
    170     foreign-mysql-real-query
    171     foreign-mysql-row-seek
    172     foreign-mysql-row-tell
    173     foreign-mysql-select-db
    174     foreign-mysql-set-character-set
    175     foreign-mysql-set-server-option
    176     foreign-mysql-shutdown
    177     foreign-mysql-sqlstate
    178     foreign-mysql-ssl-set
    179     foreign-mysql-stat
    180     foreign-mysql-store-result
    181     foreign-mysql-thread-id
    182     foreign-mysql-use-result
    183     foreign-mysql-warning-count
    184     foreign-mysql-commit
    185     foreign-mysql-rollback
    186     foreign-mysql-autocommit
    187     foreign-mysql-more-results
    188     foreign-mysql-next-result
    189 
    190     ;; scheme api
    191     mysql-connection?
    192     mysql-affected-rows
    193     mysql-change-user
    194     mysql-character-set-name
    195     mysql-close ; customized
    196     mysql-connect ; customized
     150                foreign-mysql-get-server-info
     151                foreign-mysql-get-server-version
     152                foreign-mysql-hex-string
     153                foreign-mysql-info
     154                foreign-mysql-init
     155                foreign-mysql-insert-id
     156                foreign-mysql-kill
     157                foreign-mysql-library-init
     158                foreign-mysql-library-end
     159                foreign-mysql-list-dbs
     160                foreign-mysql-list-fields
     161                foreign-mysql-list-processes
     162                foreign-mysql-list-tables
     163                foreign-mysql-num-fields
     164                foreign-mysql-num-rows
     165                foreign-mysql-options
     166                foreign-mysql-ping
     167                foreign-mysql-query
     168                foreign-mysql-real-connect
     169                foreign-mysql-real-escape-string
     170                foreign-mysql-real-query
     171                foreign-mysql-row-seek
     172                foreign-mysql-row-tell
     173                foreign-mysql-select-db
     174                foreign-mysql-set-character-set
     175                foreign-mysql-set-server-option
     176                foreign-mysql-shutdown
     177                foreign-mysql-sqlstate
     178                foreign-mysql-ssl-set
     179                foreign-mysql-stat
     180                foreign-mysql-store-result
     181                foreign-mysql-thread-id
     182                foreign-mysql-use-result
     183                foreign-mysql-warning-count
     184                foreign-mysql-commit
     185                foreign-mysql-rollback
     186                foreign-mysql-autocommit
     187                foreign-mysql-more-results
     188                foreign-mysql-next-result
     189
     190                ;; scheme api
     191                mysql-connection?
     192                mysql-affected-rows
     193                mysql-change-user
     194                mysql-character-set-name
     195                mysql-close ; customized
     196                mysql-connect ; customized
    197197                #;mysql-data-seek ; omitted (low level)
    198     mysql-debug
    199     mysql-dump-debug-info
    200     mysql-errno
    201     mysql-error ; customized
    202     mysql-escape-string ; customized
     198                mysql-debug
     199                mysql-dump-debug-info
     200                mysql-errno
     201                mysql-error ; customized
     202                mysql-escape-string ; customized
    203203                mysql-fetch-field
    204204                mysql-fetch-fields
    205205                mysql-fetch-field-direct
    206206                mysql-fetch-lengths ; customized
    207     mysql-fetch-row ; customized
    208     mysql-field-count
     207                mysql-fetch-row ; customized
     208                mysql-field-count
    209209                #;mysql-field-seek ; omitted (low level)
    210210                #;mysql-field-tell ; omitted (low level)
    211     mysql-free-result
     211                mysql-free-result
    212212                mysql-get-character-set-info
    213     mysql-get-client-info
    214     mysql-get-client-version
    215     mysql-get-host-info
     213                mysql-get-client-info
     214                mysql-get-client-version
     215                mysql-get-host-info
    216216                mysql-get-proto-info
    217     mysql-get-server-info
    218     mysql-get-server-version
     217                mysql-get-server-info
     218                mysql-get-server-version
    219219                #;mysql-hex-string ; omitted (too new)
    220     mysql-info
     220                mysql-info
    221221                #;mysql-init ; omitted (low level)
    222     mysql-insert-id
    223     mysql-kill
     222                mysql-insert-id
     223                mysql-kill
    224224                #;mysql-library-init ; omitted (too new)
    225225                #;mysql-library-end ; omitted (too new)
    226     mysql-list-dbs
     226                mysql-list-dbs
    227227                mysql-list-fields ; (nearly deprecated)
    228     mysql-list-processes
    229     mysql-list-tables
    230     mysql-num-fields
    231     mysql-num-rows
    232     mysql-ping
    233     mysql-query
     228                mysql-list-processes
     229                mysql-list-tables
     230                mysql-num-fields
     231                mysql-num-rows
     232                mysql-ping
     233                mysql-query
    234234                #;mysql-real-connect ; omitted (use mysql-connect)
    235235                #;mysql-real-escape-string ; omitted (use mysql-escape-string)
     
    237237                #;mysql-row-seek ; omitted (low level)
    238238                #;mysql-row-tell ; omitted (low level)
    239     mysql-select-db
     239                mysql-select-db
    240240                mysql-set-character-set
    241241                #;mysql-set-server-option ; omitted (too new)
    242242                #;mysql-shutdown ; omitted (too new)
    243243                #;mysql-sqlstate ; omitted (too new)
    244     mysql-stat
    245     mysql-store-result
    246     mysql-thread-id
     244                mysql-stat
     245                mysql-store-result
     246                mysql-thread-id
    247247                #;mysql-use-result ; omitted (doesn't fit with Scheme layer; see mysql-query)
    248248                #;mysql-warning-count ; omitted (too new)
     
    253253                #;mysql-next-result ; omitted (too new)
    254254
    255     ;;
    256     make-mysql-options
    257 
    258     ;; ssl parameters api
    259     make-mysql-ssl
    260     mysql-ssl?
    261     mysql-ssl-key-pathname
    262     mysql-ssl-certificate-pathname
    263     mysql-ssl-certificate-authority-pathname
    264     mysql-ssl-trusted-certificates-pathname
    265     mysql-ssl-ciphers
    266 
    267     ;; "extended" api
    268     mysql-rewind
    269 
    270     ;; "map" api
    271     mysql-row-fold
    272     mysql-row-for-each
    273     mysql-row-map
    274     mysql-query-fold
    275     mysql-query-for-each
    276     mysql-query-map
    277     ; synonyms
    278     mysql-foreach-row
    279     mysql-query-foreach
    280 
    281     ;; MY_CHARSET_INFO api
    282     ; slot getters
    283     my-charset-info-name
    284     my-charset-info-csname
    285     my-charset-info-comment
    286     my-charset-info-dir
    287     my-charset-info-mbminlen
    288     my-charset-info-mbmaxlen
    289 
    290     ;; MYSQL_FIELD api
    291     ; predicates
    292     mysql-field-flags-on?
    293     mysql-field-flags-off?
    294     mysql-field-primary-key?
    295     mysql-field-not-null?
    296     mysql-field-numeric?
    297     mysql-field-type-any?
    298     mysql-field-type=?
    299     mysql-field-type-clock?
    300     mysql-field-type-number?
    301     mysql-field-type-string?
    302     mysql-field-type-blob?
    303     mysql-field-type-magnitude?
    304     mysql-field-type-binary?
    305     mysql-field-type-text?
    306     ;
    307     mysql-fetch-field-specific
    308     ; multi-field getters
    309     mysql-field-slots
    310     mysql-fetch-field-slots-direct
    311     mysql-fetch-field-slots
    312     mysql-fetch-field-slot-direct
    313     mysql-fetch-field-slot
    314     ; slot getters
     255                ;;
     256                make-mysql-options
     257
     258                ;; ssl parameters api
     259                make-mysql-ssl
     260                mysql-ssl?
     261                mysql-ssl-key-pathname
     262                mysql-ssl-certificate-pathname
     263                mysql-ssl-certificate-authority-pathname
     264                mysql-ssl-trusted-certificates-pathname
     265                mysql-ssl-ciphers
     266
     267                ;; "extended" api
     268                mysql-rewind
     269
     270                ;; "map" api
     271                mysql-row-fold
     272                mysql-row-for-each
     273                mysql-row-map
     274                mysql-query-fold
     275                mysql-query-for-each
     276                mysql-query-map
     277                ; synonyms
     278                mysql-foreach-row
     279                mysql-query-foreach
     280
     281                ;; MY_CHARSET_INFO api
     282                ; slot getters
     283                my-charset-info-name
     284                my-charset-info-csname
     285                my-charset-info-comment
     286                my-charset-info-dir
     287                my-charset-info-mbminlen
     288                my-charset-info-mbmaxlen
     289
     290                ;; MYSQL_FIELD api
     291                ; predicates
     292                mysql-field-flags-on?
     293                mysql-field-flags-off?
     294                mysql-field-primary-key?
     295                mysql-field-not-null?
     296                mysql-field-numeric?
     297                mysql-field-type-any?
     298                mysql-field-type=?
     299                mysql-field-type-clock?
     300                mysql-field-type-number?
     301                mysql-field-type-string?
     302                mysql-field-type-blob?
     303                mysql-field-type-magnitude?
     304                mysql-field-type-binary?
     305                mysql-field-type-text?
     306                ;
     307                mysql-fetch-field-specific
     308                ; multi-field getters
     309                mysql-field-slots
     310                mysql-fetch-field-slots-direct
     311                mysql-fetch-field-slots
     312                mysql-fetch-field-slot-direct
     313                mysql-fetch-field-slot
     314                ; slot getters
    315315                mysql-field-name
    316316                mysql-field-org-name
     
    334334                mysql-field-type
    335335
    336     ;; connection client flags
    337     ; values
    338     client-long-password
    339     client-long-flag
    340     client-connect-with-db
    341     client-protocol-41
    342     client-secure-connection
    343     client-transactions
    344     client-compress
    345     client-found-rows
    346     client-ignore-sigpipe
    347     client-ignore-space
    348     client-interactive
    349     client-local-files
    350     client-multi-results
    351     client-multi-statements
    352     client-no-schema
    353     client-odbc
    354     client-ssl
     336                ;; connection client flags
     337                ; values
     338                client-long-password
     339                client-long-flag
     340                client-connect-with-db
     341                client-protocol-41
     342                client-secure-connection
     343                client-transactions
     344                client-compress
     345                client-found-rows
     346                client-ignore-sigpipe
     347                client-ignore-space
     348                client-interactive
     349                client-local-files
     350                client-multi-results
     351                client-multi-statements
     352                client-no-schema
     353                client-odbc
     354                client-ssl
    355355                ; converters
    356     mysql-client-flags-value
    357     mysql-client-flags-symbol
    358 
    359     ;; enum enum_mysql_set_option
    360     ; values
    361     mysql-option-multi-statements-on
    362     mysql-option-multi-statements-off
     356                mysql-client-flags-value
     357                mysql-client-flags-symbol
     358
     359                ;; enum enum_mysql_set_option
     360                ; values
     361                mysql-option-multi-statements-on
     362                mysql-option-multi-statements-off
    363363                ; converters
    364     mysql-server-option-value
    365     mysql-server-option-symbol
    366 
    367     ;; enum mysql_option
    368     ; values
    369     mysql-opt-connect-timeout
    370     mysql-opt-compress
    371     mysql-opt-named-pipe
    372     mysql-init-command
    373     mysql-read-default-file
    374     mysql-read-default-group
    375     mysql-set-charset-dir
    376     mysql-set-charset-name
    377     mysql-opt-local-infile
    378     mysql-opt-protocol
    379     mysql-shared-memory-base-name
    380     mysql-opt-read-timeout
    381     mysql-opt-write-timeout
    382     mysql-opt-use-result
    383     mysql-opt-use-remote-connection
    384     mysql-opt-use-embedded-connection
    385     mysql-opt-guess-connection
    386     mysql-set-client-ip
    387     mysql-secure-auth
    388     mysql-report-data-truncation
     364                mysql-server-option-value
     365                mysql-server-option-symbol
     366
     367                ;; enum mysql_option
     368                ; values
     369                mysql-opt-connect-timeout
     370                mysql-opt-compress
     371                mysql-opt-named-pipe
     372                mysql-init-command
     373                mysql-read-default-file
     374                mysql-read-default-group
     375                mysql-set-charset-dir
     376                mysql-set-charset-name
     377                mysql-opt-local-infile
     378                mysql-opt-protocol
     379                mysql-shared-memory-base-name
     380                mysql-opt-read-timeout
     381                mysql-opt-write-timeout
     382                mysql-opt-use-result
     383                mysql-opt-use-remote-connection
     384                mysql-opt-use-embedded-connection
     385                mysql-opt-guess-connection
     386                mysql-set-client-ip
     387                mysql-secure-auth
     388                mysql-report-data-truncation
    389389                ; converters
    390     mysql-option-value
    391     mysql-option-symbol
    392 
    393     ;; enum enum_field_types
    394     ; values
    395         mysql-type-decimal
    396         mysql-type-tiny
    397         mysql-type-short
    398         mysql-type-long
    399         mysql-type-int24
    400         mysql-type-float
    401         mysql-type-double
    402         mysql-type-null
    403         mysql-type-timestamp
    404         mysql-type-longlong
    405         mysql-type-date
    406         mysql-type-time
    407         mysql-type-datetime
    408         mysql-type-year
    409         mysql-type-newdate
    410         mysql-type-varchar
    411         mysql-type-bit
    412         mysql-type-newdecimal
    413         mysql-type-enum
    414         mysql-type-set
    415         mysql-type-tiny-blob
    416         mysql-type-medium-blob
    417         mysql-type-long-blob
    418         mysql-type-blob
    419         mysql-type-var-string
    420         mysql-type-string
    421         mysql-type-geometry
     390                mysql-option-value
     391                mysql-option-symbol
     392
     393                ;; enum enum_field_types
     394                ; values
     395                mysql-type-decimal
     396                mysql-type-tiny
     397                mysql-type-short
     398                mysql-type-long
     399                mysql-type-int24
     400                mysql-type-float
     401                mysql-type-double
     402                mysql-type-null
     403                mysql-type-timestamp
     404                mysql-type-longlong
     405                mysql-type-date
     406                mysql-type-time
     407                mysql-type-datetime
     408                mysql-type-year
     409                mysql-type-newdate
     410                mysql-type-varchar
     411                mysql-type-bit
     412                mysql-type-newdecimal
     413                mysql-type-enum
     414                mysql-type-set
     415                mysql-type-tiny-blob
     416                mysql-type-medium-blob
     417                mysql-type-long-blob
     418                mysql-type-blob
     419                mysql-type-var-string
     420                mysql-type-string
     421                mysql-type-geometry
    422422                ; converters
    423     mysql-type-value
    424     mysql-type-symbol
    425 
    426     ;; field flags
    427     ; values
    428     not-null-flag
    429     pri-key-flag
    430     unique-key-flag
    431     multiple-key-flag
    432     unsigned-flag
    433     zerofill-flag
    434     binary-flag
    435     auto-increment-flag
    436     no-default-value-flag
    437     ; deprecated
    438     enum-flag
    439     set-flag
    440     blob-flag
    441     timestamp-flag
     423                mysql-type-value
     424                mysql-type-symbol
     425
     426                ;; field flags
     427                ; values
     428                not-null-flag
     429                pri-key-flag
     430                unique-key-flag
     431                multiple-key-flag
     432                unsigned-flag
     433                zerofill-flag
     434                binary-flag
     435                auto-increment-flag
     436                no-default-value-flag
     437                ; deprecated
     438                enum-flag
     439                set-flag
     440                blob-flag
     441                timestamp-flag
    442442                ; converters
    443     mysql-field-flags-value
    444     mysql-field-flags-symbol ) )
     443                mysql-field-flags-value
     444                mysql-field-flags-symbol ) )
    445445
    446446;=======================================================================
     
    475475;
    476476
     477;;
     478
    477479(define-macro (gen-public-enum ?typ . ?syms)
    478   `(begin
    479      ,@(map
    480         (lambda (sym)
    481           (if (pair? sym)
    482             `(define ,(car sym) ,(cadr sym))
    483             `(define ,(string->symbol (c-name->scheme-name (symbol->string sym))) ,sym)))
    484         ?syms)
    485      (define (,(string->symbol (string-append (symbol->string ?typ) "-value")) . syms)
    486        (,(string->symbol (string-append (symbol->string ?typ) "->number")) syms))
    487      (define (,(string->symbol (string-append (symbol->string ?typ) "-symbol")) val)
    488        (,(string->symbol (string-append "number->" (symbol->string ?typ))) val))) )
    489 
    490 (define-foreign-enum (mysql-server-option (enum "enum_mysql_set_option"))
    491   #f  ; No aliases!
    492   MYSQL_OPTION_MULTI_STATEMENTS_ON
    493   MYSQL_OPTION_MULTI_STATEMENTS_OFF )
    494 
    495 (define-foreign-enum (mysql-option (enum "mysql_option"))
    496   #f  ; No aliases!
    497   MYSQL_OPT_CONNECT_TIMEOUT
    498   MYSQL_OPT_COMPRESS
    499   MYSQL_OPT_NAMED_PIPE
    500   MYSQL_INIT_COMMAND
    501   MYSQL_READ_DEFAULT_FILE
    502   MYSQL_READ_DEFAULT_GROUP
    503   MYSQL_SET_CHARSET_DIR
    504   MYSQL_SET_CHARSET_NAME
    505   MYSQL_OPT_LOCAL_INFILE
    506   MYSQL_OPT_PROTOCOL
    507   MYSQL_SHARED_MEMORY_BASE_NAME
    508   MYSQL_OPT_READ_TIMEOUT
    509   MYSQL_OPT_WRITE_TIMEOUT
    510   MYSQL_OPT_USE_RESULT
    511   MYSQL_OPT_USE_REMOTE_CONNECTION
    512   MYSQL_OPT_USE_EMBEDDED_CONNECTION
    513   MYSQL_OPT_GUESS_CONNECTION
    514   MYSQL_SET_CLIENT_IP
    515   MYSQL_SECURE_AUTH
    516   MYSQL_REPORT_DATA_TRUNCATION )
    517 
    518 (define-foreign-enum (mysql-type (enum "enum_field_types"))
    519   #f  ; No aliases!
    520   MYSQL_TYPE_DECIMAL
     480        ` ; Begin Result
     481        (begin
     482                ,@(map (lambda (sym)
     483             (if (pair? sym)
     484                 `(define ,(car sym) ,(cadr sym))
     485                 `(define ,(string->symbol (c-name->scheme-name (symbol->string sym))) ,sym)))
     486                             ?syms)
     487    (define (,(string->symbol (string-append (symbol->string ?typ) "-value")) . syms)
     488      (,(string->symbol (string-append (symbol->string ?typ) "->number")) syms))
     489    (define (,(string->symbol (string-append (symbol->string ?typ) "-symbol")) val)
     490      (,(string->symbol (string-append "number->" (symbol->string ?typ))) val))) )
     491
     492(define-macro (*define-foreign-enum ?tspec . ?rest)
     493  (let ([1st-item (lambda (x) (if (pair? x) (car x) x))])
     494    (let-values ([(?flags ?especs)
     495                  (if (null? ?rest)
     496                      (syntax-error '*define-foreign-enum "missing enumeration specification")
     497                      (if (boolean? (car ?rest))
     498                          (values (list (car ?rest)) (cdr ?rest))
     499                          (values '() ?rest) ) ) ] )
     500      (let ([?typ (1st-item ?tspec)]
     501            [?enams (map 1st-item ?especs) ] )
     502        ` ; Begin Result
     503        (begin
     504          (define-foreign-enum ,?tspec ,@?flags ,@?especs)
     505          (gen-public-enum ,?typ ,@?enams) ) ) ) ) )
     506
     507;;
     508
     509(*define-foreign-enum (mysql-server-option (enum "enum_mysql_set_option"))
     510        #f      ; No aliases!
     511        MYSQL_OPTION_MULTI_STATEMENTS_ON
     512        MYSQL_OPTION_MULTI_STATEMENTS_OFF )
     513
     514(*define-foreign-enum (mysql-option (enum "mysql_option"))
     515        #f      ; No aliases!
     516        MYSQL_OPT_CONNECT_TIMEOUT
     517        MYSQL_OPT_COMPRESS
     518        MYSQL_OPT_NAMED_PIPE
     519        MYSQL_INIT_COMMAND
     520        MYSQL_READ_DEFAULT_FILE
     521        MYSQL_READ_DEFAULT_GROUP
     522        MYSQL_SET_CHARSET_DIR
     523        MYSQL_SET_CHARSET_NAME
     524        MYSQL_OPT_LOCAL_INFILE
     525        MYSQL_OPT_PROTOCOL
     526        MYSQL_SHARED_MEMORY_BASE_NAME
     527        MYSQL_OPT_READ_TIMEOUT
     528        MYSQL_OPT_WRITE_TIMEOUT
     529        MYSQL_OPT_USE_RESULT
     530        MYSQL_OPT_USE_REMOTE_CONNECTION
     531        MYSQL_OPT_USE_EMBEDDED_CONNECTION
     532        MYSQL_OPT_GUESS_CONNECTION
     533        MYSQL_SET_CLIENT_IP
     534        MYSQL_SECURE_AUTH
     535        MYSQL_REPORT_DATA_TRUNCATION )
     536
     537(*define-foreign-enum (mysql-type (enum "enum_field_types"))
     538        #f      ; No aliases!
     539        MYSQL_TYPE_DECIMAL
    521540        MYSQL_TYPE_TINY
    522   MYSQL_TYPE_SHORT
    523   MYSQL_TYPE_LONG
    524   MYSQL_TYPE_INT24
    525   MYSQL_TYPE_FLOAT
    526   MYSQL_TYPE_DOUBLE
    527   MYSQL_TYPE_NULL
    528   MYSQL_TYPE_TIMESTAMP
    529   MYSQL_TYPE_LONGLONG
    530   MYSQL_TYPE_DATE
    531   MYSQL_TYPE_TIME
    532   MYSQL_TYPE_DATETIME
     541        MYSQL_TYPE_SHORT
     542        MYSQL_TYPE_LONG
     543        MYSQL_TYPE_INT24
     544        MYSQL_TYPE_FLOAT
     545        MYSQL_TYPE_DOUBLE
     546        MYSQL_TYPE_NULL
     547        MYSQL_TYPE_TIMESTAMP
     548        MYSQL_TYPE_LONGLONG
     549        MYSQL_TYPE_DATE
     550        MYSQL_TYPE_TIME
     551        MYSQL_TYPE_DATETIME
    533552        MYSQL_TYPE_YEAR
    534   MYSQL_TYPE_NEWDATE
     553        MYSQL_TYPE_NEWDATE
    535554        MYSQL_TYPE_VARCHAR
    536   MYSQL_TYPE_BIT
    537   MYSQL_TYPE_NEWDECIMAL
    538   MYSQL_TYPE_ENUM
    539   MYSQL_TYPE_SET
    540   MYSQL_TYPE_TINY_BLOB
    541   MYSQL_TYPE_MEDIUM_BLOB
    542   MYSQL_TYPE_LONG_BLOB
    543   MYSQL_TYPE_BLOB
    544   MYSQL_TYPE_VAR_STRING
    545   MYSQL_TYPE_STRING
    546   MYSQL_TYPE_GEOMETRY )
    547 
    548 (define-foreign-enum (mysql-field-flags unsigned-int)
    549   #f  ; No aliases!
    550   NOT_NULL_FLAG                                         ; field can't be NULL
    551   PRI_KEY_FLAG                                          ; field is part of a primary key
    552   UNIQUE_KEY_FLAG                                       ; field is part of a unique key
    553   MULTIPLE_KEY_FLAG                                     ; field is part of a key
    554   UNSIGNED_FLAG                                         ; field is unsigned
    555   ZEROFILL_FLAG                                         ; field is zerofill
    556   BINARY_FLAG                                           ; field is binary
    557   AUTO_INCREMENT_FLAG                                   ; field is a autoincrement field
    558   NO_DEFAULT_VALUE_FLAG         ; field doesn't have default value
    559   NUM_FLAG                      ; field is num (for clients)
    560   ; deprecated
    561   ENUM_FLAG                                             ; field is an enum
    562   SET_FLAG                                              ; field is a set
    563   BLOB_FLAG                                             ; field is a blob
    564   TIMESTAMP_FLAG        )                                                       ; field is a timestamp
    565 
    566 (define-foreign-enum (mysql-client-flags unsigned-int)
     555        MYSQL_TYPE_BIT
     556        MYSQL_TYPE_NEWDECIMAL
     557        MYSQL_TYPE_ENUM
     558        MYSQL_TYPE_SET
     559        MYSQL_TYPE_TINY_BLOB
     560        MYSQL_TYPE_MEDIUM_BLOB
     561        MYSQL_TYPE_LONG_BLOB
     562        MYSQL_TYPE_BLOB
     563        MYSQL_TYPE_VAR_STRING
     564        MYSQL_TYPE_STRING
     565        MYSQL_TYPE_GEOMETRY )
     566
     567(*define-foreign-enum (mysql-field-flags unsigned-int)
    567568        #f      ; No aliases!
    568   CLIENT_LONG_PASSWORD          ; new more secure passwords
    569   CLIENT_LONG_FLAG              ; Get all column flags
    570   CLIENT_CONNECT_WITH_DB        ; One can specify db on connect
    571   CLIENT_PROTOCOL_41            ; New 4.1 protocol
    572   CLIENT_SECURE_CONNECTION      ; New 4.1 authentication
    573   CLIENT_TRANSACTIONS           ; Client knows about transactions
    574         CLIENT_COMPRESS               ; Can use compression protocol
     569        NOT_NULL_FLAG                                                                   ; field can't be NULL
     570        PRI_KEY_FLAG                                                                    ; field is part of a primary key
     571        UNIQUE_KEY_FLAG                                                         ; field is part of a unique key
     572        MULTIPLE_KEY_FLAG                                                       ; field is part of a key
     573        UNSIGNED_FLAG                                                                   ; field is unsigned
     574        ZEROFILL_FLAG                                                                   ; field is zerofill
     575        BINARY_FLAG                                                                             ; field is binary
     576        AUTO_INCREMENT_FLAG                                             ; field is a autoincrement field
     577        NO_DEFAULT_VALUE_FLAG                                   ; field doesn't have default value
     578        NUM_FLAG                                                                                        ; field is num (for clients)
     579        ; deprecated
     580        ENUM_FLAG                                                                                       ; field is an enum
     581        SET_FLAG                                                                                        ; field is a set
     582        BLOB_FLAG                                                                                       ; field is a blob
     583        TIMESTAMP_FLAG  )                                                       ; field is a timestamp
     584
     585(*define-foreign-enum (mysql-client-flags unsigned-int)
     586        #f      ; No aliases!
     587        CLIENT_LONG_PASSWORD                                    ; new more secure passwords
     588        CLIENT_LONG_FLAG                                                        ; Get all column flags
     589        CLIENT_CONNECT_WITH_DB                          ; One can specify db on connect
     590        CLIENT_PROTOCOL_41                                              ; New 4.1 protocol
     591        CLIENT_SECURE_CONNECTION                        ; New 4.1 authentication
     592        CLIENT_TRANSACTIONS                                             ; Client knows about transactions
     593        CLIENT_COMPRESS                                                         ; Can use compression protocol
    575594        ; Return the number of found (matched) rows, not the number of affected rows.
    576595        CLIENT_FOUND_ROWS
     
    615634; not "mysql-field-ptr", named so getters have nice name.
    616635(define-foreign-record (mysql-field "MYSQL_FIELD")
    617   (rename: c-name->scheme-name)
    618   ; No ctor or dtor
    619   (c-string name)                       ; Name of column
    620   (c-string org_name)                   ; Original column name, if an alias
    621   (c-string table)                      ; Table of column if column was a field
    622   (c-string org_table)                  ; Org table name, if table was an alias
    623   (c-string db)                         ; Database for table
    624   (c-string catalog)                      ; Catalog for table
    625   (c-string def)                        ; Default value (set by mysql_list_fields)
    626   (unsigned-long length)                ; Width of column (create length)
    627   (unsigned-long max_length)            ; Max width for selected set
    628   (unsigned-integer name_length)
    629   (unsigned-integer org_name_length)
    630   (unsigned-integer table_length)
    631   (unsigned-integer org_table_length)
    632   (unsigned-integer db_length)
    633   (unsigned-integer catalog_length)
    634   (unsigned-integer def_length)
    635   (unsigned-integer flags)              ; Div flags
    636   (unsigned-integer decimals)           ; Number of decimals in field
    637   (unsigned-integer charsetnr)          ; Character set
    638   (mysql-type type) )                   ; Type of field. See mysql_com.h for types
     636        (rename: c-name->scheme-name)
     637        ; No ctor or dtor
     638        (c-string name)                                                                                         ; Name of column
     639        (c-string org_name)                                                                             ; Original column name, if an alias
     640        (c-string table)                                                                                        ; Table of column if column was a field
     641        (c-string org_table)                                                                    ; Org table name, if table was an alias
     642        (c-string db)                                                                                                   ; Database for table
     643        (c-string catalog)                                                                              ; Catalog for table
     644        (c-string def)                                                                                          ; Default value (set by mysql_list_fields)
     645        (unsigned-long length)                                                          ; Width of column (create length)
     646        (unsigned-long max_length)                                              ; Max width for selected set
     647        (unsigned-integer name_length)
     648        (unsigned-integer org_name_length)
     649        (unsigned-integer table_length)
     650        (unsigned-integer org_table_length)
     651        (unsigned-integer db_length)
     652        (unsigned-integer catalog_length)
     653        (unsigned-integer def_length)
     654        (unsigned-integer flags)                                                        ; Div flags
     655        (unsigned-integer decimals)                                             ; Number of decimals in field
     656        (unsigned-integer charsetnr)                                    ; Character set
     657        (mysql-type type) )                                                                             ; Type of field. See mysql_com.h for types
    639658
    640659; not "my-charset-info-ptr", named so getters have nice name.
    641660(define-foreign-record (my-charset-info "MY_CHARSET_INFO")
    642   (rename: c-name->scheme-name)
    643   (constructor: allocate-my-charset-info)
    644   (destructor: free-my-charset-info)
    645   (c-string name)                     ; character set name
    646   (c-string csname)                 ; collation name
    647   (c-string comment)              ; comment
    648   (c-string dir)                ; directory
    649   (unsigned-integer mbminlen)   ; multi byte character min. length
    650   (unsigned-integer mbmaxlen) ) ; multi byte character max. length
     661        (rename: c-name->scheme-name)
     662        (constructor: allocate-my-charset-info)
     663        (destructor: free-my-charset-info)
     664        (c-string name)                                                         ; character set name
     665        (c-string csname)                                                       ; collation name
     666        (c-string comment)                                              ; comment
     667        (c-string dir)                                                          ; directory
     668        (unsigned-integer mbminlen)             ; multi byte character min. length
     669        (unsigned-integer mbmaxlen) ) ; multi byte character max. length
    651670
    652671;-----------------------------------------------------------------------
     
    668687mysqlaux_mysql_affected_rows (MYSQL *mysql)
    669688{
    670   return ((double) mysql_affected_rows (mysql));
     689        return ((double) mysql_affected_rows (mysql));
    671690}
    672691
     
    674693mysqlaux_mysql_insert_id (MYSQL *mysql)
    675694{
    676   return ((double) mysql_insert_id (mysql));
     695        return ((double) mysql_insert_id (mysql));
    677696}
    678697
     
    680699mysqlaux_mysql_num_rows (MYSQL_RES *result)
    681700{
    682   return ((double) mysql_num_rows (result));
     701        return ((double) mysql_num_rows (result));
    683702}
    684703
     
    686705mysqlaux_mysql_data_seek (MYSQL_RES *result, double offset)
    687706{
    688   mysql_data_seek (result, (my_ulonglong) offset);
     707        mysql_data_seek (result, (my_ulonglong) offset);
    689708}
    690709<#
     
    693712; my_ulonglong mysql_affected_rows(MYSQL *mysql)
    694713(define foreign-mysql-affected-rows
    695   (foreign-lambda my-ulonglong "mysqlaux_mysql_affected_rows" mysql-ptr))
     714        (foreign-lambda my-ulonglong "mysqlaux_mysql_affected_rows" mysql-ptr))
    696715
    697716; 24.2.3.34. mysql_insert_id()
    698717; my_ulonglong mysql_insert_id(MYSQL *mysql)
    699718(define foreign-mysql-insert-id
    700   (foreign-lambda my-ulonglong "mysqlaux_mysql_insert_id" mysql-ptr))
     719        (foreign-lambda my-ulonglong "mysqlaux_mysql_insert_id" mysql-ptr))
    701720
    702721; 24.2.3.43. mysql_num_rows()
    703722; my_ulonglong mysql_num_rows(MYSQL_RES *result)
    704723(define foreign-mysql-num-rows
    705   (foreign-lambda my-ulonglong "mysqlaux_mysql_num_rows" mysql-res-ptr))
     724        (foreign-lambda my-ulonglong "mysqlaux_mysql_num_rows" mysql-res-ptr))
    706725
    707726; 24.2.3.7. mysql_data_seek()
    708727; void mysql_data_seek(MYSQL_RES *result, my_ulonglong offset)
    709728(define foreign-mysql-data-seek
    710   (foreign-lambda void "mysqlaux_mysql_data_seek" mysql-res-ptr my-ulonglong))
     729        (foreign-lambda void "mysqlaux_mysql_data_seek" mysql-res-ptr my-ulonglong))
    711730
    712731;-----------------------------------------------------------------------
     
    718737mysqlaux_mysql_options_none (MYSQL *mysql, enum mysql_option opt)
    719738{
    720   return (mysql_options (mysql, opt, NULL));
     739        return (mysql_options (mysql, opt, NULL));
    721740}
    722741
     
    724743mysqlaux_mysql_options_string (MYSQL *mysql, enum mysql_option opt, char *value)
    725744{
    726   return (mysql_options (mysql, opt, value));
     745        return (mysql_options (mysql, opt, value));
    727746}
    728747
     
    730749mysqlaux_mysql_options_ulong (MYSQL *mysql, enum mysql_option opt, unsigned long value)
    731750{
    732   return (mysql_options (mysql, opt, &value));
     751        return (mysql_options (mysql, opt, &value));
    733752}
    734753<#
    735754
    736755(define foreign-mysqlaux-options-none
    737   (foreign-lambda int "mysqlaux_mysql_options_none" mysql-ptr mysql-option) )
     756        (foreign-lambda int "mysqlaux_mysql_options_none" mysql-ptr mysql-option) )
    738757
    739758(define foreign-mysqlaux-options-string
    740   (foreign-lambda int "mysqlaux_mysql_options_string" mysql-ptr mysql-option c-string) )
     759        (foreign-lambda int "mysqlaux_mysql_options_string" mysql-ptr mysql-option c-string) )
    741760
    742761(define foreign-mysqlaux-options-ulong
    743   (foreign-lambda int "mysqlaux_mysql_options_ulong" mysql-ptr mysql-option unsigned-long) )
     762        (foreign-lambda int "mysqlaux_mysql_options_ulong" mysql-ptr mysql-option unsigned-long) )
    744763
    745764;-----------------------------------------------------------------------
     
    751770mysqlaux_field_index (MYSQL_RES *result, const char *name, unsigned int num_fields)
    752771{
    753   MYSQL_FIELD *fields = mysql_fetch_fields (result);
    754   unsigned int i;
    755 
    756   for (i = 0; i < num_fields; i++) {
    757     if (0 == strcasecmp (name, fields[i].name)) {
    758       return (i);
    759     }
    760   }
    761 
    762   return (-1);
     772        MYSQL_FIELD *fields = mysql_fetch_fields (result);
     773        unsigned int i;
     774
     775        for (i = 0; i < num_fields; i++) {
     776                if (0 == strcasecmp (name, fields[i].name)) {
     777                        return (i);
     778                }
     779        }
     780
     781        return (-1);
    763782}
    764783
     
    766785mysqlaux_is_binary_field (MYSQL_RES *result, unsigned int fldidx)
    767786{
    768   MYSQL_FIELD *fields = mysql_fetch_fields (result);
    769 
    770   switch (fields[fldidx].type) {
    771     case MYSQL_TYPE_VARCHAR:
    772     case MYSQL_TYPE_TINY_BLOB:
    773     case MYSQL_TYPE_MEDIUM_BLOB:
    774     case MYSQL_TYPE_LONG_BLOB:
    775     case MYSQL_TYPE_BLOB:
    776     case MYSQL_TYPE_VAR_STRING:
    777     case MYSQL_TYPE_STRING:
    778       return (63 == fields[fldidx].charsetnr);
    779     default:
    780     break;
    781   }
    782 
    783   return (0);
     787        MYSQL_FIELD *fields = mysql_fetch_fields (result);
     788
     789        switch (fields[fldidx].type) {
     790                case MYSQL_TYPE_VARCHAR:
     791                case MYSQL_TYPE_TINY_BLOB:
     792                case MYSQL_TYPE_MEDIUM_BLOB:
     793                case MYSQL_TYPE_LONG_BLOB:
     794                case MYSQL_TYPE_BLOB:
     795                case MYSQL_TYPE_VAR_STRING:
     796                case MYSQL_TYPE_STRING:
     797                        return (63 == fields[fldidx].charsetnr);
     798                default:
     799                break;
     800        }
     801
     802        return (0);
    784803}
    785804
     
    787806mysqlaux_fetch_column_data_direct (MYSQL_ROW row, unsigned int fldidx)
    788807{
    789   return (row[fldidx]);
     808        return (row[fldidx]);
    790809}
    791810<#
    792811
    793812(define foreign-mysqlaux-field-index
    794   (foreign-lambda int "mysqlaux_field_index" mysql-res-ptr
    795                                             nonnull-c-string unsigned-integer))
     813        (foreign-lambda int "mysqlaux_field_index" mysql-res-ptr
     814                                                                                                                                                                                nonnull-c-string unsigned-integer))
    796815
    797816(define foreign-mysqlaux-is-binary-field
    798   (foreign-lambda bool "mysqlaux_is_binary_field"
    799                         mysql-res-ptr unsigned-integer))
     817        (foreign-lambda bool "mysqlaux_is_binary_field"
     818                                                                                                mysql-res-ptr unsigned-integer))
    800819
    801820(define foreign-mysqlaux-fetch-column-string-direct
    802   (foreign-lambda c-string "mysqlaux_fetch_column_data_direct"
    803                             mysql-row unsigned-integer))
     821        (foreign-lambda c-string "mysqlaux_fetch_column_data_direct"
     822                                                                                                                mysql-row unsigned-integer))
    804823
    805824(define foreign-mysqlaux-fetch-column-data-direct
    806   (foreign-lambda c-pointer "mysqlaux_fetch_column_data_direct"
    807                             mysql-row unsigned-integer))
     825        (foreign-lambda c-pointer "mysqlaux_fetch_column_data_direct"
     826                                                                                                                mysql-row unsigned-integer))
    808827
    809828;-----------------------------------------------------------------------
     
    819838; 24.2.3.2. mysql_change_user()
    820839; my_bool mysql_change_user(MYSQL *mysql, const char *user,
    821 ;   const char *password, const char *db)
     840;               const char *password, const char *db)
    822841(define foreign-mysql-change-user
    823   (foreign-lambda my-bool "mysql_change_user" mysql-ptr c-string c-string
    824                   c-string))
     842        (foreign-lambda my-bool "mysql_change_user" mysql-ptr c-string c-string
     843                                                                        c-string))
    825844
    826845; 24.2.3.3. mysql_character_set_name()
    827846; const char *mysql_character_set_name(MYSQL *mysql)
    828847(define foreign-mysql-character-set-name
    829   (foreign-lambda c-string "mysql_character_set_name" mysql-ptr))
     848        (foreign-lambda c-string "mysql_character_set_name" mysql-ptr))
    830849
    831850; 24.2.3.4. mysql_close()
    832851; void mysql_close(MYSQL *mysql)
    833852(define foreign-mysql-close
    834   (foreign-lambda void "mysql_close" mysql-ptr))
     853        (foreign-lambda void "mysql_close" mysql-ptr))
    835854
    836855; 24.2.3.8. mysql_debug()
    837856; void mysql_debug(const char *debug)
    838857(define foreign-mysql-debug
    839   (foreign-lambda void "mysql_debug" c-string))
     858        (foreign-lambda void "mysql_debug" c-string))
    840859
    841860; 24.2.3.10. mysql_dump_debug_info()
    842861; int mysql_dump_debug_info(MYSQL *mysql)
    843862(define foreign-mysql-dump-debug-info
    844   (foreign-lambda integer "mysql_dump_debug_info" mysql-ptr))
     863        (foreign-lambda integer "mysql_dump_debug_info" mysql-ptr))
    845864
    846865; 24.2.3.12. mysql_errno()
    847866; unsigned int mysql_errno(MYSQL *mysql)
    848867(define foreign-mysql-errno
    849   (foreign-lambda unsigned-integer "mysql_errno" mysql-ptr))
     868        (foreign-lambda unsigned-integer "mysql_errno" mysql-ptr))
    850869
    851870; 24.2.3.13. mysql_error()
    852871; const char *mysql_error(MYSQL *mysql)
    853872(define foreign-mysql-error
    854   (foreign-lambda c-string "mysql_error" mysql-ptr))
     873        (foreign-lambda c-string "mysql_error" mysql-ptr))
    855874
    856875; 24.2.3.14. mysql_escape_string()
    857876; unsigned long mysql_escape_string(char *to, const char *from,
    858 ;   unsigned long length)
     877;               unsigned long length)
    859878(define foreign-mysql-escape-string
    860   (foreign-lambda unsigned-long "mysql_escape_string" c-string c-string
    861                   unsigned-long))
     879        (foreign-lambda unsigned-long "mysql_escape_string" c-string c-string
     880                                                                        unsigned-long))
    862881
    863882; 24.2.3.15. mysql_fetch_field()
    864883; MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *result)
    865884(define foreign-mysql-fetch-field
    866   (foreign-lambda mysql-field-ptr "mysql_fetch_field" mysql-res-ptr))
     885        (foreign-lambda mysql-field-ptr "mysql_fetch_field" mysql-res-ptr))
    867886
    868887; 24.2.3.16. mysql_fetch_fields()
    869888; MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES *result)
    870889(define foreign-mysql-fetch-fields
    871   (foreign-lambda mysql-field-ptr "mysql_fetch_fields" mysql-res-ptr))
     890        (foreign-lambda mysql-field-ptr "mysql_fetch_fields" mysql-res-ptr))
    872891
    873892; 24.2.3.17. mysql_fetch_field_direct()
    874893; MYSQL_FIELD *mysql_fetch_field_direct(MYSQL_RES *result, unsigned int fieldnr)
    875894(define foreign-mysql-fetch-field-direct
    876   (foreign-lambda mysql-field-ptr "mysql_fetch_field_direct" mysql-res-ptr
    877                   unsigned-integer))
     895        (foreign-lambda mysql-field-ptr "mysql_fetch_field_direct" mysql-res-ptr
     896                                                                        unsigned-integer))
    878897
    879898; 24.2.3.18. mysql_fetch_lengths()
    880899; unsigned long *mysql_fetch_lengths(MYSQL_RES *result)
    881900(define foreign-mysql-fetch-lengths
    882   (foreign-lambda (c-pointer unsigned-long) "mysql_fetch_lengths" mysql-res-ptr))
     901        (foreign-lambda (c-pointer unsigned-long) "mysql_fetch_lengths" mysql-res-ptr))
    883902
    884903; 24.2.3.19. mysql_fetch_row()
    885904; MYSQL_ROW mysql_fetch_row(MYSQL_RES *result)
    886905(define foreign-mysql-fetch-row
    887   (foreign-lambda mysql-row "mysql_fetch_row" mysql-res-ptr))
     906        (foreign-lambda mysql-row "mysql_fetch_row" mysql-res-ptr))
    888907
    889908; 24.2.3.20. mysql_field_count()
    890909; unsigned int mysql_field_count(MYSQL *mysql)
    891910(define foreign-mysql-field-count
    892   (foreign-lambda unsigned-integer "mysql_field_count" mysql-ptr))
     911        (foreign-lambda unsigned-integer "mysql_field_count" mysql-ptr))
    893912
    894913; 24.2.3.21. mysql_field_seek()
    895914; MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *result,
    896 ;   MYSQL_FIELD_OFFSET offset)
     915;               MYSQL_FIELD_OFFSET offset)
    897916(define foreign-mysql-field-seek
    898   (foreign-lambda mysql-field-offset "mysql_field_seek" mysql-res-ptr
    899                   mysql-field-offset))
     917        (foreign-lambda mysql-field-offset "mysql_field_seek" mysql-res-ptr
     918                                                                        mysql-field-offset))
    900919
    901920; 24.2.3.22. mysql_field_tell()
    902921; MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES *result)
    903922(define foreign-mysql-field-tell
    904   (foreign-lambda mysql-field-offset "mysql_field_tell" mysql-res-ptr))
     923        (foreign-lambda mysql-field-offset "mysql_field_tell" mysql-res-ptr))
    905924
    906925; 24.2.3.23. mysql_free_result()
    907926; void mysql_free_result(MYSQL_RES *result)
    908927(define foreign-mysql-free-result
    909   (foreign-lambda void "mysql_free_result" mysql-res-ptr))
     928        (foreign-lambda void "mysql_free_result" mysql-res-ptr))
    910929
    911930; 24.2.3.26.Êmysql_get_character_set_info()
    912931; void mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *cs)
    913932(define foreign-mysql-get-character-set-info
    914   (foreign-lambda void "mysql_get_character_set_info" mysql-ptr my-charset-info))
     933        (foreign-lambda void "mysql_get_character_set_info" mysql-ptr my-charset-info))
    915934
    916935; 24.2.3.25. mysql_get_client_info()
    917936; char *mysql_get_client_info(void)
    918937(define foreign-mysql-get-client-info
    919   (foreign-lambda c-string "mysql_get_client_info"))
     938        (foreign-lambda c-string "mysql_get_client_info"))
    920939
    921940; 24.2.3.26. mysql_get_client_version()
    922941; unsigned long mysql_get_client_version(void)
    923942(define foreign-mysql-get-client-version
    924   (foreign-lambda unsigned-long "mysql_get_client_version"))
     943        (foreign-lambda unsigned-long "mysql_get_client_version"))
    925944
    926945; 24.2.3.27. mysql_get_host_info()
    927946; char *mysql_get_host_info(MYSQL *mysql)
    928947(define foreign-mysql-get-host-info
    929   (foreign-lambda c-string "mysql_get_host_info" mysql-ptr))
     948        (foreign-lambda c-string "mysql_get_host_info" mysql-ptr))
    930949
    931950; 24.2.3.28. mysql_get_proto_info()
    932951; unsigned int mysql_get_proto_info(MYSQL *mysql)
    933952(define foreign-mysql-get-proto-info
    934   (foreign-lambda unsigned-integer "mysql_get_proto_info" mysql-ptr))
     953        (foreign-lambda unsigned-integer "mysql_get_proto_info" mysql-ptr))
    935954
    936955; 24.2.3.29. mysql_get_server_info()
    937956; char *mysql_get_server_info(MYSQL *mysql)
    938957(define foreign-mysql-get-server-info
    939   (foreign-lambda c-string "mysql_get_server_info" mysql-ptr))
     958        (foreign-lambda c-string "mysql_get_server_info" mysql-ptr))
    940959
    941960; 24.2.3.30. mysql_get_server_version()
    942961; unsigned long mysql_get_server_version(MYSQL *mysql)
    943962(define foreign-mysql-get-server-version
    944   (foreign-lambda unsigned-long "mysql_get_server_version" mysql-ptr))
     963        (foreign-lambda unsigned-long "mysql_get_server_version" mysql-ptr))
    945964
    946965; 24.2.3.31. mysql_hex_string()
    947966; unsigned long mysql_hex_string(char *to, const char *from,
    948 ;   unsigned long length)
     967;               unsigned long length)
    949968(define foreign-mysql-hex-string
    950   (foreign-lambda unsigned-long "mysql_hex_string" c-string c-string
    951                   unsigned-long))
     969        (foreign-lambda unsigned-long "mysql_hex_string" c-string c-string
     970                                                                        unsigned-long))
    952971
    953972; 24.2.3.32. mysql_info()
    954973; char *mysql_info(MYSQL *mysql)
    955974(define foreign-mysql-info
    956   (foreign-lambda c-string "mysql_info" mysql-ptr))
     975        (foreign-lambda c-string "mysql_info" mysql-ptr))
    957976
    958977; 24.2.3.33. mysql_init()
    959978; MYSQL *mysql_init(MYSQL *mysql)
    960979(define foreign-mysql-init
    961   (foreign-lambda mysql-ptr "mysql_init" mysql-ptr))
     980        (foreign-lambda mysql-ptr "mysql_init" mysql-ptr))
    962981
    963982; 24.2.3.35. mysql_kill()
    964983; int mysql_kill(MYSQL *mysql, unsigned long pid)
    965984(define foreign-mysql-kill
    966   (foreign-lambda integer "mysql_kill" mysql-ptr unsigned-long))
     985        (foreign-lambda integer "mysql_kill" mysql-ptr unsigned-long))
    967986
    968987; 24.2.3.36. mysql_library_init()
    969988; int mysql_library_init(int argc, char **argv, char **groups)
    970989(define foreign-mysql-library-init
    971   (foreign-lambda integer "mysql_library_init" integer c-pointer c-pointer))
     990        (foreign-lambda integer "mysql_library_init" integer c-pointer c-pointer))
    972991
    973992; 24.2.3.37. mysql_library_end()
    974993; void mysql_library_end(void)
    975994(define foreign-mysql-library-end
    976   (foreign-lambda void "mysql_library_end"))
     995        (foreign-lambda void "mysql_library_end"))
    977996
    978997; 24.2.3.38. mysql_list_dbs()
    979998; MYSQL_RES *mysql_list_dbs(MYSQL *mysql, const char *wild)
    980999(define foreign-mysql-list-dbs
    981   (foreign-lambda mysql-res-ptr "mysql_list_dbs" mysql-ptr c-string))
     1000        (foreign-lambda mysql-res-ptr "mysql_list_dbs" mysql-ptr c-string))
    9821001
    9831002; 24.2.3.39. mysql_list_fields()
    9841003; MYSQL_RES *mysql_list_fields(MYSQL *mysql, const char *table,
    985 ;   const char *wild)
     1004;               const char *wild)
    9861005(define foreign-mysql-list-fields
    987   (foreign-lambda mysql-res-ptr "mysql_list_fields" mysql-ptr c-string
    988                   c-string))
     1006        (foreign-lambda mysql-res-ptr "mysql_list_fields" mysql-ptr c-string
     1007                                                                        c-string))
    9891008
    9901009; 24.2.3.40. mysql_list_processes()
    9911010; MYSQL_RES *mysql_list_processes(MYSQL *mysql)
    9921011(define foreign-mysql-list-processes
    993   (foreign-lambda mysql-res-ptr "mysql_list_processes" mysql-ptr))
     1012        (foreign-lambda mysql-res-ptr "mysql_list_processes" mysql-ptr))
    9941013
    9951014; 24.2.3.41. mysql_list_tables()
    9961015; MYSQL_RES *mysql_list_tables(MYSQL *mysql, const char *wild)
    9971016(define foreign-mysql-list-tables
    998   (foreign-lambda mysql-res-ptr "mysql_list_tables" mysql-ptr c-string))
     1017        (foreign-lambda mysql-res-ptr "mysql_list_tables" mysql-ptr c-string))
    9991018
    10001019; 24.2.3.42. mysql_num_fields()
    10011020; unsigned int mysql_num_fields(MYSQL_RES *result)
    10021021(define foreign-mysql-num-fields
    1003   (foreign-lambda unsigned-integer "mysql_num_fields" mysql-res-ptr))
     1022        (foreign-lambda unsigned-integer "mysql_num_fields" mysql-res-ptr))
    10041023
    10051024; 24.2.3.44. mysql_options()
    10061025; int mysql_options(MYSQL *mysql, enum mysql_option option, const char *arg)
    10071026(define foreign-mysql-options
    1008   (foreign-lambda integer "mysql_options" mysql-ptr mysql-option c-pointer))
     1027        (foreign-lambda integer "mysql_options" mysql-ptr mysql-option c-pointer))
    10091028
    10101029; 24.2.3.45. mysql_ping()
    10111030; int mysql_ping(MYSQL *mysql)
    10121031(define foreign-mysql-ping
    1013   (foreign-lambda integer "mysql_ping" mysql-ptr))
     1032        (foreign-lambda integer "mysql_ping" mysql-ptr))
    10141033
    10151034; 24.2.3.46. mysql_query()
     
    10181037; NOTE: use "mysql_real_query" instead
    10191038(define foreign-mysql-query
    1020   (foreign-lambda integer "mysql_query" mysql-ptr c-string))
     1039        (foreign-lambda integer "mysql_query" mysql-ptr c-string))
    10211040
    10221041; 24.2.3.47. mysql_real_connect()
    10231042; MYSQL *mysql_real_connect(MYSQL *mysql, const char *host, const char *user,
    1024 ;   const char *passwd, const char *db, unsigned int port,
    1025 ;   const char *unix_socket, unsigned long client_flag)
     1043;               const char *passwd, const char *db, unsigned int port,
     1044;               const char *unix_socket, unsigned long client_flag)
    10261045(define foreign-mysql-real-connect
    1027   (foreign-lambda mysql-ptr "mysql_real_connect"
    1028                   mysql-ptr c-string c-string
    1029                   c-string c-string unsigned-integer
    1030                   c-string unsigned-long))
     1046        (foreign-lambda mysql-ptr "mysql_real_connect"
     1047                                                                        mysql-ptr c-string c-string
     1048                                                                        c-string c-string unsigned-integer
     1049                                                                        c-string unsigned-long))
    10311050
    10321051; 24.2.3.48. mysql_real_escape_string()
    10331052; unsigned long mysql_real_escape_string(MYSQL *mysql, char *to,
    1034 ;   const char *from, unsigned long length)
     1053;               const char *from, unsigned long length)
    10351054(define foreign-mysql-real-escape-string
    1036   (foreign-lambda unsigned-long "mysql_real_escape_string" mysql-ptr
    1037                   c-string c-string unsigned-long))
     1055        (foreign-lambda unsigned-long "mysql_real_escape_string" mysql-ptr
     1056                                                                        c-string c-string unsigned-long))
    10381057
    10391058; 24.2.3.49. mysql_real_query()
    10401059; int mysql_real_query(MYSQL *mysql, const char *query, unsigned long length)
    10411060(define foreign-mysql-real-query
    1042   (foreign-lambda unsigned-integer "mysql_real_query" mysql-ptr c-string
    1043                   unsigned-long))
     1061        (foreign-lambda unsigned-integer "mysql_real_query" mysql-ptr c-string
     1062                                                                        unsigned-long))
    10441063
    10451064; 24.2.3.51. mysql_row_seek()
    10461065; MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET offset)
    10471066(define foreign-mysql-row-seek
    1048   (foreign-lambda mysql-rows-ptr "mysql_row_seek" mysql-res-ptr mysql-rows-ptr))
     1067        (foreign-lambda mysql-rows-ptr "mysql_row_seek" mysql-res-ptr mysql-rows-ptr))
    10491068
    10501069; 24.2.3.52. mysql_row_tell()
    10511070; MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES *result)
    10521071(define foreign-mysql-row-tell
    1053   (foreign-lambda mysql-rows-ptr "mysql_row_tell" mysql-res-ptr))
     1072        (foreign-lambda mysql-rows-ptr "mysql_row_tell" mysql-res-ptr))
    10541073
    10551074; 24.2.3.53. mysql_select_db()
    10561075; int mysql_select_db(MYSQL *mysql, const char *db)
    10571076(define foreign-mysql-select-db
    1058   (foreign-lambda integer "mysql_select_db" mysql-ptr c-string))
     1077        (foreign-lambda integer "mysql_select_db" mysql-ptr c-string))
    10591078
    10601079; 24.2.3.54. mysql_set_character_set()
    10611080; int mysql_set_character_set(MYSQL *mysql, char *csname)
    10621081(define foreign-mysql-set-character-set
    1063   (foreign-lambda integer "mysql_set_character_set" mysql-ptr c-string))
     1082        (foreign-lambda integer "mysql_set_character_set" mysql-ptr c-string))
    10641083
    10651084; 24.2.3.55. mysql_set_server_option()
    10661085; int mysql_set_server_option(MYSQL *mysql, enum enum_mysql_set_option option)
    10671086(define foreign-mysql-set-server-option
    1068   (foreign-lambda integer "mysql_set_server_option" mysql-ptr mysql-server-option))
     1087        (foreign-lambda integer "mysql_set_server_option" mysql-ptr mysql-server-option))
    10691088
    10701089; 24.2.3.56. mysql_shutdown()
    10711090; int mysql_shutdown(MYSQL *mysql, enum enum_shutdown_level shutdown_level)
    10721091(define foreign-mysql-shutdown
    1073   (foreign-lambda integer "mysql_shutdown" mysql-ptr integer))
     1092        (foreign-lambda integer "mysql_shutdown" mysql-ptr integer))
    10741093
    10751094; 24.2.3.57. mysql_sqlstate()
    10761095; const char *mysql_sqlstate(MYSQL *mysql)
    10771096(define foreign-mysql-sqlstate
    1078   (foreign-lambda c-string "mysql_sqlstate" mysql-ptr))
     1097        (foreign-lambda c-string "mysql_sqlstate" mysql-ptr))
    10791098
    10801099; 24.2.3.58. mysql_ssl_set()
    10811100; int mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
    1082 ;   const char *ca, const char *capath, const char *cipher)
     1101;               const char *ca, const char *capath, const char *cipher)
    10831102(define foreign-mysql-ssl-set
    1084   (foreign-lambda integer "mysql_ssl_set" mysql-ptr c-string c-string
    1085                   c-string c-string c-string))
     1103        (foreign-lambda integer "mysql_ssl_set" mysql-ptr c-string c-string
     1104                                                                        c-string c-string c-string))
    10861105
    10871106; 24.2.3.59. mysql_stat()
    10881107; char *mysql_stat(MYSQL *mysql)
    10891108(define foreign-mysql-stat
    1090   (foreign-lambda c-string "mysql_stat" mysql-ptr))
     1109        (foreign-lambda c-string "mysql_stat" mysql-ptr))
    10911110
    10921111; 24.2.3.60. mysql_store_result()
    10931112; MYSQL_RES *mysql_store_result(MYSQL *mysql)
    10941113(define foreign-mysql-store-result
    1095   (foreign-lambda mysql-res-ptr "mysql_store_result" mysql-ptr))
     1114        (foreign-lambda mysql-res-ptr "mysql_store_result" mysql-ptr))
    10961115
    10971116; 24.2.3.61. mysql_thread_id()
    10981117; unsigned long mysql_thread_id(MYSQL *mysql)
    10991118(define foreign-mysql-thread-id
    1100   (foreign-lambda unsigned-long "mysql_thread_id" mysql-ptr))
     1119        (foreign-lambda unsigned-long "mysql_thread_id" mysql-ptr))
    11011120
    11021121; 24.2.3.62. mysql_use_result()
    11031122; MYSQL_RES *mysql_use_result(MYSQL *mysql)
    11041123(define foreign-mysql-use-result
    1105   (foreign-lambda mysql-res-ptr "mysql_use_result" mysql-ptr))
     1124        (foreign-lambda mysql-res-ptr "mysql_use_result" mysql-ptr))
    11061125
    11071126; 24.2.3.63. mysql_warning_count()
    11081127; unsigned int mysql_warning_count(MYSQL *mysql)
    11091128(define foreign-mysql-warning-count
    1110   (foreign-lambda unsigned-integer "mysql_warning_count" mysql-ptr))
     1129        (foreign-lambda unsigned-integer "mysql_warning_count" mysql-ptr))
    11111130
    11121131; 24.2.3.64. mysql_commit()
    11131132; my_bool mysql_commit(MYSQL *mysql)
    11141133(define foreign-mysql-commit
    1115   (foreign-lambda my-bool "mysql_commit" mysql-ptr))
     1134        (foreign-lambda my-bool "mysql_commit" mysql-ptr))
    11161135
    11171136; 24.2.3.65. mysql_rollback()
    11181137; my_bool mysql_rollback(MYSQL *mysql)
    11191138(define foreign-mysql-rollback
    1120   (foreign-lambda my-bool "mysql_rollback" mysql-ptr))
     1139        (foreign-lambda my-bool "mysql_rollback" mysql-ptr))
    11211140
    11221141; 24.2.3.66. mysql_autocommit()
    11231142; my_bool mysql_autocommit(MYSQL *mysql, my_bool mode)
    11241143(define foreign-mysql-autocommit
    1125   (foreign-lambda my-bool "mysql_autocommit" mysql-ptr my-bool))
     1144        (foreign-lambda my-bool "mysql_autocommit" mysql-ptr my-bool))
    11261145
    11271146; 24.2.3.67. mysql_more_results()
    11281147; my_bool mysql_more_results(MYSQL *mysql)
    11291148(define foreign-mysql-more-results
    1130   (foreign-lambda my-bool "mysql_more_results" mysql-ptr))
     1149        (foreign-lambda my-bool "mysql_more_results" mysql-ptr))
    11311150
    11321151; 24.2.3.68. mysql_next_result()
    11331152; int mysql_next_result(MYSQL *mysql)
    11341153(define foreign-mysql-next-result
    1135   (foreign-lambda integer "mysql_next_result" mysql-ptr))
     1154        (foreign-lambda integer "mysql_next_result" mysql-ptr))
    11361155
    11371156;=======================================================================
     
    11451164; record printer helper
    11461165(define (record-slot->string val lbl #!optional (tst val))
    1147   (if tst
    1148       (conc #\space lbl #\: #\space #\" val #\")
    1149       "") )
     1166        (if tst
     1167                        (conc #\space lbl #\: #\space #\" val #\")
     1168                        "") )
    11501169
    11511170(define (unsigned-long-array->u32vector ulptr cnt)
    1152   (let* ([siz (* cnt UNSIGNED-LONG-SIZE)]
    1153         [store (make-blob siz)])
    1154     (move-memory! ulptr store siz)
    1155     (blob->u32vector/shared store) ) )
     1171        (let* ([siz (* cnt UNSIGNED-LONG-SIZE)]
     1172                                [store (make-blob siz)])
     1173                (move-memory! ulptr store siz)
     1174                (blob->u32vector/shared store) ) )
    11561175
    11571176#; ; UNUSED
    11581177(define char-pointer->string
    1159   (foreign-lambda* c-string ((c-pointer chrptr))
    1160     "return ((char *) chrptr);") )
     1178        (foreign-lambda* c-string ((c-pointer chrptr))
     1179                "return ((char *) chrptr);") )
    11611180
    11621181(define (binary-char-pointer->string chrptr size)
    1163   (let ([blob (make-blob size)])
    1164     (move-memory! chrptr blob size)
    1165     (blob->string blob) ) )
     1182        (let ([blob (make-blob size)])
     1183                (move-memory! chrptr blob size)
     1184                (blob->string blob) ) )
    11661185
    11671186(define (%mysql-get-field-index resptr field fldcnt)
    1168   (let ([fldidx (if (number? field)
    1169                     field
    1170                     (foreign-mysqlaux-field-index resptr
    1171                                                   (->string field) fldcnt))])
    1172     (and (<= 0 fldidx) (< fldidx fldcnt)
    1173         fldidx ) ) )
     1187        (let ([fldidx (if (number? field)
     1188                                                                                field
     1189                                                                                (foreign-mysqlaux-field-index resptr
     1190                                                                                                                                                                                                        (->string field) fldcnt))])
     1191                (and (<= 0 fldidx) (< fldidx fldcnt)
     1192                                fldidx ) ) )
    11741193
    11751194(define (%mysql-options mysqlptr opt val)
    1176   (cond [(null? val)
    1177           (foreign-mysqlaux-options-none mysqlptr opt)]
    1178         [(string? val)
    1179           (foreign-mysqlaux-options-string mysqlptr opt val)]
    1180         [(number? val)
    1181           (foreign-mysqlaux-options-ulong mysqlptr opt val)]
    1182         [else
    1183           1 ] ) )
     1195        (cond [(null? val)
     1196                                        (foreign-mysqlaux-options-none mysqlptr opt)]
     1197                                [(string? val)
     1198                                        (foreign-mysqlaux-options-string mysqlptr opt val)]
     1199                                [(number? val)
     1200                                        (foreign-mysqlaux-options-ulong mysqlptr opt val)]
     1201                                [else
     1202                                        1 ] ) )
    11841203
    11851204;-----------------------------------------------------------------------
     
    11881207
    11891208(define (make-exn-condition loc msg . args)
    1190   (make-property-condition 'exn 'location loc 'message msg 'arguments args) )
     1209        (make-property-condition 'exn 'location loc 'message msg 'arguments args) )
    11911210
    11921211(define (make-mysql-condition)
    1193   (make-property-condition 'mysql) )
     1212        (make-property-condition 'mysql) )
    11941213
    11951214(define (make-exn-mysql-condition loc msg . args)
    1196   (make-composite-condition
    1197   (apply make-exn-condition loc msg args)
    1198   (make-mysql-condition)) )
     1215        (make-composite-condition
     1216        (apply make-exn-condition loc msg args)
     1217        (make-mysql-condition)) )
    11991218
    12001219(define (signal-mysql-condition loc msg . args)
    1201   (signal (apply make-exn-mysql-condition loc msg args)) )
     1220        (signal (apply make-exn-mysql-condition loc msg args)) )
    12021221
    12031222(define (signal-mysql-error loc conn . args)
    1204   (let ([msg (or (mysql-error conn)
    1205                 (mysql-errno conn))])
    1206     (apply signal-mysql-condition loc msg args) ) )
     1223        (let ([msg (or (mysql-error conn)
     1224                                                                (mysql-errno conn))])
     1225                (apply signal-mysql-condition loc msg args) ) )
    12071226
    12081227;-----------------------------------------------------------------------
     
    12141233
    12151234(define-record-type mysql-ssl
    1216   (%make-mysql-ssl key cert ca capath cipher)
    1217   mysql-ssl?
    1218   (key mysql-ssl-key-pathname)
    1219   (cert mysql-ssl-certificate-pathname)
    1220   (ca mysql-ssl-certificate-authority-pathname)
    1221   (capath mysql-ssl-trusted-certificates-pathname)
    1222   (cipher mysql-ssl-ciphers) )
     1235        (%make-mysql-ssl key cert ca capath cipher)
     1236        mysql-ssl?
     1237        (key mysql-ssl-key-pathname)
     1238        (cert mysql-ssl-certificate-pathname)
     1239        (ca mysql-ssl-certificate-authority-pathname)
     1240        (capath mysql-ssl-trusted-certificates-pathname)
     1241        (cipher mysql-ssl-ciphers) )
    12231242
    12241243(define (make-mysql-ssl #!key key certificate certificate-authority
    1225                               trusted-certificates ciphers)
    1226   (%make-mysql-ssl key certificate certificate-authority trusted-certificates ciphers) )
     1244                                                                                                                        trusted-certificates ciphers)
     1245        (%make-mysql-ssl key certificate certificate-authority trusted-certificates ciphers) )
    12271246
    12281247(define-record-printer (mysql-ssl ssl out)
    1229   (let ([key (mysql-ssl-key-pathname ssl)]
    1230         [cert (mysql-ssl-certificate-pathname ssl)]
    1231         [ca (mysql-ssl-certificate-authority-pathname ssl)]
    1232         [capath (mysql-ssl-trusted-certificates-pathname ssl)]
    1233         [cipher (mysql-ssl-ciphers ssl)])
    1234     (display
    1235     (string-append
    1236       "#<mysql-ssl"
    1237       (record-slot->string key      "key")
    1238       (record-slot->string cert     "cert")
    1239       (record-slot->string ca       "ca")
    1240       (record-slot->string capath   "capath")
    1241       (record-slot->string cipher   "cipher")
    1242       ">")
    1243     out) ) )
     1248        (let ([key (mysql-ssl-key-pathname ssl)]
     1249                                [cert (mysql-ssl-certificate-pathname ssl)]
     1250                                [ca (mysql-ssl-certificate-authority-pathname ssl)]
     1251                                [capath (mysql-ssl-trusted-certificates-pathname ssl)]
     1252                                [cipher (mysql-ssl-ciphers ssl)])
     1253                (display
     1254                (string-append
     1255                        "#<mysql-ssl"
     1256                        (record-slot->string key                        "key")
     1257                        (record-slot->string cert                       "cert")
     1258                        (record-slot->string ca                         "ca")
     1259                        (record-slot->string capath             "capath")
     1260                        (record-slot->string cipher             "cipher")
     1261                        ">")
     1262                out) ) )
    12441263
    12451264;-----------------------------------------------------------------------
     
    12481267
    12491268(define (make-mysql-options . opts)
    1250   (let loop ([opts opts] [alst '()])
    1251     (if (null? opts)
    1252         alst
    1253         (let* ([opt (car opts)]
    1254               [nxt (cdr opts)]
    1255               [val (if (null? nxt)
    1256                         (error 'make-options "missing value for option" opt)
    1257                         (car nxt))])
    1258           (unless (number? opt)
    1259             (error 'make-options "invalid option" opt) )
    1260           (unless (or (number? val) (string? val) (not val) (null? val))
    1261             (error 'make-options "invalid option value" val) )
    1262           (loop (cdr nxt) (alist-cons opt val alst)) ) ) ) )
     1269        (let loop ([opts opts] [alst '()])
     1270                (if (null? opts)
     1271                                alst
     1272                                (let* ([opt (car opts)]
     1273                                                        [nxt (cdr opts)]
     1274                                                        [val (if (null? nxt)
     1275                                                                                                (error 'make-options "missing value for option" opt)
     1276                                                                                                (car nxt))])
     1277                                        (unless (number? opt)
     1278                                                (error 'make-options "invalid option" opt) )
     1279                                        (unless (or (number? val) (string? val) (not val) (null? val))
     1280                                                (error 'make-options "invalid option value" val) )
     1281                                        (loop (cdr nxt) (alist-cons opt val alst)) ) ) ) )
    12631282
    12641283;-----------------------------------------------------------------------
     
    12681287; record. The record is here for a few reasons:
    12691288;
    1270 ;   1) Instead of an ugly #<pointer>, I've defined a pretty printer
    1271 ;      to demonstrate that we've actually got a MySQL connection.
    1272 ;   2) The C API is somewhat more verbose than what normal usage would
    1273 ;      need. (For example, usually you don't care whether results are
    1274 ;      all read into memory as fast as possible, or if they're read from
    1275 ;      the network one-by-one. Thus, the mysql-query function provided
    1276 ;      automatically reads the results into memory. For finer granularity,
    1277 ;      you're always free to write your own version to use the "raw"
    1278 ;      foreign-* functions. I suppose a contribution to determine this
    1279 ;      behavior via a (make-parameter ...) parameter may also be
    1280 ;      accepted. ;)) Slots are provided in the mysql-connection record
    1281 ;      type to allow for this sort of simplifying behavior.
     1289;               1) Instead of an ugly #<pointer>, I've defined a pretty printer
     1290;                        to demonstrate that we've actually got a MySQL connection.
     1291;               2) The C API is somewhat more verbose than what normal usage would
     1292;                        need. (For example, usually you don't care whether results are
     1293;                        all read into memory as fast as possible, or if they're read from
     1294;                        the network one-by-one. Thus, the mysql-query function provided
     1295;                        automatically reads the results into memory. For finer granularity,
     1296;                        you're always free to write your own version to use the "raw"
     1297;                        foreign-* functions. I suppose a contribution to determine this
     1298;                        behavior via a (make-parameter ...) parameter may also be
     1299;                        accepted. ;)) Slots are provided in the mysql-connection record
     1300;                        type to allow for this sort of simplifying behavior.
    12821301;
    12831302; All of the "Scheme API" MySQL functions take instances of this record
     
    12861305
    12871306(define-record-type mysql-connection
    1288   (make-mysql-connection host user passwd db port unix-socket
    1289                         client-flag ptr result result-start ssl opts
    1290                         #;stmt #;bind)
    1291   mysql-connection?
    1292   (host mysql-connection-host)
    1293   (user mysql-connection-user)
    1294   (passwd mysql-connection-passwd)
    1295   (db mysql-connection-db)
    1296   (port mysql-connection-port)
    1297   (unix-socket mysql-connection-unix-socket)
    1298   (client-flag mysql-connection-client-flag)
    1299   (ptr mysql-connection-ptr mysql-connection-ptr-set!)
    1300   (result mysql-connection-result mysql-connection-result-set!)
    1301   (result-start mysql-connection-result-start mysql-connection-result-start-set!)
    1302   (ssl mysql-connection-ssl)
    1303   (opts mysql-connection-options)
    1304   #;(stmt mysql-connection-statement mysql-connection-statement-set!)
    1305   #;(bind mysql-connection-binding mysql-connection-binding-set!) )
     1307        (make-mysql-connection host user passwd db port unix-socket
     1308                                                                                                client-flag ptr result result-start ssl opts
     1309                                                                                                #;stmt #;bind)
     1310        mysql-connection?
     1311        (host mysql-connection-host)
     1312        (user mysql-connection-user)
     1313        (passwd mysql-connection-passwd)
     1314        (db mysql-connection-db)
     1315        (port mysql-connection-port)
     1316        (unix-socket mysql-connection-unix-socket)
     1317        (client-flag mysql-connection-client-flag)
     1318        (ptr mysql-connection-ptr mysql-connection-ptr-set!)
     1319        (result mysql-connection-result mysql-connection-result-set!)
     1320        (result-start mysql-connection-result-start mysql-connection-result-start-set!)
     1321        (ssl mysql-connection-ssl)
     1322        (opts mysql-connection-options)
     1323        #;(stmt mysql-connection-statement mysql-connection-statement-set!)
     1324        #;(bind mysql-connection-binding mysql-connection-binding-set!) )
    13061325
    13071326(define-record-printer (mysql-connection conn out)
    1308   (let ([host (mysql-connection-host conn)]
    1309         [user (mysql-connection-user conn)]
    1310         [passwd (mysql-connection-passwd conn)]
    1311         [db (mysql-connection-db conn)]
    1312         [tcp-port (mysql-connection-port conn)]
    1313         [unix-socket (mysql-connection-unix-socket conn)]
    1314         [client-flag (mysql-connection-client-flag conn)]
    1315         [ssl (mysql-connection-ssl conn)]
    1316         [opts (mysql-connection-options conn)]
    1317         #;[stmt (mysql-connection-statement conn)]
    1318         #;[bind (mysql-connection-binding conn)])
    1319     (display
    1320     (string-append
    1321       "#<mysql-connection"
    1322       (if (mysql-connection-ptr conn)
    1323           (string-append
    1324             (record-slot->string host         "host")
    1325             (record-slot->string user         "user")
    1326             (record-slot->string passwd       "passwd")
    1327             (record-slot->string db           "db")
    1328             (record-slot->string tcp-port     "tcp-port"    (not (zero? tcp-port)))
    1329             (record-slot->string unix-socket  "unix-socket")
    1330             (record-slot->string client-flag  "client-flag" (not (zero? client-flag)))
    1331             (record-slot->string ssl          "ssl")
    1332             (record-slot->string opts         "options")
    1333             #;(record-slot->string stmt         "statement")
    1334             #;(record-slot->string bind         "binding") )
    1335           " INVALID")
    1336       ">")
    1337     out) ) )
     1327        (let ([host (mysql-connection-host conn)]
     1328                                [user (mysql-connection-user conn)]
     1329                                [passwd (mysql-connection-passwd conn)]
     1330                                [db (mysql-connection-db conn)]
     1331                                [tcp-port (mysql-connection-port conn)]
     1332                                [unix-socket (mysql-connection-unix-socket conn)]
     1333                                [client-flag (mysql-connection-client-flag conn)]
     1334                                [ssl (mysql-connection-ssl conn)]
     1335                                [opts (mysql-connection-options conn)]
     1336                                #;[stmt (mysql-connection-statement conn)]
     1337                                #;[bind (mysql-connection-binding conn)])
     1338                (display
     1339                (string-append
     1340                        "#<mysql-connection"
     1341                        (if (mysql-connection-ptr conn)
     1342                                        (string-append
     1343                                                (record-slot->string host                                       "host")
     1344                                                (record-slot->string user                                       "user")
     1345                                                (record-slot->string passwd                             "passwd")
     1346                                                (record-slot->string db                                         "db")
     1347                                                (record-slot->string tcp-port                   "tcp-port"              (not (zero? tcp-port)))
     1348                                                (record-slot->string unix-socket        "unix-socket")
     1349                                                (record-slot->string client-flag        "client-flag" (not (zero? client-flag)))
     1350                                                (record-slot->string ssl                                        "ssl")
     1351                                                (record-slot->string opts                                       "options")
     1352                                                #;(record-slot->string stmt                                     "statement")
     1353                                                #;(record-slot->string bind                                     "binding") )
     1354                                        " INVALID")
     1355                        ">")
     1356                out) ) )
    13381357
    13391358;-----------------------------------------------------------------------
     
    13451364
    13461365(define (mysql-affected-rows conn)
    1347   (let ([cnt (foreign-mysql-affected-rows (mysql-connection-ptr conn))])
    1348     (and (not (= -1 cnt))
    1349         cnt ) ) )
     1366        (let ([cnt (foreign-mysql-affected-rows (mysql-connection-ptr conn))])
     1367                (and (not (= -1 cnt))
     1368                                cnt ) ) )
    13501369
    13511370(define (mysql-change-user conn #!key (user #f) (passwd #f) (db #f))
    1352   (foreign-mysql-change-user (mysql-connection-ptr conn) user passwd db) )
     1371        (foreign-mysql-change-user (mysql-connection-ptr conn) user passwd db) )
    13531372
    13541373(define (mysql-character-set-name conn)
    1355   (foreign-mysql-character-set-name (mysql-connection-ptr conn)))
     1374        (foreign-mysql-character-set-name (mysql-connection-ptr conn)))
    13561375
    13571376; Closes a mysql connection and invalidates the mysql connection object.
     
    13601379; upon termination.
    13611380(define (mysql-close conn)
    1362   #;(%mysql-stmt-close conn)
    1363   (mysql-free-result conn)
    1364   (foreign-mysql-close (mysql-connection-ptr conn))
    1365   (mysql-connection-ptr-set! conn #f) )
     1381        #;(%mysql-stmt-close conn)
     1382        (mysql-free-result conn)
     1383        (foreign-mysql-close (mysql-connection-ptr conn))
     1384        (mysql-connection-ptr-set! conn #f) )
    13661385
    13671386; Returns a mysql connection object, or #f on failure.
    13681387(define (mysql-connect #!key (host #f) (user #f) (passwd #f) (db #f) (port 0)
    1369                       (unix-socket #f) (client-flag 0)
    1370                       (options #f) (ssl #f))
    1371   (let ([mysql (foreign-mysql-init #f)])
    1372     (cond
    1373       [mysql
    1374         (when ssl
    1375           (foreign-mysql-ssl-set mysql
    1376                                 (mysql-ssl-key-pathname ssl)
    1377                                 (mysql-ssl-certificate-pathname ssl)
    1378                                 (mysql-ssl-certificate-authority-pathname ssl)
    1379                                 (mysql-ssl-trusted-certificates-pathname ssl)
    1380                                 (mysql-ssl-ciphers ssl)) )
    1381         (when options
    1382           (for-each
    1383           (lambda (optitm)
    1384             (let ([opt (car optitm)]
    1385                   [val (cdr optitm)])
    1386               (unless (zero? (%mysql-options mysql opt val))
    1387                 (signal-mysql-condition 'mysql-connect "unknown option" opt val))))
    1388           options) )
    1389         (let ([mysqlptr (foreign-mysql-real-connect mysql
    1390                                                     host user passwd
    1391                                                     db
    1392                                                     port unix-socket
    1393                                                     client-flag)])
    1394           (if mysqlptr
    1395               (make-mysql-connection host user passwd db port unix-socket
    1396                                     client-flag mysqlptr #f #f options ssl
    1397                                     #;#f #;#f)
    1398               (signal-mysql-condition 'mysql-connect
    1399               (foreign-mysql-error mysql)
    1400               host user passwd db port unix-socket client-flag options ssl options) ) ) ]
    1401       [else
    1402         (signal-mysql-condition 'mysql-connect "failed to initialize mysql") ] ) ) )
     1388                                                                                        (unix-socket #f) (client-flag 0)
     1389                                                                                        (options #f) (ssl #f))
     1390        (let ([mysql (foreign-mysql-init #f)])
     1391                (cond
     1392                        [mysql
     1393                                (when ssl
     1394                                        (foreign-mysql-ssl-set mysql
     1395                                                                                                                                (mysql-ssl-key-pathname ssl)
     1396                                                                                                                                (mysql-ssl-certificate-pathname ssl)
     1397                                                                                                                                (mysql-ssl-certificate-authority-pathname ssl)
     1398                                                                                                                                (mysql-ssl-trusted-certificates-pathname ssl)
     1399                                                                                                                                (mysql-ssl-ciphers ssl)) )
     1400                                (when options
     1401                                        (for-each
     1402                                        (lambda (optitm)
     1403                                                (let ([opt (car optitm)]
     1404                                                                        [val (cdr optitm)])
     1405                                                        (unless (zero? (%mysql-options mysql opt val))
     1406                                                                (signal-mysql-condition 'mysql-connect "unknown option" opt val))))
     1407                                        options) )
     1408                                (let ([mysqlptr (foreign-mysql-real-connect mysql
     1409                                                                                                                                                                                                                host user passwd
     1410                                                                                                                                                                                                                db
     1411                                                                                                                                                                                                                port unix-socket
     1412                                                                                                                                                                                                                client-flag)])
     1413                                        (if mysqlptr
     1414                                                        (make-mysql-connection host user passwd db port unix-socket
     1415                                                                                                                                                client-flag mysqlptr #f #f options ssl
     1416                                                                                                                                                #;#f #;#f)
     1417                                                        (signal-mysql-condition 'mysql-connect
     1418                                                        (foreign-mysql-error mysql)
     1419                                                        host user passwd db port unix-socket client-flag options ssl options) ) ) ]
     1420                        [else
     1421                                (signal-mysql-condition 'mysql-connect "failed to initialize mysql") ] ) ) )
    14031422
    14041423(define (mysql-debug debug)
    1405   (foreign-mysql-debug debug) )
     1424        (foreign-mysql-debug debug) )
    14061425
    14071426(define (mysql-dump-debug-info conn)
    1408   (foreign-mysql-dump-debug-info (mysql-connection-ptr conn)) )
     1427        (foreign-mysql-dump-debug-info (mysql-connection-ptr conn)) )
    14091428
    14101429(define (mysql-errno conn)
    1411   (foreign-mysql-errno (mysql-connection-ptr conn)))
     1430        (foreign-mysql-errno (mysql-connection-ptr conn)))
    14121431
    14131432; Returns a string describing the last mysql error, or #f if no error
    14141433; has occurred.
    14151434(define (mysql-error conn)
    1416   (let ([errstr (foreign-mysql-error (mysql-connection-ptr conn))])
    1417     (and (not (string=? "" errstr))
    1418         errstr) ) )
     1435        (let ([errstr (foreign-mysql-error (mysql-connection-ptr conn))])
     1436                (and (not (string=? "" errstr))
     1437                                errstr) ) )
    14191438
    14201439(define (mysql-escape-string conn str)
    14211440        (let-location ([escstr c-string*])
    1422     ((foreign-lambda* void ((mysql-ptr mysql) (c-pointer to) (c-string from) (unsigned-long length))
    1423       "if ((*((char **) to) = ((char *) C_malloc ((2 * length) + 1)))) {\n"
    1424       "    (void) mysql_real_escape_string (mysql, *((char **) to), from, length);\n"
    1425       "}")
    1426     #$escstr
    1427     str (string-length str))
    1428     escstr ) )
     1441                ((foreign-lambda* void ((mysql-ptr mysql) (c-pointer to) (c-string from) (unsigned-long length))
     1442                        "if ((*((char **) to) = ((char *) C_malloc ((2 * length) + 1)))) {\n"
     1443                        "                (void) mysql_real_escape_string (mysql, *((char **) to), from, length);\n"
     1444                        "}")
     1445                #$escstr
     1446                str (string-length str))
     1447                escstr ) )
    14291448
    14301449; returns a mysql-field-ptr or #f when no more fields.
    14311450; returns #f when no result set.
    14321451(define (mysql-fetch-field conn)
    1433   (and-let* ([resptr (mysql-connection-result conn)])
    1434     (foreign-mysql-fetch-field resptr) ) )
     1452        (and-let* ([resptr (mysql-connection-result conn)])
     1453                (foreign-mysql-fetch-field resptr) ) )
    14351454
    14361455; returns a mysql-field-ptr to a vector of MYSQL_FIELD or #f when no fields.
    14371456; returns #f when no result set.
    14381457(define (mysql-fetch-fields conn)
    1439   (and-let* ([resptr (mysql-connection-result conn)])
    1440     (foreign-mysql-fetch-fields resptr) ) )
     1458        (and-let* ([resptr (mysql-connection-result conn)])
     1459                (foreign-mysql-fetch-fields resptr) ) )
    14411460
    14421461; returns a mysql-field-ptr or #f when no such field.
    14431462; returns #f when no result set.
    14441463(define (mysql-fetch-field-direct conn field-number)
    1445   (and-let* ([resptr (mysql-connection-result conn)])
    1446     (foreign-mysql-fetch-field-direct resptr field-number) ) )
     1464        (and-let* ([resptr (mysql-connection-result conn)])
     1465                (foreign-mysql-fetch-field-direct resptr field-number) ) )
    14471466
    14481467; returns a u32vector of length num-fields.
    14491468; returns #f when no result set.
    14501469(define (%mysql-fetch-lengths resptr cnt)
    1451   (and-let* ([ulptr (foreign-mysql-fetch-lengths resptr)])
    1452     (unsigned-long-array->u32vector ulptr cnt) ) )
     1470        (and-let* ([ulptr (foreign-mysql-fetch-lengths resptr)])
     1471                (unsigned-long-array->u32vector ulptr cnt) ) )
    14531472
    14541473; returns a u32vector of length num-fields.
    14551474; returns #f when no result set.
    14561475(define (mysql-fetch-lengths conn)
    1457   (and-let* ([resptr (mysql-connection-result conn)])
    1458     (%mysql-fetch-lengths resptr (foreign-mysql-num-fields resptr)) ) )
     1476        (and-let* ([resptr (mysql-connection-result conn)])
     1477                (%mysql-fetch-lengths resptr (foreign-mysql-num-fields resptr)) ) )
    14591478
    14601479; After a mysql-query that has results, use mysql-fetch-row to retrieve
     
    14651484; column name).
    14661485(define (mysql-fetch-row conn)
    1467   (and-let* ([resptr (mysql-connection-result conn)]
    1468             [row (foreign-mysql-fetch-row resptr)])
    1469     (let ([fldcnt (foreign-mysql-num-fields resptr)]
    1470           [fldlens #f])
    1471       (lambda (field)
    1472         (and-let* ([fldidx (%mysql-get-field-index resptr field fldcnt)])
    1473           (if (foreign-mysqlaux-is-binary-field resptr fldidx)
    1474               (binary-char-pointer->string
    1475               (foreign-mysqlaux-fetch-column-data-direct row fldidx)
    1476               (u32vector-ref
    1477                 (or fldlens
    1478                     (begin
    1479                       (set! fldlens (%mysql-fetch-lengths resptr fldcnt))
    1480                       fldlens ) )
    1481                 fldidx))
    1482               (foreign-mysqlaux-fetch-column-string-direct row fldidx) ) ) ) ) ) )
     1486        (and-let* ([resptr (mysql-connection-result conn)]
     1487                                                [row (foreign-mysql-fetch-row resptr)])
     1488                (let ([fldcnt (foreign-mysql-num-fields resptr)]
     1489                                        [fldlens #f])
     1490                        (lambda (field)
     1491                                (and-let* ([fldidx (%mysql-get-field-index resptr field fldcnt)])
     1492                                        (if (foreign-mysqlaux-is-binary-field resptr fldidx)
     1493                                                        (binary-char-pointer->string
     1494                                                        (foreign-mysqlaux-fetch-column-data-direct row fldidx)
     1495                                                        (u32vector-ref
     1496                                                                (or fldlens
     1497                                                                                (begin
     1498                                                                                        (set! fldlens (%mysql-fetch-lengths resptr fldcnt))
     1499                                                                                        fldlens ) )
     1500                                                                fldidx))
     1501                                                        (foreign-mysqlaux-fetch-column-string-direct row fldidx) ) ) ) ) ) )
    14831502
    14841503(define (mysql-field-count conn)
    1485   (foreign-mysql-field-count (mysql-connection-ptr conn)) )
     1504        (foreign-mysql-field-count (mysql-connection-ptr conn)) )
    14861505
    14871506(define (mysql-free-result conn)
    1488   (and-let* ([res (mysql-connection-result conn)])
    1489     (foreign-mysql-free-result res) )
    1490   (mysql-connection-result-set! conn #f)
    1491   (mysql-connection-result-start-set! conn #f) )
     1507        (and-let* ([res (mysql-connection-result conn)])
     1508                (foreign-mysql-free-result res) )
     1509        (mysql-connection-result-set! conn #f)
     1510        (mysql-connection-result-start-set! conn #f) )
    14921511
    14931512; returns a c-pointer to a MY_CHARSET_INFO struct.
    14941513; a finalizer is supplied.
    14951514(define (mysql-get-character-set-info conn)
    1496   (let ([chrsetinfo (allocate-my-charset-info)])
    1497     (foreign-mysql-get-character-set-info (mysql-connection-ptr conn) chrsetinfo)
    1498     (set-finalizer! chrsetinfo free-my-charset-info)
    1499     chrsetinfo ) )
     1515        (let ([chrsetinfo (allocate-my-charset-info)])
     1516                (foreign-mysql-get-character-set-info (mysql-connection-ptr conn) chrsetinfo)
     1517                (set-finalizer! chrsetinfo free-my-charset-info)
     1518                chrsetinfo ) )
    15001519
    15011520(define (mysql-get-client-info)
    1502   (foreign-mysql-get-client-info) )
     1521        (foreign-mysql-get-client-info) )
    15031522
    15041523(define (mysql-get-client-version)
    1505   (foreign-mysql-get-client-version) )
     1524        (foreign-mysql-get-client-version) )
    15061525
    15071526(define (mysql-get-host-info conn)
    1508   (foreign-mysql-get-host-info (mysql-connection-ptr conn)) )
     1527        (foreign-mysql-get-host-info (mysql-connection-ptr conn)) )
    15091528
    15101529(define (mysql-get-proto-info conn)
    1511   (foreign-mysql-get-proto-info (mysql-connection-ptr conn)) )
     1530        (foreign-mysql-get-proto-info (mysql-connection-ptr conn)) )
    15121531
    15131532(define (mysql-get-server-info conn)
    1514   (foreign-mysql-get-server-info (mysql-connection-ptr conn)) )
     1533        (foreign-mysql-get-server-info (mysql-connection-ptr conn)) )
    15151534
    15161535(define (mysql-get-server-version conn)
    1517   (foreign-mysql-get-server-version (mysql-connection-ptr conn)) )
     1536        (foreign-mysql-get-server-version (mysql-connection-ptr conn)) )
    15181537
    15191538(define (mysql-info conn)
    1520   (foreign-mysql-info (mysql-connection-ptr conn)) )
     1539        (foreign-mysql-info (mysql-connection-ptr conn)) )
    15211540
    15221541(define (mysql-insert-id conn)
    1523   (foreign-mysql-insert-id (mysql-connection-ptr conn)) )
     1542        (foreign-mysql-insert-id (mysql-connection-ptr conn)) )
    15241543
    15251544(define (mysql-kill conn pid)
    1526   (foreign-mysql-kill (mysql-connection-ptr conn) pid) )
     1545        (foreign-mysql-kill (mysql-connection-ptr conn) pid) )
    15271546
    15281547(define (mysql-list-dbs conn like)
    1529   (mysql-free-result conn)
    1530   (mysql-connection-result-set! conn
    1531     (foreign-mysql-list-dbs (mysql-connection-ptr conn) like)) )
     1548        (mysql-free-result conn)
     1549        (mysql-connection-result-set! conn
     1550                (foreign-mysql-list-dbs (mysql-connection-ptr conn) like)) )
    15321551
    15331552(define (mysql-list-fields conn table wild)
    1534   (mysql-free-result conn)
    1535   (mysql-connection-result-set! conn
    1536     (foreign-mysql-list-fields (mysql-connection-ptr conn) table wild)) )
     1553        (mysql-free-result conn)
     1554        (mysql-connection-result-set! conn
     1555                (foreign-mysql-list-fields (mysql-connection-ptr conn) table wild)) )
    15371556
    15381557(define (mysql-list-processes conn)
    1539   (mysql-free-result conn)
    1540   (mysql-connection-result-set! conn
    1541     (foreign-mysql-list-processes (mysql-connection-ptr conn))) )
     1558        (mysql-free-result conn)
     1559        (mysql-connection-result-set! conn
     1560                (foreign-mysql-list-processes (mysql-connection-ptr conn))) )
    15421561
    15431562(define (mysql-list-tables conn wild)
    1544   (mysql-free-result conn)
    1545   (mysql-connection-result-set! conn
    1546     (foreign-mysql-list-tables (mysql-connection-ptr conn) wild)) )
     1563        (mysql-free-result conn)
     1564        (mysql-connection-result-set! conn
     1565                (foreign-mysql-list-tables (mysql-connection-ptr conn) wild)) )
    15471566
    15481567(define (mysql-num-fields conn)
    1549   (foreign-mysql-num-fields (mysql-connection-result conn)) )
     1568        (foreign-mysql-num-fields (mysql-connection-result conn)) )
    15501569
    15511570(define (mysql-num-rows conn)
    1552   (and-let* ([res (mysql-connection-result conn)])
    1553     (foreign-mysql-num-rows res)) )
     1571        (and-let* ([res (mysql-connection-result conn)])
     1572                (foreign-mysql-num-rows res)) )
    15541573
    15551574(define (mysql-ping conn)
    1556   (foreign-mysql-ping (mysql-connection-ptr conn)) )
     1575        (foreign-mysql-ping (mysql-connection-ptr conn)) )
    15571576
    15581577; returns #t if the query was successful, signals exception otherwise.
    15591578(define (mysql-query conn query)
    1560   (let ([mysql-ptr (mysql-connection-ptr conn)])
    1561     ; zero indicates success
    1562     (if (zero? (foreign-mysql-real-query mysql-ptr query (string-length query)))
    1563         (begin (mysql-store-result conn) #t)
    1564         (signal-mysql-error 'mysql-query conn query) ) ) )
     1579        (let ([mysql-ptr (mysql-connection-ptr conn)])
     1580                ; zero indicates success
     1581                (if (zero? (foreign-mysql-real-query mysql-ptr query (string-length query)))
     1582                                (begin (mysql-store-result conn) #t)
     1583                                (signal-mysql-error 'mysql-query conn query) ) ) )
    15651584
    15661585; returns #t if the select was successful, signals exception otherwise.
    15671586(define (mysql-select-db conn db)
    1568   (or (zero? (foreign-mysql-select-db (mysql-connection-ptr conn) db))
    1569       (signal-mysql-error 'mysql-select-db conn db) ) )
     1587        (or (zero? (foreign-mysql-select-db (mysql-connection-ptr conn) db))
     1588                        (signal-mysql-error 'mysql-select-db conn db) ) )
    15701589
    15711590; returns #t if the set was successful, signals exception otherwise.
    15721591(define (mysql-set-character-set conn csname)
    1573   (or (zero? (foreign-mysql-set-character-set (mysql-connection-ptr conn) csname))
    1574       (signal-mysql-condition 'mysql-set-character-set "bad character set name" csname) ) )
     1592        (or (zero? (foreign-mysql-set-character-set (mysql-connection-ptr conn) csname))
     1593                        (signal-mysql-condition 'mysql-set-character-set "bad character set name" csname) ) )
    15751594
    15761595(define (mysql-stat conn)
    1577   (foreign-mysql-stat (mysql-connection-ptr conn)) )
     1596        (foreign-mysql-stat (mysql-connection-ptr conn)) )
    15781597
    15791598(define (mysql-store-result conn)
    1580   (mysql-connection-result-set! conn
    1581     (foreign-mysql-store-result (mysql-connection-ptr conn)))
    1582   (mysql-connection-result-start-set! conn
    1583     (and (mysql-connection-result conn)
    1584         (foreign-mysql-row-tell (mysql-connection-result conn))) ) )
     1599        (mysql-connection-result-set! conn
     1600                (foreign-mysql-store-result (mysql-connection-ptr conn)))
     1601        (mysql-connection-result-start-set! conn
     1602                (and (mysql-connection-result conn)
     1603                                (foreign-mysql-row-tell (mysql-connection-result conn))) ) )
    15851604
    15861605(define (mysql-thread-id conn)
    1587   (foreign-mysql-thread-id (mysql-connection-ptr conn)) )
     1606        (foreign-mysql-thread-id (mysql-connection-ptr conn)) )
    15881607
    15891608;-----------------------------------------------------------------------
     
    15961615; current result set.
    15971616(define (mysql-rewind conn)
    1598   (and-let* ([resptr (mysql-connection-result-start conn)])
    1599     (foreign-mysql-row-seek (mysql-connection-result conn) resptr) ) )
     1617        (and-let* ([resptr (mysql-connection-result-start conn)])
     1618                (foreign-mysql-row-seek (mysql-connection-result conn) resptr) ) )
    16001619
    16011620;-----------------------------------------------------------------------
     
    16191638; using mysql-fetch-row.
    16201639(define (mysql-row-fold conn proc init)
    1621   (mysql-rewind conn)
    1622   (let loop ([rownum 1] [acc init])
    1623     (let ([row (mysql-fetch-row conn)])
    1624       (if row
    1625           (loop (+ rownum 1) (proc row rownum acc))
    1626           acc ) ) ) )
     1640        (mysql-rewind conn)
     1641        (let loop ([rownum 1] [acc init])
     1642                (let ([row (mysql-fetch-row conn)])
     1643                        (if row
     1644                                        (loop (+ rownum 1) (proc row rownum acc))
     1645                                        acc ) ) ) )
    16271646
    16281647; calls proc on every row in the current result set. proc should take 2
     
    16361655; using mysql-fetch-row.
    16371656(define (mysql-row-for-each conn proc)
    1638   (mysql-row-fold conn
    1639                   (lambda (row rownum _) (proc row rownum))
    1640                   #t) )
     1657        (mysql-row-fold conn
     1658                                                                        (lambda (row rownum _) (proc row rownum))
     1659                                                                        #t) )
    16411660
    16421661; calls proc on every row in the current result set. proc should take 2
     
    16521671; using mysql-fetch-row.
    16531672(define (mysql-row-map conn proc)
    1654   (reverse!
    1655     (mysql-row-fold conn
    1656                     (lambda (row rownum lst) (cons (proc row rownum) lst))
    1657                     '())) )
     1673        (reverse!
     1674                (mysql-row-fold conn
     1675                                                                                (lambda (row rownum lst) (cons (proc row rownum) lst))
     1676                                                                                '())) )
    16581677
    16591678; executes query and then mysql-row-for-each with the given proc. the proc
    16601679; must meet the contract specified for the proc passed to mysql-row-for-each.
    16611680(define (mysql-query-fold conn query proc init)
    1662   (mysql-query conn query)
    1663   (mysql-row-fold conn proc init) )
     1681        (mysql-query conn query)
     1682        (mysql-row-fold conn proc init) )
    16641683
    16651684; executes query and then mysql-row-for-each with the given proc. the proc
    16661685; must meet the contract specified for the proc passed to mysql-row-for-each.
    16671686(define (mysql-query-for-each conn query proc)
    1668   (mysql-query conn query)
    1669   (mysql-row-for-each conn proc) )
     1687        (mysql-query conn query)
     1688        (mysql-row-for-each conn proc) )
    16701689
    16711690; executes query and then mysql-row-for-each with the given proc. the proc
    16721691; must meet the contract specified for the proc passed to mysql-row-for-each.
    16731692(define (mysql-query-map conn query proc)
    1674   (mysql-query conn query)
    1675   (mysql-row-map conn proc) )
     1693        (mysql-query conn query)
     1694        (mysql-row-map conn proc) )
    16761695
    16771696; synonyms
     
    16841703
    16851704(define (mysql-field-flags-test fldptr mask)
    1686   (bitwise-and (mysql-field-flags fldptr) mask) )
     1705        (bitwise-and (mysql-field-flags fldptr) mask) )
    16871706
    16881707(define (mysql-field-flags-mask flags)
    1689   (apply bitwise-ior flags) )
     1708        (apply bitwise-ior flags) )
    16901709
    16911710;;
    16921711
    16931712(define (mysql-field-flags-on? fldptr . flags)
    1694   (let ([mask (mysql-field-flags-mask flags)])
    1695     (= mask (mysql-field-flags-test fldptr mask)) ) )
     1713        (let ([mask (mysql-field-flags-mask flags)])
     1714                (= mask (mysql-field-flags-test fldptr mask)) ) )
    16961715
    16971716(define (mysql-field-flags-off? fldptr . flags)
    1698   (zero? (mysql-field-flags-test fldptr (mysql-field-flags-mask flags))) )
     1717        (zero? (mysql-field-flags-test fldptr (mysql-field-flags-mask flags))) )
    16991718
    17001719;;
    17011720
    17021721(define (mysql-field-type-any? fldptr . types)
    1703   (memv (mysql-field-type fldptr) types) )
     1722        (memv (mysql-field-type fldptr) types) )
    17041723
    17051724(define (mysql-field-type=? fldptr type)
    1706   (eqv? type (mysql-field-type fldptr)) )
     1725        (eqv? type (mysql-field-type fldptr)) )
    17071726
    17081727;;
    17091728
    17101729(define (mysql-field-primary-key? fldptr)
    1711   (mysql-field-flags-on? fldptr pri-key-flag) )
     1730        (mysql-field-flags-on? fldptr pri-key-flag) )
    17121731
    17131732(define (mysql-field-not-null? fldptr)
    1714   (mysql-field-flags-on? fldptr not-null-flag) )
     1733        (mysql-field-flags-on? fldptr not-null-flag) )
    17151734
    17161735(define (mysql-field-binary? fldptr)
    1717   (= 63 (mysql-field-charsetnr fldptr)) )
     1736        (= 63 (mysql-field-charsetnr fldptr)) )
    17181737
    17191738(define (mysql-field-numeric? fldptr)
    1720   (mysql-field-flags-on? fldptr num-flag) )
     1739        (mysql-field-flags-on? fldptr num-flag) )
    17211740
    17221741;;
    17231742
    17241743(define mysql-field-type-clock?
    1725   (let ([numtypes (list mysql-type-timestamp mysql-type-datetime
    1726                         mysql-type-date mysql-type-time
    1727                         mysql-type-newdate mysql-type-year)])
    1728     (lambda (fldptr)
    1729       (apply mysql-field-type-any? fldptr numtypes) ) ) )
     1744        (let ([numtypes (list mysql-type-timestamp mysql-type-datetime
     1745                                                                                                mysql-type-date mysql-type-time
     1746                                                                                                mysql-type-newdate mysql-type-year)])
     1747                (lambda (fldptr)
     1748                        (apply mysql-field-type-any? fldptr numtypes) ) ) )
    17301749
    17311750; note - not the same as the "IS_NUM" macro.
    17321751(define mysql-field-type-number?
    1733   (let ([numtypes (list mysql-type-decimal mysql-type-tiny mysql-type-short
    1734                             mysql-type-long mysql-type-float mysql-type-double
    1735                         mysql-type-longlong mysql-type-newdecimal
    1736                         mysql-type-bit)])
    1737     (lambda (fldptr)
    1738       (apply mysql-field-type-any? fldptr numtypes) ) ) )
     1752        (let ([numtypes (list mysql-type-decimal mysql-type-tiny mysql-type-short
     1753                                                                                                mysql-type-long mysql-type-float mysql-type-double
     1754                                                                                                mysql-type-longlong mysql-type-newdecimal
     1755                                                                                                mysql-type-bit)])
     1756                (lambda (fldptr)
     1757                        (apply mysql-field-type-any? fldptr numtypes) ) ) )
    17391758
    17401759(define mysql-field-type-blob?
    1741   (let ([blobtypes (list mysql-type-tiny-blob mysql-type-medium-blob
    1742                         mysql-type-long-blob mysql-type-blob)])
    1743     (lambda (fldptr)
    1744       (apply mysql-field-type-any? fldptr blobtypes) ) ) )
     1760        (let ([blobtypes (list mysql-type-tiny-blob mysql-type-medium-blob
     1761                                                                                                mysql-type-long-blob mysql-type-blob)])
     1762                (lambda (fldptr)
     1763                        (apply mysql-field-type-any? fldptr blobtypes) ) ) )
    17451764
    17461765(define mysql-field-type-string?
    1747   (let ([numtypes (list mysql-type-varchar mysql-type-var-string
    1748                         mysql-type-string
    1749                         mysql-type-enum mysql-type-set)])
    1750     (lambda (fldptr)
    1751       (apply mysql-field-type-any? fldptr numtypes) ) ) )
     1766        (let ([numtypes (list mysql-type-varchar mysql-type-var-string
     1767                                                                                                mysql-type-string
     1768                                                                                                mysql-type-enum mysql-type-set)])
     1769                (lambda (fldptr)
     1770                        (apply mysql-field-type-any? fldptr numtypes) ) ) )
    17521771
    17531772;;
     
    17551774; note - the same as the "IS_NUM" macro.
    17561775(define mysql-field-type-magnitude?
    1757   (let ([magtypes (list mysql-type-timestamp mysql-type-year mysql-type-null)])
    1758     (lambda (fldptr)
    1759       (or (mysql-field-type-number? fldptr)
    1760           (apply mysql-field-type-any? fldptr magtypes) ) ) ) )
     1776        (let ([magtypes (list mysql-type-timestamp mysql-type-year mysql-type-null)])
     1777                (lambda (fldptr)
     1778                        (or (mysql-field-type-number? fldptr)
     1779                                        (apply mysql-field-type-any? fldptr magtypes) ) ) ) )
    17611780
    17621781(define (mysql-field-type-binary? fldptr)
    1763   (and (mysql-field-binary? fldptr)
    1764       (or (mysql-field-type-blob? fldptr)
    1765           (mysql-field-type-string? fldptr) ) ) )
     1782        (and (mysql-field-binary? fldptr)
     1783                        (or (mysql-field-type-blob? fldptr)
     1784                                        (mysql-field-type-string? fldptr) ) ) )
    17661785
    17671786(define (mysql-field-type-text? fldptr)
    1768   (and (not (mysql-field-binary? fldptr))
    1769       (or (mysql-field-type-blob? fldptr)
    1770           (mysql-field-type-string? fldptr) ) ) )
     1787        (and (not (mysql-field-binary? fldptr))
     1788                        (or (mysql-field-type-blob? fldptr)
     1789                                        (mysql-field-type-string? fldptr) ) ) )
    17711790
    17721791;-----------------------------------------------------------------------
     
    17761795; returns a list of field items.
    17771796(define (mysql-field-slots fldptr . getters)
    1778   (and fldptr
    1779       (map (cut <> fldptr) getters) ) )
     1797        (and fldptr
     1798                        (map (cut <> fldptr) getters) ) )
    17801799
    17811800; returns a list of field items for nth field.
    17821801(define (mysql-fetch-field-slots-direct conn nth . getters)
    1783   (apply mysql-field-slots (mysql-fetch-field-direct conn nth) getters) )
     1802        (apply mysql-field-slots (mysql-fetch-field-direct conn nth) getters) )
    17841803
    17851804; returns a field item for nth field.
    17861805(define (mysql-fetch-field-slot-direct conn nth getter)
    1787   (and-let* ([lst (mysql-field-slots (mysql-fetch-field-direct conn nth) getter)])
    1788     (car lst) ) )
     1806        (and-let* ([lst (mysql-field-slots (mysql-fetch-field-direct conn nth) getter)])
     1807                (car lst) ) )
    17891808
    17901809; returns a list of field items for the next field.
    17911810(define (mysql-fetch-field-slots conn . getters)
    1792   (apply mysql-field-slots (mysql-fetch-field conn) getters) )
     1811        (apply mysql-field-slots (mysql-fetch-field conn) getters) )
    17931812
    17941813; returns a field item for the next field.
    17951814(define (mysql-fetch-field-slot conn getter)
    1796   (and-let* ([lst (mysql-field-slots (mysql-fetch-field conn) getter)])
    1797     (car lst) ) )
     1815        (and-let* ([lst (mysql-field-slots (mysql-fetch-field conn) getter)])
     1816                (car lst) ) )
    17981817
    17991818; returns a field pointer or #f.
    18001819(define (mysql-fetch-field-specific conn field)
    1801   (and-let* ([resptr (mysql-connection-result conn)]
    1802             [fldidx (%mysql-get-field-index resptr field (foreign-mysql-num-fields resptr))])
    1803     (foreign-mysql-fetch-field-direct resptr fldidx) ) )
     1820        (and-let* ([resptr (mysql-connection-result conn)]
     1821                                                [fldidx (%mysql-get-field-index resptr field (foreign-mysql-num-fields resptr))])
     1822                (foreign-mysql-fetch-field-direct resptr fldidx) ) )
    18041823
    18051824#|
     
    18091828
    18101829(declare
    1811   (export
    1812     ;; enum enum_mysql_timestamp_type
    1813     mysql-timestamp-date
    1814     mysql-timestamp-datetime
    1815     mysql-timestamp-error
    1816     mysql-timestamp-none
    1817     mysql-timestamp-time
    1818     ;
    1819     mysql-timestamp-type-symbol
    1820     mysql-timestamp-type-value
    1821     ;; MYSQL_TIME
    1822     mysql-time-day-set!
    1823     mysql-time-hour-set!
    1824     mysql-time-minute-set!
    1825     mysql-time-month-set!
    1826     mysql-time-neg-set!
    1827     mysql-time-second-part-set!
    1828     mysql-time-second-set!
    1829     mysql-time-time-type-set!
    1830     mysql-time-year-set!
    1831     ;
    1832     mysql-time-day
    1833     mysql-time-hour
    1834     mysql-time-minute
    1835     mysql-time-month
    1836     mysql-time-neg
    1837     mysql-time-second
    1838     mysql-time-second-part
    1839     mysql-time-time-type
    1840     mysql-time-year
    1841     ;
    1842     make-mysql-time
    1843     allocate-myysql-time
    1844     free-mysql-time ) )
     1830        (export
     1831                ;; enum enum_mysql_timestamp_type
     1832                mysql-timestamp-date
     1833                mysql-timestamp-datetime
     1834                mysql-timestamp-error
     1835                mysql-timestamp-none
     1836                mysql-timestamp-time
     1837                ;
     1838                mysql-timestamp-type-symbol
     1839                mysql-timestamp-type-value
     1840                ;; MYSQL_TIME
     1841                mysql-time-day-set!
     1842                mysql-time-hour-set!
     1843                mysql-time-minute-set!
     1844                mysql-time-month-set!
     1845                mysql-time-neg-set!
     1846                mysql-time-second-part-set!
     1847                mysql-time-second-set!
     1848                mysql-time-time-type-set!
     1849                mysql-time-year-set!
     1850                ;
     1851                mysql-time-day
     1852                mysql-time-hour
     1853                mysql-time-minute
     1854                mysql-time-month
     1855                mysql-time-neg
     1856                mysql-time-second
     1857                mysql-time-second-part
     1858                mysql-time-time-type
     1859                mysql-time-year
     1860                ;
     1861                make-mysql-time
     1862                allocate-myysql-time
     1863                free-mysql-time ) )
    18451864
    18461865;;
     
    18501869;;
    18511870
    1852 (define-foreign-enum (mysql-timestamp-type (enum "enum_mysql_timestamp_type"))
    1853   #f  ; No aliases!
    1854   MYSQL_TIMESTAMP_NONE
    1855   MYSQL_TIMESTAMP_ERROR
    1856   MYSQL_TIMESTAMP_DATE
    1857   MYSQL_TIMESTAMP_DATETIME
    1858   MYSQL_TIMESTAMP_TIME )
    1859 
    1860 (gen-public-enum mysql-timestamp-type
    1861   MYSQL_TIMESTAMP_NONE
    1862   MYSQL_TIMESTAMP_ERROR
    1863   MYSQL_TIMESTAMP_DATE
    1864   MYSQL_TIMESTAMP_DATETIME
    1865   MYSQL_TIMESTAMP_TIME )
     1871(*define-foreign-enum (mysql-timestamp-type (enum "enum_mysql_timestamp_type"))
     1872        #f      ; No aliases!
     1873        MYSQL_TIMESTAMP_NONE
     1874        MYSQL_TIMESTAMP_ERROR
     1875        MYSQL_TIMESTAMP_DATE
     1876        MYSQL_TIMESTAMP_DATETIME
     1877        MYSQL_TIMESTAMP_TIME )
     1878
    18661879;;
    18671880
    18681881(define-foreign-record (mysql-time "MYSQL_TIME")
    1869   (rename: c-name->scheme-name)
    1870   (constructor: allocate-myysql-time)
    1871   (destructor: free-mysql-time)
    1872   (unsigned-int year)
    1873   (unsigned-int month)
    1874   (unsigned-int day)
    1875   (unsigned-int hour)
    1876   (unsigned-int minute)
    1877   (unsigned-int second)
    1878   (unsigned-long second_part)
    1879   (my-bool neg)
    1880   (mysql-timestamp-type time_type) )
     1882        (rename: c-name->scheme-name)
     1883        (constructor: allocate-myysql-time)
     1884        (destructor: free-mysql-time)
     1885        (unsigned-int year)
     1886        (unsigned-int month)
     1887        (unsigned-int day)
     1888        (unsigned-int hour)
     1889        (unsigned-int minute)
     1890        (unsigned-int second)
     1891        (unsigned-long second_part)
     1892        (my-bool neg)
     1893        (mysql-timestamp-type time_type) )
    18811894
    18821895(define (make-mysql-time type #!key (year 0) (month 0) (day 0)
    1883                                     (hour 0) (minute 0) (second 0)
    1884                                     (second-part 0)
    1885                                     is-negative)
    1886   (let ([timptr (allocate-myysql-time)])
    1887     (mysql-time-time-type-set! timptr type)
    1888     (mysql-time-year-set! timptr year)
    1889     (mysql-time-month-set! timptr month)
    1890     (mysql-time-day-set! timptr day)
    1891     (mysql-time-hour-set! timptr hour)
    1892     (mysql-time-minute-set! timptr minute)
    1893     (mysql-time-second-set! timptr second)
    1894     (mysql-time-second-part-set! timptr second-part)
    1895     (mysql-time-neg-set! timptr is-negative)
    1896     (set-finalizer! timptr free-mysql-time)
    1897     timptr ) )
     1896                                                                                                                                                (hour 0) (minute 0) (second 0)
     1897                                                                                                                                                (second-part 0)
     1898                                                                                                                                                is-negative)
     1899        (let ([timptr (allocate-myysql-time)])
     1900                (mysql-time-time-type-set! timptr type)
     1901                (mysql-time-year-set! timptr year)
     1902                (mysql-time-month-set! timptr month)
     1903                (mysql-time-day-set! timptr day)
     1904                (mysql-time-hour-set! timptr hour)
     1905                (mysql-time-minute-set! timptr minute)
     1906                (mysql-time-second-set! timptr second)
     1907                (mysql-time-second-part-set! timptr second-part)
     1908                (mysql-time-neg-set! timptr is-negative)
     1909                (set-finalizer! timptr free-mysql-time)
     1910                timptr ) )
    18981911
    18991912;=======================================================================
     
    19021915
    19031916(declare
    1904   (bound-to-procedure
    1905     mysql-stmt-errno
    1906     mysql-stmt-error
    1907     mysql-stmt-sqlstate )
    1908   (export
    1909     ;;
    1910     stmt-attr-cursor-type
    1911     stmt-attr-prefetch-rows
    1912     stmt-attr-update-max-length
    1913     ;
    1914     mysql-stmt-attr-type-symbol
    1915     mysql-stmt-attr-type-value
    1916     ;;
    1917     mysql-stmt-init-done
    1918     mysql-stmt-execute-done
    1919     mysql-stmt-prepare-done
    1920     mysql-stmt-fetch-done
    1921     ;
    1922     mysql-stmt-state-symbol
    1923     mysql-stmt-state-value
    1924     ;;
    1925     mysql-no-data
    1926     mysql-data-truncated
    1927     ;
    1928     mysql-status-return-code-symbol
    1929     mysql-status-return-code-value
    1930     ;;
    1931     foreign-mysql-stmt-affected-rows
    1932     foreign-mysql-stmt-attr-get
    1933     foreign-mysql-stmt-attr-set
    1934     foreign-mysql-stmt-bind-param
    1935     foreign-mysql-stmt-bind-result
    1936     foreign-mysql-stmt-close
    1937     foreign-mysql-stmt-data-seek
    1938     foreign-mysql-stmt-errno
    1939     foreign-mysql-stmt-error
    1940     foreign-mysql-stmt-execute
    1941     foreign-mysql-stmt-fetch
    1942     foreign-mysql-stmt-fetch-column
    1943     foreign-mysql-stmt-field-count
    1944     foreign-mysql-stmt-free-result
    1945     foreign-mysql-stmt-init
    1946     foreign-mysql-stmt-insert-id
    1947     foreign-mysql-stmt-num-rows
    1948     foreign-mysql-stmt-param-count
    1949     foreign-mysql-stmt-param-metadata
    1950     foreign-mysql-stmt-prepare
    1951     foreign-mysql-stmt-reset
    1952     foreign-mysql-stmt-result-metadata
    1953     foreign-mysql-stmt-row-seek
    1954     foreign-mysql-stmt-row-tell
    1955     foreign-mysql-stmt-send-long-data
    1956     foreign-mysql-stmt-sqlstate
    1957     foreign-mysql-stmt-store-result
    1958     ;; basic
     1917        (bound-to-procedure
     1918                mysql-stmt-errno
     1919                mysql-stmt-error
     1920                mysql-stmt-sqlstate )
     1921        (export
     1922                ;;
     1923                stmt-attr-cursor-type
     1924                stmt-attr-prefetch-rows
     1925                stmt-attr-update-max-length
     1926                ;
     1927                mysql-stmt-attr-type-symbol
     1928                mysql-stmt-attr-type-value
     1929                ;;
     1930                mysql-stmt-init-done
     1931                mysql-stmt-execute-done
     1932                mysql-stmt-prepare-done
     1933                mysql-stmt-fetch-done
     1934                ;
     1935                mysql-stmt-state-symbol
     1936                mysql-stmt-state-value
     1937                ;;
     1938                mysql-no-data
     1939                mysql-data-truncated
     1940                ;
     1941                mysql-status-return-code-symbol
     1942                mysql-status-return-code-value
     1943                ;;
     1944                foreign-mysql-stmt-affected-rows
     1945                foreign-mysql-stmt-attr-get
     1946                foreign-mysql-stmt-attr-set
     1947                foreign-mysql-stmt-bind-param
     1948                foreign-mysql-stmt-bind-result
     1949                foreign-mysql-stmt-close
     1950                foreign-mysql-stmt-data-seek
     1951                foreign-mysql-stmt-errno
     1952                foreign-mysql-stmt-error
     1953                foreign-mysql-stmt-execute
     1954                foreign-mysql-stmt-fetch
     1955                foreign-mysql-stmt-fetch-column
     1956                foreign-mysql-stmt-field-count
     1957                foreign-mysql-stmt-free-result
     1958                foreign-mysql-stmt-init
     1959                foreign-mysql-stmt-insert-id
     1960                foreign-mysql-stmt-num-rows
     1961                foreign-mysql-stmt-param-count
     1962                foreign-mysql-stmt-param-metadata
     1963                foreign-mysql-stmt-prepare
     1964                foreign-mysql-stmt-reset
     1965                foreign-mysql-stmt-result-metadata
     1966                foreign-mysql-stmt-row-seek
     1967                foreign-mysql-stmt-row-tell
     1968                foreign-mysql-stmt-send-long-data
     1969                foreign-mysql-stmt-sqlstate
     1970                foreign-mysql-stmt-store-result
     1971                ;; basic
    19591972                mysql-stmt-errno
    19601973                mysql-stmt-error
     
    19731986                mysql-stmt-attr-set
    19741987                mysql-stmt-attr-get
    1975     ;; extended
     1988                ;; extended
    19761989                mysql-stmt-rewind
    19771990                mysql-stmt-row-fetch
    19781991                mysql-stmt-query
    1979     ;; mapping
     1992                ;; mapping
    19801993                mysql-stmt-row-fold
    19811994                mysql-stmt-row-for-each
     
    19841997                mysql-stmt-query-for-each
    19851998                mysql-stmt-query-map
    1986     ;; MYSQL_BIND
    1987     allocate-mysql-bind
    1988     free-mysql-bind
    1989     mysql-bind-ref
    1990     mysql-bind-clear!
    1991     mysql-bind-param-init
    1992     mysql-bind-result-init
    1993     ;
    1994     mysql-bind-buffer-set!
    1995     mysql-bind-buffer-length-set!
    1996     mysql-bind-buffer-type-set!
    1997     mysql-bind-error-set!
    1998     mysql-bind-error-value-set!
    1999     mysql-bind-is-null-set!
    2000     mysql-bind-is-null-value-set!
    2001     mysql-bind-is-unsigned-set!
    2002     mysql-bind-length-set!
    2003     ;
    2004     mysql-bind-buffer
    2005     mysql-bind-buffer-length
    2006     mysql-bind-buffer-type
    2007     mysql-bind-error
    2008     mysql-bind-error-value
    2009     mysql-bind-is-null
    2010     mysql-bind-is-null-value
    2011     mysql-bind-is-unsigned
    2012     mysql-bind-length ) )
     1999                ;; MYSQL_BIND
     2000                allocate-mysql-bind
     2001                free-mysql-bind
     2002                mysql-bind-ref
     2003                mysql-bind-clear!
     2004                mysql-bind-param-init
     2005                mysql-bind-result-init
     2006                ;
     2007                mysql-bind-buffer-set!
     2008                mysql-bind-buffer-length-set!
     2009                mysql-bind-buffer-type-set!
     2010                mysql-bind-error-set!
     2011                mysql-bind-error-value-set!
     2012                mysql-bind-is-null-set!
     2013                mysql-bind-is-null-value-set!
     2014                mysql-bind-is-unsigned-set!
     2015                mysql-bind-length-set!
     2016                ;
     2017                mysql-bind-buffer
     2018                mysql-bind-buffer-length
     2019                mysql-bind-buffer-type
     2020                mysql-bind-error
     2021                mysql-bind-error-value
     2022                mysql-bind-is-null
     2023                mysql-bind-is-null-value
     2024                mysql-bind-is-unsigned
     2025                mysql-bind-length ) )
    20132026
    20142027;;
     
    20222035;;
    20232036
    2024 (define-foreign-enum (mysql-stmt-state (enum "enum_mysql_stmt_state"))
    2025   #f  ; No aliases!
    2026   MYSQL_STMT_INIT_DONE
    2027   MYSQL_STMT_PREPARE_DONE
    2028   MYSQL_STMT_EXECUTE_DONE
    2029   MYSQL_STMT_FETCH_DONE )
    2030 
    2031 (gen-public-enum mysql-stmt-state
    2032   MYSQL_STMT_INIT_DONE
    2033   MYSQL_STMT_PREPARE_DONE
    2034   MYSQL_STMT_EXECUTE_DONE
    2035   MYSQL_STMT_FETCH_DONE )
    2036 
    2037 (define-foreign-enum (mysql-stmt-attr-type (enum "enum_stmt_attr_type"))
    2038   #f  ; No aliases!
    2039   STMT_ATTR_UPDATE_MAX_LENGTH
    2040   STMT_ATTR_CURSOR_TYPE
    2041   STMT_ATTR_PREFETCH_ROWS )
    2042 
    2043 (gen-public-enum mysql-stmt-attr-type
    2044   STMT_ATTR_UPDATE_MAX_LENGTH
    2045   STMT_ATTR_CURSOR_TYPE
    2046   STMT_ATTR_PREFETCH_ROWS )
    2047 
    2048 (define-foreign-enum (mysql-status-return-code unsigned-int)
    2049   #f  ; No aliases!
    2050   MYSQL_NO_DATA
    2051   MYSQL_DATA_TRUNCATED )
    2052 
    2053 (gen-public-enum mysql-status-return-code
    2054   MYSQL_NO_DATA
    2055   MYSQL_DATA_TRUNCATED )
     2037(*define-foreign-enum (mysql-stmt-state (enum "enum_mysql_stmt_state"))
     2038        #f      ; No aliases!
     2039        MYSQL_STMT_INIT_DONE
     2040        MYSQL_STMT_PREPARE_DONE
     2041        MYSQL_STMT_EXECUTE_DONE
     2042        MYSQL_STMT_FETCH_DONE )
     2043
     2044(*define-foreign-enum (mysql-stmt-attr-type (enum "enum_stmt_attr_type"))
     2045        #f      ; No aliases!
     2046        STMT_ATTR_UPDATE_MAX_LENGTH
     2047        STMT_ATTR_CURSOR_TYPE
     2048        STMT_ATTR_PREFETCH_ROWS )
     2049
     2050(*define-foreign-enum (mysql-status-return-code unsigned-int)
     2051        #f      ; No aliases!
     2052        MYSQL_NO_DATA
     2053        MYSQL_DATA_TRUNCATED )
    20562054
    20572055;;
     
    20592057;MYSQL_STMT *mysql_stmt_init(MYSQL *mysql)
    20602058(define foreign-mysql-stmt-init
    2061   (foreign-lambda mysql-stmt-ptr "mysql_stmt_init" mysql-ptr))
     2059        (foreign-lambda mysql-stmt-ptr "mysql_stmt_init" mysql-ptr))
    20622060
    20632061;my_bool mysql_stmt_close(MYSQL_STMT *mysql)
     
    21092107mysqlaux_stmt_attr_set_bool (MYSQL_STMT *stmt, enum enum_stmt_attr_type attr, my_bool value)
    21102108{
    2111   return (mysql_stmt_attr_set (stmt, attr, &value));
     2109        return (mysql_stmt_attr_set (stmt, attr, &value));
    21122110}
    21132111
     
    21152113mysqlaux_stmt_attr_set_ulong (MYSQL_STMT *stmt, enum enum_stmt_attr_type attr, unsigned long value)
    21162114{
    2117   return (mysql_stmt_attr_set (stmt, attr, &value));
     2115        return (mysql_stmt_attr_set (stmt, attr, &value));
    21182116}
    21192117<#
    21202118
    21212119(define foreign-mysqlaux-stmt-attr-set-bool
    2122   (foreign-lambda int "mysqlaux_stmt_attr_set_bool"
    2123                       mysql-stmt-ptr mysql-stmt-attr-type my-bool) )
     2120        (foreign-lambda int "mysqlaux_stmt_attr_set_bool"
     2121                                                                                        mysql-stmt-ptr mysql-stmt-attr-type my-bool) )
    21242122
    21252123(define foreign-mysqlaux-stmt-attr-set-ulong
    2126   (foreign-lambda int "mysqlaux_stmt_attr_set_ulong"
    2127                       mysql-stmt-ptr mysql-stmt-attr-type unsigned-long) )
     2124        (foreign-lambda int "mysqlaux_stmt_attr_set_ulong"
     2125                                                                                        mysql-stmt-ptr mysql-stmt-attr-type unsigned-long) )
    21282126
    21292127;my_bool mysql_stmt_reset(MYSQL_STMT * stmt)
     
    21712169mysqlaux_stmt_data_seek (MYSQL_STMT *stmt, double offset)
    21722170{
    2173   mysql_stmt_data_seek (stmt, (my_ulonglong) offset);
     2171        mysql_stmt_data_seek (stmt, (my_ulonglong) offset);
    21742172}
    21752173
     
    21772175mysqlaux_stmt_num_rows (MYSQL_STMT *stmt)
    21782176{
    2179   return ((double) mysql_stmt_num_rows (stmt));
     2177        return ((double) mysql_stmt_num_rows (stmt));
    21802178}
    21812179
     
    21832181mysqlaux_stmt_affected_rows (MYSQL_STMT *stmt)
    21842182{
    2185   return ((double) mysql_stmt_affected_rows (stmt));
     2183        return ((double) mysql_stmt_affected_rows (stmt));
    21862184}
    21872185
     
    21892187mysqlaux_stmt_insert_id (MYSQL_STMT *stmt)
    21902188{
    2191   return ((double) mysql_stmt_insert_id (stmt));
     2189        return ((double) mysql_stmt_insert_id (stmt));
    21922190}
    21932191<#
     
    22162214
    22172215(define-foreign-record (mysql-bind "MYSQL_BIND")
    2218   (rename: c-name->scheme-name)
    2219   ; special ctor
    2220   (destructor: free-mysql-bind)
    2221   ((c-pointer "unsigned long") length)    ; output length pointer
    2222   ((c-pointer "my_bool") is_null)                   ; Pointer to null indicator
    2223   (c-pointer buffer)                      ; buffer to get/put data
    2224   ((c-pointer "my_bool") error)                 ; set this if you want to track data truncations happened during fetch
    2225   (unsigned-long buffer_length)           ; output buffer length, must be set when fetching str/binary
    2226   (mysql-type buffer_type)                          ; buffer type
    2227   (my-bool is_unsigned)                         ; set if integer type is unsigned
    2228   ; ???
    2229   (my-bool error_value)                         ; used if error is 0
    2230   (my-bool is_null_value) )               ; Used if is_null is 0
     2216        (rename: c-name->scheme-name)
     2217        ; special ctor
     2218        (destructor: free-mysql-bind)
     2219        ((c-pointer "unsigned long") length)            ; output length pointer
     2220        ((c-pointer "my_bool") is_null)                                 ; Pointer to null indicator
     2221        (c-pointer buffer)                                                                                      ; buffer to get/put data
     2222        ((c-pointer "my_bool") error)                                           ; set this if you want to track data truncations happened during fetch
     2223        (unsigned-long buffer_length)                                           ; output buffer length, must be set when fetching str/binary
     2224        (mysql-type buffer_type)                                                                ; buffer type
     2225        (my-bool is_unsigned)                                                                           ; set if integer type is unsigned
     2226        ; ???
     2227        (my-bool error_value)                                                                           ; used if error is 0
     2228        (my-bool is_null_value) )                                                               ; Used if is_null is 0
    22312229
    22322230;; Returns a c-vector of MYSQL_BIND - zeroed
     
    22342232
    22352233(define (allocate-mysql-bind #!optional (cnt 1))
    2236   ((foreign-lambda* mysql-bind-ptr ((unsigned-integer cnt))
    2237   "return ((1 <= cnt) ? ((MYSQL_BIND *) calloc (cnt, sizeof(MYSQL_BIND))) : NULL);")
    2238   cnt) )
     2234        ((foreign-lambda* mysql-bind-ptr ((unsigned-integer cnt))
     2235        "return ((1 <= cnt) ? ((MYSQL_BIND *) calloc (cnt, sizeof(MYSQL_BIND))) : NULL);")
     2236        cnt) )
    22392237
    22402238;; Zeros MYSQL_BIND at index in a c-vector or MYSQL_BIND
     
    22422240
    22432241(define (mysql-bind-clear! bindptr idx)
    2244   ((foreign-lambda* mysql-bind-ptr ((mysql-bind-ptr ptr) (unsigned-integer idx))
    2245   "memset (&(ptr[idx]), 0, sizeof(MYSQL_BIND));")
    2246   bindptr idx) )
     2242        ((foreign-lambda* mysql-bind-ptr ((mysql-bind-ptr ptr) (unsigned-integer idx))
     2243        "memset (&(ptr[idx]), 0, sizeof(MYSQL_BIND));")
     2244        bindptr idx) )
    22472245
    22482246;; Returns c-pointer to MYSQL_BIND at index in a c-vector or MYSQL_BIND
     
    22502248
    22512249(define (mysql-bind-ref bindptr idx)
    2252   ((foreign-lambda* mysql-bind-ptr ((mysql-bind-ptr ptr) (unsigned-integer idx))
    2253   "return (&(ptr[idx]));")
    2254   bindptr idx) )
     2250        ((foreign-lambda* mysql-bind-ptr ((mysql-bind-ptr ptr) (unsigned-integer idx))
     2251        "return (&(ptr[idx]));")
     2252        bindptr idx) )
    22552253
    22562254;; Allocates a memory block for a MYSQL_BIND value slots
     
    22582256
    22592257(define (allocate-mysql-bind-variables bindptr len is-null error)
    2260   ((foreign-lambda* void ((mysql-bind-ptr bind) (unsigned-integer len)
    2261                           (my-bool is_null) (my-bool error))
     2258        ((foreign-lambda* void ((mysql-bind-ptr bind) (unsigned-integer len)
     2259                                                                                                        (my-bool is_null) (my-bool error))
    22622260#<<END
    2263     /* Contiguous variable allocation template */
    2264     typedef struct {
    2265       unsigned long length;
    2266       my_bool is_null;
    2267       my_bool error;
    2268       C_word buffer[1]; /* len is size of the C storage type */
    2269     } bind_slots;
    2270 
    2271     /* Allocate variables in contiguous, zero filled, memory */
    2272     size_t siz = (sizeof(bind_slots) - sizeof(((bind_slots *)0)->buffer))
    2273                   + (((len / sizeof (C_word)) + (len % sizeof (C_word))) * sizeof (C_word));
    2274     bind_slots * ptr = ((bind_slots *) calloc (siz, sizeof (char)));
    2275 
    2276     ptr->is_null = is_null;
    2277     ptr->length = len;
    2278     ptr->error = error;
    2279 
    2280     bind->buffer_length = len;
    2281     bind->buffer = (char *) &(ptr->buffer);
    2282     bind->is_null = &(ptr->is_null);
    2283     bind->length = &(ptr->length);
    2284     bind->error = &(ptr->error);
     2261                /* Contiguous variable allocation template */
     2262                typedef struct {
     2263                        unsigned long length;
     2264                        my_bool is_null;
     2265                        my_bool error;
     2266                        C_word buffer[1]; /* len is size of the C storage type */
     2267                } bind_slots;
     2268
     2269                /* Allocate variables in contiguous, zero filled, memory */
     2270                size_t siz = (sizeof(bind_slots) - sizeof(((bind_slots *)0)->buffer))
     2271                                                                        + (((len / sizeof (C_word)) + (len % sizeof (C_word))) * sizeof (C_word));
     2272                bind_slots * ptr = ((bind_slots *) calloc (siz, sizeof (char)));
     2273
     2274                ptr->is_null = is_null;
     2275                ptr->length = len;
     2276                ptr->error = error;
     2277
     2278                bind->buffer_length = len;
     2279                bind->buffer = (char *) &(ptr->buffer);
     2280                bind->is_null = &(ptr->is_null);
     2281                bind->length = &(ptr->length);
     2282                bind->error = &(ptr->error);
    22852283END
    2286   )
    2287   bindptr len is-null error) )
     2284        )
     2285        bindptr len is-null error) )
    22882286
    22892287(define (%mysql-foreign-type-length foreign-type #!optional (obj (void)))
     
    22972295
    22982296(define (mysql-bind-param-init-direct bindptr idx obj #!key type is-unsigned is-null error)
    2299   (mysql-bind-clear! bindptr idx)
    2300   (unless type
    2301     (let-values ([(typ uflg nflg) (%mysql-determine-type obj is-unsigned is-null)])
    2302       (set! type typ)
    2303       (set! is-unsigned uflg)
    2304       (set! is-null nflg) ) )
    2305   (when (and (mysql-null-object? obj) (not (eqv? mysql-type-null type)))
    2306     (warning "null object implies null type")
    2307     (set! type mysql-type-null) )
    2308   (mysql-bind-buffer-type-set! bindptr type)
    2309   (unless (eqv? mysql-type-null type)
    2310     (mysql-bind-is-unsigned-set! bindptr is-unsigned)
    2311     (let* ([foreign-type (%mysql-determine-foreign-type type is-unsigned is-null)]
    2312           [len (%mysql-foreign-type-length foreign-type obj)])
    2313       (allocate-mysql-bind-variables bindptr len is-null error) ) ) )
     2297        (mysql-bind-clear! bindptr idx)
     2298        (unless type
     2299                (let-values ([(typ uflg nflg) (%mysql-determine-type obj is-unsigned is-null)])
     2300                        (set! type typ)
     2301                        (set! is-unsigned uflg)
     2302                        (set! is-null nflg) ) )
     2303        (when (and (mysql-null-object? obj) (not (eqv? mysql-type-null type)))
     2304                (warning "null object implies null type")
     2305                (set! type mysql-type-null) )
     2306        (mysql-bind-buffer-type-set! bindptr type)
     2307        (unless (eqv? mysql-type-null type)
     2308                (mysql-bind-is-unsigned-set! bindptr is-unsigned)
     2309                (let* ([foreign-type (%mysql-determine-foreign-type type is-unsigned is-null)]
     2310                                        [len (%mysql-foreign-type-length foreign-type obj)])
     2311                        (allocate-mysql-bind-variables bindptr len is-null error) ) ) )
    23142312
    23152313(define (mysql-bind-result-init-direct bindptr idx type #!optional len)
    2316   (mysql-bind-clear! bindptr idx)
    2317   (mysql-bind-buffer-type-set! bindptr type)
    2318   (unless (eqv? mysql-type-null type)
    2319     (let* ([foreign-type (%mysql-determine-foreign-type type #f #f)]
    2320           [len (or len
    2321                     (%mysql-foreign-type-length foreign-type))])
    2322       (allocate-mysql-bind-variables bindptr len #f #f) ) ) )
     2314        (mysql-bind-clear! bindptr idx)
     2315        (mysql-bind-buffer-type-set! bindptr type)
     2316        (unless (eqv? mysql-type-null type)
     2317                (let* ([foreign-type (%mysql-determine-foreign-type type #f #f)]
     2318                                        [len (or len
     2319                                                                                (%mysql-foreign-type-length foreign-type))])
     2320                        (allocate-mysql-bind-variables bindptr len #f #f) ) ) )
    23232321
    23242322;;
    23252323
    23262324; (mysql-bind-param-init
    2327 ;   (list obj #:key T #:is-unsigned B #:is-null B #:error B)
    2328 ;   ...
    2329 ;   (list obj #:key T #:is-unsigned B #:is-null B #:error B))
     2325;               (list obj #:key T #:is-unsigned B #:is-null B #:error B)
     2326;               ...
     2327;               (list obj #:key T #:is-unsigned B #:is-null B #:error B))
    23302328
    23312329(define (mysql-bind-param-init . inits)
    2332   (let ([bindptr (allocate-mysql-bind (length inits))])
    2333     (let loop ([inits inits] [idx 0])
    2334       (if (null? inits)
    2335           bindptr
    2336           (begin
    2337             (apply mysql-bind-param-init-direct bindptr idx (car inits))
    2338             (loop (cdr inits) (+ idx 1)) ) ) ) ) )
     2330        (let ([bindptr (allocate-mysql-bind (length inits))])
     2331                (let loop ([inits inits] [idx 0])
     2332                        (if (null? inits)
     2333                                        bindptr
     2334                                        (begin
     2335                                                (apply mysql-bind-param-init-direct bindptr idx (car inits))
     2336                                                (loop (cdr inits) (+ idx 1)) ) ) ) ) )
    23392337
    23402338; (mysql-bind-result-init
    2341 ;   (list T #:len I)
    2342 ;   ...
    2343 ;   (list T #:len I))
     2339;               (list T #:len I)
     2340;               ...
     2341;               (list T #:len I))
    23442342
    23452343(define (mysql-bind-result-init conn . inits)
    2346   (let ([bindptr (allocate-mysql-bind (length inits))])
    2347     (let loop ([inits inits] [idx 0])
    2348       (if (null? inits)
    2349           bindptr
    2350           (begin
    2351             (apply mysql-bind-result-init-direct bindptr idx (car inits))
    2352             (loop (cdr inits) (+ idx 1)) ) ) ) ) )
     2344        (let ([bindptr (allocate-mysql-bind (length inits))])
     2345                (let loop ([inits inits] [idx 0])
     2346                        (if (null? inits)
     2347                                        bindptr
     2348                                        (begin
     2349                                                (apply mysql-bind-result-init-direct bindptr idx (car inits))
     2350                                                (loop (cdr inits) (+ idx 1)) ) ) ) ) )
    23532351
    23542352;;
     
    23562354#;
    23572355(define (mysql-bind-result->object bindptr)
    2358   (void) )
     2356        (void) )
    23592357
    23602358;;
    23612359
    23622360(define (%mysql-stmt-attr-set stmtptr attr val)
    2363   (cond [(boolean? val)
    2364           (foreign-mysqlaux-stmt-attr-set-bool stmtptr attr val)]
    2365         [(number? val)
    2366           (foreign-mysqlaux-stmt-attr-set-ulong stmtptr attr val)]
    2367         [else
    2368           #t ] ) )
     2361        (cond [(boolean? val)
     2362                                        (foreign-mysqlaux-stmt-attr-set-bool stmtptr attr val)]
     2363                                [(number? val)
     2364                                        (foreign-mysqlaux-stmt-attr-set-ulong stmtptr attr val)]
     2365                                [else
     2366                                        #t ] ) )
    23692367
    23702368(define (%mysql-stmt-attr-get stmtptr attr)
    2371   (select attr
    2372     [(stmt-attr-cursor-type stmt-attr-prefetch-rows)
    2373       (let-location ([val unsigned-long])
    2374         (foreign-mysql-stmt-attr-get stmtptr attr #$val)
    2375         val ) ]
    2376     [(stmt-attr-update-max-length)
    2377       (let-location ([val my-bool])
    2378         (foreign-mysql-stmt-attr-get stmtptr attr #$val)
    2379         val ) ]
    2380     [else
    2381       (void) ] ) )
     2369        (select attr
     2370                [(stmt-attr-cursor-type stmt-attr-prefetch-rows)
     2371                        (let-location ([val unsigned-long])
     2372                                (foreign-mysql-stmt-attr-get stmtptr attr #$val)
     2373                                val ) ]
     2374                [(stmt-attr-update-max-length)
     2375                        (let-location ([val my-bool])
     2376                                (foreign-mysql-stmt-attr-get stmtptr attr #$val)
     2377                                val ) ]
     2378                [else
     2379                        (void) ] ) )
    23822380
    23832381(define (%mysql-free-bind conn)
    2384   (and-let* ([bindptr (mysql-connection-binding conn)])
    2385     (free-mysql-bind bindptr)
    2386     (mysql-connection-binding-set! conn #f) ) )
     2382        (and-let* ([bindptr (mysql-connection-binding conn)])
     2383                (free-mysql-bind bindptr)
     2384                (mysql-connection-binding-set! conn #f) ) )
    23872385
    23882386(define (%mysql-stmt-close conn)
    2389   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2390     (mysql-connection-statement-set! conn #f)
    2391     (%mysql-free-bind conn) ; free any result/param binding
    2392     (when (foreign-mysql-stmt-close stmtptr)
    2393       (signal-mysql-stmt-error 'mysql-stmt-close conn) ) ) )
     2387        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2388                (mysql-connection-statement-set! conn #f)
     2389                (%mysql-free-bind conn) ; free any result/param binding
     2390                (when (foreign-mysql-stmt-close stmtptr)
     2391                        (signal-mysql-stmt-error 'mysql-stmt-close conn) ) ) )
    23942392
    23952393;;
    23962394
    23972395(define (mysql-null-object? obj)
    2398   (void) )
     2396        (void) )
    23992397
    24002398;;
    24012399
    24022400(define (signal-mysql-stmt-error loc conn . args)
    2403   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2404     (let ([err (or (mysql-stmt-error stmtptr)
    2405                   (mysql-stmt-errno stmtptr))]
    2406           [sta (mysql-stmt-sqlstate conn)])
    2407       (apply signal-mysql-condition loc
    2408                                     (string-append err
    2409                                                   (if sta
    2410                                                       (string-append " - " sta)
    2411                                                       ""))
    2412                                     conn args) ) ) )
     2401        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2402                (let ([err (or (mysql-stmt-error stmtptr)
     2403                                                                        (mysql-stmt-errno stmtptr))]
     2404                                        [sta (mysql-stmt-sqlstate conn)])
     2405                        (apply signal-mysql-condition loc
     2406                                                                                                                                                (string-append err
     2407                                                                                                                                                                                                        (if sta
     2408                                                                                                                                                                                                                        (string-append " - " sta)
     2409                                                                                                                                                                                                                        ""))
     2410                                                                                                                                                conn args) ) ) )
    24132411
    24142412;-----------------------------------------------------------------------
     
    24192417
    24202418(define (mysql-stmt-errno conn)
    2421   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2422     (foreign-mysql-stmt-errno stmtptr) ) )
     2419        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2420                (foreign-mysql-stmt-errno stmtptr) ) )
    24232421
    24242422; Returns a string describing the last mysql stmt error, or #f if no error
    24252423; has occurred.
    24262424(define (mysql-stmt-error conn)
    2427   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2428     (let ([errstr (foreign-mysql-stmt-error stmtptr)])
    2429       (and (not (string=? "" errstr))
    2430           errstr ) ) ) )
     2425        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2426                (let ([errstr (foreign-mysql-stmt-error stmtptr)])
     2427                        (and (not (string=? "" errstr))
     2428                                        errstr ) ) ) )
    24312429
    24322430; Returns a string describing the last mysql stmt state error, or #f if no error
    24332431; has occurred.
    24342432(define (mysql-stmt-sqlstate conn)
    2435   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2436     (let ([errstr (foreign-mysql-stmt-sqlstate stmtptr)])
    2437       (and (not (or (string=? "00000" errstr)
    2438                     (string=? "HY000" errstr)))
    2439           errstr ) ) ) )
     2433        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2434                (let ([errstr (foreign-mysql-stmt-sqlstate stmtptr)])
     2435                        (and (not (or (string=? "00000" errstr)
     2436                                                                                (string=? "HY000" errstr)))
     2437                                        errstr ) ) ) )
    24402438
    24412439(define (mysql-stmt-init conn)
    2442   (%mysql-stmt-close conn)
    2443   (let ([stmtptr (foreign-mysql-stmt-init (mysql-connection-ptr conn))])
    2444     (if stmtptr
    2445         (mysql-connection-statement-set! conn stmtptr)
    2446         (signal-mysql-condition 'mysql-stmt-init "out of memory") ) ) )
     2440        (%mysql-stmt-close conn)
     2441        (let ([stmtptr (foreign-mysql-stmt-init (mysql-connection-ptr conn))])
     2442                (if stmtptr
     2443                                (mysql-connection-statement-set! conn stmtptr)
     2444                                (signal-mysql-condition 'mysql-stmt-init "out of memory") ) ) )
    24472445
    24482446(define (mysql-stmt-prepare conn sql)
    2449   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2450     (unless (zero? (foreign-mysql-stmt-prepare stmtptr sql (string-length sql)))
    2451       (signal-mysql-stmt-error 'mysql-stmt-prepare stmtptr) ) ) )
     2447        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2448                (unless (zero? (foreign-mysql-stmt-prepare stmtptr sql (string-length sql)))
     2449                        (signal-mysql-stmt-error 'mysql-stmt-prepare stmtptr) ) ) )
    24522450
    24532451(define (mysql-stmt-param-count conn)
    2454   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2455     (foreign-mysql-stmt-param-count stmtptr) ) )
     2452        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2453                (foreign-mysql-stmt-param-count stmtptr) ) )
    24562454
    24572455(define (mysql-stmt-bind-param conn bindptr)
    2458   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2459     #; ;This souldn't be necessary
    2460     (%mysql-free-bind conn)
    2461     (if (foreign-mysql-stmt-bind-param stmtptr bindptr)
    2462         (signal-mysql-stmt-error 'mysql-stmt-bind-param stmtptr)
    2463         (mysql-connection-binding-set! conn bindptr) ) ) )
     2456        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2457                #; ;This souldn't be necessary
     2458                (%mysql-free-bind conn)
     2459                (if (foreign-mysql-stmt-bind-param stmtptr bindptr)
     2460                                (signal-mysql-stmt-error 'mysql-stmt-bind-param stmtptr)
     2461                                (mysql-connection-binding-set! conn bindptr) ) ) )
    24642462
    24652463(define (mysql-stmt-execute conn)
    2466   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2467     (unless (zero? (foreign-mysql-stmt-execute stmtptr))
    2468       (signal-mysql-stmt-error 'mysql-stmt-execute stmtptr) ) ) )
     2464        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2465                (unless (zero? (foreign-mysql-stmt-execute stmtptr))
     2466                        (signal-mysql-stmt-error 'mysql-stmt-execute stmtptr) ) ) )
    24692467
    24702468(define (mysql-stmt-affected-rows conn)
    2471   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2472     (let ([cnt (foreign-mysql-stmt-affected-rows stmtptr)])
    2473       (and (not (= -1 cnt))
    2474           cnt ) ) ) )
     2469        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2470                (let ([cnt (foreign-mysql-stmt-affected-rows stmtptr)])
     2471                        (and (not (= -1 cnt))
     2472                                        cnt ) ) ) )
    24752473
    24762474(define (mysql-stmt-bind-result conn bindptr)
    2477   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2478     (%mysql-free-bind conn) ; free the param bindings
    2479     (if (foreign-mysql-stmt-bind-result stmtptr bindptr)
    2480         (signal-mysql-stmt-error 'mysql-stmt-bind-result stmtptr)
    2481         (mysql-connection-binding-set! conn bindptr) ) ) )
     2475        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2476                (%mysql-free-bind conn) ; free the param bindings
     2477                (if (foreign-mysql-stmt-bind-result stmtptr bindptr)
     2478                                (signal-mysql-stmt-error 'mysql-stmt-bind-result stmtptr)
     2479                                (mysql-connection-binding-set! conn bindptr) ) ) )
    24822480
    24832481; returns boolean for success, mysql-data-truncated, or signals
    24842482; an exception.
    24852483(define (mysql-stmt-fetch conn)
    2486   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2487     (let ([val (foreign-mysql-stmt-fetch stmtptr)])
    2488       (cond [(zero? val)
    2489               #t]
    2490             [(= mysql-no-data val)
    2491               #f]
    2492             [(= mysql-data-truncated val)
    2493               mysql-data-truncated]
    2494             [(= 1 val)
    2495               (signal-mysql-stmt-error 'mysql-stmt-fetch stmtptr) ] ) ) ) )
     2484        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2485                (let ([val (foreign-mysql-stmt-fetch stmtptr)])
     2486                        (cond [(zero? val)
     2487                                                        #t]
     2488                                                [(= mysql-no-data val)
     2489                                                        #f]
     2490                                                [(= mysql-data-truncated val)
     2491                                                        mysql-data-truncated]
     2492                                                [(= 1 val)
     2493                                                        (signal-mysql-stmt-error 'mysql-stmt-fetch stmtptr) ] ) ) ) )
    24962494
    24972495; causes the result to be buffered. does not touch the connection
    24982496; result!
    24992497(define (mysql-stmt-store-result conn)
    2500   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2501     (when (zero? (foreign-mysql-stmt-store-result stmtptr))
    2502       (signal-mysql-stmt-error 'mysql-stmt-store-result stmtptr) ) ) )
     2498        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2499                (when (zero? (foreign-mysql-stmt-store-result stmtptr))
     2500                        (signal-mysql-stmt-error 'mysql-stmt-store-result stmtptr) ) ) )
    25032501
    25042502; can only be invoked after a stmt-store-result and stmt-fetch.
    25052503(define (mysql-stmt-result-metadata conn)
    2506   (mysql-free-result conn)
    2507   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2508     (let ([resptr (foreign-mysql-stmt-result-metadata stmtptr)])
    2509       (if resptr
    2510           (begin
    2511             (mysql-connection-result-set! conn resptr)
    2512             (mysql-connection-result-start-set! conn
    2513               (foreign-mysql-stmt-row-tell (mysql-connection-result conn))) )
    2514           (signal-mysql-stmt-error 'mysql-stmt-result-metadata stmtptr) ) ) ) )
     2504        (mysql-free-result conn)
     2505        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2506                (let ([resptr (foreign-mysql-stmt-result-metadata stmtptr)])
     2507                        (if resptr
     2508                                        (begin
     2509                                                (mysql-connection-result-set! conn resptr)
     2510                                                (mysql-connection-result-start-set! conn
     2511                                                        (foreign-mysql-stmt-row-tell (mysql-connection-result conn))) )
     2512                                        (signal-mysql-stmt-error 'mysql-stmt-result-metadata stmtptr) ) ) ) )
    25152513
    25162514(define (mysql-stmt-attr-set conn attr val)
    2517   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2518     (when (%mysql-stmt-attr-set stmtptr attr val)
    2519       (signal-mysql-condition 'stmt-attr-set
    2520                               "unknown statement attribute" attr val) ) ) )
     2515        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2516                (when (%mysql-stmt-attr-set stmtptr attr val)
     2517                        (signal-mysql-condition 'stmt-attr-set
     2518                                                                                                                        "unknown statement attribute" attr val) ) ) )
    25212519
    25222520(define (mysql-stmt-attr-get conn attr)
    2523   (and-let* ([stmtptr (mysql-connection-statement conn)])
    2524     (let ([val (%mysql-stmt-attr-get stmtptr attr)])
    2525       (if (eq? (void) val)
    2526           (signal-mysql-condition 'stmt-attr-get
    2527                                   "unknown statement attribute" attr)
    2528           val ) ) ) )
     2521        (and-let* ([stmtptr (mysql-connection-statement conn)])
     2522                (let ([val (%mysql-stmt-attr-get stmtptr attr)])
     2523                        (if (eq? (void) val)
     2524                                        (signal-mysql-condition 'stmt-attr-get
     2525                                                                                                                                        "unknown statement attribute" attr)
     2526                                        val ) ) ) )
    25292527
    25302528;-----------------------------------------------------------------------
     
    25372535; current result set.
    25382536(define (mysql-stmt-rewind conn)
    2539   (and-let* ([stmtptr (mysql-connection-statement conn)]
    2540             [resptr (mysql-connection-result-start conn)])
    2541     (foreign-mysql-stmt-row-seek stmtptr resptr) ) )
     2537        (and-let* ([stmtptr (mysql-connection-statement conn)]
     2538                                                [resptr (mysql-connection-result-start conn)])
     2539                (foreign-mysql-stmt-row-seek stmtptr resptr) ) )
    25422540
    25432541; returns a procedure, or #f when no connection.
     
    25462544; when no more rows to fetch.
    25472545(define (mysql-stmt-row-fetch conn)
    2548   (and-let* ([resptr (mysql-connection-result conn)]
    2549             [bindptr (mysql-connection-binding conn)]
    2550             [(mysql-stmt-fetch conn)])
    2551     (let ([fldcnt (mysql-num-fields conn)])
    2552       (lambda (field)
    2553         (and-let* ([fldidx (%mysql-get-field-index resptr field fldcnt)])
    2554           (mysql-bind-ref bindptr fldidx) ) ) ) ) )
     2546        (and-let* ([resptr (mysql-connection-result conn)]
     2547                                                [bindptr (mysql-connection-binding conn)]
     2548                                                [(mysql-stmt-fetch conn)])
     2549                (let ([fldcnt (mysql-num-fields conn)])
     2550                        (lambda (field)
     2551                                (and-let* ([fldidx (%mysql-get-field-index resptr field fldcnt)])
     2552                                        (mysql-bind-ref bindptr fldidx) ) ) ) ) )
    25552553
    25562554;
    25572555(define (mysql-stmt-query conn query params #!optional results)
    2558   (mysql-stmt-prepare conn query)
    2559   (mysql-stmt-bind-param conn params)
    2560   (mysql-stmt-execute conn)
    2561   (when results
    2562     (mysql-stmt-result-metadata conn)
    2563     (mysql-stmt-bind-result conn results) ) )
     2556        (mysql-stmt-prepare conn query)
     2557        (mysql-stmt-bind-param conn params)
     2558        (mysql-stmt-execute conn)
     2559        (when results
     2560                (mysql-stmt-result-metadata conn)
     2561                (mysql-stmt-bind-result conn results) ) )
    25642562
    25652563;-----------------------------------------------------------------------
     
    25832581; using mysql-stmt-row-fetch.
    25842582(define (mysql-stmt-row-fold conn proc init)
    2585   (mysql-stmt-rewind conn)
    2586   (let loop ([rownum 1] [acc init])
    2587     (let ([row (mysql-stmt-row-fetch conn)])
    2588       (if row
    2589           (loop (+ rownum 1) (proc row rownum acc))
    2590           acc ) ) ) )
     2583        (mysql-stmt-rewind conn)
     2584        (let loop ([rownum 1] [acc init])
     2585                (let ([row (mysql-stmt-row-fetch conn)])
     2586                        (if row
     2587                                        (loop (+ rownum 1) (proc row rownum acc))
     2588                                        acc ) ) ) )
    25912589
    25922590; calls proc on every row in the current result set. proc should take 2
     
    26002598; using mysql-stmt-row-fetch.
    26012599(define (mysql-stmt-row-for-each conn proc)
    2602   (mysql-stmt-row-fold conn
    2603                       (lambda (row rownum _) (proc row rownum))
    2604                       #t) )
     2600        (mysql-stmt-row-fold conn
     2601                                                                                        (lambda (row rownum _) (proc row rownum))
     2602                                                                                        #t) )
    26052603
    26062604; calls proc on every row in the current result set. proc should take 2
     
    26162614; using mysql-stmt-row-fetch.
    26172615(define (mysql-stmt-row-map conn proc)
    2618   (reverse!
    2619     (mysql-stmt-row-fold conn
    2620                         (lambda (row rownum lst) (cons (proc row rownum) lst))
    2621                         '())) )
     2616        (reverse!
     2617                (mysql-stmt-row-fold conn
     2618                                                                                                (lambda (row rownum lst) (cons (proc row rownum) lst))
     2619                                                                                                '())) )
    26222620
    26232621; executes query and then mysql-row-for-each with the given proc. the proc
    26242622; must meet the contract specified for the proc passed to mysql-stmt-row-fold.
    26252623(define (mysql-stmt-query-fold conn query proc init params #!optional results)
    2626   (mysql-stmt-query conn query params results)
    2627   (mysql-stmt-row-fold conn proc init) )
     2624        (mysql-stmt-query conn query params results)
     2625        (mysql-stmt-row-fold conn proc init) )
    26282626
    26292627; executes query and then mysql-row-for-each with the given proc. the proc
    26302628; must meet the contract specified for the proc passed to mysql-stmt-row-for-each.
    26312629(define (mysql-stmt-query-for-each conn query proc params #!optional results)
    2632   (mysql-stmt-query conn query params results)
    2633   (mysql-stmt-row-for-each conn proc) )
     2630        (mysql-stmt-query conn query params results)
     2631        (mysql-stmt-row-for-each conn proc) )
    26342632
    26352633; executes query and then mysql-row-for-each with the given proc. the proc
    26362634; must meet the contract specified for the proc passed to mysql-stmt-row-map.
    26372635(define (mysql-stmt-query-map conn query proc params #!optional results)
    2638   (mysql-stmt-query conn query params results)
    2639   (mysql-stmt-row-map conn proc) )
     2636        (mysql-stmt-query conn query params results)
     2637        (mysql-stmt-row-map conn proc) )
    26402638|#
    26412639
     
    26442642Bind Parameter:
    26452643
    2646   When MySQL type unspecified attempt to determine from Scheme type:
    2647  
    2648     Ex: string => mysql-type-string
    2649 
    2650   When MySQL type unspecified attempt to determine from database schema type:
    2651  
    2652     Ex:
    2653 
    2654   When MySQL type specified coerce the Scheme value:
    2655 
    2656     mysql-null, sql-null, (void) & '() -> MYSQL_TYPE_NULL
    2657  
    2658     When types are a straight-forward match, then no coercion:
    2659    
    2660       Ex: mysql-type-string & string
    2661  
    2662     When types are not a straight-forward match, then attempt coercion:
    2663    
    2664       Ex: mysql-type-string & number
    2665 
    2666   The 'is-unsigned' flag must be used for numbers since no unsigned Scheme numbers.
    2667 
    2668   The 'error' flag is problematic - should truncation error reporting always be on?
    2669 
    2670   The 'is-null' flag is problematic - are mysql-bind objects to be re-used?
     2644        When MySQL type unspecified attempt to determine from Scheme type:
     2645       
     2646                Ex: string => mysql-type-string
     2647
     2648        When MySQL type unspecified attempt to determine from database schema type:
     2649       
     2650                Ex:
     2651
     2652        When MySQL type specified coerce the Scheme value:
     2653
     2654                mysql-null, sql-null, (void) & '() -> MYSQL_TYPE_NULL
     2655       
     2656                When types are a straight-forward match, then no coercion:
     2657               
     2658                        Ex: mysql-type-string & string
     2659       
     2660                When types are not a straight-forward match, then attempt coercion:
     2661               
     2662                        Ex: mysql-type-string & number
     2663
     2664        The 'is-unsigned' flag must be used for numbers since no unsigned Scheme numbers.
     2665
     2666        The 'error' flag is problematic - should truncation error reporting always be on?
     2667
     2668        The 'is-null' flag is problematic - are mysql-bind objects to be re-used?
    26712669
    26722670Bind Result:
    26732671
    2674   When the C storage length (len argument) is unspecified attempt to determine
    2675   from the MySQL type.
    2676 
    2677   When the type value length can vary use a default maximum length (a Scheme
    2678   parameter?).
     2672        When the C storage length (len argument) is unspecified attempt to determine
     2673        from the MySQL type.
     2674
     2675        When the type value length can vary use a default maximum length (a Scheme
     2676        parameter?).
    26792677
    26802678Type Mapping:
    26812679
    2682   ; MySQL Type                ; Scheme Type         ; Return Type     ; Allocate Size
    2683 
    2684   ;; "Null"
    2685   MYSQL_TYPE_NULL             ; sql-null            ; n/a             ; n/a
    2686 
    2687 
    2688   ;; "Boolean" is TINYINT(1)
    2689         MYSQL_TYPE_TINY             ; boolean             ; bool            ; uint8_t
    2690 
    2691 
    2692   ;; "Numeric"
    2693         MYSQL_TYPE_TINY             ; fixnum              ; char            ; int8_t
    2694   MYSQL_TYPE_SHORT            ; fixnum              ; short           ; int16_t
    2695   MYSQL_TYPE_INT24            ; fixnum              ; int             ; int32_t
    2696   MYSQL_TYPE_LONG             ; flonum              ; long            ; int32_t
    2697   MYSQL_TYPE_LONGLONG         ; flonum              ; integer64       ; int64_t
    2698 
    2699   MYSQL_TYPE_FLOAT            ; flonum              ; float           ; float
    2700   MYSQL_TYPE_DOUBLE           ; flonum              ; double          ; double
    2701 
    2702   MYSQL_TYPE_DECIMAL          ; flonum              ;                 ;
    2703   MYSQL_TYPE_NEWDECIMAL       ; flonum              ;                 ;
    2704 
    2705   MYSQL_TYPE_BIT              ; flonum              ; integer64       ; uint64_t
    2706 
    2707 
    2708   ;; "Time"
    2709   MYSQL_TYPE_TIMESTAMP        ; mysql-time          ; mysql-time-ptr  ; MYSQL_TIME
    2710   MYSQL_TYPE_DATE             ; mysql-time          ; mysql-time-ptr  ; MYSQL_TIME
    2711   MYSQL_TYPE_NEWDATE          ; mysql-time          ; mysql-time-ptr  ; MYSQL_TIME
    2712   MYSQL_TYPE_TIME             ; mysql-time          ; mysql-time-ptr  ; MYSQL_TIME
    2713   MYSQL_TYPE_DATETIME         ; mysql-time          ; mysql-time-ptr  ; MYSQL_TIME
    2714 
    2715         MYSQL_TYPE_YEAR             ; fixnum              ; unsigned-int    ; unsigned int
    2716 
    2717 
    2718   ;; "String"
    2719   MYSQL_TYPE_TINY_BLOB        ; blob                ; blob            ; uint8_t * length
    2720   MYSQL_TYPE_MEDIUM_BLOB      ; blob                ; blob            ; uint8_t * length
    2721   MYSQL_TYPE_LONG_BLOB        ; blob                ; blob            ; uint8_t * length
    2722   MYSQL_TYPE_BLOB             ; blob                ; blob            ; uint8_t * length
    2723 
    2724         MYSQL_TYPE_VARCHAR          ; string              ; c-string        ; uint8_t * length
    2725   MYSQL_TYPE_VAR_STRING       ; string              ; c-string        ; uint8_t * length
    2726   MYSQL_TYPE_STRING           ; string              ; c-string        ; uint8_t * length
    2727 
    2728   MYSQL_TYPE_ENUM             ; string              ; c-string        ; uint8_t * length
    2729   MYSQL_TYPE_SET              ; list-of string      ;                 ;
    2730 
    2731 
    2732   MYSQL_TYPE_GEOMETRY         ;                     ;                 ;
     2680        ; MySQL Type                                                            ; Scheme Type                                   ; Return Type                   ; Allocate Size
     2681
     2682        ;; "Null"
     2683        MYSQL_TYPE_NULL                                                 ; sql-null                                              ; n/a                                                   ; n/a
     2684
     2685
     2686        ;; "Boolean" is TINYINT(1)
     2687        MYSQL_TYPE_TINY                                                 ; boolean                                                       ; bool                                          ; uint8_t
     2688
     2689
     2690        ;; "Numeric"
     2691        MYSQL_TYPE_TINY                                                 ; fixnum                                                        ; char                                          ; int8_t
     2692        MYSQL_TYPE_SHORT                                                ; fixnum                                                        ; short                                         ; int16_t
     2693        MYSQL_TYPE_INT24                                                ; fixnum                                                        ; int                                                   ; int32_t
     2694        MYSQL_TYPE_LONG                                                 ; flonum                                                        ; long                                          ; int32_t
     2695        MYSQL_TYPE_LONGLONG                                     ; flonum                                                        ; integer64                             ; int64_t
     2696
     2697        MYSQL_TYPE_FLOAT                                                ; flonum                                                        ; float                                         ; float
     2698        MYSQL_TYPE_DOUBLE                                               ; flonum                                                        ; double                                        ; double
     2699
     2700        MYSQL_TYPE_DECIMAL                                      ; flonum                                                        ;                                                                       ;
     2701        MYSQL_TYPE_NEWDECIMAL                           ; flonum                                                        ;                                                                       ;
     2702
     2703        MYSQL_TYPE_BIT                                                  ; flonum                                                        ; integer64                             ; uint64_t
     2704
     2705
     2706        ;; "Time"
     2707        MYSQL_TYPE_TIMESTAMP                            ; mysql-time                                    ; mysql-time-ptr        ; MYSQL_TIME
     2708        MYSQL_TYPE_DATE                                                 ; mysql-time                                    ; mysql-time-ptr        ; MYSQL_TIME
     2709        MYSQL_TYPE_NEWDATE                                      ; mysql-time                                    ; mysql-time-ptr        ; MYSQL_TIME
     2710        MYSQL_TYPE_TIME                                                 ; mysql-time                                    ; mysql-time-ptr        ; MYSQL_TIME
     2711        MYSQL_TYPE_DATETIME                                     ; mysql-time                                    ; mysql-time-ptr        ; MYSQL_TIME
     2712
     2713        MYSQL_TYPE_YEAR                                                 ; fixnum                                                        ; unsigned-int          ; unsigned int
     2714
     2715
     2716        ;; "String"
     2717        MYSQL_TYPE_TINY_BLOB                            ; blob                                                          ; blob                                          ; uint8_t * length
     2718        MYSQL_TYPE_MEDIUM_BLOB                  ; blob                                                          ; blob                                          ; uint8_t * length
     2719        MYSQL_TYPE_LONG_BLOB                            ; blob                                                          ; blob                                          ; uint8_t * length
     2720        MYSQL_TYPE_BLOB                                                 ; blob                                                          ; blob                                          ; uint8_t * length
     2721
     2722        MYSQL_TYPE_VARCHAR                                      ; string                                                        ; c-string                              ; uint8_t * length
     2723        MYSQL_TYPE_VAR_STRING                           ; string                                                        ; c-string                              ; uint8_t * length
     2724        MYSQL_TYPE_STRING                                               ; string                                                        ; c-string                              ; uint8_t * length
     2725
     2726        MYSQL_TYPE_ENUM                                                 ; string                                                        ; c-string                              ; uint8_t * length
     2727        MYSQL_TYPE_SET                                                  ; list-of string                        ;                                                                       ;
     2728
     2729
     2730        MYSQL_TYPE_GEOMETRY                                     ;                                                                                       ;                                                                       ;
    27332731|#
    2734 
Note: See TracChangeset for help on using the changeset viewer.