1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #ifndef PHP_PDO_PGSQL_INT_H
24 #define PHP_PDO_PGSQL_INT_H
25
26 #include <libpq-fe.h>
27 #include <libpq/libpq-fs.h>
28 #include <php.h>
29
30 #define PHP_PDO_PGSQL_CONNECTION_FAILURE_SQLSTATE "08006"
31
32 typedef struct {
33 const char *file;
34 int line;
35 unsigned int errcode;
36 char *errmsg;
37 } pdo_pgsql_error_info;
38
39
40 typedef struct {
41 PGconn *server;
42 unsigned attached:1;
43 unsigned _reserved:31;
44 pdo_pgsql_error_info einfo;
45 Oid pgoid;
46 unsigned int stmt_counter;
47
48
49 zend_bool emulate_prepares;
50 zend_bool disable_native_prepares;
51 zend_bool disable_prepares;
52 } pdo_pgsql_db_handle;
53
54 typedef struct {
55 char *def;
56 zend_long intval;
57 Oid pgsql_type;
58 zend_bool boolval;
59 } pdo_pgsql_column;
60
61 typedef struct {
62 pdo_pgsql_db_handle *H;
63 PGresult *result;
64 pdo_pgsql_column *cols;
65 char *cursor_name;
66 char *stmt_name;
67 char *query;
68 char **param_values;
69 int *param_lengths;
70 int *param_formats;
71 Oid *param_types;
72 int current_row;
73 zend_bool is_prepared;
74 } pdo_pgsql_stmt;
75
76 typedef struct {
77 Oid oid;
78 } pdo_pgsql_bound_param;
79
80 extern pdo_driver_t pdo_pgsql_driver;
81
82 extern int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *sqlstate, const char *msg, const char *file, int line);
83 #define pdo_pgsql_error(d,e,z) _pdo_pgsql_error(d, NULL, e, z, NULL, __FILE__, __LINE__)
84 #define pdo_pgsql_error_msg(d,e,m) _pdo_pgsql_error(d, NULL, e, NULL, m, __FILE__, __LINE__)
85 #define pdo_pgsql_error_stmt(s,e,z) _pdo_pgsql_error(s->dbh, s, e, z, NULL, __FILE__, __LINE__)
86 #define pdo_pgsql_error_stmt_msg(s,e,m) _pdo_pgsql_error(s->dbh, s, e, NULL, m, __FILE__, __LINE__)
87
88 extern struct pdo_stmt_methods pgsql_stmt_methods;
89
90 #define pdo_pgsql_sqlstate(r) PQresultErrorField(r, PG_DIAG_SQLSTATE)
91
92 enum {
93 PDO_PGSQL_ATTR_DISABLE_PREPARES = PDO_ATTR_DRIVER_SPECIFIC,
94 };
95
96 struct pdo_pgsql_lob_self {
97 zval dbh;
98 PGconn *conn;
99 int lfd;
100 Oid oid;
101 };
102
103 enum pdo_pgsql_specific_constants {
104 PGSQL_TRANSACTION_IDLE = PQTRANS_IDLE,
105 PGSQL_TRANSACTION_ACTIVE = PQTRANS_ACTIVE,
106 PGSQL_TRANSACTION_INTRANS = PQTRANS_INTRANS,
107 PGSQL_TRANSACTION_INERROR = PQTRANS_INERROR,
108 PGSQL_TRANSACTION_UNKNOWN = PQTRANS_UNKNOWN
109 };
110
111 php_stream *pdo_pgsql_create_lob_stream(zval *pdh, int lfd, Oid oid);
112 extern php_stream_ops pdo_pgsql_lob_stream_ops;
113
114 #endif
115
116
117
118
119
120
121
122
123