summaryrefslogtreecommitdiff
path: root/ext/pdo_firebird/firebird_driver.c
diff options
context:
space:
mode:
authorStanley Sufficool <ssufficool@php.net>2014-10-20 21:33:32 -0700
committerStanley Sufficool <ssufficool@php.net>2014-10-20 21:33:32 -0700
commit8defcb855ab01d9c8ab4759cb793d80149b55a8c (patch)
treeed51eb30a2cbc92b102557498fb3e4113da1bb07 /ext/pdo_firebird/firebird_driver.c
parent9c7dbb0487f5991fde03873ea8f5e66d6688415f (diff)
parentbaddb1c73a170ef1d2c31bd54cddbc6e1ab596b9 (diff)
downloadphp-git-8defcb855ab01d9c8ab4759cb793d80149b55a8c.tar.gz
Merge branch 'master' of https://git.php.net/push/php-src
* 'master' of https://git.php.net/push/php-src: (6215 commits) Extra comma Moved proxy object support in ASSIGN_ADD (and family) from VM to slow paths of corresponding operators Simplification zend_get_property_info_quick() cleanup and optimization initialize lineno before calling compile file file in phar Use ADDREF instead of DUP, it must be enough. Removed old irrelevant comment fixed compilation error Fix bug #68262: Broken reference across cloned objects export functions needed for phpdbg Fixed compilation Optimized property access handlers. Removed EG(std_property_info). Fixed bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads) Don't make difference between undefined and unaccessible properies when call __get() and family Don't make useless CSE array_pop/array_shift optimization check for zlib headers as well as lib for mysqlnd a realpath cache key can be int or float, catching this News entry for new curl constants News entry for new curl constants ...
Diffstat (limited to 'ext/pdo_firebird/firebird_driver.c')
-rw-r--r--ext/pdo_firebird/firebird_driver.c59
1 files changed, 28 insertions, 31 deletions
diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c
index bda6d23fa4..298d2539e3 100644
--- a/ext/pdo_firebird/firebird_driver.c
+++ b/ext/pdo_firebird/firebird_driver.c
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2013 The PHP Group |
+ | Copyright (c) 1997-2014 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 |
@@ -16,8 +16,6 @@
+----------------------------------------------------------------------+
*/
-/* $Id$ */
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -35,11 +33,11 @@
#include "php_pdo_firebird.h"
#include "php_pdo_firebird_int.h"
-static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, long, XSQLDA*, isc_stmt_handle*,
+static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, zend_long, XSQLDA*, isc_stmt_handle*,
HashTable* TSRMLS_DC);
/* map driver specific error message to PDO error */
-void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC) /* {{{ */
+void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, zend_long line TSRMLS_DC) /* {{{ */
{
#if 0
pdo_firebird_db_handle *H = stmt ? ((pdo_firebird_stmt *)stmt->driver_data)->H
@@ -134,7 +132,7 @@ static int firebird_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
/* }}} */
/* called by PDO to prepare an SQL query */
-static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, /* {{{ */
+static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, /* {{{ */
pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC)
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
@@ -220,7 +218,7 @@ static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_le
/* }}} */
/* called by PDO to execute a statement that doesn't produce a result set */
-static long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC) /* {{{ */
+static zend_long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
isc_stmt_handle stmt = NULL;
@@ -393,12 +391,12 @@ static int firebird_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
/* }}} */
/* used by prepare and exec to allocate a statement handle and prepare the SQL */
-static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, long sql_len, /* {{{ */
+static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, zend_long sql_len, /* {{{ */
XSQLDA *out_sqlda, isc_stmt_handle *s, HashTable *named_params TSRMLS_DC)
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
char *c, *new_sql, in_quote, in_param, pname[64], *ppname;
- long l, pindex = -1;
+ zend_long l, pindex = -1;
/* Firebird allows SQL statements up to 64k, so bail if it doesn't fit */
if (sql_len > 65536) {
@@ -449,8 +447,9 @@ static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, long sql
} else {
*ppname++ = 0;
if (named_params) {
- zend_hash_update(named_params, pname, (unsigned int)(ppname-pname),
- (void*)&pindex, sizeof(long)+1,NULL);
+ zval tmp;
+ ZVAL_LONG(&tmp, pindex);
+ zend_hash_str_update(named_params, pname, (unsigned int)(ppname - pname - 1), &tmp);
}
}
}
@@ -471,7 +470,7 @@ static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, long sql
/* }}} */
/* called by PDO to set a driver-specific dbh attribute */
-static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */
+static int firebird_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
@@ -481,9 +480,9 @@ static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
convert_to_boolean(val);
/* ignore if the new value equals the old one */
- if (dbh->auto_commit ^ Z_BVAL_P(val)) {
+ if (dbh->auto_commit ^ (Z_TYPE_P(val) == IS_TRUE? 1 : 0)) {
if (dbh->in_txn) {
- if (Z_BVAL_P(val)) {
+ if (Z_TYPE_P(val) == IS_TRUE) {
/* turning on auto_commit with an open transaction is illegal, because
we won't know what to do with it */
H->last_app_error = "Cannot enable auto-commit while a transaction is already open";
@@ -496,13 +495,13 @@ static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
dbh->in_txn = 0;
}
}
- dbh->auto_commit = Z_BVAL_P(val);
+ dbh->auto_commit = Z_TYPE_P(val) == IS_TRUE? 1 : 0;
}
return 1;
case PDO_ATTR_FETCH_TABLE_NAMES:
convert_to_boolean(val);
- H->fetch_table_names = Z_BVAL_P(val);
+ H->fetch_table_names = Z_TYPE_P(val) == IS_TRUE? 1 : 0;
return 1;
case PDO_FB_ATTR_DATE_FORMAT:
@@ -546,7 +545,7 @@ static void firebird_info_cb(void *arg, char const *s) /* {{{ */
/* }}} */
/* called by PDO to get a driver-specific dbh attribute */
-static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */
+static int firebird_handle_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
@@ -569,17 +568,15 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
#else
HMODULE l = GetModuleHandle("fbclient");
- if (!l && !(l = GetModuleHandle("gds32"))) {
+ if (!l) {
break;
}
info_func = (info_func_t)GetProcAddress(l, "isc_get_client_version");
#endif
if (info_func) {
info_func(tmp);
- ZVAL_STRING(val,tmp,1);
- } else {
- ZVAL_STRING(val,"Firebird 1.0/Interbase 6",1);
- }
+ ZVAL_STRING(val, tmp);
+ }
#else
ZVAL_NULL(val);
#endif
@@ -591,7 +588,7 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
*tmp = 0;
if (!isc_version(&H->db, firebird_info_cb, (void*)tmp)) {
- ZVAL_STRING(val,tmp,1);
+ ZVAL_STRING(val, tmp);
return 1;
}
@@ -607,21 +604,21 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
static int pdo_firebird_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
- ISC_STATUS *s = H->isc_status;
+ const ISC_STATUS *s = H->isc_status;
char buf[400];
- long i = 0, l, sqlcode = isc_sqlcode(s);
+ zend_long i = 0, l, sqlcode = isc_sqlcode(s);
if (sqlcode) {
add_next_index_long(info, sqlcode);
- while ((l = isc_interprete(&buf[i],&s))) {
+ while ((sizeof(buf)>(i+2))&&(l = fb_interpret(&buf[i],(sizeof(buf)-i-2),&s))) {
i += l;
strcpy(&buf[i++], " ");
}
- add_next_index_string(info, buf, 1);
+ add_next_index_string(info, buf);
} else if (H->last_app_error) {
add_next_index_long(info, -999);
- add_next_index_string(info, const_cast(H->last_app_error),1);
+ add_next_index_string(info, const_cast(H->last_app_error));
}
return 1;
}
@@ -697,8 +694,8 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
if (!dbh->methods) {
char errmsg[512];
- ISC_STATUS *s = H->isc_status;
- isc_interprete(errmsg, &s);
+ const ISC_STATUS *s = H->isc_status;
+ fb_interpret(errmsg, sizeof(errmsg),&s);
zend_throw_exception_ex(php_pdo_get_exception(), H->isc_status[1] TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
"HY000", H->isc_status[1], errmsg);
}