Changeset 8191 in project


Ignore:
Timestamp:
02/06/08 07:22:47 (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-eggdoc.scm

    r7944 r8191  
    3131(use mysql)
    3232
    33 (let [(db (mysql-connect host: "mysql.example.com" user: "example"
    34                          passwd: "secret"))]
     33(let ((db (mysql-connect host: "mysql.example.com" user: "example" passwd: "secret")))
    3534  (mysql-query db "SHOW DATABASES")
    36   (do [(row (mysql-fetch-row db) (mysql-fetch-row db))]
    37       [(not row)]
    38     (display (conc "Row " idx ": " (row "Database") "\n")))
    39   (mysql-close db))
     35  (do ((row (mysql-fetch-row db) (mysql-fetch-row db)))
     36      ((not row))
     37    (print "Row " idx ": " (row "Database")) )
     38  (mysql-close db) )
    4039END
    4140)
     
    4443(use mysql)
    4544
    46 (let [(db (mysql-connect host: "mysql.example.com" user: "example"
    47                          passwd: "secret"))]
    48   (mysql-query-foreach db "SHOW DATABASES"
    49                        (lambda (row idx)
    50                          (display (conc "Row " idx ": " (row "Database") "\n"))))
    51   (mysql-close db))
     45(let ((db (mysql-connect host: "mysql.example.com" user: "example" passwd: "secret")))
     46  (mysql-query-for-each
     47   db "SHOW DATABASES" (lambda (row idx) (print "Row " idx ": " (row "Database"))))
     48  (mysql-close db) )
    5249END
    5350)
     
    200197            "most recent call to " (tt "mysql-query") ". If the "
    201198            "last query failed, or if there are no more rows left "
    202             "in the result set, returns " (tt "#f") "; otherwise "
     199            "in the result set, returns " (code "#f") "; otherwise "
    203200            "returns a row object.")
    204201          (a (@ (" name='rowobj'")))
     
    207204            "takes a single argument. If the argument is a number, "
    208205            "the function returns the value of the field for which "
    209             "that number is the index, or " (tt "#f") " if the "
     206            "that number is the index, or " (code "#f") " if the "
    210207            "index is out of range. Otherwise, the argument must "
    211208            "be a symbol or string, in which case the function returns "
    212209            "the value of the field for which that string (or symbol "
    213210            "converted into a string) is the field/column name. If "
    214             "no such field exists, returns " (tt "#f") ".") )
     211            "no such field exists, returns " (code "#f") ".") )
    215212
    216213        (procedure "(mysql-field-count CONN)"
     
    233230          (p
    234231            "Returns the number of rows in the current result set. "
    235             "If no result set exists, returns " (tt "#f") ".") )
     232            "If no result set exists, returns " (code "#f") ".") )
    236233
    237234        (procedure "(mysql-num-fields CONN)"
    238235          (p
    239236            "Returns the number of fields in the current result set. "
    240             "If no result set exists, returns " (tt "#f") ".") )
     237            "If no result set exists, returns " (code "#f") ".") )
    241238
    242239        (procedure "(mysql-affected-rows CONN)"
     
    833830        "All MySQL result data (except NULL) are returned as Scheme strings.")
    834831      (p
    835         "The NULL value is represented by " (tt "#f") ".")
    836       (p "Booleans are expressed "
    837         "as the Scheme strings " (tt "\"1\"") " and " (tt "\"0\"") ".")
    838       (p "All remaining "
    839         "types, including numeric types, blobs, and strings are returned as Scheme "
    840         "strings.")
     832        "The NULL value is represented by " (code "#f") ".")
     833      (p
     834        "Booleans are expressed as the Scheme strings " (code "\"1\"") " and "
     835        (code "\"0\"") ".")
     836      (p
     837        "All remaining types, including numeric types, blobs, and strings are "
     838        "returned as Scheme strings.")
    841839    ) ; section "Data Type Conversion"
    842840
  • release/3/mysql/trunk/mysql.scm

    r7969 r8191  
    8888  (generic)
    8989  (no-procedure-checks-for-usual-bindings)
     90  (no-bound-checks)
    9091  (inline)
    9192  (unused
     
    492493  MYSQL_OPTION_MULTI_STATEMENTS_OFF )
    493494
    494 (gen-public-enum mysql-server-option
    495   MYSQL_OPTION_MULTI_STATEMENTS_ON
    496   MYSQL_OPTION_MULTI_STATEMENTS_OFF)
    497 
    498495(define-foreign-enum (mysql-option (enum "mysql_option"))
    499496  #f  ; No aliases!
    500   MYSQL_OPT_CONNECT_TIMEOUT
    501   MYSQL_OPT_COMPRESS
    502   MYSQL_OPT_NAMED_PIPE
    503   MYSQL_INIT_COMMAND
    504   MYSQL_READ_DEFAULT_FILE
    505   MYSQL_READ_DEFAULT_GROUP
    506   MYSQL_SET_CHARSET_DIR
    507   MYSQL_SET_CHARSET_NAME
    508   MYSQL_OPT_LOCAL_INFILE
    509   MYSQL_OPT_PROTOCOL
    510   MYSQL_SHARED_MEMORY_BASE_NAME
    511   MYSQL_OPT_READ_TIMEOUT
    512   MYSQL_OPT_WRITE_TIMEOUT
    513   MYSQL_OPT_USE_RESULT
    514   MYSQL_OPT_USE_REMOTE_CONNECTION
    515   MYSQL_OPT_USE_EMBEDDED_CONNECTION
    516   MYSQL_OPT_GUESS_CONNECTION
    517   MYSQL_SET_CLIENT_IP
    518   MYSQL_SECURE_AUTH
    519   MYSQL_REPORT_DATA_TRUNCATION )
    520 
    521 (gen-public-enum mysql-option
    522497  MYSQL_OPT_CONNECT_TIMEOUT
    523498  MYSQL_OPT_COMPRESS
     
    571546  MYSQL_TYPE_GEOMETRY )
    572547
    573 (gen-public-enum mysql-type
    574   MYSQL_TYPE_DECIMAL
    575         MYSQL_TYPE_TINY
    576   MYSQL_TYPE_SHORT
    577   MYSQL_TYPE_LONG
    578   MYSQL_TYPE_INT24
    579   MYSQL_TYPE_FLOAT
    580   MYSQL_TYPE_DOUBLE
    581   MYSQL_TYPE_NULL
    582   MYSQL_TYPE_TIMESTAMP
    583   MYSQL_TYPE_LONGLONG
    584   MYSQL_TYPE_DATE
    585   MYSQL_TYPE_TIME
    586   MYSQL_TYPE_DATETIME
    587         MYSQL_TYPE_YEAR
    588   MYSQL_TYPE_NEWDATE
    589         MYSQL_TYPE_VARCHAR
    590   MYSQL_TYPE_BIT
    591   MYSQL_TYPE_NEWDECIMAL
    592   MYSQL_TYPE_ENUM
    593   MYSQL_TYPE_SET
    594   MYSQL_TYPE_TINY_BLOB
    595   MYSQL_TYPE_MEDIUM_BLOB
    596   MYSQL_TYPE_LONG_BLOB
    597   MYSQL_TYPE_BLOB
    598   MYSQL_TYPE_VAR_STRING
    599   MYSQL_TYPE_STRING
    600   MYSQL_TYPE_GEOMETRY )
    601 
    602548(define-foreign-enum (mysql-field-flags unsigned-int)
    603549  #f  ; No aliases!
     
    617563  BLOB_FLAG                                             ; field is a blob
    618564  TIMESTAMP_FLAG        )                                                       ; field is a timestamp
    619 
    620 (gen-public-enum mysql-field-flags
    621   NOT_NULL_FLAG
    622   PRI_KEY_FLAG
    623   UNIQUE_KEY_FLAG
    624   MULTIPLE_KEY_FLAG
    625   UNSIGNED_FLAG
    626   ZEROFILL_FLAG
    627   BINARY_FLAG
    628   AUTO_INCREMENT_FLAG
    629   NO_DEFAULT_VALUE_FLAG
    630   NUM_FLAG
    631   ; deprecated
    632   ENUM_FLAG
    633   SET_FLAG
    634   BLOB_FLAG
    635   TIMESTAMP_FLAG )
    636565
    637566(define-foreign-enum (mysql-client-flags unsigned-int)
     
    679608        ; mysql_ssl_set() before calling mysql_real_connect().
    680609        CLIENT_SSL )
    681 
    682 (gen-public-enum mysql-client-flags
    683   CLIENT_LONG_PASSWORD
    684   CLIENT_LONG_FLAG
    685   CLIENT_CONNECT_WITH_DB
    686   CLIENT_PROTOCOL_41
    687   CLIENT_SECURE_CONNECTION
    688   CLIENT_TRANSACTIONS
    689   CLIENT_COMPRESS
    690   CLIENT_FOUND_ROWS
    691   CLIENT_IGNORE_SIGPIPE
    692   CLIENT_IGNORE_SPACE
    693   CLIENT_INTERACTIVE
    694   CLIENT_LOCAL_FILES
    695   CLIENT_MULTI_RESULTS
    696   CLIENT_MULTI_STATEMENTS
    697   CLIENT_NO_SCHEMA
    698   CLIENT_ODBC
    699   CLIENT_SSL )
    700610
    701611;-----------------------------------------------------------------------
     
    23032213        (foreign-lambda unsigned-int "mysql_stmt_field_count" mysql-stmt-ptr))
    23042214
    2305 ;;
     2215;; MYSQL_BIND
    23062216
    23072217(define-foreign-record (mysql-bind "MYSQL_BIND")
     
    23152225  (unsigned-long buffer_length)           ; output buffer length, must be set when fetching str/binary
    23162226  (mysql-type buffer_type)                          ; buffer type
     2227  (my-bool is_unsigned)                         ; set if integer type is unsigned
     2228  ; ???
    23172229  (my-bool error_value)                         ; used if error is 0
    2318   (my-bool is_unsigned)                         ; set if integer type is unsigned
    23192230  (my-bool is_null_value) )               ; Used if is_null is 0
    23202231
    2321 (define (allocate-mysql-bind cnt)
     2232;; Returns a c-vector of MYSQL_BIND - zeroed
     2233;; Count must be at least 1!
     2234
     2235(define (allocate-mysql-bind #!optional (cnt 1))
    23222236  ((foreign-lambda* mysql-bind-ptr ((unsigned-integer cnt))
    23232237   "return ((1 <= cnt) ? ((MYSQL_BIND *) calloc (cnt, sizeof(MYSQL_BIND))) : NULL);")
    23242238  cnt) )
     2239
     2240;; Zeros MYSQL_BIND at index in a c-vector or MYSQL_BIND
     2241;; No range checks!
     2242
     2243(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) )
     2247
     2248;; Returns c-pointer to MYSQL_BIND at index in a c-vector or MYSQL_BIND
     2249;; No range checks!
    23252250
    23262251(define (mysql-bind-ref bindptr idx)
     
    23292254   bindptr idx) )
    23302255
    2331 (define (mysql-bind-clear! bindptr idx)
    2332   ((foreign-lambda* mysql-bind-ptr ((mysql-bind-ptr ptr) (unsigned-integer idx))
    2333    "memset (&(ptr[idx]), 0, sizeof(MYSQL_BIND));")
    2334    bindptr idx) )
    2335 
    2336 (define (allocate-mysql-bind-slots bindptr len is-null error)
     2256;; Allocates a memory block for a MYSQL_BIND value slots
     2257;; The length is byte count of the actual value representation!
     2258
     2259(define (allocate-mysql-bind-variables bindptr len is-null error)
    23372260  ((foreign-lambda* void ((mysql-bind-ptr bind) (unsigned-integer len)
    23382261                          (my-bool is_null) (my-bool error))
    23392262#<<END
     2263    /* Contiguous variable allocation template */
    23402264    typedef struct {
    23412265      unsigned long length;
    23422266      my_bool is_null;
    23432267      my_bool error;
    2344       C_word buffer[1];
     2268      C_word buffer[1]; /* len is size of the C storage type */
    23452269    } bind_slots;
     2270
     2271    /* Allocate variables in contiguous, zero filled, memory */
    23462272    size_t siz = (sizeof(bind_slots) - sizeof(((bind_slots *)0)->buffer))
    23472273                  + (((len / sizeof (C_word)) + (len % sizeof (C_word))) * sizeof (C_word));
    2348     bind_slots * ptr = ((bind_slots *) malloc (siz));
    2349     memset (ptr, 0, siz);
     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;
    23502281    bind->buffer = (char *) &(ptr->buffer);
    2351     bind->buffer_length = len;
    2352     ptr->is_null = is_null;
    23532282    bind->is_null = &(ptr->is_null);
    2354     ptr->length = len;
    23552283    bind->length = &(ptr->length);
    2356     ptr->error = error;
    23572284    bind->error = &(ptr->error);
    23582285END
    23592286   )
    2360      bindptr len is-null error) )
     2287   bindptr len is-null error) )
    23612288
    23622289(define (%mysql-foreign-type-length foreign-type #!optional (obj (void)))
     
    23842311    (let* ([foreign-type (%mysql-determine-foreign-type type is-unsigned is-null)]
    23852312           [len (%mysql-foreign-type-length foreign-type obj)])
    2386       (allocate-mysql-bind-slots bindptr len is-null error) ) ) )
     2313      (allocate-mysql-bind-variables bindptr len is-null error) ) ) )
    23872314
    23882315(define (mysql-bind-result-init-direct bindptr idx type #!optional len)
     
    23932320           [len (or len
    23942321                    (%mysql-foreign-type-length foreign-type))])
    2395       (allocate-mysql-bind-slots bindptr len #f #f) ) ) )
     2322      (allocate-mysql-bind-variables bindptr len #f #f) ) ) )
    23962323
    23972324;;
Note: See TracChangeset for help on using the changeset viewer.