| 1 | #include <libpq-fe.h> |
| 2 | #include <postgres_fe.h> |
| 3 | #include <dbd/common.h> |
| 4 | |
| 5 | /* |
| 6 | * length of a prepared statement ID |
| 7 | * dbd-postgresql-\d{17}\0 |
| 8 | */ |
| 9 | #define IDLEN 15+17+1 |
| 10 | |
| 11 | #define DBD_POSTGRESQL_CONNECTION "DBD.PostgreSQL.Connection" |
| 12 | #define DBD_POSTGRESQL_STATEMENT "DBD.PostgreSQL.Statement" |
| 13 | |
| 14 | /* |
| 15 | * connection object implentation |
| 16 | */ |
| 17 | typedef struct _connection { |
| 18 | PGconn *postgresql; |
| 19 | int autocommit; |
| 20 | unsigned int statement_id; /* sequence for statement IDs */ |
| 21 | } connection_t; |
| 22 | |
| 23 | /* |
| 24 | * statement object implementation |
| 25 | */ |
| 26 | typedef struct _statement { |
| 27 | PGconn *postgresql; |
| 28 | PGresult *result; |
| 29 | char name[IDLEN]; /* statement ID */ |
| 30 | int tuple; /* number of rows returned */ |
| 31 | } statement_t; |