Changeset 14768 for release/4/postgresql/trunk/postgresql.scm
- Timestamp:
- 05/25/09 05:47:51 (16 months ago)
- Files:
-
- 1 modified
-
release/4/postgresql/trunk/postgresql.scm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
release/4/postgresql/trunk/postgresql.scm
r14767 r14768 600 600 " }" 601 601 "}" 602 "res = PQsendQueryParams( conn, query, num, NULL,"603 " vals, lens, fmts, resfmt);"602 "res = PQsendQueryParams((PGconn *)conn, query, num, NULL," 603 " (const char * const *)vals, lens, fmts, resfmt);" 604 604 "for (i=0,cons=params; i < num; ++i,cons=C_u_i_cdr(cons)) {" 605 605 " obj = C_u_i_car(cons);" … … 631 631 ;; This can allocate up to twice as much memory than the string actually 632 632 ;; uses; in extreme cases this could be a problem. 633 (foreign-lambda* c-string* ((p ointer conn) (c-string from) (int fromlen))633 (foreign-lambda* c-string* ((pgconn* conn) (c-string from) (int flen)) 634 634 "int err = 0; char *to;" 635 "to = malloc(sizeof(char) * (f romlen * 2 + 1));"636 "PQescapeStringConn( conn, to, from, fromlen, &err);"635 "to = malloc(sizeof(char) * (flen * 2 + 1));" 636 "PQescapeStringConn((PGconn *)conn, to, from, (size_t)flen, &err);" 637 637 "if (err) {" 638 638 " free(to);" … … 640 640 "}" 641 641 "C_return(to);")) 642 (or (%escape-string-conn connstr (string-length str))642 (or (%escape-string-conn (pg-connection-ptr conn) str (string-length str)) 643 643 (postgresql-error 'escape-string 644 644 (conc "String escaping failed. " … … 648 648 (define %escape-bytea-conn 649 649 ;; This must copy because libpq returns a malloced ptr... 650 (foreign-safe-lambda* scheme-object ((p ointerconn)650 (foreign-safe-lambda* scheme-object ((pgconn* conn) 651 651 ;; not copied/NUL interpreted: 652 652 ((const unsigned-c-string*) from) 653 (int f romlen))653 (int flen)) 654 654 "size_t tolen=0; C_word res, *fin; unsigned char *esc;" 655 "esc = PQescapeByteaConn( conn, from, (size_t)fromlen, &tolen);"655 "esc = PQescapeByteaConn((PGconn *)conn, from, (size_t)flen, &tolen);" 656 656 "if (esc == NULL)" 657 " C_return(C_SCHEME_FALSE);"657 " C_return(C_SCHEME_FALSE);" 658 658 "fin = C_alloc(C_bytestowords(tolen + sizeof(C_header)));" 659 659 "/* tolen includes the resulting NUL byte */" … … 661 661 "PQfreemem(esc);" 662 662 "C_return(res);")) 663 (or (%escape-bytea-conn connstr (string-length str))663 (or (%escape-bytea-conn (pg-connection-ptr conn) str (string-length str)) 664 664 (postgresql-error 'escape-bytea 665 665 (conc "Byte array escaping failed. " … … 673 673 "unesc = PQunescapeBytea(from, &tolen);" 674 674 "if (unesc == NULL)" 675 " C_return(C_SCHEME_FALSE);"675 " C_return(C_SCHEME_FALSE);" 676 676 "fin = C_alloc(C_bytestowords(tolen + sizeof(C_header)));" 677 677 "res = C_string(&fin, tolen, (char *)unesc);"
