Back to index

php5  5.3.10
php_pdo_pgsql_int.h
Go to the documentation of this file.
00001 /*
00002   +----------------------------------------------------------------------+
00003   | PHP Version 5                                                        |
00004   +----------------------------------------------------------------------+
00005   | Copyright (c) 1997-2012 The PHP Group                                |
00006   +----------------------------------------------------------------------+
00007   | This source file is subject to version 3.01 of the PHP license,      |
00008   | that is bundled with this package in the file LICENSE, and is        |
00009   | available through the world-wide-web at the following url:           |
00010   | http://www.php.net/license/3_01.txt                                  |
00011   | If you did not receive a copy of the PHP license and are unable to   |
00012   | obtain it through the world-wide-web, please send a note to          |
00013   | license@php.net so we can mail you a copy immediately.               |
00014   +----------------------------------------------------------------------+
00015   | Authors: Edin Kadribasic <edink@emini.dk>                            |
00016   |          Ilia Alshanestsky <ilia@prohost.org>                        |
00017   |          Wez Furlong <wez@php.net>                                   |
00018   +----------------------------------------------------------------------+
00019 */
00020 
00021 /* $Id: php_pdo_pgsql_int.h 321634 2012-01-01 13:15:04Z felipe $ */
00022 
00023 #ifndef PHP_PDO_PGSQL_INT_H
00024 #define PHP_PDO_PGSQL_INT_H
00025 
00026 #include <libpq-fe.h>
00027 #include <libpq/libpq-fs.h>
00028 #include <php.h>
00029 
00030 #define PHP_PDO_PGSQL_CONNECTION_FAILURE_SQLSTATE "08006"
00031 
00032 typedef struct {
00033        const char *file;
00034        int line;
00035        unsigned int errcode;
00036        char *errmsg;
00037 } pdo_pgsql_error_info;
00038 
00039 /* stuff we use in a pgsql database handle */
00040 typedef struct {
00041        PGconn        *server;
00042        unsigned      attached:1;
00043        unsigned      _reserved:31;
00044        pdo_pgsql_error_info einfo;
00045        Oid           pgoid;
00046 #if HAVE_PQPREPARE
00047        /* The following two variables have the same purpose. Unfortunately we need
00048           to keep track of two different attributes having the same effect.
00049           It might be worth to deprecate the driver specific one soon. */
00050        int           emulate_prepares;
00051        int           disable_native_prepares;
00052 #endif
00053        unsigned int stmt_counter;
00054 } pdo_pgsql_db_handle;
00055 
00056 typedef struct {
00057        char         *def;
00058        Oid          pgsql_type;
00059        long         intval;
00060        zend_bool    boolval;
00061 } pdo_pgsql_column;
00062 
00063 typedef struct {
00064        pdo_pgsql_db_handle     *H;
00065        PGresult                *result;
00066        int                     current_row;
00067        pdo_pgsql_column        *cols;
00068        char *cursor_name;
00069 #if HAVE_PQPREPARE
00070        char *stmt_name;
00071        char *query;
00072        char **param_values;
00073        int *param_lengths;
00074        int *param_formats;
00075        Oid *param_types;
00076 #endif
00077        zend_bool is_prepared;
00078 } pdo_pgsql_stmt;
00079 
00080 typedef struct {
00081        Oid     oid;
00082 } pdo_pgsql_bound_param;
00083 
00084 extern pdo_driver_t pdo_pgsql_driver;
00085 
00086 extern int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *sqlstate, const char *file, int line TSRMLS_DC);
00087 #define pdo_pgsql_error(d,e,z)     _pdo_pgsql_error(d, NULL, e, z, __FILE__, __LINE__ TSRMLS_CC)
00088 #define pdo_pgsql_error_stmt(s,e,z)       _pdo_pgsql_error(s->dbh, s, e, z, __FILE__, __LINE__ TSRMLS_CC)
00089 
00090 extern struct pdo_stmt_methods pgsql_stmt_methods;
00091 
00092 #define pdo_pgsql_sqlstate(r) PQresultErrorField(r, PG_DIAG_SQLSTATE)
00093 
00094 enum {
00095        PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT = PDO_ATTR_DRIVER_SPECIFIC,
00096 };
00097 
00098 struct pdo_pgsql_lob_self {
00099        pdo_dbh_t *dbh;
00100        PGconn *conn;
00101        int lfd;
00102        Oid oid;
00103 };
00104 
00105 enum pdo_pgsql_specific_constants {
00106        PGSQL_TRANSACTION_IDLE = PQTRANS_IDLE,
00107        PGSQL_TRANSACTION_ACTIVE = PQTRANS_ACTIVE,
00108        PGSQL_TRANSACTION_INTRANS = PQTRANS_INTRANS,
00109        PGSQL_TRANSACTION_INERROR = PQTRANS_INERROR,
00110        PGSQL_TRANSACTION_UNKNOWN = PQTRANS_UNKNOWN
00111 };
00112 
00113 php_stream *pdo_pgsql_create_lob_stream(pdo_dbh_t *stmt, int lfd, Oid oid TSRMLS_DC);
00114 extern php_stream_ops pdo_pgsql_lob_stream_ops;
00115 
00116 #endif /* PHP_PDO_PGSQL_INT_H */
00117 
00118 /*
00119  * Local variables:
00120  * tab-width: 4
00121  * c-basic-offset: 4
00122  * End:
00123  * vim600: noet sw=4 ts=4 fdm=marker
00124  * vim<600: noet sw=4 ts=4
00125  */