1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 7 | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 1997-2018 The PHP Group | 6 +----------------------------------------------------------------------+ 7 | This source file is subject to version 3.01 of the PHP license, | 8 | that is bundled with this package in the file LICENSE, and is | 9 | available through the world-wide-web at the following url: | 10 | http://www.php.net/license/3_01.txt | 11 | If you did not receive a copy of the PHP license and are unable to | 12 | obtain it through the world-wide-web, please send a note to | 13 | license@php.net so we can mail you a copy immediately. | 14 +----------------------------------------------------------------------+ 15 | Authors: Edin Kadribasic <edink@emini.dk> | 16 | Ilia Alshanestsky <ilia@prohost.org> | 17 | Wez Furlong <wez@php.net> | 18 +----------------------------------------------------------------------+ 19 */ 20 21 /* $Id$ */ 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 /* stuff we use in a pgsql database handle */ 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 /* The following two variables have the same purpose. Unfortunately we need 48 to keep track of two different attributes having the same effect. */ 49 zend_bool emulate_prepares; 50 zend_bool disable_native_prepares; /* deprecated since 5.6 */ 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 /* PHP_PDO_PGSQL_INT_H */ 115 116 /* 117 * Local variables: 118 * tab-width: 4 119 * c-basic-offset: 4 120 * End: 121 * vim600: noet sw=4 ts=4 fdm=marker 122 * vim<600: noet sw=4 ts=4 123 */ 124