Skip to content

Commit be0793d

Browse files
committed
MFH: Add mysqlnd support for PDO_mysql, fixes at least bug#41997,#42499,
pecl#12794, pecl#12401 # Running the tests: # (Note: Doesn't work currnetly on HEAD, see: # http://news.php.net/php.qa/64378) # # PDO_MYSQL_TEST_DSN - DSN # For example: mysql:dbname=test;host=localhost;port=3306 # # PDO_MYSQL_TEST_HOST - database host # PDO_MYSQL_TEST_DB - database (schema) name # PDO_MYSQL_TEST_SOCKET - database server socket # PDO_MYSQL_TEST_ENGINE - storage engine to use # PDO_MYSQL_TEST_USER - database user # PDO_MYSQL_TEST_PASS - database user password # PDO_MYSQL_TEST_CHARSET - database charset # # NOTE: if any of PDO_MYSQL_TEST_[HOST|DB|SOCKET|ENGINE|CHARSET] is # part of PDO_MYSQL_TEST_DSN, the values must match. That is, for example, # for PDO_MYSQL_TEST_DSN = mysql:dbname=test you MUST set PDO_MYSQL_TEST_DB=test.
1 parent c6c238c commit be0793d

File tree

107 files changed

+10616
-505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+10616
-505
lines changed

NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ PHP NEWS
206206
- Fixed an issue where exec() on Windows would eat the first and last double quotes.
207207
(Scott)
208208

209+
- Fixed PECL bug #12794 (PDOStatement->nextRowset() doesn�t work). (Johannes)
209210
- Fixed PECL bug #12431 (OCI8 ping functionality is broken). (Oracle Corp.)
211+
- Fixed PECL bug #12401 (Add support for ATTR_FETCH_TABLE_NAMES). (Johannes)
210212

211213
- Fixed bug #45571 (ReflectionClass::export() shows superclasses' private static
212214
methods). (robin_fernandes at uk dot ibm dot com)
@@ -266,6 +268,8 @@ PHP NEWS
266268
- Fixed bug #42637 (SoapFault : Only http and https are allowed). (Bill Moran)
267269
- Fixed bug #42548 (mysqli PROCEDURE calls can't return result sets). (hartmut)
268270
- Fixed bug #42509 (gmp leaks memory when gmp_init() not used). (Stas)
271+
- Fixed bug #42499 (PDO_MYSQL: multi-statement execution via PDO::exec() makes
272+
connection unusable). (Johannes)
269273
- Fixed bug #42443 (PDO SQLite driver binds integers and booleans as strings).
270274
(Scott)
271275
- Fixed bug #42284 (duplicate of #39700). (Lars W)
@@ -274,6 +278,8 @@ PHP NEWS
274278
DateTimeZone). (Derick)
275279
- Fixed bug #42069 (parse_ini_file() allows using some non-alpha numeric
276280
characters). (Jani)
281+
- Fixed bug #41997 (pdo_mysql: stored procedure call returning single rowset
282+
blocks future queries). (Johannes)
277283
- Fixed bug #41599 (setTime() fails after modify() is used). (Derick)
278284
- Fixed bug #41522 (PDO firebird driver returns null if it fails to connect).
279285
(Lars W)

ext/pdo/pdo_stmt.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,20 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *typ
545545
stmt->methods->get_col(stmt, colno, &value, &value_len, &caller_frees TSRMLS_CC);
546546

547547
switch (type) {
548+
case PDO_PARAM_ZVAL:
549+
if (value && value_len == sizeof(zval)) {
550+
int need_copy = (new_type != PDO_PARAM_ZVAL || stmt->dbh->stringify) ? 1 : 0;
551+
zval *zv = *(zval**)value;
552+
ZVAL_ZVAL(dest, zv, need_copy, 1);
553+
} else {
554+
ZVAL_NULL(dest);
555+
}
556+
557+
if (Z_TYPE_P(dest) == IS_NULL) {
558+
type = new_type;
559+
}
560+
break;
561+
548562
case PDO_PARAM_INT:
549563
if (value && value_len == sizeof(long)) {
550564
ZVAL_LONG(dest, *(long*)value);
@@ -1883,7 +1897,10 @@ static PHP_METHOD(PDOStatement, getColumnMeta)
18831897
add_assoc_string(return_value, "name", col->name, 1);
18841898
add_assoc_long(return_value, "len", col->maxlen); /* FIXME: unsigned ? */
18851899
add_assoc_long(return_value, "precision", col->precision);
1886-
add_assoc_long(return_value, "pdo_type", col->param_type);
1900+
if (col->param_type != PDO_PARAM_ZVAL) {
1901+
/* if param_type is PDO_PARAM_ZVAL the driver has to provide correct data */
1902+
add_assoc_long(return_value, "pdo_type", col->param_type);
1903+
}
18871904
}
18881905
/* }}} */
18891906

ext/pdo/php_pdo_driver.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ PDO_API char *php_pdo_int64_to_str(pdo_int64_t i64 TSRMLS_DC);
4444
# define FALSE 0
4545
#endif
4646

47-
#define PDO_DRIVER_API 20060511
47+
#define PDO_DRIVER_API 20080721
4848

4949
enum pdo_param_type {
5050
PDO_PARAM_NULL,
@@ -67,7 +67,12 @@ enum pdo_param_type {
6767
PDO_PARAM_STMT, /* hierarchical result set */
6868

6969
/* get_col ptr should point to a zend_bool */
70-
PDO_PARAM_BOOL
70+
PDO_PARAM_BOOL,
71+
72+
/* get_col ptr should point to a zval*
73+
and the driver is responsible for adding correct type information to get_column_meta()
74+
*/
75+
PDO_PARAM_ZVAL
7176
};
7277

7378
/* magic flag to denote a parameter as being input/output */

ext/pdo/tests/bug_34630.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
4545
var_dump($db->query("SELECT * from test")->fetchAll(PDO::FETCH_ASSOC));
4646

4747
?>
48+
--XFAIL--
49+
This bug might be still open on aix5.2-ppc64 and hpux11.23-ia64
4850
--EXPECT--
4951
array(1) {
5052
[0]=>

ext/pdo/tests/bug_39656.phpt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
PDO Common: Bug #39656 (Crash when calling fetch() on a PDO statment object after closeCursor())
33
--SKIPIF--
4-
<?php
4+
<?php
55
if (!extension_loaded('pdo')) die('skip');
66
$dir = getenv('REDIR_TEST_DIR');
77
if (false == $dir) die('skip no driver');
@@ -15,13 +15,13 @@ if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE_
1515
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
1616
$db = PDOTest::factory();
1717

18-
@$db->exec("DROP TABLE testtable");
18+
@$db->exec("DROP TABLE test");
1919
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
2020

21-
$db->exec("CREATE TABLE testtable (id INTEGER NOT NULL PRIMARY KEY, usr VARCHAR( 256 ) NOT NULL)");
22-
$db->exec("INSERT INTO testtable (id, usr) VALUES (1, 'user')");
21+
$db->exec("CREATE TABLE test (id INTEGER NOT NULL PRIMARY KEY, usr VARCHAR( 256 ) NOT NULL)");
22+
$db->exec("INSERT INTO test (id, usr) VALUES (1, 'user')");
2323

24-
$stmt = $db->prepare("SELECT * FROM testtable WHERE id = ?");
24+
$stmt = $db->prepare("SELECT * FROM test WHERE id = ?");
2525
$stmt->bindValue(1, 1, PDO::PARAM_INT );
2626
$stmt->execute();
2727
$row = $stmt->fetch();
@@ -32,9 +32,10 @@ $stmt->closeCursor();
3232
$row = $stmt->fetch(); // this line will crash CLI
3333
var_dump( $row );
3434

35+
@$db->exec("DROP TABLE test");
3536
echo "Done\n";
3637
?>
37-
--EXPECT--
38+
--EXPECT--
3839
array(4) {
3940
["id"]=>
4041
string(1) "1"

ext/pdo/tests/bug_43130.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE_
1616
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
1717
$db = PDOTest::factory();
1818

19+
if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql')
20+
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
21+
1922
$db->exec("CREATE TABLE test (a varchar(100), b varchar(100), c varchar(100))");
2023

2124
for ($i = 0; $i < 5; $i++) {

ext/pdo/tests/bug_43663.phpt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
PDO Common: Bug #43663 (__call on classes derived from PDO)
33
--SKIPIF--
44
<?php # vim:ft=php
5-
if (!extension_loaded('pdo_sqlite')) die('skip no pdo_sqlite');
5+
if (!extension_loaded('pdo')) die('skip');
6+
if (!extension_loaded('pdo_sqlite')) die('skip');
7+
$dir = getenv('REDIR_TEST_DIR');
8+
if (false == $dir) die('skip no driver');
9+
require_once $dir . 'pdo_test.inc';
10+
PDOTest::skip();
611
?>
712
--FILE--
813
<?php
@@ -14,6 +19,10 @@ class test extends PDO{
1419
echo "Called foo in ".__CLASS__."\n";
1520
}
1621
}
22+
23+
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
24+
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
25+
1726
$a = new test('sqlite::memory:');
1827
$a->foo();
1928
$a->bar();

ext/pdo/tests/bug_44159.phpt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
--TEST--
22
Bug #44159 (Crash: $pdo->setAttribute(PDO::STATEMENT_ATTR_CLASS, NULL))
33
--SKIPIF--
4-
<?php
5-
if (!extension_loaded('pdo_sqlite')) die('skip no pdo_sqlite');
4+
<?php # vim:ft=php
5+
if (!extension_loaded('pdo')) die('skip PDO not available');
6+
try {
7+
$pdo = new PDO("sqlite:/tmp/foo.db");
8+
} catch (Exception $e) {
9+
die("skip PDP_SQLITE not available");
10+
}
611
?>
712
--FILE--
813
<?php
9-
1014
$pdo = new PDO("sqlite:/tmp/foo.db");
1115

1216
$attrs = array(PDO::ATTR_STATEMENT_CLASS, PDO::ATTR_STRINGIFY_FETCHES, PDO::NULL_TO_STRING);

ext/pdo/tests/pdo.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ function set_sql($name, $query)
77
$GLOBALS['SQL'][$name] = $query;
88
}
99
}
10-
1110
?>

ext/pdo/tests/pdo_017.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ try {
1616
}
1717

1818
if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
19-
if (false === PDOTest::detect_transactional_mysql_engine($db)) {
19+
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
20+
if (false === MySQLPDOTest::detect_transactional_mysql_engine($db)) {
2021
die('skip your mysql configuration does not support working transactions');
2122
}
2223
}
@@ -28,14 +29,15 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
2829
$db = PDOTest::factory();
2930

3031
if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
31-
$suf = ' Type=' . PDOTest::detect_transactional_mysql_engine($db);
32+
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
33+
$suf = ' ENGINE=' . MySQLPDOTest::detect_transactional_mysql_engine($db);
3234
} else {
3335
$suf = '';
3436
}
3537

3638
$db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10))'.$suf);
37-
$db->exec("INSERT INTO test VALUES(1, 'A')");
38-
$db->exec("INSERT INTO test VALUES(2, 'B')");
39+
$db->exec("INSERT INTO test VALUES(1, 'A')");
40+
$db->exec("INSERT INTO test VALUES(2, 'B')");
3941
$db->exec("INSERT INTO test VALUES(3, 'C')");
4042
$delete = $db->prepare('DELETE FROM test');
4143

0 commit comments

Comments
 (0)