summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Baratz <adambaratz@php.net>2016-09-13 16:14:55 -0400
committerAdam Baratz <adambaratz@php.net>2016-09-13 16:14:55 -0400
commit421f654874b8ae1d765be1a5c177c13cb4b3cfc7 (patch)
tree1ae7c9c7344390e1f0b29f1c27c4a71a9da48657
parent1b1b7f88097b7ea77607be24edca0397a6750157 (diff)
parent9cdf2042bd3e1a34c15e120cba85a76ef54eb854 (diff)
downloadphp-git-421f654874b8ae1d765be1a5c177c13cb4b3cfc7.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Allow \PDO::setAttribute() to set pdo_dblib query timeouts
-rw-r--r--ext/pdo_dblib/dblib_driver.c7
-rw-r--r--ext/pdo_dblib/tests/timeout.phpt30
2 files changed, 33 insertions, 4 deletions
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index 64a3646b32..13ddd8a472 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -253,14 +253,13 @@ static int dblib_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val)
{
switch(attr) {
case PDO_ATTR_TIMEOUT:
- return 0;
-
+ case PDO_DBLIB_ATTR_QUERY_TIMEOUT:
+ return SUCCEED == dbsettime(zval_get_long(val)) ? 1 : 0;
case PDO_DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER:
((pdo_dblib_db_handle *)dbh->driver_data)->stringify_uniqueidentifier = zval_get_long(val);
return 1;
-
default:
- return 1;
+ return 0;
}
}
diff --git a/ext/pdo_dblib/tests/timeout.phpt b/ext/pdo_dblib/tests/timeout.phpt
index f92a7da72f..d711f2a3a0 100644
--- a/ext/pdo_dblib/tests/timeout.phpt
+++ b/ext/pdo_dblib/tests/timeout.phpt
@@ -18,6 +18,32 @@ if ($stmt->execute()) {
echo "OK\n";
}
+// regular timeout attribute, set after instance created, will affect query timeout, causing this query to fail
+$db = new PDO($dsn, $user, $pass);
+$db->setAttribute(PDO::ATTR_TIMEOUT, 1);
+$stmt = $db->prepare($sql);
+if (!$stmt->execute()) {
+ echo "OK\n";
+
+ // expect some kind of error code
+ if ($stmt->errorCode() != '00000') {
+ echo "OK\n";
+ }
+}
+
+// pdo_dblib-specific timeout attribute, set after instance created, will control query timeout, causing this query to fail
+$db = new PDO($dsn, $user, $pass);
+$db->setAttribute(PDO::DBLIB_ATTR_QUERY_TIMEOUT, 1);
+$stmt = $db->prepare($sql);
+if (!$stmt->execute()) {
+ echo "OK\n";
+
+ // expect some kind of error code
+ if ($stmt->errorCode() != '00000') {
+ echo "OK\n";
+ }
+}
+
// regular timeout attribute will affect query timeout, causing this query to fail
$db = new PDO($dsn, $user, $pass, [PDO::ATTR_TIMEOUT => 1]);
$stmt = $db->prepare($sql);
@@ -49,3 +75,7 @@ OK
OK
OK
OK
+OK
+OK
+OK
+OK