From fff7ef9412689b543c85cce1ca4a77bffa898bf5 Mon Sep 17 00:00:00 2001 From: Ulf Wendel Date: Mon, 28 Sep 2009 10:39:42 +0000 Subject: [PATCH] Allow setting of default connection flags through the environment variable MYSQL_TEST_CONNECT_FLAGS --- ext/mysql/tests/connect.inc | 8 ++++++-- ext/mysql/tests/skipifconnectfailure.inc | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ext/mysql/tests/connect.inc b/ext/mysql/tests/connect.inc index 70017b9e26..86c0ee6748 100755 --- a/ext/mysql/tests/connect.inc +++ b/ext/mysql/tests/connect.inc @@ -20,14 +20,17 @@ if (!function_exists('sys_get_temp_dir')) { } /* wrapper to simplify test porting */ -function my_mysql_connect($host, $user, $passwd, $db, $port, $socket) { +function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL) { + global $connect_flags; + + $flags = ($flags === NULL) ? $connect_flags : $flags; if ($socket) $host = sprintf("%s:%s", $host, $socket); else if ($port) $host = sprintf("%s:%s", $host, $port); - if (!$link = mysql_connect($host, $user, $passwd, true)) { + if (!$link = mysql_connect($host, $user, $passwd, true, $flags)) { printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n", $host, $user, $passwd, mysql_errno(), mysql_error()); @@ -55,6 +58,7 @@ $db = getenv("MYSQL_TEST_DB") ? getenv("MYSQL_TEST_DB") : "test"; $engine = getenv("MYSQL_TEST_ENGINE") ? getenv("MYSQL_TEST_ENGINE") : "MyISAM"; $socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null; $skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true; +$connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0; /* Development setting: test experimal features and/or feature requests that never worked before? */ $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ? diff --git a/ext/mysql/tests/skipifconnectfailure.inc b/ext/mysql/tests/skipifconnectfailure.inc index e586a33f3b..a57c7dbd58 100755 --- a/ext/mysql/tests/skipifconnectfailure.inc +++ b/ext/mysql/tests/skipifconnectfailure.inc @@ -6,7 +6,7 @@ if ($skip_on_connect_failure) { else if ($port) $myhost = sprintf("%s:%s", $host, $port); - if (!$link = @mysql_connect($myhost, $user, $passwd, true)) + if (!$link = @mysql_connect($myhost, $user, $passwd, true, $connect_flags)) die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysql_errno(), mysql_error())); if (!@mysql_select_db($db, $link)) -- 2.40.0