summaryrefslogtreecommitdiff
path: root/ext/pdo_mysql
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo_mysql')
-rwxr-xr-xext/pdo_mysql/config.m430
-rw-r--r--ext/pdo_mysql/config.w323
-rwxr-xr-xext/pdo_mysql/mysql_driver.c32
-rw-r--r--ext/pdo_mysql/tests/bug_33689.phpt2
-rw-r--r--ext/pdo_mysql/tests/bug_37445.phpt21
-rw-r--r--ext/pdo_mysql/tests/last_insert_id.phpt36
-rw-r--r--ext/pdo_mysql/tests/pecl_bug_5200.phpt1
-rw-r--r--ext/pdo_mysql/tests/pecl_bug_5780.phpt1
-rw-r--r--ext/pdo_mysql/tests/pecl_bug_5802.phpt1
-rw-r--r--ext/pdo_mysql/tests/show_tables.phpt3
10 files changed, 113 insertions, 17 deletions
diff --git a/ext/pdo_mysql/config.m4 b/ext/pdo_mysql/config.m4
index 26172b644..b08a65f82 100755
--- a/ext/pdo_mysql/config.m4
+++ b/ext/pdo_mysql/config.m4
@@ -1,11 +1,11 @@
dnl
-dnl $Id: config.m4,v 1.25.2.7 2006/05/02 00:59:22 wez Exp $
+dnl $Id: config.m4,v 1.25.2.7.2.3 2006/08/14 20:11:31 tony2001 Exp $
dnl
if test "$PHP_PDO" != "no"; then
AC_DEFUN([PDO_MYSQL_LIB_CHK], [
- str="$PDO_MYSQL_DIR/$1/libmysqlclient.*"
+ str="$PDO_MYSQL_DIR/$1/libmysqlclient*"
for j in `echo $str`; do
if test -r $j; then
PDO_MYSQL_LIB_DIR=$MYSQL_DIR/$1
@@ -53,8 +53,14 @@ if test "$PHP_PDO_MYSQL" != "no"; then
if test "x$SED" = "x"; then
AC_PATH_PROG(SED, sed)
fi
+ if test "$enable_maintainer_zts" = "yes"; then
+ PDO_MYSQL_LIBNAME=mysqlclient_r
+ PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs_r | $SED -e "s/'//g"`
+ else
+ PDO_MYSQL_LIBNAME=mysqlclient
+ PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs | $SED -e "s/'//g"`
+ fi
PDO_MYSQL_INCLUDE=`$PDO_MYSQL_CONFIG --cflags | $SED -e "s/'//g"`
- PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs | $SED -e "s/'//g"`
PDO_MYSQL_SOCKET=`$PDO_MYSQL_CONFIG --socket`
elif test -z "$PDO_MYSQL_DIR"; then
AC_MSG_RESULT([not found])
@@ -66,7 +72,7 @@ if test "$PHP_PDO_MYSQL" != "no"; then
PDO_MYSQL_INC_DIR=$PDO_MYSQL_DIR/include/mysql
else
PDO_MYSQL_INC_DIR=$PDO_MYSQL_DIR/include
- fi
+ fi
if test -r $PDO_MYSQL_DIR/lib/mysql; then
PDO_MYSQL_LIB_DIR=$PDO_MYSQL_DIR/lib/mysql
else
@@ -80,24 +86,25 @@ if test "$PHP_PDO_MYSQL" != "no"; then
AC_MSG_ERROR([Unable to find your mysql installation])
fi
- PHP_ADD_LIBRARY_WITH_PATH(mysqlclient, $PDO_MYSQL_LIB_DIR, PDO_MYSQL_SHARED_LIBADD)
+ PHP_ADD_LIBRARY_WITH_PATH($PDO_MYSQL_LIBNAME, $PDO_MYSQL_LIB_DIR, PDO_MYSQL_SHARED_LIBADD)
PHP_ADD_INCLUDE($PDO_MYSQL_INC_DIR)
PDO_MYSQL_INCLUDE=-I$PDO_MYSQL_INC_DIR
fi
AC_DEFINE_UNQUOTED(PDO_MYSQL_UNIX_ADDR, "$PDO_MYSQL_SOCKET", [ ])
-
- _SAVE_LIBS=$LIBS
- LIBS="$LIBS $PDO_MYSQL_LIBS"
- PHP_CHECK_LIBRARY(mysqlclient, mysql_query,
+
+ PHP_CHECK_LIBRARY($PDO_MYSQL_LIBNAME, mysql_query,
[
+ PHP_EVAL_INCLINE($PDO_MYSQL_INCLUDE)
PHP_EVAL_LIBLINE($PDO_MYSQL_LIBS, PDO_MYSQL_SHARED_LIBADD)
],[
AC_MSG_ERROR([mysql_query missing!?])
],[
$PDO_MYSQL_LIBS
])
+ _SAVE_LIBS=$LIBS
+ LIBS="$LIBS $PDO_MYSQL_LIBS"
AC_CHECK_FUNCS([mysql_commit mysql_stmt_prepare mysql_next_result mysql_sqlstate])
LIBS=$_SAVE_LIBS
@@ -118,14 +125,13 @@ if test "$PHP_PDO_MYSQL" != "no"; then
AC_MSG_RESULT($pdo_inc_path)
])
- PHP_NEW_EXTENSION(pdo_mysql, pdo_mysql.c mysql_driver.c mysql_statement.c, $ext_shared,,-I$pdo_inc_path $PDO_MYSQL_INCLUDE)
+ PHP_NEW_EXTENSION(pdo_mysql, pdo_mysql.c mysql_driver.c mysql_statement.c, $ext_shared,,-I$pdo_inc_path)
ifdef([PHP_ADD_EXTENSION_DEP],
[
PHP_ADD_EXTENSION_DEP(pdo_mysql, pdo)
])
PDO_MYSQL_MODULE_TYPE=external
-
- PDO_MYSQL_SHARED_LIBADD=$PDO_MYSQL_LIBS
+
PHP_SUBST(PDO_MYSQL_SHARED_LIBADD)
PHP_SUBST_OLD(PDO_MYSQL_MODULE_TYPE)
fi
diff --git a/ext/pdo_mysql/config.w32 b/ext/pdo_mysql/config.w32
index 23ff7daa3..49ba874b5 100644
--- a/ext/pdo_mysql/config.w32
+++ b/ext/pdo_mysql/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32,v 1.4 2004/08/15 15:56:33 helly Exp $
+// $Id: config.w32,v 1.4.4.1 2006/05/11 21:43:59 edink Exp $
// vim:ft=javascript
ARG_WITH("pdo-mysql", "MySQL support for PDO", "no");
@@ -7,7 +7,6 @@ if (PHP_PDO_MYSQL != "no") {
if (CHECK_LIB("libmysql.lib", "pdo_mysql", PHP_PDO_MYSQL) &&
CHECK_HEADER_ADD_INCLUDE("mysql.h", "CFLAGS_PDO_MYSQL", PHP_PHP_BUILD + "\\include\\mysql;" + PHP_PDO_MYSQL)) {
EXTENSION("pdo_mysql", "pdo_mysql.c mysql_driver.c mysql_statement.c");
- ADD_FLAG('CFLAGS_PDO_MYSQL', "/I ..\\pecl");
} else {
WARNING("pdo_mysql not enabled; libraries and headers not found");
}
diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c
index 39a22f164..650b832d9 100755
--- a/ext/pdo_mysql/mysql_driver.c
+++ b/ext/pdo_mysql/mysql_driver.c
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mysql_driver.c,v 1.59.2.13 2006/04/09 08:11:31 wez Exp $ */
+/* $Id: mysql_driver.c,v 1.59.2.13.2.1 2006/10/02 22:09:49 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -379,6 +379,34 @@ static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value
return 1;
}
+static int pdo_mysql_check_liveness(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
+{
+ pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
+#if MYSQL_VERSION_ID <= 32230
+ void (*handler) (int);
+ unsigned int my_errno;
+#endif
+
+#if MYSQL_VERSION_ID > 32230
+ if (mysql_ping(H->server)) {
+ return FAILURE;
+ }
+#else /* no mysql_ping() */
+ handler=signal(SIGPIPE, SIG_IGN);
+ mysql_stat(H->server);
+ switch (mysql_errno(H->server)) {
+ case CR_SERVER_GONE_ERROR:
+ /* case CR_SERVER_LOST: I'm not sure this means the same as "gone" for us */
+ signal(SIGPIPE, handler);
+ return FAILURE;
+ default:
+ break;
+ }
+ signal(SIGPIPE, handler);
+#endif /* end mysql_ping() */
+ return SUCCESS;
+}
+/* }}} */
static struct pdo_dbh_methods mysql_methods = {
mysql_handle_closer,
@@ -392,7 +420,7 @@ static struct pdo_dbh_methods mysql_methods = {
pdo_mysql_last_insert_id,
pdo_mysql_fetch_error_func,
pdo_mysql_get_attribute,
- NULL /* check_liveness: TODO: ping */
+ pdo_mysql_check_liveness
};
#ifndef PDO_MYSQL_UNIX_ADDR
diff --git a/ext/pdo_mysql/tests/bug_33689.phpt b/ext/pdo_mysql/tests/bug_33689.phpt
index 609e3dce5..bd0a40904 100644
--- a/ext/pdo_mysql/tests/bug_33689.phpt
+++ b/ext/pdo_mysql/tests/bug_33689.phpt
@@ -5,10 +5,12 @@ PDO MySQL Bug #33689
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
PDOTest::skip();
?>
--FILE--
<?php
+require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
diff --git a/ext/pdo_mysql/tests/bug_37445.phpt b/ext/pdo_mysql/tests/bug_37445.phpt
new file mode 100644
index 000000000..c4d760083
--- /dev/null
+++ b/ext/pdo_mysql/tests/bug_37445.phpt
@@ -0,0 +1,21 @@
+--TEST--
+PDO MySQL Bug #37445 (Premature stmt object destruction)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
+require dirname(__FILE__) . '/config.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+
+$db->setAttribute(PDO :: ATTR_EMULATE_PREPARES, true);
+$stmt = $db->prepare("SELECT 1");
+$stmt->bindParam(':a', 'b');
+
+--EXPECTF--
+Fatal error: Cannot pass parameter 2 by reference in %s/bug_37445.php on line %d \ No newline at end of file
diff --git a/ext/pdo_mysql/tests/last_insert_id.phpt b/ext/pdo_mysql/tests/last_insert_id.phpt
new file mode 100644
index 000000000..d48ba1499
--- /dev/null
+++ b/ext/pdo_mysql/tests/last_insert_id.phpt
@@ -0,0 +1,36 @@
+--TEST--
+PDO MySQL auto_increment / last insert id
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
+require dirname(__FILE__) . '/config.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+
+print_r($db->query("CREATE TABLE test (id int auto_increment primary key, num int)"));
+
+print_r($db->query("INSERT INTO test (id, num) VALUES (23, 42)"));
+
+print_r($db->query("INSERT INTO test (num) VALUES (451)"));
+
+print_r($db->lastInsertId());
+--EXPECT--
+PDOStatement Object
+(
+ [queryString] => CREATE TABLE test (id int auto_increment primary key, num int)
+)
+PDOStatement Object
+(
+ [queryString] => INSERT INTO test (id, num) VALUES (23, 42)
+)
+PDOStatement Object
+(
+ [queryString] => INSERT INTO test (num) VALUES (451)
+)
+24 \ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pecl_bug_5200.phpt b/ext/pdo_mysql/tests/pecl_bug_5200.phpt
index 2dffd1141..639a640c8 100644
--- a/ext/pdo_mysql/tests/pecl_bug_5200.phpt
+++ b/ext/pdo_mysql/tests/pecl_bug_5200.phpt
@@ -5,6 +5,7 @@ PDO MySQL PECL Bug #5200
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
PDOTest::skip();
?>
--FILE--
diff --git a/ext/pdo_mysql/tests/pecl_bug_5780.phpt b/ext/pdo_mysql/tests/pecl_bug_5780.phpt
index 643597c01..ef94db13c 100644
--- a/ext/pdo_mysql/tests/pecl_bug_5780.phpt
+++ b/ext/pdo_mysql/tests/pecl_bug_5780.phpt
@@ -5,6 +5,7 @@ PDO MySQL PECL Bug #5780
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
PDOTest::skip();
?>
--FILE--
diff --git a/ext/pdo_mysql/tests/pecl_bug_5802.phpt b/ext/pdo_mysql/tests/pecl_bug_5802.phpt
index 70bd46163..f154dd13a 100644
--- a/ext/pdo_mysql/tests/pecl_bug_5802.phpt
+++ b/ext/pdo_mysql/tests/pecl_bug_5802.phpt
@@ -5,6 +5,7 @@ PDO MySQL PECL Bug #5802
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
PDOTest::skip();
?>
--FILE--
diff --git a/ext/pdo_mysql/tests/show_tables.phpt b/ext/pdo_mysql/tests/show_tables.phpt
index 90b07db32..97dfe686e 100644
--- a/ext/pdo_mysql/tests/show_tables.phpt
+++ b/ext/pdo_mysql/tests/show_tables.phpt
@@ -4,7 +4,8 @@ PDO MySQL SHOW TABLES
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
-require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
PDOTest::skip();
?>
--FILE--