1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 03:03:26 +02:00

Merge branch 'PHP-7.0' into PHP-7.1

* PHP-7.0:
  Add special case for earlier versions of TDS
  Adjust error formatting so ext/pdo/tests/bug_43130.phpt passes with pdo_dblib
  Free error and message strings when cleaning up PDO instances that use pdo_dblib
  Add common suite
This commit is contained in:
Adam Baratz
2016-09-13 17:02:53 -04:00
6 changed files with 59 additions and 19 deletions
+14 -3
View File
@@ -129,9 +129,20 @@ unset($stmt);
echo "===DATA===\n";
$res = $db->query('SELECT test.val FROM test')->fetchAll(PDO::FETCH_COLUMN);
// For Oracle map NULL to empty string so the test doesn't diff
if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci' && $res[0] === null) {
$res[0] = "";
switch ($db->getAttribute(PDO::ATTR_DRIVER_NAME)) {
case 'dblib':
// map whitespace (from early TDS versions) to empty string so the test doesn't diff
if ($res[0] === ' ') {
$res[0] = '';
}
break;
case 'oci':
// map NULL to empty string so the test doesn't diff
if ($res[0] === null) {
$res[0] = '';
}
break;
}
var_dump($res);
+6
View File
@@ -57,6 +57,11 @@ static int dblib_fetch_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info)
msg = einfo->dberrstr;
}
/* don't return anything if there's nothing to return */
if (msg == NULL && einfo->dberr == 0 && einfo->oserr == 0 && einfo->severity == 0) {
return 0;
}
spprintf(&message, 0, "%s [%d] (severity %d) [%s]",
msg, einfo->dberr, einfo->severity, stmt ? stmt->active_query_string : "");
@@ -88,6 +93,7 @@ static int dblib_handle_closer(pdo_dbh_t *dbh)
}
pefree(H, dbh->is_persistent);
dbh->driver_data = NULL;
pdo_dblib_err_dtor(&H->err);
}
return 0;
}
-16
View File
@@ -95,22 +95,6 @@ static char *pdo_dblib_get_field_name(int type)
}
/* }}} */
static void pdo_dblib_err_dtor(pdo_dblib_err *err)
{
if (err->dberrstr) {
efree(err->dberrstr);
err->dberrstr = NULL;
}
if (err->lastmsg) {
efree(err->lastmsg);
err->lastmsg = NULL;
}
if (err->oserrstr) {
efree(err->oserrstr);
err->oserrstr = NULL;
}
}
static int pdo_dblib_stmt_cursor_closer(pdo_stmt_t *stmt)
{
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
+20
View File
@@ -146,6 +146,26 @@ int pdo_dblib_msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
return 0;
}
void pdo_dblib_err_dtor(pdo_dblib_err *err)
{
if (!err) {
return;
}
if (err->dberrstr) {
efree(err->dberrstr);
err->dberrstr = NULL;
}
if (err->lastmsg) {
efree(err->lastmsg);
err->lastmsg = NULL;
}
if (err->oserrstr) {
efree(err->oserrstr);
err->oserrstr = NULL;
}
}
static PHP_GINIT_FUNCTION(dblib)
{
memset(dblib_globals, 0, sizeof(*dblib_globals));
+2
View File
@@ -108,6 +108,8 @@ typedef struct {
char *lastmsg;
} pdo_dblib_err;
void pdo_dblib_err_dtor(pdo_dblib_err *err);
typedef struct {
LOGINREC *login;
DBPROCESS *link;
+17
View File
@@ -0,0 +1,17 @@
--TEST--
DBLIB
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded('pdo_dblib')) die('skip not loaded');
?>
--REDIRECTTEST--
# magic auto-configuration
return [
'ENV' => [
'PDOTEST_DSN' => getenv('PDO_DBLIB_TEST_DSN') ?: 'dblib:host=localhost;dbname=test',
'PDOTEST_USER' => getenv('PDO_DBLIB_TEST_USER') ?: 'php',
'PDOTEST_PASS' => getenv('PDO_DBLIB_TEST_PASS') ?: 'password',
],
'TESTS' => __DIR__ . '/ext/pdo/tests',
];