Changeset 14631 in project


Ignore:
Timestamp:
05/14/09 22:37:13 (11 years ago)
Author:
sjamaan
Message:

Prepare for testing
Fix a few small mistakes/bugs
Get rid of non-connected (deprecated) string escape procedure

Location:
release/4/postgresql/trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/postgresql/trunk/postgresql.meta

    r14620 r14631  
    99 (hidden) ;; Not ready yet!
    1010 (license "BSD")
    11  (files "postgresql.setup" "postgresql.html" "postgresql.scm" "ppchar.c"))
     11 (test-depends test)
     12 (files "postgresql.setup" "postgresql.html" "postgresql.scm" "tests"))
  • release/4/postgresql/trunk/postgresql.scm

    r14620 r14631  
    122122  (signal (make-pg-condition loc message args: args)))
    123123
    124 (define (make-pg-condition loc message #!key (args '()) severity error-class error-code message-detail
    125                            message-hint statement-position context source-file source-line
     124(define (make-pg-condition loc message #!key (args '()) severity
     125                           error-class error-code message-detail
     126                           message-hint statement-position context
     127                           source-file source-line
    126128                           source-function)
    127129  (make-composite-condition
    128     (make-property-condition 'exn 'location loc 'message message 'arguments args)
    129     (make-property-condition 'postgresql 'severity severity 'error-class error-class
    130                              'error-code error-code 'message-detail message-detail
    131                              'message-hint message-hint 'statement-position statement-position
    132                              'context context 'source-file source-file 'source-line source-line
    133                              ;; Might break not-terribly-old versions of postgresql
    134                              ;;'internal-position internal-position 'internal-query internal-query
    135                              'source-function source-function)))
     130    (make-property-condition
     131     'exn 'location loc 'message message 'arguments args)
     132    (make-property-condition
     133     'postgresql 'severity severity 'error-class error-class
     134     'error-code error-code 'message-detail message-detail
     135     'message-hint message-hint 'statement-position statement-position
     136     'context context 'source-file source-file 'source-line source-line
     137     ;; Might break not-terribly-old versions of postgresql
     138     ;;'internal-position internal-position 'internal-query internal-query
     139     'source-function source-function)))
    136140
    137141(define-record pg:connection
     
    196200     
    197201      (define (connspec-escape s)
    198         (string-translate* (->string s) '(("'" . "\\'"))))
     202        (string-translate* (->string s) '(("\\" . "\\\\") ("'" . "\\'"))))
    199203     
    200204      (let ([conn (make-pg:connection
     
    483487                   format-ranges)))))))))
    484488
    485 (define-time-parser date-parser "YYYY-MM-DD")
     489(Define-time-parser date-parser "YYYY-MM-DD")
    486490(define-time-parser timestamp-parser "YYYY-MM-DD hh:mm:ss.ssssss")
    487491(define-time-parser timestamp/tz-parser "YYYY-MM-DD hh:mm:ss.sssssszzz")
     
    535539
    536540;; Escape strings
    537 (define %pg:escape-string
    538   (foreign-lambda* c-string* ((c-string from) (int fromlen))
    539                    "char *to = malloc(sizeof(char)*fromlen*2+1);" ;;
    540                    "PQescapeString(to, from, fromlen);"
    541                    "return(to);"
    542                    ))
    543 
    544541(define %pg:escape-string-conn
    545542  (foreign-lambda* c-string* ((pointer conn) (c-string from) (int fromlen))
    546                    "int err = 0; char *to = malloc(sizeof(char)*fromlen*2+1);" ;;
     543                   "int err = 0; char *to;"
     544                   "to = malloc(sizeof(char) * (fromlen * 2 + 1));"
    547545                   "PQescapeStringConn(conn, to, from, fromlen, &err);"
    548                    "if (err == 1) {"
     546                   "if (err) {"
    549547                   "  free(to);"
    550                    "  return(NULL);"
     548                   "  C_return(NULL);"
    551549                   "}"
    552                    "return(to);"
     550                   "C_return(to);"
    553551                   ))
    554552
    555 (define pg:escape-string
    556   (case-lambda
    557     ((str) (%pg:escape-string str (string-length str)))
    558     ((conn str) (or (%pg:escape-string-conn conn str (string-length str))
    559                     (pg:error 'pg:connect (conc "String escaping failed. " (PQerrorMessage conn)))))))
     553(define (pg:escape-string str)
     554  (or (%pg:escape-string-conn conn str (string-length str))
     555      (pg:error 'pg:connect
     556                (conc "String escaping failed. " (PQerrorMessage conn)))))
    560557
    561558
     
    777774         (lambda (s) (cdr (assoc s dict)))))
    778775
    779 
    780 
    781776;;; query with params stuff
    782777
Note: See TracChangeset for help on using the changeset viewer.