|
|
| version 1.7, 2001/08/01 07:41:37 | version 1.8, 2001/08/01 09:30:35 |
|---|---|
| Line 16 static const char *RCSId="$Id$"; | Line 16 static const char *RCSId="$Id$"; |
| #include <libpq-fe.h> | #include <libpq-fe.h> |
| #include <libpq-fs.h> | #include <libpq-fs.h> |
| // #include <catalog/pg_type.h> | // OIDOID from #include <catalog/pg_type.h> |
| #define OIDOID 26 | #define OIDOID 26 |
| #define LO_BUFSIZE 0x1000/*8192*/ | // LO_BUFSIZE from interfaces\libpq\fe-lobj.c = 8192 (0x2000) |
| // actually writing chunks of that size failed, reduced it twice | |
| #define LO_BUFSIZE 0x1000 | |
| #include "ltdl.h" | #include "ltdl.h" |
| Line 66 public: | Line 67 public: |
| /** connect | /** connect |
| @param used_only_in_connect_url | @param used_only_in_connect_url |
| format: @b user:pass@host[:port]|[local]/database | format: @b user:pass@host[:port]|[local]/database |
| 3.23.22b | |
| Currently the only option for @b character_set_name is cp1251_koi8. | |
| WARNING: must be used only to connect, for buffer doesn't live long | |
| */ | */ |
| void connect( | void connect( |
| char *used_only_in_connect_url, | char *used_only_in_connect_url, |
| Line 81 public: | Line 79 public: |
| char *pwd=lsplit(user, ':'); | char *pwd=lsplit(user, ':'); |
| char *port=lsplit(host, ':'); | char *port=lsplit(host, ':'); |
| // _asm int 3; | |
| PGconn *conn=PQsetdbLogin( | PGconn *conn=PQsetdbLogin( |
| strcasecmp(host, "local")==0?NULL/* local Unix domain socket */:host, port, | strcasecmp(host, "local")==0?NULL/* local Unix domain socket */:host, port, |
| NULL, NULL, db, user, pwd); | NULL, NULL, db, user, pwd); |
| Line 94 public: | Line 91 public: |
| begin_transaction(services, conn); | begin_transaction(services, conn); |
| } | } |
| void disconnect(SQL_Driver_services&, void *connection) { | void disconnect(SQL_Driver_services&, void *connection) { |
| // _asm int 3; | |
| PQfinish((PGconn *)connection); | PQfinish((PGconn *)connection); |
| } | } |
| void commit(SQL_Driver_services& services, void *connection) { | void commit(SQL_Driver_services& services, void *connection) { |
| // _asm int 3; | |
| PGconn *conn=(PGconn *)connection; | PGconn *conn=(PGconn *)connection; |
| if(PGresult *res=PQexec(conn, "COMMIT")) | if(PGresult *res=PQexec(conn, "COMMIT")) |
| PQclear(res); | PQclear(res); |
| Line 107 public: | Line 102 public: |
| begin_transaction(services, conn); | begin_transaction(services, conn); |
| } | } |
| void rollback(SQL_Driver_services& services, void *connection) { | void rollback(SQL_Driver_services& services, void *connection) { |
| // _asm int 3; | |
| PGconn *conn=(PGconn *)connection; | PGconn *conn=(PGconn *)connection; |
| if(PGresult *res=PQexec(conn, "ROLLBACK")) | if(PGresult *res=PQexec(conn, "ROLLBACK")) |
| PQclear(res); | PQclear(res); |
| Line 198 public: | Line 192 public: |
| void *ptr; | void *ptr; |
| if(PQftype(res, i)==OIDOID) { | if(PQftype(res, i)==OIDOID) { |
| // ObjectID column, read object bytes | // ObjectID column, read object bytes |
| // _asm int 3; | |
| char *error_pos=0; | char *error_pos=0; |
| Oid oid=cell?atoi(cell):0; | Oid oid=cell?atoi(cell):0; |
| Line 227 public: | Line 220 public: |
| } else | } else |
| PQclear_throwPQerror; | PQclear_throwPQerror; |
| } else { | } else { |
| // normal column, read it as ASCII string | // normal column, read it normally |
| size=(size_t)PQgetlength(res, r, i); | size=(size_t)PQgetlength(res, r, i); |
| if(size) { | if(size) { |
| ptr=services.malloc(size); | ptr=services.malloc(size); |