--- embedaddon/php/ext/pdo_pgsql/pgsql_driver.c 2012/02/21 23:47:59 1.1.1.1 +++ embedaddon/php/ext/pdo_pgsql/pgsql_driver.c 2013/07/22 01:31:59 1.1.1.3 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2012 The PHP Group | + | Copyright (c) 1997-2013 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql_driver.c,v 1.1.1.1 2012/02/21 23:47:59 misho Exp $ */ +/* $Id: pgsql_driver.c,v 1.1.1.3 2013/07/22 01:31:59 misho Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -76,7 +76,7 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, einfo->errmsg = NULL; } - if (sqlstate == NULL) { + if (sqlstate == NULL || strlen(sqlstate) >= sizeof(pdo_error_type)) { strcpy(*pdo_err, "HY000"); } else { @@ -299,7 +299,7 @@ static long pgsql_handle_doer(pdo_dbh_t *dbh, const ch return -1; } H->pgoid = PQoidValue(res); - ret = atol(PQcmdTuples(res)); + ret = (qs == PGRES_COMMAND_OK) ? atol(PQcmdTuples(res)) : 0L; PQclear(res); return ret; @@ -497,6 +497,15 @@ static int pgsql_handle_rollback(pdo_dbh_t *dbh TSRMLS return pdo_pgsql_transaction_cmd("ROLLBACK", dbh TSRMLS_CC); } +static int pgsql_handle_in_transaction(pdo_dbh_t *dbh TSRMLS_DC) +{ + pdo_pgsql_db_handle *H; + + H = (pdo_pgsql_db_handle *)dbh->driver_data; + + return PQtransactionStatus(H->server); +} + /* {{{ proto string PDO::pgsqlCopyFromArray(string $table_name , array $rows [, string $delimiter [, string $null_as ] [, string $fields]) Returns true if the copy worked fine or false if error */ static PHP_METHOD(PDO, pgsqlCopyFromArray) @@ -619,7 +628,7 @@ static PHP_METHOD(PDO, pgsqlCopyFromFile) ExecStatusType status; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|sss", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sp|sss", &table_name, &table_name_len, &filename, &filename_len, &pg_delim, &pg_delim_len, &pg_null_as, &pg_null_as_len, &pg_fields, &pg_fields_len) == FAILURE) { return; @@ -713,7 +722,7 @@ static PHP_METHOD(PDO, pgsqlCopyToFile) php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|sss", + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sp|sss", &table_name, &table_name_len, &filename, &filename_len, &pg_delim, &pg_delim_len, &pg_null_as, &pg_null_as_len, &pg_fields, &pg_fields_len) == FAILURE) { return; @@ -1022,6 +1031,7 @@ static struct pdo_dbh_methods pgsql_methods = { pdo_pgsql_check_liveness, /* check_liveness */ pdo_pgsql_get_driver_methods, /* get_driver_methods */ NULL, + pgsql_handle_in_transaction, }; static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC) /* {{{ */