Browse Source

merge other PDO fixes from 5.1 branch.

Allow pdo_sqlite to build against 5.0 and 5.1 too.
migration/RELEASE_1_0_0
Wez Furlong 21 years ago
parent
commit
37ace0651b
  1. 2
      ext/pdo_mysql/mysql_driver.c
  2. 12
      ext/pdo_oci/oci_driver.c
  3. 4
      ext/pdo_pgsql/pgsql_statement.c
  4. 35
      ext/pdo_sqlite/sqlite_driver.c

2
ext/pdo_mysql/mysql_driver.c

@ -424,7 +424,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
}
dbname = vars[1].optval;
host = vars[2].optval;
host = vars[2].optval;
if(vars[3].optval) {
port = atoi(vars[3].optval);
}

12
ext/pdo_oci/oci_driver.c

@ -144,6 +144,18 @@ ub4 _oci_error(OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, swor
}
}
if (stmt) {
/* always propogate the error code back up to the dbh,
* so that we can catch the error information when execute
* is called via query. See Bug #33707 */
if (H->einfo.errmsg) {
efree(H->einfo.errmsg);
}
H->einfo = *einfo;
H->einfo.errmsg = einfo->errmsg ? estrdup(einfo->errmsg) : NULL;
strcpy(dbh->error_code, stmt->error_code);
}
/* little mini hack so that we can use this code from the dbh ctor */
if (!dbh->methods) {
zend_throw_exception_ex(php_pdo_get_exception(TSRMLS_C), 0 TSRMLS_CC, "SQLSTATE[%s]: %s", *pdo_err, einfo->errmsg);

4
ext/pdo_pgsql/pgsql_statement.c

@ -203,6 +203,10 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
Z_TYPE_P(param->parameter) == IS_NULL) {
S->param_values[param->paramno] = NULL;
S->param_lengths[param->paramno] = 0;
} else if (Z_TYPE_P(param->parameter) == IS_BOOL) {
S->param_values[param->paramno] = Z_BVAL_P(param->parameter) ? "t" : "f";
S->param_lengths[param->paramno] = 1;
S->param_formats[param->paramno] = 1;
} else {
convert_to_string(param->parameter);
S->param_values[param->paramno] = Z_STRVAL_P(param->parameter);

35
ext/pdo_sqlite/sqlite_driver.c

@ -457,7 +457,11 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
char *func_name;
int func_name_len;
long argc = -1;
#ifdef IS_UNICODE
zval cbname;
#else
char *cbname;
#endif
pdo_dbh_t *dbh;
pdo_sqlite_db_handle *H;
int ret;
@ -470,11 +474,20 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
if (!zend_is_callable(callback, 0, &cbname)) {
#ifdef IS_UNICODE
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%R' is not callable", Z_TYPE(cbname), Z_UNIVAL(cbname));
zval_dtor(&cbname);
#else
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname);
efree(cbname);
#endif
RETURN_FALSE;
}
#ifdef IS_UNICODE
zval_dtor(&cbname);
#else
efree(cbname);
#endif
H = (pdo_sqlite_db_handle *)dbh->driver_data;
@ -528,7 +541,11 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
char *func_name;
int func_name_len;
long argc = -1;
#ifdef IS_UNICODE
zval cbname;
#else
char *cbname;
#endif
pdo_dbh_t *dbh;
pdo_sqlite_db_handle *H;
int ret;
@ -541,17 +558,35 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
if (!zend_is_callable(step_callback, 0, &cbname)) {
#ifdef IS_UNICODE
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%R' is not callable", Z_TYPE(cbname), Z_UNIVAL(cbname));
zval_dtor(&cbname);
#else
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname);
efree(cbname);
#endif
RETURN_FALSE;
}
#ifdef IS_UNICODE
zval_dtor(&cbname);
#else
efree(cbname);
#endif
if (!zend_is_callable(fini_callback, 0, &cbname)) {
#ifdef IS_UNICODE
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%R' is not callable", Z_TYPE(cbname), Z_UNIVAL(cbname));
zval_dtor(&cbname);
#else
php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname);
efree(cbname);
#endif
RETURN_FALSE;
}
#ifdef IS_UNICODE
zval_dtor(&cbname);
#else
efree(cbname);
#endif
H = (pdo_sqlite_db_handle *)dbh->driver_data;

Loading…
Cancel
Save