svn: /pecl/mysqlnd_ms/trunk/ mysqlnd_ms.c mysqlnd_ms_config_json.c tests/connect.inc tests/mysqlnd_ms_no_master.phpt tests/mysqlnd_ms_no_slaves.phpt
tests/mysqlnd_ms_settings_ini_file_invalid.phpt
| From: | Andrey Hristov | Date: | Tue, 24 May 2011 12:10:21 +0000 |
| Subject: | svn: /pecl/mysqlnd_ms/trunk/ mysqlnd_ms.c mysqlnd_ms_config_json.c tests/connect.inc tests/mysqlnd_ms_no_master.phpt tests/mysqlnd_ms_no_slaves.phpt tests/mysqlnd_ms_settings_ini_file_invalid.phpt |
||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-15679@lists.php.net to get a copy of this message | ||
andrey Tue, 24 May 2011 12:10:21 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=311386
Log:
Fix tests
Changed paths:
U pecl/mysqlnd_ms/trunk/mysqlnd_ms.c
U pecl/mysqlnd_ms/trunk/mysqlnd_ms_config_json.c
U pecl/mysqlnd_ms/trunk/tests/connect.inc
U pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_no_master.phpt
U pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_no_slaves.phpt
U pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_settings_ini_file_invalid.phpt
Modified: pecl/mysqlnd_ms/trunk/mysqlnd_ms.c
===================================================================
--- pecl/mysqlnd_ms/trunk/mysqlnd_ms.c 2011-05-24 10:47:35 UTC (rev 311385)
+++ pecl/mysqlnd_ms/trunk/mysqlnd_ms.c 2011-05-24 12:10:21 UTC (rev 311386)
@@ -216,6 +216,16 @@
recursive = (TRUE == mysqlnd_ms_config_json_section_is_list(subsection TSRMLS_CC)
&&
TRUE == mysqlnd_ms_config_json_section_is_object_list(subsection TSRMLS_CC));
+ } else {
+ char error_buf[128];
+ failures++;
+ DBG_ERR_FMT("Cannot find %s section", subsection_name);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, MYSQLND_MS_ERROR_PREFIX " Cannot find %s section
in config", subsection_name);
+ if (conn) {
+ snprintf(error_buf, sizeof(error_buf), MYSQLND_MS_ERROR_PREFIX " Cannot find %s section in
config", subsection_name);
+ error_buf[sizeof(error_buf) - 1] = '\0';
+ SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, error_buf);
+ }
}
do {
char * socket_to_use = NULL;
@@ -552,7 +562,7 @@
MS_STAT_NON_LAZY_CONN_MASTER_FAILURE TSRMLS_CC);
if (FAIL == ret) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, MYSQLND_MS_ERROR_PREFIX " Error while
connecting to the master(s)");
- SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE,
+ SET_CLIENT_ERROR(conn->error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE,
MYSQLND_MS_ERROR_PREFIX " Error while connecting to the master(s)");
break;
}
@@ -564,9 +574,11 @@
MS_STAT_NON_LAZY_CONN_SLAVE_SUCCESS,
MS_STAT_NON_LAZY_CONN_SLAVE_FAILURE TSRMLS_CC);
if (FAIL == ret) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, MYSQLND_MS_ERROR_PREFIX " Error while
connecting to the slaves");
- SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE,
- MYSQLND_MS_ERROR_PREFIX " Error while connecting to the slaves");
+ if (!conn->error_info.error_no) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, MYSQLND_MS_ERROR_PREFIX " Error while
connecting to the slaves");
+ SET_CLIENT_ERROR(conn->error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE,
+ MYSQLND_MS_ERROR_PREFIX " Error while connecting to the slaves");
+ }
break;
}
Modified: pecl/mysqlnd_ms/trunk/mysqlnd_ms_config_json.c
===================================================================
--- pecl/mysqlnd_ms/trunk/mysqlnd_ms_config_json.c 2011-05-24 10:47:35 UTC (rev 311385)
+++ pecl/mysqlnd_ms/trunk/mysqlnd_ms_config_json.c 2011-05-24 12:10:21 UTC (rev 311386)
@@ -235,6 +235,8 @@
stream = php_stream_open_wrapper_ex(json_file_name, "rb", REPORT_ERRORS, NULL, NULL);
if (!stream) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, MYSQLND_MS_ERROR_PREFIX
+ " Failed to parse server list ini file %s", json_file_name);
break;
}
str_data_len = php_stream_copy_to_mem(stream, &str_data, PHP_STREAM_COPY_ALL, 0);
Modified: pecl/mysqlnd_ms/trunk/tests/connect.inc
===================================================================
--- pecl/mysqlnd_ms/trunk/tests/connect.inc 2011-05-24 10:47:35 UTC (rev 311385)
+++ pecl/mysqlnd_ms/trunk/tests/connect.inc 2011-05-24 12:10:21 UTC (rev 311386)
@@ -282,12 +282,32 @@
$json[$application] = array();
if (isset($config['master'])) {
foreach ($config['master'] as $host) {
- $json[$application]['master'][] = (string)$host;
+ $host_config = array();
+ list($real_host, $port) = explode(':', $host);
+ $host_config['host'] = $real_host;
+ if ($port) {
+ if (!is_numeric($port)) {
+ $host_config['socket'] = $port;
+ } else {
+ $host_config['port'] = $port;
+ }
+ }
+ $json[$application]['master'][] = $host_config;
}
}
if (isset($config['slave'])) {
foreach ($config['slave'] as $host) {
- $json[$application]['slave'][] = (string)$host;
+ $host_config = array();
+ list($real_host, $port) = explode(':', $host);
+ $host_config['host'] = $real_host;
+ if ($port) {
+ if (!is_numeric($port)) {
+ $host_config['socket'] = $port;
+ } else {
+ $host_config['port'] = $port;
+ }
+ }
+ $json[$application]['slave'][] = $host_config;
}
}
if (isset($config['pick'])) {
Modified: pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_no_master.phpt
===================================================================
--- pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_no_master.phpt 2011-05-24 10:47:35 UTC (rev 311385)
+++ pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_no_master.phpt 2011-05-24 12:10:21 UTC (rev 311386)
@@ -33,12 +33,14 @@
?>
--CLEAN--
<?php
- if (!unlink("test_mysqlnd_ms_no_master.ini"))
- printf("[clean] Cannot unlink ini file 'test_mysqlnd_ms_no_master.ini'.\n");
+// if (!unlink("test_mysqlnd_ms_no_master.ini"))
+// printf("[clean] Cannot unlink ini file
'test_mysqlnd_ms_no_master.ini'.\n");
?>
--EXPECTF--
Warning: mysqli_real_connect(): (mysqlnd_ms) Cannot find master section in config in %s on line %d
-Warning: mysqli_real_connect(): (HY000/2000): (mysqlnd_ms) Cannot find master section in config in
%s on line %d
-[001] [2000] (mysqlnd_ms) Cannot find master section in config
+Warning: mysqli_real_connect(): (mysqlnd_ms) Error while connecting to the master(s) in %s on line
%d
+
+Warning: mysqli_real_connect(): (HY000/2002): (mysqlnd_ms) Error while connecting to the master(s)
in %s on line %d
+[001] [2002] (mysqlnd_ms) Error while connecting to the master(s)
done!
\ No newline at end of file
Modified: pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_no_slaves.phpt
===================================================================
--- pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_no_slaves.phpt 2011-05-24 10:47:35 UTC (rev 311385)
+++ pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_no_slaves.phpt 2011-05-24 12:10:21 UTC (rev 311386)
@@ -40,8 +40,10 @@
printf("[clean] Cannot unlink ini file 'test_mysqlnd_ms_no_slaves.ini'.\n");
?>
--EXPECTF--
-Warning: mysqli_real_connect(): (mysqlnd_ms) Cannot find slaves section in config in %s on line %d
+Warning: mysqli_real_connect(): (mysqlnd_ms) Cannot find slave section in config in %s on line %d
-Warning: mysqli_real_connect(): (HY000/2000): (mysqlnd_ms) Cannot find slaves section in config in
%s on line %d
-[001] [2000] (mysqlnd_ms) Cannot find slaves section in config
+Warning: mysqli_real_connect(): (mysqlnd_ms) Error while connecting to the slaves in %s on line %d
+
+Warning: mysqli_real_connect(): (HY000/2002): (mysqlnd_ms) Error while connecting to the slaves in
%s on line %d
+[001] [2002] (mysqlnd_ms) Error while connecting to the slaves
done!
\ No newline at end of file
Modified: pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_settings_ini_file_invalid.phpt
===================================================================
--- pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_settings_ini_file_invalid.phpt 2011-05-24 10:47:35 UTC
(rev 311385)
+++ pecl/mysqlnd_ms/trunk/tests/mysqlnd_ms_settings_ini_file_invalid.phpt 2011-05-24 12:10:21 UTC
(rev 311386)
@@ -6,8 +6,9 @@
--FILE--
<?php
echo "DONE";
+?>
--EXPECTF--
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
-Warning: Unknown: (mysqlnd_ms) Failed to parse server list ini file
a_file_by_this_name_better_not_exists.ini (current working dir: %s) in Unknown on line 0
+Warning: Unknown: (mysqlnd_ms) Failed to parse server list ini file
a_file_by_this_name_better_not_exists.ini in Unknown on line 0
DONE