RE: [PHP-CVS] com php-src: Allow \PDO::setAttribute() to set pdo_dblib query timeouts: ext/pdo_dblib/dblib_driver.c ext/pdo_dblib/tests/timeout.phpt

From: Date: Wed, 14 Sep 2016 11:10:27 +0000
Subject: RE: [PHP-CVS] com php-src: Allow \PDO::setAttribute() to set pdo_dblib query timeouts: ext/pdo_dblib/dblib_driver.c ext/pdo_dblib/tests/timeout.phpt
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-94511@lists.php.net to get a copy of this message
Hi Adam, > -----Original Message----- > From: Adam Baratz [mailto:adambaratz@php.net] > Sent: Tuesday, September 13, 2016 10:13 PM > To: php-cvs@lists.php.net > Subject: [PHP-CVS] com php-src: Allow \PDO::setAttribute() to set pdo_dblib > query timeouts: ext/pdo_dblib/dblib_driver.c ext/pdo_dblib/tests/timeout.phpt > > Commit: 9cdf2042bd3e1a34c15e120cba85a76ef54eb854 > Author: Adam Baratz <adambaratz@php.net> Tue, 13 Sep 2016 15:24:28 - > 0400 > Parents: 3a739c9f9f049335c1a1194cd3a50b0cab211d0b > Branches: PHP-7.0 > > Link: http://git.php.net/?p=php- > src.git;a=commitdiff;h=9cdf2042bd3e1a34c15e120cba85a76ef54eb854 > > Log: > Allow \PDO::setAttribute() to set pdo_dblib query timeouts > > Changed paths: > M ext/pdo_dblib/dblib_driver.c > M ext/pdo_dblib/tests/timeout.phpt > > Some of these are probably worth to mention in the NEWS or UPGRADING. It might make sense to check the bug tracker, maybe some tickets in this regard do exist and can be closed. If so, the bug number can be put into the NEWS as well. Thanks. > Diff: > diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c index > 64a3646..13ddd8a 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 f92a7da..d711f2a 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 > > > -- > PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php

« previous php.cvs (#94511) next »