From: Edin Kadribasic Date: Thu, 20 May 2004 02:27:49 +0000 (+0000) Subject: PostgreSQL PDO driver. X-Git-Tag: RELEASE_0_1~82 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d6c2599889e972fa43ff38e563b0f3ea200bbba;p=php PostgreSQL PDO driver. --- diff --git a/ext/pdo_pgsql/CREDITS b/ext/pdo_pgsql/CREDITS new file mode 100644 index 0000000000..74b60e369c --- /dev/null +++ b/ext/pdo_pgsql/CREDITS @@ -0,0 +1,2 @@ +PostgreSQL driver for PDO +Edin Kadribasic diff --git a/ext/pdo_pgsql/config.m4 b/ext/pdo_pgsql/config.m4 new file mode 100644 index 0000000000..66b4949bea --- /dev/null +++ b/ext/pdo_pgsql/config.m4 @@ -0,0 +1,101 @@ +dnl +dnl $Id$ +dnl + +AC_DEFUN(PHP_PGSQL_CHECK_FUNCTIONS,[ +]) + +PHP_ARG_WITH(pdo-pgsql,for PostgreSQL support for PDO, +[ --with-pdo-pgsql[=DIR] Include PDO PostgreSQL support. DIR + is the PostgreSQL base install directory + or the path to pg_config.]) + +if test "$PHP_PDO_PGSQL" != "no"; then + PHP_EXPAND_PATH($PGSQL_INCLUDE, PGSQL_INCLUDE) + + AC_MSG_CHECKING(for pg_config) + for i in $PHP_PDO_PGSQL $PHP_PDO_PGSQL/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do + if test -x $i/pg_config; then + PG_CONFIG="$i/pg_config" + break; + fi + done + + if test -n "$PG_CONFIG"; then + AC_MSG_RESULT([$PG_CONFIG]) + PGSQL_INCLUDE=`$PG_CONFIG --includedir` + PGSQL_LIBDIR=`$PG_CONFIG --libdir` + AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h]) + else + AC_MSG_RESULT(not found) + if test "$PHP_PDO_PGSQL" = "yes"; then + PGSQL_SEARCH_PATHS="/usr /usr/local /usr/local/pgsql" + else + PGSQL_SEARCH_PATHS=$PHP_PDO_PGSQL + fi + + for i in $PGSQL_SEARCH_PATHS; do + for j in include include/pgsql include/postgres include/postgresql ""; do + if test -r "$i/$j/libpq-fe.h"; then + PGSQL_INC_BASE=$i + PGSQL_INCLUDE=$i/$j + if test -r "$i/$j/pg_config.h"; then + AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h]) + fi + fi + done + + for j in lib lib/pgsql lib/postgres lib/postgresql ""; do + if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then + PGSQL_LIBDIR=$i/$j + fi + done + done + fi + + if test -z "$PGSQL_INCLUDE"; then + AC_MSG_ERROR(Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path) + fi + + if test -z "$PGSQL_LIBDIR"; then + AC_MSG_ERROR(Cannot find libpq.so. Please specify correct PostgreSQL installation path) + fi + + if test -z "$PGSQL_INCLUDE" -a -z "$PGSQL_LIBDIR" ; then + AC_MSG_ERROR([Unable to find libpq anywhere under $withval]) + fi + + AC_DEFINE(HAVE_PDO_PGSQL,1,[Whether to build PostgreSQL for PDO support or not]) + old_LIBS=$LIBS + old_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -L$PGSQL_LIBDIR" + AC_CHECK_LIB(pq, PQescapeString,AC_DEFINE(HAVE_PQESCAPE,1,[PostgreSQL 7.2.0 or later])) + AC_CHECK_LIB(pq, PQsetnonblocking,AC_DEFINE(HAVE_PQSETNONBLOCKING,1,[PostgreSQL 7.0.x or later])) + AC_CHECK_LIB(pq, PQcmdTuples,AC_DEFINE(HAVE_PQCMDTUPLES,1,[Broken libpq under windows])) + AC_CHECK_LIB(pq, PQoidValue,AC_DEFINE(HAVE_PQOIDVALUE,1,[Older PostgreSQL])) + AC_CHECK_LIB(pq, PQclientEncoding,AC_DEFINE(HAVE_PQCLIENTENCODING,1,[PostgreSQL 7.0.x or later])) + AC_CHECK_LIB(pq, PQparameterStatus,AC_DEFINE(HAVE_PQPARAMETERSTATUS,1,[PostgreSQL 7.4 or later])) + AC_CHECK_LIB(pq, PQprotocolVersion,AC_DEFINE(HAVE_PQPROTOCOLVERSION,1,[PostgreSQL 7.4 or later])) + AC_CHECK_LIB(pq, PQtransactionStatus,AC_DEFINE(HAVE_PGTRANSACTIONSTATUS,1,[PostgreSQL 7.4 or later])) + AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibye])) + LIBS=$old_LIBS + LDFLAGS=$old_LDFLAGS + + PHP_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR, PDO_PGSQL_SHARED_LIBADD) + PHP_SUBST(PDO_PGSQL_SHARED_LIBADD) + + PHP_ADD_INCLUDE($PGSQL_INCLUDE) + +dnl find PDO sources + if test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then + pdo_inc_path=$prefix/include/php/ext + elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then + pdo_inc_path=$abs_srcdir/ext + elif test -f ext/pdo/php_pdo_driver.h; then + pdo_inc_path=ext + else + AC_MSG_ERROR([Cannot find php_pdo_driver.h.]) + fi + + PHP_NEW_EXTENSION(pdo_pgsql, pdo_pgsql.c pgsql_driver.c pgsql_statement.c, $ext_shared,,-I$pdo_inc_path) +fi diff --git a/ext/pdo_pgsql/config.w32 b/ext/pdo_pgsql/config.w32 new file mode 100644 index 0000000000..f65e51131d --- /dev/null +++ b/ext/pdo_pgsql/config.w32 @@ -0,0 +1,15 @@ +// $Id$ +// vim:ft=javascript + +ARG_WITH("pdo-pgsql", "PostgreSQL support for PDO", "no"); + +if (PHP_PDO_PGSQL != "no") { + if (CHECK_LIB("libpq.lib", "pdo_pgsql", PHP_PDO_PGSQL) && + CHECK_HEADER_ADD_INCLUDE("libpq-fe.h", "CFLAGS_PDO_PGSQL", PHP_PHP_BUILD + "\\include\\pgsql;" + PHP_PDO_PGSQL)) { + EXTENSION("pdo_pgsql", "pdo_pgsql.c pgsql_driver.c pgsql_statement.c"); + ADD_FLAG('CFLAGS_PDO_PGSQL', "/I ..\\pecl"); + } else { + WARNING("pdo_pgsql not enabled; libraries and headers not found"); + } + ADD_EXTENSION_DEP('pdo_pgsql', 'pdo'); +} diff --git a/ext/pdo_pgsql/package.xml b/ext/pdo_pgsql/package.xml new file mode 100644 index 0000000000..f3cdd1e5e7 --- /dev/null +++ b/ext/pdo_pgsql/package.xml @@ -0,0 +1,42 @@ + + + + pdo_oci + PostgreSQL driver for PDO + + + edink + Edin Kadribasic + edink@emini.dk + lead + + + + This extension provides a PostgreSQL driver for PDO. + + PHP + + alpha + 0.1dev + 2004-05-18 + + + Hope it works! + + + + + + + + + + + + + + + + + + diff --git a/ext/pdo_pgsql/pdo_pgsql.c b/ext/pdo_pgsql/pdo_pgsql.c new file mode 100644 index 0000000000..f6c4616e7a --- /dev/null +++ b/ext/pdo_pgsql/pdo_pgsql.c @@ -0,0 +1,113 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2004 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.0 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_0.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Edin Kadribasic | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "pdo/php_pdo.h" +#include "pdo/php_pdo_driver.h" +#include "php_pdo_pgsql.h" +#include "php_pdo_pgsql_int.h" + +/* {{{ pdo_pgsql_functions[] */ +function_entry pdo_pgsql_functions[] = { + {NULL, NULL, NULL} +}; +/* }}} */ + +/* {{{ pdo_pgsql_module_entry */ +zend_module_entry pdo_pgsql_module_entry = { + STANDARD_MODULE_HEADER, + "pdo_pgsql", + pdo_pgsql_functions, + PHP_MINIT(pdo_pgsql), + PHP_MSHUTDOWN(pdo_pgsql), + PHP_RINIT(pdo_pgsql), + PHP_RSHUTDOWN(pdo_pgsql), + PHP_MINFO(pdo_pgsql), + "0.1", + STANDARD_MODULE_PROPERTIES +}; +/* }}} */ + +#ifdef COMPILE_DL_PDO_PGSQL +ZEND_GET_MODULE(pdo_pgsql) +#endif + +/* true global environment */ + +/* {{{ PHP_MINIT_FUNCTION + */ +PHP_MINIT_FUNCTION(pdo_pgsql) +{ + php_pdo_register_driver(&pdo_pgsql_driver); + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_MSHUTDOWN_FUNCTION + */ +PHP_MSHUTDOWN_FUNCTION(pdo_pgsql) +{ + php_pdo_unregister_driver(&pdo_pgsql_driver); + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_RINIT_FUNCTION + */ +PHP_RINIT_FUNCTION(pdo_pgsql) +{ + // php_pdo_register_driver(&pdo_pgsql_driver); + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_MSHUTDOWN_FUNCTION + */ +PHP_RSHUTDOWN_FUNCTION(pdo_pgsql) +{ + // php_pdo_unregister_driver(&pdo_pgsql_driver); + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_MINFO_FUNCTION + */ +PHP_MINFO_FUNCTION(pdo_pgsql) +{ + php_info_print_table_start(); + php_info_print_table_header(2, "PDO Driver for PostgreSQL", "enabled"); + php_info_print_table_end(); +} +/* }}} */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c new file mode 100644 index 0000000000..28a726d172 --- /dev/null +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -0,0 +1,172 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2004 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.0 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_0.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Edin Kadribasic | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "pdo/php_pdo.h" +#include "pdo/php_pdo_driver.h" +#include "php_pdo_pgsql.h" +#include "php_pdo_pgsql_int.h" + +int _pdo_pgsql_error(char *what, char *errmsg, const char *file, int line TSRMLS_DC) /* {{{ */ +{ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "(%s:%d) %s", file, line, errmsg); + return 1; +} +/* }}} */ + +int pgsql_handle_error(pdo_dbh_t *dbh, pdo_pgsql_db_handle *H, int errcode) /* {{{ */ +{ + return 0; +} +/* }}} */ + +static int pgsql_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */ +{ + pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; + + if (H->server) { + PQfinish(H->server); + H->server = NULL; + } + return 0; +} +/* }}} */ + +static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, long options, zval *driver_options TSRMLS_DC) +{ + pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; + pdo_pgsql_stmt *S = ecalloc(1, sizeof(pdo_pgsql_stmt)); + + S->H = H; + stmt->driver_data = S; + stmt->methods = &pgsql_stmt_methods; + + return 1; +} + +static int pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql TSRMLS_DC) +{ + pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; + + return 0; +} + +static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen TSRMLS_DC) +{ + pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; + *quoted = emalloc(2*unquotedlen + 3); + (*quoted)[0] = '"'; + *quotedlen = PQescapeString(*quoted + 1, unquoted, unquotedlen); + (*quoted)[*quotedlen + 1] = '"'; + (*quoted)[*quotedlen + 2] = '\0'; + *quotedlen += 2; + return 1; +} + + +static struct pdo_dbh_methods pgsql_methods = { + pgsql_handle_closer, + pgsql_handle_preparer, + pgsql_handle_doer, + pgsql_handle_quoter +}; + +static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC) /* {{{ */ +{ + pdo_pgsql_db_handle *H; + int i, ret = 0; + char *host, *port, *dbname; + struct pdo_data_src_parser vars[] = { + { "host", "", 0 }, + { "port", "", 0 }, + { "dbname", "", 0 }, + }; + + php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, 3); + + H = pecalloc(1, sizeof(pdo_pgsql_db_handle), dbh->is_persistent); + dbh->driver_data = H; + + /* handle for the server */ + host = vars[0].optval; + port = vars[1].optval; + dbname = vars[2].optval; + + H->server = + PQsetdbLogin(host, + port, + NULL, /* options */ + NULL, /* tty */ + dbname, + dbh->username, + dbh->password + ); + + if (PQstatus(H->server) != CONNECTION_OK) { + H->last_err = PQerrorMessage(H->server); + pdo_pgsql_error("pdo_pgsql_handle_factory", H->last_err); + goto cleanup; + } + + H->attached = 1; + + dbh->methods = &pgsql_methods; + dbh->alloc_own_columns = 1; + dbh->supports_placeholders = 1; + dbh->emulate_prepare = 1; + dbh->placeholders_can_be_strings = 1; + dbh->max_escaped_char_length = 2; + + ret = 1; + +cleanup: + for (i = 0; i < sizeof(vars)/sizeof(vars[0]); i++) { + if (vars[i].freeme) { + efree(vars[i].optval); + } + } + + if (!ret) { + pgsql_handle_closer(dbh TSRMLS_CC); + } + + return ret; +} +/* }}} */ + +pdo_driver_t pdo_pgsql_driver = { + PDO_DRIVER_HEADER(pgsql), + pdo_pgsql_handle_factory +}; + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c new file mode 100644 index 0000000000..f3a275d7d9 --- /dev/null +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -0,0 +1,150 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2004 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.0 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_0.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Edin Kadribasic | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "pdo/php_pdo.h" +#include "pdo/php_pdo_driver.h" +#include "php_pdo_pgsql.h" +#include "php_pdo_pgsql_int.h" + + +static int pgsql_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) +{ + pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; + int i; + + if (S->result) { + /* free the resource */ + PQclear(S->result); + S->result = NULL; + } + if(S->cols) { + efree(S->cols); + S->cols = NULL; + } + efree(S); + return 1; +} + +static int pgsql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) +{ + pdo_dbh_t *dbh = stmt->dbh; + pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; + pdo_pgsql_db_handle *H = S->H; + ExecStatusType status; + + if (stmt->executed) { + /* ensure that we free any previous unfetched results */ + if(S->result) { + PQclear(S->result); + S->result = NULL; + } + } + + S->result = PQexec(H->server, stmt->active_query_string); + status = PQresultStatus(S->result); + + if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK) { + H->last_err = PQerrorMessage(H->server); + pdo_pgsql_error("pgsql_stmt_execute", H->last_err); + return 0; + } + + if(!stmt->executed) { + stmt->column_count = (int) PQnfields(S->result); + S->cols = ecalloc(stmt->column_count, sizeof(pdo_pgsql_column)); + } + + + if (status == PGRES_COMMAND_OK) { + stmt->row_count = (long)atoi(PQcmdTuples(S->result)); + } else { + stmt->row_count = (long)PQntuples(S->result); + } + + return 1; +} + +static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, + enum pdo_param_event event_type TSRMLS_DC) +{ + return 1; +} + +static int pgsql_stmt_fetch(pdo_stmt_t *stmt TSRMLS_DC) +{ + pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; + + if (S->current_row < stmt->row_count) { + S->current_row++; + return 1; + } else { + return 0; + } +} + +static int pgsql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) +{ + pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; + struct pdo_column_data *cols = stmt->columns; + + cols[colno].name = estrdup(PQfname(S->result, colno)); + cols[colno].namelen = strlen(cols[colno].name); + cols[colno].maxlen = PQfsize(S->result, colno); + cols[colno].precision = PQfmod(S->result, colno); + cols[colno].param_type = PDO_PARAM_STR; + + return 1; +} + +static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len TSRMLS_DC) +{ + pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; + + /* We have already increased count by 1 in pgsql_stmt_fetch() */ + *ptr = estrdup(PQgetvalue(S->result, S->current_row - 1, colno)); + *len = strlen(*ptr); + + return 1; +} + +struct pdo_stmt_methods pgsql_stmt_methods = { + pgsql_stmt_dtor, + pgsql_stmt_execute, + pgsql_stmt_fetch, + pgsql_stmt_describe, + pgsql_stmt_get_col, + pgsql_stmt_param_hook +}; + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/pdo_pgsql/php_pdo_pgsql.h b/ext/pdo_pgsql/php_pdo_pgsql.h new file mode 100644 index 0000000000..bcfd2bb2cd --- /dev/null +++ b/ext/pdo_pgsql/php_pdo_pgsql.h @@ -0,0 +1,58 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2004 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.0 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_0.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Edin Kadribasic | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef PHP_PDO_PGSQL_H +#define PHP_PDO_PGSQL_H + +#if HAVE_PDO_PGSQL + +#include + +extern zend_module_entry pdo_pgsql_module_entry; +#define phpext_pdo_pgsql_ptr &pdo_pgsql_module_entry + +#ifdef PHP_WIN32 +#define PHP_PDO_PGSQL_API __declspec(dllexport) +#else +#define PHP_PDO_PGSQL_API +#endif + +#ifdef ZTS +#include "TSRM.h" +#endif + +PHP_MINIT_FUNCTION(pdo_pgsql); +PHP_MSHUTDOWN_FUNCTION(pdo_pgsql); +PHP_RINIT_FUNCTION(pdo_pgsql); +PHP_RSHUTDOWN_FUNCTION(pdo_pgsql); +PHP_MINFO_FUNCTION(pdo_pgsql); + +#endif /* HAVE_PDO_PGSQL */ +#endif /* PHP_PDO_PGSQL_H */ + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h new file mode 100644 index 0000000000..91a4d3451c --- /dev/null +++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h @@ -0,0 +1,73 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2004 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.0 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_0.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Edin Kadribasic | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef PHP_PDO_PGSQL_INT_H +#define PHP_PDO_PGSQL_INT_H + +#if HAVE_PDO_PGSQL + +#include + +/* stuff we use in a pgsql database handle */ +typedef struct { + PGconn *server; + char *last_err; + unsigned attached:1; + unsigned _reserved:31; +} pdo_pgsql_db_handle; + +typedef struct { + char *def; +} pdo_pgsql_column; + +typedef struct { + pdo_pgsql_db_handle *H; + PGresult *result; + int current_row; + char *last_err; + pdo_pgsql_column *cols; +} pdo_pgsql_stmt; + +typedef struct { + char *repr; + long repr_len; + int pgsql_type; + void *thing; /* for LOBS, REFCURSORS etc. */ +} pdo_pgsql_bound_param; + +extern pdo_driver_t pdo_pgsql_driver; + +extern int _pdo_pgsql_error(char *what, char *errmsg, const char *file, int line TSRMLS_DC); +#define pdo_pgsql_error(w,s) _pdo_pgsql_error(w, s, __FILE__, __LINE__ TSRMLS_CC) +extern int pgsql_handle_error(pdo_dbh_t *dbh, pdo_pgsql_db_handle *H, int errcode); + +extern struct pdo_stmt_methods pgsql_stmt_methods; + +#endif /* HAVE_PDO_PGSQL */ +#endif /* PHP_PDO_PGSQL_INT_H */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */