]> granicus.if.org Git - php/commitdiff
svn merge mysql-related fixes
authorJohannes Schlüter <johannes@php.net>
Wed, 14 Oct 2009 13:51:25 +0000 (13:51 +0000)
committerJohannes Schlüter <johannes@php.net>
Wed, 14 Oct 2009 13:51:25 +0000 (13:51 +0000)
# I hope svn adds some more info in the history/commit mail

253 files changed:
ext/mysql/php_mysql.c
ext/mysql/tests/bug48754.phpt [new file with mode: 0644]
ext/mysql/tests/connect.inc
ext/mysql/tests/mysql_connect.phpt
ext/mysql/tests/mysql_fetch_array.phpt
ext/mysql/tests/mysql_fetch_field.phpt
ext/mysql/tests/mysql_list_fields.phpt
ext/mysql/tests/mysql_mysqlnd_read_timeout_long.phpt [new file with mode: 0644]
ext/mysql/tests/mysql_pconn_max_links.phpt
ext/mysql/tests/skipifconnectfailure.inc
ext/mysqli/mysqli.c
ext/mysqli/mysqli_api.c
ext/mysqli/mysqli_nonapi.c
ext/mysqli/php_mysqli_structs.h
ext/mysqli/tests/001.phpt
ext/mysqli/tests/002.phpt
ext/mysqli/tests/003.phpt
ext/mysqli/tests/004.phpt
ext/mysqli/tests/005.phpt
ext/mysqli/tests/006.phpt
ext/mysqli/tests/007.phpt
ext/mysqli/tests/008.phpt
ext/mysqli/tests/009.phpt
ext/mysqli/tests/010.phpt
ext/mysqli/tests/011.phpt
ext/mysqli/tests/012.phpt
ext/mysqli/tests/013.phpt
ext/mysqli/tests/014.phpt
ext/mysqli/tests/015.phpt
ext/mysqli/tests/016.phpt
ext/mysqli/tests/017.phpt
ext/mysqli/tests/018.phpt
ext/mysqli/tests/019.phpt
ext/mysqli/tests/020.phpt
ext/mysqli/tests/021.phpt
ext/mysqli/tests/022.phpt
ext/mysqli/tests/023.phpt
ext/mysqli/tests/024.phpt
ext/mysqli/tests/025.phpt
ext/mysqli/tests/026.phpt
ext/mysqli/tests/027.phpt
ext/mysqli/tests/028.phpt
ext/mysqli/tests/029.phpt
ext/mysqli/tests/030.phpt
ext/mysqli/tests/031.phpt
ext/mysqli/tests/032.phpt
ext/mysqli/tests/033.phpt
ext/mysqli/tests/034.phpt
ext/mysqli/tests/035.phpt
ext/mysqli/tests/036.phpt
ext/mysqli/tests/037.phpt
ext/mysqli/tests/038.phpt
ext/mysqli/tests/039.phpt
ext/mysqli/tests/040.phpt
ext/mysqli/tests/041.phpt
ext/mysqli/tests/042.phpt
ext/mysqli/tests/043.phpt
ext/mysqli/tests/044.phpt
ext/mysqli/tests/045.phpt
ext/mysqli/tests/046.phpt
ext/mysqli/tests/047.phpt
ext/mysqli/tests/048.phpt
ext/mysqli/tests/049.phpt
ext/mysqli/tests/050.phpt
ext/mysqli/tests/051.phpt
ext/mysqli/tests/052.phpt
ext/mysqli/tests/053.phpt
ext/mysqli/tests/054.phpt
ext/mysqli/tests/055.phpt
ext/mysqli/tests/057.phpt
ext/mysqli/tests/058.phpt
ext/mysqli/tests/059.phpt
ext/mysqli/tests/060.phpt
ext/mysqli/tests/061.phpt
ext/mysqli/tests/062.phpt
ext/mysqli/tests/063.phpt
ext/mysqli/tests/064.phpt
ext/mysqli/tests/065.phpt
ext/mysqli/tests/066.phpt
ext/mysqli/tests/067.phpt
ext/mysqli/tests/069.phpt
ext/mysqli/tests/070.phpt
ext/mysqli/tests/071.phpt
ext/mysqli/tests/072.phpt
ext/mysqli/tests/074.phpt
ext/mysqli/tests/bug31668.phpt
ext/mysqli/tests/bug32405.phpt
ext/mysqli/tests/bug33090.phpt
ext/mysqli/tests/bug34785.phpt
ext/mysqli/tests/bug34810.phpt
ext/mysqli/tests/bug35103.phpt
ext/mysqli/tests/bug35517.phpt
ext/mysqli/tests/bug35759.phpt
ext/mysqli/tests/bug36420.phpt
ext/mysqli/tests/bug36745.phpt
ext/mysqli/tests/bug36802.phpt
ext/mysqli/tests/bug36949.phpt
ext/mysqli/tests/bug37090.phpt
ext/mysqli/tests/bug38710.phpt
ext/mysqli/tests/bug42378.phpt
ext/mysqli/tests/bug42548.phpt
ext/mysqli/tests/bug44897.phpt
ext/mysqli/tests/bug45019.phpt
ext/mysqli/tests/bug45289.phpt
ext/mysqli/tests/bug46614.phpt
ext/mysqli/tests/bug47050.phpt
ext/mysqli/tests/bug48909.phpt [new file with mode: 0644]
ext/mysqli/tests/bug49027.phpt
ext/mysqli/tests/bug49442.phpt [new file with mode: 0644]
ext/mysqli/tests/clean_table.inc
ext/mysqli/tests/connect.inc
ext/mysqli/tests/mysqli_affected_rows.phpt
ext/mysqli/tests/mysqli_affected_rows_oo.phpt
ext/mysqli/tests/mysqli_autocommit.phpt
ext/mysqli/tests/mysqli_autocommit_oo.phpt
ext/mysqli/tests/mysqli_change_user.phpt
ext/mysqli/tests/mysqli_change_user_get_lock.phpt
ext/mysqli/tests/mysqli_change_user_insert_id.phpt
ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt
ext/mysqli/tests/mysqli_change_user_oo.phpt
ext/mysqli/tests/mysqli_change_user_prepared_statements.phpt
ext/mysqli/tests/mysqli_change_user_rollback.phpt
ext/mysqli/tests/mysqli_change_user_set_names.phpt
ext/mysqli/tests/mysqli_character_set.phpt
ext/mysqli/tests/mysqli_character_set_name.phpt
ext/mysqli/tests/mysqli_character_set_name_oo.phpt
ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt
ext/mysqli/tests/mysqli_class_mysqli_interface.phpt
ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt
ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt
ext/mysqli/tests/mysqli_class_mysqli_warning.phpt
ext/mysqli/tests/mysqli_close.phpt
ext/mysqli/tests/mysqli_close_oo.phpt
ext/mysqli/tests/mysqli_commit.phpt
ext/mysqli/tests/mysqli_commit_oo.phpt
ext/mysqli/tests/mysqli_connect_errno.phpt
ext/mysqli/tests/mysqli_connect_error.phpt
ext/mysqli/tests/mysqli_connect_twice.phpt
ext/mysqli/tests/mysqli_disable_reads_from_master.phpt
ext/mysqli/tests/mysqli_driver.phpt
ext/mysqli/tests/mysqli_dump_debug_info.phpt
ext/mysqli/tests/mysqli_enable_reads_from_master.phpt
ext/mysqli/tests/mysqli_errno.phpt
ext/mysqli/tests/mysqli_error.phpt
ext/mysqli/tests/mysqli_fetch_all_oo.phpt
ext/mysqli/tests/mysqli_fetch_array_large.phpt [new file with mode: 0644]
ext/mysqli/tests/mysqli_fetch_array_oo.phpt
ext/mysqli/tests/mysqli_fetch_assoc_bit.phpt
ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt
ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt
ext/mysqli/tests/mysqli_fetch_field_flags.phpt
ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt
ext/mysqli/tests/mysqli_fetch_object_oo.phpt
ext/mysqli/tests/mysqli_fork.phpt
ext/mysqli/tests/mysqli_get_cache_stats_off.phpt
ext/mysqli/tests/mysqli_get_client_stats.phpt
ext/mysqli/tests/mysqli_get_connection_stats.phpt
ext/mysqli/tests/mysqli_get_connection_stats_off.phpt
ext/mysqli/tests/mysqli_get_warnings.phpt
ext/mysqli/tests/mysqli_info.phpt
ext/mysqli/tests/mysqli_insert_id_variation.phpt
ext/mysqli/tests/mysqli_kill.phpt
ext/mysqli/tests/mysqli_max_links.phpt
ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt [new file with mode: 0644]
ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt [new file with mode: 0644]
ext/mysqli/tests/mysqli_mysqlnd_read_timeout_zero.phpt [new file with mode: 0644]
ext/mysqli/tests/mysqli_no_reconnect.phpt
ext/mysqli/tests/mysqli_options.phpt
ext/mysqli/tests/mysqli_options_init_command.phpt
ext/mysqli/tests/mysqli_options_openbasedir.phpt
ext/mysqli/tests/mysqli_pconn_disabled.phpt
ext/mysqli/tests/mysqli_pconn_kill.phpt
ext/mysqli/tests/mysqli_pconn_limits.phpt
ext/mysqli/tests/mysqli_pconn_max_links.phpt
ext/mysqli/tests/mysqli_pconn_reuse.phpt
ext/mysqli/tests/mysqli_pconnect.phpt
ext/mysqli/tests/mysqli_ping.phpt
ext/mysqli/tests/mysqli_poll.phpt
ext/mysqli/tests/mysqli_poll_kill.phpt
ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt
ext/mysqli/tests/mysqli_poll_reference.phpt
ext/mysqli/tests/mysqli_prepare.phpt
ext/mysqli/tests/mysqli_prepare_no_object.phpt
ext/mysqli/tests/mysqli_ps_select_union.phpt [new file with mode: 0644]
ext/mysqli/tests/mysqli_query.phpt
ext/mysqli/tests/mysqli_query_local_infile_large.phpt
ext/mysqli/tests/mysqli_query_stored_proc.phpt
ext/mysqli/tests/mysqli_real_connect.phpt
ext/mysqli/tests/mysqli_reconnect.phpt
ext/mysqli/tests/mysqli_report.phpt
ext/mysqli/tests/mysqli_report_wo_ps.phpt
ext/mysqli/tests/mysqli_result_references.phpt
ext/mysqli/tests/mysqli_result_references_mysqlnd.phpt
ext/mysqli/tests/mysqli_result_unclonable.phpt
ext/mysqli/tests/mysqli_rollback.phpt
ext/mysqli/tests/mysqli_select_db.phpt
ext/mysqli/tests/mysqli_send_query.phpt
ext/mysqli/tests/mysqli_set_charset.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt
ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt
ext/mysqli/tests/mysqli_set_opt.phpt
ext/mysqli/tests/mysqli_ssl_set.phpt
ext/mysqli/tests/mysqli_stmt_affected_rows.phpt
ext/mysqli/tests/mysqli_stmt_attr_set.phpt
ext/mysqli/tests/mysqli_stmt_bind_param_references.phpt
ext/mysqli/tests/mysqli_stmt_bind_result.phpt
ext/mysqli/tests/mysqli_stmt_bind_result_bit.phpt
ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt
ext/mysqli/tests/mysqli_stmt_datatype_change.phpt
ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt
ext/mysqli/tests/mysqli_stmt_fetch_bit.phpt
ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt [new file with mode: 0644]
ext/mysqli/tests/mysqli_stmt_get_result_bit.phpt
ext/mysqli/tests/mysqli_stmt_get_result_geom.phpt [new file with mode: 0644]
ext/mysqli/tests/mysqli_stmt_get_result_types.phpt
ext/mysqli/tests/mysqli_stmt_store_result.phpt
ext/mysqli/tests/mysqli_stmt_unclonable.phpt
ext/mysqli/tests/mysqli_unclonable.phpt
ext/mysqli/tests/mysqli_warning_unclonable.phpt
ext/mysqli/tests/skipifconnectfailure.inc
ext/mysqli/tests/table.inc
ext/mysqlnd/config9.m4
ext/mysqlnd/mysqlnd.c
ext/mysqlnd/mysqlnd.h
ext/mysqlnd/mysqlnd_enum_n_def.h
ext/mysqlnd/mysqlnd_palloc.c
ext/mysqlnd/mysqlnd_portability.h
ext/mysqlnd/mysqlnd_priv.h
ext/mysqlnd/mysqlnd_ps.c
ext/mysqlnd/mysqlnd_ps_codec.c
ext/mysqlnd/mysqlnd_result.c
ext/mysqlnd/mysqlnd_result_meta.c
ext/mysqlnd/mysqlnd_structs.h
ext/mysqlnd/mysqlnd_wireprotocol.c
ext/mysqlnd/mysqlnd_wireprotocol.h
ext/mysqlnd/php_mysqlnd.c
ext/pdo_mysql/mysql_driver.c
ext/pdo_mysql/pdo_mysql.c
ext/pdo_mysql/php_pdo_mysql_int.h
ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt

index 53c6edd637c5e472889375f7415b5e673b79e830..694640f59cb6b444c7276c9449bdae9d061ff8f6 100644 (file)
@@ -971,6 +971,7 @@ PHP_FUNCTION(mysql_pconnect)
    Close a MySQL connection */
 PHP_FUNCTION(mysql_close)
 {
+       int resource_id;
        zval *mysql_link=NULL;
        php_mysql_conn *mysql;
 
@@ -984,24 +985,25 @@ PHP_FUNCTION(mysql_close)
                ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, NULL, MySG(default_link), "MySQL-Link", le_link, le_plink);
        }
 
+       resource_id = mysql_link ? Z_RESVAL_P(mysql_link) : MySG(default_link);
+       PHPMY_UNBUFFERED_QUERY_CHECK();
 #ifdef MYSQL_USE_MYSQLND
        {
                int tmp;
-               if ((mysql = zend_list_find(Z_RESVAL_P(mysql_link), &tmp)) && tmp == le_plink) {
+               if ((mysql = zend_list_find(resource_id, &tmp)) && tmp == le_plink) {
                        mysqlnd_end_psession(mysql->conn);
                }
        }
 #endif
-       if (mysql_link) { /* explicit resource number */
-               PHPMY_UNBUFFERED_QUERY_CHECK();
-               zend_list_delete(Z_RESVAL_P(mysql_link));
-       }
+       zend_list_delete(resource_id);
 
        if (!mysql_link 
                || (mysql_link && Z_RESVAL_P(mysql_link)==MySG(default_link))) {
-               PHPMY_UNBUFFERED_QUERY_CHECK();
-               zend_list_delete(MySG(default_link));
                MySG(default_link) = -1;
+               if (mysql_link) {
+                       /* on an explicit close of the default connection it had a refcount of 2 so we need one more call */
+                       zend_list_delete(resource_id);
+               }
        }
 
        RETURN_TRUE;
@@ -1970,7 +1972,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
                }
        }
 
-       if ((result_type & MYSQL_BOTH) == 0) {
+       if (result_type & ~MYSQL_BOTH) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH");
                result_type = MYSQL_BOTH;
        }
@@ -2147,6 +2149,11 @@ PHP_FUNCTION(mysql_fetch_array)
        }
        ZEND_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, -1, "MySQL result", le_result);
 
+       if (mode & ~MYSQL_BOTH) {
+                php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH");
+                mode = MYSQL_BOTH;
+        }
+
        mysqlnd_fetch_into(result, mode, return_value, MYSQLND_MYSQL);
 #endif
 }
diff --git a/ext/mysql/tests/bug48754.phpt b/ext/mysql/tests/bug48754.phpt
new file mode 100644 (file)
index 0000000..fb322f4
--- /dev/null
@@ -0,0 +1,92 @@
+--TEST--
+Bug #48754 (mysql_close() crash php when no handle specified)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+require_once('connect.inc');
+
+function my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket) {
+       if ($socket)
+               $host = sprintf("%s:%s", $host, $socket);
+       else if ($port)
+               $host = sprintf("%s:%s", $host, $port);
+
+       if (!$link = mysql_pconnect($host, $user, $passwd, true)) {
+               printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n",
+                       $host, $user, $passwd,
+                       mysql_errno(), mysql_error());
+               return false;
+       }
+       return $link;
+}
+
+echo "Explicit connection on close\n";
+$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket);
+$link1_thread_id = mysql_thread_id($link);
+$default1_thread_id = mysql_thread_id();
+echo 'Expect same thread id for $link and default conn: ';
+var_dump($link1_thread_id == $default1_thread_id);
+var_dump($link);
+mysql_close($link);
+var_dump($link);
+
+// we sohuld have no default link anymore
+mysql_close();
+
+echo "\nClosing default link\n";
+$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket);
+$link2_thread_id = mysql_thread_id($link);
+$default2_thread_id = mysql_thread_id();
+echo 'Expect same thread id for $link and default conn but not the previous: ';
+var_dump($link1_thread_id == $default1_thread_id && $link1_thread_id != $link2_thread_id);
+var_dump($link);
+mysql_close();
+var_dump($link);
+mysql_close($link);
+var_dump($link);
+
+echo "\nExplicit resource and pconnect\n";
+$link = my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket);
+var_dump($link);
+mysql_close($link);
+var_dump($link);
+
+// we sohuld have no default link
+mysql_close();
+
+echo "\nDefault link and pconnect\n";
+$link = my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket);
+var_dump($link);
+mysql_close();
+var_dump($link);
+mysql_close($link);
+var_dump($link);
+?>
+--EXPECTF--
+Explicit connection on close
+Expect same thread id for $link and default conn: bool(true)
+resource(%d) of type (mysql link)
+resource(%d) of type (Unknown)
+
+Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d
+
+Closing default link
+Expect same thread id for $link and default conn but not the previous: bool(true)
+resource(%d) of type (mysql link)
+resource(%d) of type (mysql link)
+resource(%d) of type (Unknown)
+
+Explicit resource and pconnect
+resource(%d) of type (mysql link persistent)
+resource(%d) of type (Unknown)
+
+Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d
+
+Default link and pconnect
+resource(%d) of type (mysql link persistent)
+resource(%d) of type (mysql link persistent)
+resource(%d) of type (Unknown)
index 70017b9e2695abf71682982efe096f7cadac9b06..86c0ee674852d5e0673aa579a63e288d729b0666 100755 (executable)
@@ -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))) ?
index acb632e009aabd5ca87aaa2776490b33e64d366d..be094cce204c6a3f4a1c0d156afb7673111fd1ab 100644 (file)
@@ -20,17 +20,23 @@ if (!$link = mysql_connect($myhost, $user, $passwd, true))
 
 mysql_close($link);
 
+if (!$link = mysql_connect($myhost, $user, $passwd, true))
+       printf("[003] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+               $host, $myhost, $user, $db, $port, $socket);
+
+mysql_close();
+
 if ($link = mysql_connect($myhost, $user . 'unknown_really', $passwd . 'non_empty', true))
-       printf("[003] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
+       printf("[004] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
                $host, $myhost, $user . 'unknown_really', $db, $port, $socket);
 
 if (false !== $link)
-printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
+printf("[005] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
 
 // Run the following tests without an anoynmous MySQL user and use a password for the test user!
 ini_set('mysql.default_socket', $socket);
 if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
-       printf("[005] Usage of mysql.default_socket failed\n");
+       printf("[006] Usage of mysql.default_socket failed\n");
 } else {
        mysql_close($link);
 }
@@ -39,42 +45,49 @@ if (!ini_get('sql.safe_mode')) {
 
        ini_set('mysql.default_port', $port);
        if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
-               printf("[006] Usage of mysql.default_port failed\n");
+               printf("[007] Usage of mysql.default_port failed\n");
        } else {
                mysql_close($link);
        }
 
        ini_set('mysql.default_password', $passwd);
        if (!is_resource($link = mysql_connect($myhost, $user))) {
-               printf("[007] Usage of mysql.default_password failed\n");
+               printf("[008] Usage of mysql.default_password failed\n");
        } else {
                mysql_close($link);
        }
        ini_set('mysql.default_user', $user);
        if (!is_resource($link = mysql_connect($myhost))) {
-               printf("[008] Usage of mysql.default_user failed\n");
+               printf("[009] Usage of mysql.default_user failed\n");
        } else {
                mysql_close($link);
        }
 
        ini_set('mysql.default_host', $myhost);
        if (!is_resource($link = mysql_connect())) {
-               printf("[009] Usage of mysql.default_host failed\n") ;
+               printf("[010] Usage of mysql.default_host failed\n") ;
        } else {
                mysql_close($link);
        }
 
+       if (!is_resource($link = mysql_connect()) || !is_resource($link2 = mysql_connect())) {
+               printf("[011] Usage of mysql.default_host failed\n") ;
+       } else {
+               mysql_close();
+               mysql_close($link2);
+       }
+
        if (!stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'netware')) {
                ini_set('mysql.default_port', -1);
                if (putenv(sprintf('MYSQL_TCP_PORT=%d', $port))) {
                        if (!is_resource($link = mysql_connect())) {
-                               printf("[010] Usage of env MYSQL_TCP_PORT failed\n") ;
+                               printf("[012] Usage of env MYSQL_TCP_PORT failed\n") ;
                        } else {
                        mysql_close($link);
                }
                } else if (putenv(sprintf('MYSQL_TCP_PORT=%d', $port + 1))) {
                        if (!is_resource($link = mysql_connect())) {
-                               printf("[011] Usage of env MYSQL_TCP_PORT=%d should have failed\n", $port + 1) ;
+                               printf("[013] Usage of env MYSQL_TCP_PORT=%d should have failed\n", $port + 1) ;
                                mysql_close($link);
                }
                }
index 924c71750195fdf89f910ae59528c3ce975d5bcd..635e6d1097f8387a4f23609f172e2aeb63e292f3 100644 (file)
@@ -56,7 +56,7 @@ exit(1);
 do {
        $illegal_mode = mt_rand(0, 10000);
 } while (in_array($illegal_mode, array(MYSQL_ASSOC, MYSQL_NUM, MYSQL_BOTH)));
-$tmp = @mysql_fetch_array($res, $illegal_mode);
+$tmp = mysql_fetch_array($res, $illegal_mode);
 if (!is_array($tmp))
        printf("[013] Expecting array, got %s/%s. [%d] %s\n",
                gettype($tmp), $tmp, mysql_errno($link), mysql_error($link));
@@ -355,5 +355,7 @@ array(11) {
   %unicode|string%(1) "1"
 }
 
+Warning: mysql_fetch_array(): The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH in %s on line %d
+
 Warning: mysql_fetch_array(): %d is not a valid MySQL result resource in %s on line %d
 done!
index f9767c82b7fa923f01d76308fd8f9e0efce55985..65c44edc5e1a93509eb94b3fbc4dfc413c08cca3 100644 (file)
@@ -124,9 +124,16 @@ require_once('skipifconnectfailure.inc');
                printf("[017] [%d] %s\n", mysql_errno($link), mysql_error($link));
        }
        $res = mysql_list_fields($db, 'test');
-       while ($tmp = mysql_fetch_field($res))
-               if ($tmp->name == 'id')
+       $found = false;
+       while ($tmp = mysql_fetch_field($res)) {
+               if ($tmp->name == 'id') {
+                       printf("Fetch field from mysql_list_fields result set.\n");
+                       $found = true;
                        var_dump($tmp);
+               }
+       }
+       if (!$found)
+               printf("[018] mysqli_list_fields result set processing has failed.\n");
 
        mysql_free_result($res);
 
@@ -227,6 +234,7 @@ object(stdClass)#%d (13) {
   [%u|b%"zerofill"]=>
   int(0)
 }
+Fetch field from mysql_list_fields result set.
 object(stdClass)#%d (13) {
   [%u|b%"name"]=>
   %unicode|string%(2) "id"
index 7d1d4f2ddeeb6f3ab0f2738fa2dedbab5d112225..e0b3fd5e39368a1ecd0225e70b67be8b22a13482 100644 (file)
@@ -12,29 +12,36 @@ require_once 'connect.inc';
 $tmp    = NULL;
 $link   = NULL;
 
-// This will implicitly try to connect, and we don't want it
-//if (false !== ($tmp = mysql_list_fields($link, $link)))
-//     printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
-
 require 'table.inc';
 
 if (!$res = mysql_list_fields($db, 'test', $link))
        printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
 
 if (2 !== ($num = mysql_num_fields($res)))
-       printf("[004] Expecting two fields, got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link));
+       printf("[004] Expecting two fields from 'test', got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link));
 
 mysql_free_result($res);
 
-if (!mysql_query("DROP TABLE IF EXISTS test2", $link) ||
-       !mysql_query("CREATE TABLE test2(id INT)", $link))
+if (!mysql_query("DROP TABLE IF EXISTS test2", $link))
        printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
 
-if (!$res = mysql_list_fields($db, 'test', $link))
+if (!$res = @mysql_list_fields($db, 'test2', $link))
        printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
 
+if (!$res = mysql_list_fields($db, 'test', $link))
+       printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
 if (2 !== ($num = mysql_num_fields($res)))
-       printf("[007] Expecting 3 fields from test and test2, got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link));
+       printf("[008] Expecting 2 fields from 'test', got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link));
+
+var_dump(mysql_fetch_assoc($res));
+for ($field_offset = 0; $field_offset < mysql_num_fields($res); $field_offset++) {
+       printf("Field Offset %d\n", $field_offset);
+       printf("mysql_field_flags(): %s\n", mysql_field_flags($res, $field_offset));
+       printf("mysql_field_len(): %s\n", mysql_field_len($res, $field_offset));
+       printf("mysql_field_name(): %s\n", mysql_field_name($res, $field_offset));
+       printf("mysql_field_type(): %s\n", mysql_field_type($res, $field_offset));
+}
 
 mysql_free_result($res);
 mysql_close($link);
@@ -57,4 +64,16 @@ if (!mysql_query("DROP TABLE IF EXISTS test2", $link))
 mysql_close($link);
 ?>
 --EXPECTF--
+[006] [%d] %s
+bool(false)
+Field Offset 0
+mysql_field_flags()%s
+mysql_field_len(): 11
+mysql_field_name(): id
+mysql_field_type(): int
+Field Offset 1
+mysql_field_flags()%s
+mysql_field_len(): 1
+mysql_field_name(): label
+mysql_field_type(): string
 done!
diff --git a/ext/mysql/tests/mysql_mysqlnd_read_timeout_long.phpt b/ext/mysql/tests/mysql_mysqlnd_read_timeout_long.phpt
new file mode 100644 (file)
index 0000000..d54cb50
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+mysqlnd.net_read_timeout > default_socket_timeout
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+require_once('connect.inc');
+?>
+--INI--
+default_socket_timeout=1
+mysqlnd.net_read_timeout=12
+max_execution_time=12
+--FILE--
+<?php
+       set_time_limit(12);
+       include ("connect.inc");
+
+       if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {
+               printf("[001] Connect failed, [%d] %s\n", mysql_errno(), mysqlerror());
+       }
+
+       if (!$res = mysql_query("SELECT SLEEP(6)", $link))
+               printf("[002] [%d] %s\n",  mysql_errno($link), mysql_error($link));
+
+       var_dump(mysql_fetch_assoc($res));
+
+       mysql_free_result($res);
+       mysql_close($link);
+
+       print "done!";
+?>
+--EXPECTF--
+array(1) {
+  [%u|b%"SLEEP(6)"]=>
+  %unicode|string%(1) "0"
+}
+done!
\ No newline at end of file
index f9776d57976f1f53407769682957f1faba9d9fa3..1d39e98b429f64a024e392286428b12ece02cf11 100644 (file)
@@ -18,26 +18,35 @@ Persistent connections and mysql.max_persistent
        if (!mysql_select_db($db, $link))
                die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link)));
 
+       if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link))
+               die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link)));
+
+       $row = mysql_fetch_assoc($res);
+       mysql_free_result($res);
+       $host = substr($row['_user'], strrpos($row['_user'], "@") + 1, strlen($row['_user']));
+
        mysql_query('DROP USER pcontest', $link);
-       if (!mysql_query('CREATE USER pcontest IDENTIFIED BY "pcontest"', $link)) {
+       mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
+       if (!mysql_query(sprintf('CREATE USER pcontest@"%s" IDENTIFIED BY "pcontest"', mysql_real_escape_string($host, $link)), $link)) {
                printf("skip Cannot create second DB user [%d] %s", mysql_errno($link), mysql_error($link));
                mysql_close($link);
                die();
        }
 
        // we might be able to specify the host using CURRENT_USER(), but...
-       if (!mysql_query(sprintf("GRANT SELECT ON TABLE %s.test TO pcontest@'%%'", $db), $link)) {
+       if (!mysql_query(sprintf('GRANT SELECT ON TABLE %s.test TO pcontest@"%s"', $db, mysql_real_escape_string($host, $link)), $link)) {
                printf("skip Cannot GRANT SELECT to second DB user [%d] %s", mysql_errno($link), mysql_error($link));
-               mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link);
-               mysql_query('DROP USER pcontest', $link);
+               mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
+               mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
                mysql_close($link);
                die();
        }
+
        mysql_close($link);
 ?>
 --INI--
-mysql.max_links=2
-mysql.max_persistent=1
+mysql.max_links=3
+mysql.max_persistent=2
 mysql.allow_persistent=1
 --FILE--
 <?php
@@ -76,18 +85,26 @@ mysql.allow_persistent=1
        var_dump($row);
 
        // change the password for the second DB user and kill the persistent connection
-       if (!mysql_query('SET PASSWORD FOR pcontest = PASSWORD("newpass")', $link))
-               printf("[006] Cannot change PW of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link));
+       if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link))
+               printf("[006] [%d] %s", mysql_errno($link), mysql_error($link));
+
+       $row = mysql_fetch_assoc($res);
+       mysql_free_result($res);
+       $host = substr($row['_user'], strrpos($row['_user'], "@") + 1, strlen($row['_user']));
+
+       $sql = sprintf('SET PASSWORD FOR pcontest@"%s" = PASSWORD("newpass")', mysql_real_escape_string($host, $link));
+       if (!mysql_query($sql, $link))
+               printf("[007] Cannot change PW of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link));
 
        // persistent connections cannot be closed but only be killed
        $pthread_id = mysql_thread_id($plink);
        if (!mysql_query(sprintf('KILL %d', $pthread_id), $link))
-               printf("[007] Cannot KILL persistent connection of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link));
+               printf("[008] Cannot KILL persistent connection of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link));
        // give the server a second to really kill the thread
        sleep(1);
 
        if (!$res = mysql_query("SHOW FULL PROCESSLIST", $link))
-               printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link));
+               printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link));
 
        $running_threads = array();
        while ($row = mysql_fetch_assoc($res))
@@ -95,11 +112,11 @@ mysql.allow_persistent=1
        mysql_free_result($res);
 
        if (isset($running_threads[$pthread_id]))
-               printf("[009] Persistent connection has not been killed");
+               printf("[010] Persistent connection has not been killed\n");
 
        // we might get the old handle
        if ($plink = @mysql_pconnect($host, 'pcontest', 'pcontest'))
-               printf("[010] Can connect using the old password, [%d] %s\n",
+               printf("[011] Can connect using the old password, [%d] %s\n",
                        mysql_errno(), mysql_error());
 
        ob_start();
@@ -108,34 +125,34 @@ mysql.allow_persistent=1
        ob_end_clean();
        $phpinfo = substr($phpinfo, strpos($phpinfo, 'MySQL Support => enabled'), 500);
        if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches))
-               printf("[011] Cannot get # active persistent links from phpinfo()");
+               printf("[012] Cannot get # active persistent links from phpinfo()\n");
 
        $num_plinks_kill = $matches[1];
-       if ($num_plinks_kill >= $num_plinks)
-               printf("[012] Statistics seems to be wrong, got %d active persistent links, expecting < %d links",
+       if ($num_plinks_kill > $num_plinks)
+               printf("[013] Statistics seems to be wrong, got %d active persistent links, expecting < %d links\n",
                        $num_plinks_kill, $num_plinks);
 
        // The first connection has been closed, the last pconnect() was unable to connect -> no connection open
        // We must be able to connect because max_persistent limit has not been reached
        if (!$plink = mysql_pconnect($host, 'pcontest', 'newpass'))
-               printf("[013] Cannot connect using the second DB, [%d] %s\n",
-                       mysql_errno(), mysql_error());
+               die(sprintf("[014] Cannot connect using the second DB, [%d] %s\n",
+                       mysql_errno(), mysql_error()));
 
        if (!mysql_select_db($db, $plink))
-               printf("[014] [%d] %s\n", mysql_errno($plink), mysql_error($plink));
+               printf("[015] [%d] %s\n", mysql_errno($plink), mysql_error($plink));
 
        if (!$res = mysql_query('SELECT id, label FROM test WHERE id = 1', $plink))
-               printf("[015] Cannot run query on persistent connection of second DB user, [%d] %s\n",
+               printf("[016] Cannot run query on persistent connection of second DB user, [%d] %s\n",
                        mysql_errno($plink), mysql_error($plink));
 
        if (!$row = mysql_fetch_assoc($res))
-               printf("[016] Cannot run fetch result, [%d] %s\n",
+               printf("[017] Cannot run fetch result, [%d] %s\n",
                        mysql_errno($plink), mysql_error($plink));
        mysql_free_result($res);
        var_dump($row);
 
-       mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link);
-       mysql_query('DROP USER pcontest', $link);
+       mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
+       mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
        mysql_close($link);
        print "done!";
 ?>
@@ -148,8 +165,15 @@ if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {
          $host, $myhost, $user, $db, $port, $socket);
 }
 
-@mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link);
-@mysql_query('DROP USER pcontest', $link);
+if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link))
+       printf("[c002] [%d] %s", mysql_errno($link), mysql_error($link));
+
+$row = mysql_fetch_assoc($res);
+mysql_free_result($res);
+$host = substr($row['_user'], strrpos($row['_user'], "@") + 1, strlen($row['_user']));
+
+@mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
+@mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
 
 mysql_close($link);
 ?>
index e586a33f3b0583bbe6358b04d42e879f384da6cb..a57c7dbd586340b8ab83625be32c19b1a3202176 100755 (executable)
@@ -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))
index 3a13583b652bb2824897fca8204b93fc4fbef452..b5867a0efb47e471df9e347a155a16e33346d36e 100644 (file)
@@ -32,6 +32,7 @@
 #include "ext/standard/php_string.h"
 #include "php_mysqli_structs.h"
 #include "zend_exceptions.h"
+#include "ext/mysqlnd/mysqlnd_portability.h"
 
 ZEND_DECLARE_MODULE_GLOBALS(mysqli)
 static PHP_GINIT_FUNCTION(mysqli);
@@ -379,7 +380,6 @@ void mysqli_write_property(zval *object, zval *member, zval *value TSRMLS_DC)
        zval tmp_member;
        mysqli_object *obj;
        mysqli_prop_handler *hnd;
-       zend_object_handlers *std_hnd;
        int ret;
 
        if (member->type != IS_STRING) {
@@ -1201,12 +1201,37 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
 
                        MAKE_STD_ZVAL(res);
 
-                       /* check if we need magic quotes */
-                       if (PG(magic_quotes_runtime)) {
-                               Z_TYPE_P(res) = IS_STRING;
-                               Z_STRVAL_P(res) = php_addslashes(row[i], field_len[i], &Z_STRLEN_P(res), 0 TSRMLS_CC);
-                       } else {
-                               ZVAL_STRINGL(res, row[i], field_len[i], 1);     
+#if MYSQL_VERSION_ID > 50002
+                       if (mysql_fetch_field_direct(result, i)->type == MYSQL_TYPE_BIT) {
+                               my_ulonglong llval;
+                               char tmp[22];
+                               switch (field_len[i]) {
+                                       case 8:llval = (my_ulonglong)  bit_uint8korr(row[i]);break;
+                                       case 7:llval = (my_ulonglong)  bit_uint7korr(row[i]);break;
+                                       case 6:llval = (my_ulonglong)  bit_uint6korr(row[i]);break;
+                                       case 5:llval = (my_ulonglong)  bit_uint5korr(row[i]);break;
+                                       case 4:llval = (my_ulonglong)  bit_uint4korr(row[i]);break;
+                                       case 3:llval = (my_ulonglong)  bit_uint3korr(row[i]);break;
+                                       case 2:llval = (my_ulonglong)  bit_uint2korr(row[i]);break;
+                                       case 1:llval = (my_ulonglong)  uint1korr(row[i]);break;
+                               }
+                               /* even though lval is declared as unsigned, the value
+                                * may be negative. Therefor we cannot use MYSQLI_LLU_SPEC and must
+                                * use MYSQLI_LL_SPEC.
+                                */
+                               snprintf(tmp, sizeof(tmp), (mysql_fetch_field_direct(result, i)->flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval);
+                               ZVAL_STRING(res, tmp, 1);
+                       } else 
+#endif
+                       {
+
+                               /* check if we need magic quotes */
+                               if (PG(magic_quotes_runtime)) {
+                                       Z_TYPE_P(res) = IS_STRING;
+                                       Z_STRVAL_P(res) = php_addslashes(row[i], field_len[i], &Z_STRLEN_P(res), 0 TSRMLS_CC);
+                               } else {
+                                       ZVAL_STRINGL(res, row[i], field_len[i], 1);     
+                               }
                        }
 
                        if (fetchtype & MYSQLI_NUM) {
index 38bf9ae946e6ec3bfe64905d3818e09dc89cadca..07bc303d725292257866cd343502e000d0663101 100644 (file)
@@ -31,6 +31,7 @@
 #include "php_globals.h"
 #include "ext/standard/info.h"
 #include "php_mysqli_structs.h"
+#include "ext/mysqlnd/mysqlnd_portability.h"
 
 /* {{{ proto mixed mysqli_affected_rows(object link)
    Get number of affected rows in previous MySQL operation */
@@ -356,6 +357,7 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc,
                                bind[ofs].is_null = &stmt->result.is_null[ofs];
                                bind[ofs].buffer_length = stmt->result.buf[ofs].buflen;
                                bind[ofs].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0;
+                               bind[ofs].length = &stmt->result.buf[ofs].output_len;
                                break;
 
                        case MYSQL_TYPE_DATE:
@@ -370,6 +372,7 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc,
                        case MYSQL_TYPE_LONG_BLOB:
                        case MYSQL_TYPE_TIMESTAMP:
                        case MYSQL_TYPE_DECIMAL:
+                       case MYSQL_TYPE_GEOMETRY:
 #ifdef FIELD_TYPE_NEWDECIMAL
                        case MYSQL_TYPE_NEWDECIMAL:
 #endif
@@ -395,7 +398,9 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc,
                                          different lengths and you will see that we get different lengths in stmt->stmt->fields[ofs].length
                                          The just take 256 and saves us from realloc-ing.
                                        */
-                                       stmt->result.buf[ofs].buflen = 256;
+                                       stmt->result.buf[ofs].buflen =
+                                               (stmt->stmt->fields) ? (stmt->stmt->fields[ofs].length) ? stmt->stmt->fields[ofs].length + 1: 256: 256;
+
                                } else {
                                        /*
                                                the user has called store_result(). if he does not there is no way to determine the
@@ -409,7 +414,7 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc,
                                bind[ofs].buffer = stmt->result.buf[ofs].val;
                                bind[ofs].is_null = &stmt->result.is_null[ofs];
                                bind[ofs].buffer_length = stmt->result.buf[ofs].buflen;
-                               bind[ofs].length = &stmt->result.buf[ofs].buflen;
+                               bind[ofs].length = &stmt->result.buf[ofs].output_len;
                                break;
                        }
                        default:
@@ -732,7 +737,7 @@ PHP_FUNCTION(mysqli_stmt_execute)
                for (i = 0; i < stmt->param.var_cnt; i++) {
                        for (j = i + 1; j < stmt->param.var_cnt; j++) {
                                /* Oops, someone binding the same variable - clone */
-                               if (stmt->param.vars[j] == stmt->param.vars[i]) {
+                               if (stmt->param.vars[j] == stmt->param.vars[i] && stmt->param.vars[i]) {
                                        php_mysqli_stmt_copy_it(&copies, stmt->param.vars[i], stmt->param.var_cnt, i);
                                        break;
                                }
@@ -877,9 +882,29 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
                                                ZVAL_DOUBLE(stmt->result.vars[i], *(double *)stmt->result.buf[i].val);
                                                break;
                                        case IS_STRING:
-                                               if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG) {
+                                               if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG
+#if MYSQL_VERSION_ID > 50002
+                                                || stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT
+#endif
+                                                ) {
                                                        my_bool uns= (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? 1:0;
-                                                       llval= *(my_ulonglong *) stmt->result.buf[i].val;
+#if MYSQL_VERSION_ID > 50002
+                                                       if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT) {
+                                                               switch (stmt->result.buf[i].output_len) {
+                                                                       case 8:llval = (my_ulonglong)  bit_uint8korr(stmt->result.buf[i].val);break;
+                                                                       case 7:llval = (my_ulonglong)  bit_uint7korr(stmt->result.buf[i].val);break;
+                                                                       case 6:llval = (my_ulonglong)  bit_uint6korr(stmt->result.buf[i].val);break;
+                                                                       case 5:llval = (my_ulonglong)  bit_uint5korr(stmt->result.buf[i].val);break;
+                                                                       case 4:llval = (my_ulonglong)  bit_uint4korr(stmt->result.buf[i].val);break;
+                                                                       case 3:llval = (my_ulonglong)  bit_uint3korr(stmt->result.buf[i].val);break;
+                                                                       case 2:llval = (my_ulonglong)  bit_uint2korr(stmt->result.buf[i].val);break;
+                                                                       case 1:llval = (my_ulonglong)  uint1korr(stmt->result.buf[i].val);break;
+                                                               }
+                                                       } else
+#endif
+                                                       {
+                                                               llval= *(my_ulonglong *) stmt->result.buf[i].val;
+                                                       }
 #if SIZEOF_LONG==8
                                                        if (uns && llval > 9223372036854775807L) {
 #elif SIZEOF_LONG==4
@@ -898,14 +923,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
                                                        } else {
                                                                ZVAL_LONG(stmt->result.vars[i], llval);
                                                        }
-                                               }
-#if MYSQL_VERSION_ID > 50002
-                                               else if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT) {
-                                                       llval = *(my_ulonglong *)stmt->result.buf[i].val;
-                                                       ZVAL_LONG(stmt->result.vars[i], llval);
-                                               }
-#endif
-                                               else {
+                                               } else {
 #if defined(MYSQL_DATA_TRUNCATED) && MYSQL_VERSION_ID > 50002
                                                        if (ret == MYSQL_DATA_TRUNCATED && *(stmt->stmt->bind[i].error) != 0) {
                                                                /* result was truncated */
@@ -916,7 +934,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
                                                        {
 #endif
                                                                ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
-                                                                                        stmt->result.buf[i].buflen, 1);
+                                                                                        stmt->result.buf[i].output_len, 1);
                                                        }
                                                }
                                                break;
@@ -2097,7 +2115,6 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
        long    mode_in;
        ulong   mode;
        ulong   attr;
-       int             rc;
 
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll", &mysql_stmt, mysqli_stmt_class_entry, &attr, &mode_in) == FAILURE) {
                return;
@@ -2110,7 +2127,11 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
        }
 
        mode = mode_in;
-       if ((rc = mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode))) {
+#if !defined(MYSQLI_USE_MYSQLND)
+       if (FALSE == mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode)) {
+#else
+       if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode)) {
+#endif
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -2281,7 +2302,8 @@ PHP_FUNCTION(mysqli_stmt_store_result)
                for (i = mysql_stmt_field_count(stmt->stmt) - 1; i >=0; --i) {
                        if (stmt->stmt->fields && (stmt->stmt->fields[i].type == MYSQL_TYPE_BLOB ||
                                stmt->stmt->fields[i].type == MYSQL_TYPE_MEDIUM_BLOB ||
-                               stmt->stmt->fields[i].type == MYSQL_TYPE_LONG_BLOB))
+                               stmt->stmt->fields[i].type == MYSQL_TYPE_LONG_BLOB ||
+                               stmt->stmt->fields[i].type == MYSQL_TYPE_GEOMETRY))
                        {
                                my_bool tmp=1;
                                mysql_stmt_attr_set(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp);
index 95ddb9e6dfdb0eeeb364a1c2d16b87d3133b836b..187b9bec30a29c0e50dceb8d8282df89140250cf 100644 (file)
@@ -217,7 +217,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
                                                                MyG(num_active_persistent) + MyG(num_inactive_persistent));
                goto err;
        }
-       if (!is_real_connect && !mysql->mysql) {
+       if (!mysql->mysql) {
 #if !defined(MYSQLI_USE_MYSQLND)
                if (!(mysql->mysql = mysql_init(NULL))) {
 #else
index ce02059488b69024879e3815968e450456086d14..81d1044ce14317e3e236e61af8d0b265b7e61553 100644 (file)
@@ -73,8 +73,9 @@ enum mysqli_status {
 };
 
 typedef struct {
-       ulong           buflen;
        char            *val;
+       ulong           buflen;
+       ulong           output_len;
        ulong           type;
 } VAR_BUFFER;
 
index 77f3dcbd189443bea9dbf6f05aa1b4f39696be55..4e19d810909c1ab99bd43a50e43ed64c3780cb7d 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 mysqli connect
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
@@ -13,25 +13,25 @@ require_once('skipifconnectfailure.inc');
        $test = "";
 
        /*** test mysqli_connect localhost:port ***/
-       $link = mysqli_connect($host, $user, $passwd, "", $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, "", $port, $socket);
        $test .= ($link) ? "1" : "0";
        mysqli_close($link);
 
        /*** test mysqli_real_connect ***/
        $link = mysqli_init();
-       $test.= (mysqli_real_connect($link, $host, $user, $passwd, "", $port, $socket) )
+       $test.= (my_mysqli_real_connect($link, $host, $user, $passwd, "", $port, $socket) )
                ? "1" : "0";
        mysqli_close($link);
 
        /*** test mysqli_real_connect with db ***/
        $link = mysqli_init();
-       $test .= (mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+       $test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
                ? "1" : "0";
        mysqli_close($link);
 
        /*** test mysqli_real_connect with port ***/
        $link = mysqli_init();
-       $test .= (mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+       $test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
                ? "1":"0";
        mysqli_close($link);
 
@@ -40,7 +40,7 @@ require_once('skipifconnectfailure.inc');
                if (!$link = mysqli_init())
                        printf("[001 + %d] mysqli_init() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
 
-               if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+               if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
                        printf("[002 + %d] mysqli_real_connect() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
 
                mysqli_close($link);
@@ -49,7 +49,7 @@ require_once('skipifconnectfailure.inc');
        /*** test mysqli_real_connect compressed ***/
        /*
        $link = mysqli_init();
-       $test .= (mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS))
+       $test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS))
                ? "1" : "0";
        mysqli_close($link);
   */
index 680f0f4fc306607f24b9acf15392e9eb787369bf..6bbdecfdcc5ddc387b915259ad3681983a15f893 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
           printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
@@ -49,7 +49,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
index f780a248df39c7cedf157161ba6f086b20fb8562..e22fec143e96136ef9a07845ff04610d6a1ab1f7 100644 (file)
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 <?php
        include "connect.inc";
 
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_query($link, "SET sql_mode=''");
 
@@ -75,7 +75,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
index 6f549de613cc247440c12b4db713f4208e0eb0f6..1eae99df705529b220f0e46976ec2bece9c6b16c 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include ("connect.inc");
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -50,7 +50,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index 69e04c7a6044fec68b752e0bb430d338c7a9b060..728f45e06cc832d8d0265b6755c155c191d20dea 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -32,6 +32,9 @@ require_once('skipifconnectfailure.inc');
 
        var_dump($test);
 
+       /* this will crash with libmysql from PHP 5.0.6 (or earlier) to 5.3.0 */
+       mysqli_fetch($stmt);
+
        mysqli_stmt_close($stmt);
        mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
        mysqli_close($link);
@@ -40,7 +43,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index 5b6ce14822d4c386f691a39813c44a9ce0625b57..a10e22c44c69c4222b2cfddb78f47e7ee9c5fda5 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "SET sql_mode=''"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -48,7 +48,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index a9a081106ca888ebb3c6d8310b9eae1051f9e620..fe266bf1b2ec2979e3de27ace554a23ef00dcfa4 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "SET sql_mode=''"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -48,7 +48,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index fb63512aa7656193aa951b47a9fff643c9d8cfe7..685110f08e4191bc9652c144fb2c8fc7b1a6ad33 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "SET sql_mode=''"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -48,7 +48,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index 479c5b5700bf69b3f8bb72031d58bd3bd1911b93..0584a14cfde4bfb683fda6676a2b71d5d33952f8 100644 (file)
@@ -14,7 +14,7 @@ mysqli fetch bigint values (ok to fail with 4.1.x)
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "SET sql_mode=''"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -81,7 +81,7 @@ mysqli fetch bigint values (ok to fail with 4.1.x)
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index bb184eeb2ab9f5a014ce50e3205ab38611048ce3..de22c0824189f4198b8bf9958a7e0fb515f70b57 100644 (file)
@@ -12,7 +12,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "SET sql_mode=''"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -51,7 +51,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index 5b58beb762036ad0d68c8eeb6f4986ff0544c87a..4c4ff77069b823daca6cd6ea92c98c05c187d371 100644 (file)
@@ -12,7 +12,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -48,7 +48,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
index 9a9c985b2645270202309ff8c3a68248c81da8c1..2ce81040051c4c2c53ee9decf3e483676228803b 100644 (file)
@@ -12,7 +12,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -47,7 +47,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
index 1d41e5668b667b63603bcc6c249b4bd14a48ae4f..8c123d1ab40a911e0b806476d72f8331b5ca5b0e 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -59,7 +59,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
index a7bbaa7dedd6ac7d728a9ae3e8ee8f20a093c95f..cd7fa19c7273b910aa1eafeec515cb4549b99b4e 100644 (file)
@@ -5,7 +5,7 @@ mysqli autocommit/commit/rollback
        require_once('skipif.inc');
        require_once('skipifconnectfailure.inc');
        include "connect.inc";
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        if (!$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) {
                die("skip Cannot check for required InnoDB suppot");
        }
@@ -22,7 +22,7 @@ mysqli autocommit/commit/rollback
 --FILE--
 <?php
        include "connect.inc";
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_autocommit($link, TRUE))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
index 722a16a42954b262a1a2d4850bdf936ed7feb6ca..b3af0142ae79124e24e736ca61200572c5cb2aaa 100644 (file)
@@ -5,7 +5,7 @@ mysqli autocommit/commit/rollback with innodb
        require_once('skipif.inc');
        require_once('skipifconnectfailure.inc');
        include "connect.inc";
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        $result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
        $row = mysqli_fetch_row($result);
        mysqli_free_result($result);
@@ -19,7 +19,7 @@ mysqli autocommit/commit/rollback with innodb
 <?php
        include "connect.inc";
 
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        if (!$link)
                printf("[001] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
index 286df398d30dd1d56898edd7de5af0c0a7d385f5..c8046de9a10bb71285a49a5f92b307a7b7222cc3 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "SET @dummy='foobar'"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
index d201c7b80ee9939d52648c42a9b1c0265756badb..7220b4ef09368afe057b8f0fea4fe86e40f2eb0e 100644 (file)
@@ -11,7 +11,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!$stmt = mysqli_prepare($link, "SELECT md5('bar'), database(), 'foo'"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
index c5c60c7ae6cbfd6b69985e5eb5ce3d1eac354cd2..1a8d76208876dc78dc775a56d1b018c9e9da5381 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 mysqli fetch system variables
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "SET AUTOCOMMIT=0"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
index d6033200992be01516a67495440a96b143f6d53c..f3741a5d3299cc3010aca89d94c4c4977bcf538f 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        if (!mysqli_query($link, "DROP TABLE IF EXISTS insert_read"))
                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -58,7 +58,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS insert_read"))
index 159cdf51ecac6e247285f80c3b7f114de7e7d69b..f313a616a1e7b587ba0c506beb9170f765340ccc 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
@@ -70,7 +70,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
index d4f246374d3ad7843f92999063e5aaee8e14dbc2..3843566ea2d44e08fe41ee9fb4ff3ecca8f4c932 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -41,7 +41,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index 378a4ac49025b953a904ba324735c0f38fb34787..5c448b9c1ed6fdcbab0aaa4918c889c17218ef97 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -46,7 +46,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index be0540dec553542d96c75dd79c66c3a49ac1d496..d3d4762a6ce71131ff7e2ce6b715cc9a83ddcb20 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
@@ -55,7 +55,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index 0d96cffcc0073e8641d5a2e576f49f49ae321117..7dd54085374325d932dddd52e801d5745ce68e58 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
@@ -55,7 +55,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index 4aa34a2fed07a9074640a0a42b336de4cb056591..9c076dfaeb51b67fb455f7060e855042cc78cc8c 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
@@ -60,7 +60,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index dd92c7bea370152f504f3392ade98c981e5637f3..57fe33e0062f570184c02b4c4a08c38416fbb68d 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
@@ -47,7 +47,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index c52c73e619e56dbb8ec4e5414ca6c0bd6ea4c1c7..0926b70e27ec6c738e13f4cd92bb5b814fb29dca 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 function test: mysqli_stat
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $status = mysqli_stat($link);
 
index a518b7dad71ffb6c2c3047809c365ea7b794d3ae..6c4425e2b47ff00022f5faad0f8a26b92be05868 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $cset = substr(mysqli_character_set_name($link),0,6);
 
index 9ec3bae362e7ad08b2682421e9038610b429b92a..bfc54bcc61c8b92a9dce0707afbba6a6426b02d5 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -29,7 +29,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS general_test"))
index af0210c87099bd3442f42ad6ad0c0e07f267d6d0..656946fb62b8fc2bc87738d8e510e243a1597e0c 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        $errno = mysqli_errno($link);
        var_dump($errno);
 
index cf70e9bcab1c750a404e62315b1c197d54f4e4f2..9f632cb42a45ea2081ce1606e4c27094b089f0f4 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        $error = mysqli_error($link);
        var_dump($error);
 
index b3ca26474b72e0a17e29233283c366e65b0f0394..386883d0e8d03c4b1192297ff2c671bc7f105490 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -29,7 +29,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS general_test"))
index 081be99a2f9013e530396d6bcc49e26ebbc05ead..ade0bb8329167151ca4b0ebd57e9e8d5a9a62a35 100644 (file)
@@ -11,7 +11,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $hinfo = mysqli_get_host_info($link);
 
index c195d7bff3421da517fa61be282b02e853a892e8..cc415344c27f5bf817bca440bf387c109314d6aa 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 function test: mysqli_get_proto_info
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
@@ -11,7 +11,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $pinfo = mysqli_get_proto_info($link);
 
index 58f0246dfb528f591ec09527d15527fbcf6b54d5..7b621aa22201afcc63b03c05dcbc22731f03f1b7 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 function test: mysqli_get_server_info
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $sinfo = substr(mysqli_get_server_info($link),0,1);
 
index a118cdf4631e35a1d8cc478e2b6fc57fbeb377af..4e68b6c2a1858e4ebdb55e8610cd8d79f7cd6079 100644 (file)
@@ -14,7 +14,7 @@ function test: mysqli_insert_id()
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -45,7 +45,7 @@ function test: mysqli_insert_id()
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS t036"))
index 29a01c6d398a6215c075e8632203d1b056b03290..856bdc69821ea2aa69de0480ab6baf74323e6ddb 100644 (file)
@@ -11,7 +11,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -35,7 +35,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
index 7d9c2b348556eee9c233868c73d523e0b2bf95d4..7be16f4493ff05f8a8fff9179b99ca6d5f37973d 100644 (file)
@@ -11,7 +11,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -36,7 +36,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
index 173c1922278c581a886f41a67705b197ed85ff29..9ed7ef9ea1e99dd6df892357969ca337be503551 100644 (file)
@@ -11,7 +11,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_real_query($link, "SHOW VARIABLES");
 
index da787ab687d4515ab7d6dd2adae26bc81f4302ee..6b115166bdf7300740a5d2d0fb92ad49d23894bd 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -34,7 +34,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
index 329e5d5072d3f52b72963f6e5b57c4c3d0a74270..aac91f86a2d4f5ce0a94f201df871a1603acee54 100644 (file)
@@ -11,7 +11,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        mysqli_select_db($link, $db);
 
        mysqli_query($link, "DROP TABLE IF EXISTS test_warnings");
@@ -25,7 +25,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"))
index 7c0556a6349f26b3fccc2909335eab29dff4c666..9d79f148cba8d7f43e724b4651de978f76ebf2ec 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
@@ -51,7 +51,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index f2be1c8d7bd3f2df1a874c68433b09d522702f07..51b2a91ff6c80c9bdcdedb998d58c5eda6e213b2 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -43,7 +43,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_update"))
index 0a2495b9cfe49f663bf169202a482b15d37a0ea4..9d227f49e5ce1734a667ba2fc3b4d5c10ececb9c 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 mysqli_get_server_version
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $i = mysqli_get_server_version($link);
 
index bae2ce8e2c8a4a5957ac15d1b9e156e6aa2ed089..d5ee5ad2bc483c363751452ba81d2b76e1d44b68 100644 (file)
@@ -7,7 +7,7 @@ mysqli_bind_result (SHOW)
        require_once('skipifconnectfailure.inc');
 
        include "connect.inc";
-       $link = mysqli_connect($host, $user, $passwd);
+       $link = my_mysqli_connect($host, $user, $passwd);
 
        $stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'");
        mysqli_execute($stmt);
@@ -23,7 +23,7 @@ mysqli_bind_result (SHOW)
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'");
        mysqli_execute($stmt);
index 8e8991a40d571f505deff154b097ac7b7c4240db..cf773921011a89ed6b79d5f70126478e3d84c722 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -37,7 +37,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_affected"))
index 4c90b113b88f51b18fddc67514a32c3c8dad993f..3401418e91a067b3001c8ced1547506b76796f3c 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -48,7 +48,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_affected"))
index c8ec77ecb31dbceb4656182a2d6558ec1c8ae44c..5ab60e5a5f586346dac59edaed0730ffa5e5eb75 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $mysql = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $mysql->select_db($db);
        $mysql->query("DROP TABLE IF EXISTS test_fetch_null");
@@ -43,7 +43,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
index afd23765491a613fbdd5008e9a45774345d0cd20..eb977a8b697576264773c937f419b96d6fc159ad 100644 (file)
@@ -11,7 +11,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $mysql = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $mysql->select_db($db);
        $result = $mysql->query("SELECT DATABASE()");
@@ -19,6 +19,8 @@ require_once('skipifconnectfailure.inc');
        $result->close();
 
        var_dump($row);
+       if ($row[0] != $db)
+               printf("[001] Expecting '%s' got '%s'\n", $db, $row[0]);
 
        $mysql->close();
        print "done!";
index ee1c20322e263718206cd8ca6b48677c7ea016d2..ba668f0a84c259bff6dfe59b5e7698307bdbe130 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 non freed statement test
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -12,7 +12,7 @@ require_once('skipifconnectfailure.inc');
        /************************
         * non freed stamement
         ************************/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $stmt = mysqli_prepare($link, "SELECT CURRENT_USER()");
        mysqli_execute($stmt);
index 8ff75d59bf25a63b74e1907d6c5565cfc020bf31..82665156dbec4c7cfe39a85ea525ece83b2cbc88 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 free statement after close
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -12,7 +12,7 @@ require_once('skipifconnectfailure.inc');
        /************************
         * free statement after close
         ************************/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $stmt1 = mysqli_prepare($link, "SELECT CURRENT_USER()");
        mysqli_execute($stmt1);
index 95fdc2f27c74e1dcc71dd71e570db3f979cce4f4..f280d8406184f2609f0d414fdc6e6661f90510d1 100644 (file)
@@ -1,18 +1,18 @@
 --TEST--
 call statement after close
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /************************
-        * statement call  after close 
+        * statement call  after close
         ************************/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
 
index 5a60b0fc013ef4b576c86f787e717a0035b456a4..e0bbcbeee36fba87f78b518c41b6546fa57381c8 100644 (file)
@@ -1,18 +1,18 @@
 --TEST--
-not freed resultset 
+not freed resultset
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /************************
-        * non freed resultset 
+        * non freed resultset
         ************************/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $result = mysqli_query($link, "SELECT CURRENT_USER()");
        mysqli_close($link);
index 969ae7a1f13cbf21fd17556d21b94d0b001b0e59..2d957cb3cc05fb4077f79b5e4817a2e3971bb1f0 100644 (file)
@@ -1,18 +1,18 @@
 --TEST--
-free resultset after close 
+free resultset after close
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /************************
-        * free resultset after close 
+        * free resultset after close
         ************************/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $result1 = mysqli_query($link, "SELECT CURRENT_USER()");
        mysqli_close($link);
index 1d0f6c9df6322786994b04c9ed40e716c297ffc1..1f0461bb24acb4ad2e67c98be768fb52c695509a 100644 (file)
@@ -1,18 +1,18 @@
 --TEST--
-free nothing 
+free nothing
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /************************
-        * don't free anything 
+        * don't free anything
         ************************/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $result2 = mysqli_query($link, "SELECT CURRENT_USER()");
        $stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
index a98ff46cb533c5f309e8d52851135639462dfc9c..9da9a10149b94f1444a0047e6a2cceb3733d6c75 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -65,7 +65,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_store_result"))
index 288d0863424c9bb569e6a1023b9c526e6ef68906..d1a90a00410e84c5911281e80aa47daa2bac0ffb 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -51,7 +51,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS mbind"))
index 1b42848d78dc4a007182fad4b83cefbee45bde01..4897981cf44fbbab4a748ce3d7114c6eac60f1f9 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
 
@@ -44,7 +44,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS mbind"))
index cd574d3321d2d2cd78adfa7b4b5520b2d59814a1..f1c20bfa1d0260c5b7747ff483257fc2420a8894 100644 (file)
@@ -16,7 +16,7 @@ require_once('skipifconnectfailure.inc');
        }
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
@@ -45,7 +45,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch"))
index 618c4399f0133d77e5016ca26eab509ec407cdf3..e40f3a273afdfb1f6ea06e6aab0f3168a9ecb521 100644 (file)
@@ -17,7 +17,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
        }
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        /* create temporary file */
        $filename = dirname(__FILE__) . "061.csv";
@@ -52,7 +52,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS t_061"))
index 738b2ec8ccfe98a420a24d5c24bb69b28918f12c..04385536512f1f993dc377e71ff615b47d0fd77d 100644 (file)
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 <?php
        include "connect.inc";
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
        $mysql->real_query("SELECT 'foo' FROM DUAL");
 
index fbbdacd5989ab9f49c834104313f242f846f0d55..9b42ab7fbf5c1fd89a8cbcfe86b29780088783f5 100644 (file)
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 <?php
        include "connect.inc";
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
        $stmt = new mysqli_stmt($mysql, "SELECT 'foo' FROM DUAL");
        $stmt->execute();
index 729fb6b45fa2fc27eb7d0cdedd8ee8352c5a0b97..a308e4ab29b738a230093bdf2324d0752b776dc1 100644 (file)
@@ -1,15 +1,15 @@
 --TEST--
-NULL binding 
+NULL binding
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
        include "connect.inc";
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
        $stmt = new mysqli_stmt($mysql, "SELECT NULL FROM DUAL");
        $stmt->execute();
index 9819f26132a47d8f6e9ffd3c2e6dd952cd98aa7a..d0f1d16291748a1b0cb5dfc199f6cb48610b1da7 100644 (file)
@@ -16,7 +16,7 @@ if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
 <?php
        include "connect.inc";
 
-       if (!$mysql = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        if (!mysqli_query($mysql, "SET sql_mode=''"))
index e22fc7d215745554329ad2223d1162d35add6e4a..7581876ca46f33f5c58375e4f3c4fa72d39bf3cb 100644 (file)
@@ -11,7 +11,7 @@ require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
        $mysql->query("DROP TABLE IF EXISTS test_warnings");
 
@@ -31,7 +31,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"))
index fa1cee9d717abb602390463b392769a7a0fee2e2..f571495185270e79ccab9ca57acc19898e1e92c9 100644 (file)
@@ -6,7 +6,7 @@ function test: nested selects (cursors)
        require_once('skipifconnectfailure.inc');
        include "connect.inc";
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                die("skip Cannot connect to check required version");
 
        /* skip cursor test for versions < 50004 */
@@ -30,7 +30,7 @@ function test: nested selects (cursors)
        }
 
        include "connect.inc";
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
        if ((!$IS_MYSQLND && mysqli_get_client_version() < 50009) ||
                (mysqli_get_server_version($mysql) < 50009)) {
@@ -67,7 +67,7 @@ function test: nested selects (cursors)
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 for ($i =0; $i < 3; $i++) {
index c6b498e8a67125498e4f12601a3c28b0fffbe311..404b6ab106409c1348a28d923cb579a70140790c 100644 (file)
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 <?php
        include "connect.inc";
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
        $mysql->multi_query('SELECT 1;SELECT 2');
        do {
                $res = $mysql->store_result();
index 3064ac11e706b0817b853242ce2ef038365b7804..eee5125133f819c4ab24482da9e041e0a4192665 100644 (file)
@@ -1,15 +1,15 @@
 --TEST--
 mysqli ping
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
        include "connect.inc";
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
        var_dump($mysql->ping());
        $mysql->close();
        print "done!";
index e2fcaf18ae85fe479045845d8b54a7c3a56471e0..8888fb1706414113c4a8f108ee4f0c6d1e4cd0a7 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 mysqli thread_id & kill
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
 <?php
        include "connect.inc";
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
        var_dump($mysql->ping());
 
@@ -20,7 +20,7 @@ require_once('skipifconnectfailure.inc');
 
        $mysql->close();
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
        var_dump(mysqli_ping($mysql));
 
index db05d5d227eca667408c7d77b795e6284ae621e9..637014b29cede2fcd222f99fdd498208b06962d4 100644 (file)
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 <?php
        include "connect.inc";
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
        $mysql->query("DROP TABLE IF EXISTS not_exists");
 
index 0d935d35d1ec7e3148314bf8b9e1a331d0f83509..883655bc5e579a726b5c8abd926288da75fe7524 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
 
        include "connect.inc";
 
-       $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
        var_dump($mysqli->autocommit(false));
        $result = $mysqli->query("SELECT @@autocommit");
index b9a95895589c3b0a9a69fb36bdeeaf0d3bc3e609..cdca551f2103f06e110bd7e70bdf0c9732a00ff6 100644 (file)
@@ -11,7 +11,7 @@ error_reporting = E_ALL & ~E_STRICT
 <?php
        include "connect.inc";
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
        $mysql->multi_query('SELECT 1;SELECT 2');
        do {
                $res = $mysql->store_result();
@@ -25,7 +25,7 @@ error_reporting = E_ALL & ~E_STRICT
        var_dump($mysql->error, __LINE__);
        $mysql->close();
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
        $mysql->multi_query('SELECT 1;SELECT 2');
        do {
                $res = $mysql->store_result();
index a6e4d19a8d17b141a0461549174ea3b9935afc6b..24bcdb4d0f446c9f7a40e584b1c5712a9a75698a 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include ("connect.inc");
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        mysqli_select_db($link, "test");
        mysqli_query($link, "SET sql_mode=''");
 
@@ -34,7 +34,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_users"))
index d7d569698180db257f016f30aed9ad6d882ff3c2..c95043c5517ce93012e6f0f37c08b4a46d4aae89 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 Bug #33090 (mysql_prepare doesn't return an error)
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -10,13 +10,13 @@ require_once('skipifconnectfailure.inc');
        include ("connect.inc");
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, null, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, null, $port, $socket);
        mysqli_select_db($link, $db);
 
        if (!($link->prepare("this makes no sense"))) {
                printf("%d\n", $link->errno);
                printf("%s\n", $link->sqlstate);
-       }       
+       }
        $link->close();
 ?>
 --EXPECT--
index 2130ccaf3a48fb77642b8132be582dae94b6a1e5..18dd4c3566bb404e3f75e530ff92aaf9a1f27ced 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 Bug #34785 (Can not properly subclass mysqli_stmt)
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -24,7 +24,7 @@ require_once('skipifconnectfailure.inc');
        }
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        mysqli_query($link, "SET sql_mode=''");
 
        $stmt = new my_stmt($link, "SELECT 'foo' FROM DUAL");
index e1a6ca30c974a73031248319a348209cc1d87652..fac805312ac6a7702e81f6cfc4b86d8cb2932fd3 100644 (file)
@@ -12,14 +12,14 @@ class DbConnection {
        public function connect() {
                include "connect.inc";
 
-               $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+               $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
                var_dump($link);
 
                $link = mysqli_init();
                /* @ is to supress 'Property access is not allowed yet' */
                @var_dump($link);
 
-               $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+               $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
                $mysql->query("DROP TABLE IF EXISTS test_warnings");
                $mysql->query("CREATE TABLE test_warnings (a int not null)");
                $mysql->query("SET sql_mode=''");
@@ -36,7 +36,7 @@ echo "Done\n";
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"))
index f307b2002a204f6972b49026a334eea23df041e4..9c137b5543f4eb7e3590802b530280cbe9ceead9 100644 (file)
@@ -14,7 +14,7 @@ DROP TABLE test_buint;
 EOSQL;
        include "connect.inc";
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
        $mysql->query("DROP TABLE IF EXISTS test_bint");
        $mysql->query("CREATE TABLE test_bint (a bigint(20) default NULL) ENGINE=MYISAM");
        $mysql->query("INSERT INTO test_bint VALUES (9223372036854775807),(-9223372036854775808),(-2147483648),(-2147483649),(-2147483647),(2147483647),(2147483648),(2147483649)");
@@ -54,7 +54,7 @@ EOSQL;
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bint") || !mysqli_query($link, "DROP TABLE IF EXISTS test_buint"))
index 9a77032996b1ceef089528802fe5f950d587c63d..c769eed1f13c0f553745251af5d07dc4a77146f0 100644 (file)
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 <?php
        include "connect.inc";
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
        $mysql->query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)");
        $mysql->query("INSERT INTO temp (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)");
@@ -40,7 +40,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS temp"))
index 3850b44f18f896e9e5a73899ea31c31b883fc0f8..39b21c476e74b80b249344c53dd88dbb4adef6aa 100644 (file)
@@ -48,7 +48,7 @@ EOSQL;
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS blobby"))
index 49804e18aef02a54503e6f2e6de6eeb60f481041..54657a70011020981ce56ebf43f89312a1b0c73d 100644 (file)
@@ -1,15 +1,15 @@
 --TEST--
 Bug #36420 (segfault when access result->num_rows after calling result->close())
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
 
 include "connect.inc";
-$mysqli = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
 $result = $mysqli->query('select 1');
 
@@ -21,7 +21,7 @@ echo $result->num_rows;
 
 echo "Done\n";
 ?>
---EXPECTF--    
+--EXPECTF--
 Warning: main(): Couldn't fetch mysqli_result in %s on line %d
 
 Warning: main(): Couldn't fetch mysqli_result in %s on line %d
index c1f2a11ab5daf9eb29e435b9fe3567373171c9ce..511eaf38fdeab208ef1108d9e5a7a5e85815bae7 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
        include ("connect.inc");
 
        /*** test mysqli_connect 127.0.0.1 ***/
-       $mysql = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $mysql->query("DROP TABLE IF EXISTS litest");
        $mysql->query("CREATE TABLE litest (a VARCHAR(20))");
@@ -24,7 +24,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS litest"))
index b276a0a978fbad47d343bb94f90678a59eeb21ed..d7144bddad2ebe997d368d2134e3a3ba22135e1c 100644 (file)
@@ -4,16 +4,13 @@ Bug #36802 (crashes with with mysqli_set_charset())
 <?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
-
-       class my_mysqli extends mysqli {
-               function __construct() 
+       class really_my_mysqli extends mysqli {
+               function __construct()
                {
                }
        }
 
        include "connect.inc";
-
-
        $mysql = mysqli_init();
 
        /* following operations should not work */
@@ -24,12 +21,10 @@ Bug #36802 (crashes with with mysqli_set_charset())
        }
        $x[1] = @$mysql->query("SELECT 'foo' FROM DUAL");
 
-       /* following operations should work */ 
+       /* following operations should work */
        $x[2] = ($mysql->client_version > 0);
        $x[3] = $mysql->errno;
        $mysql->close();
-       
-
 
        var_dump($x);
 ?>
index 10aaad5ccd0025c29cdee0a9ffb8e294a8d63798..39909f9efd04750a88d793538134a8294e2f7b3f 100644 (file)
@@ -50,7 +50,7 @@ $B = new B();
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS my_time"))
index d74f57b767a07e3c2928a45840a3a3a64c4e5e22..7e8b4931b2fe49212f657fb97f4b42323e59927f 100644 (file)
@@ -15,7 +15,7 @@ if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1)) {
 <?php
        include "connect.inc";
 
-       $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 
        $cs = array();
        $cs[] = $mysql->set_charset("latin1");
index 490810cbc7f462c35bbc7fac3d9d29f5201e25cf..280a51a6fcae9b8e2fa961a04ef87069bcb3d443 100755 (executable)
@@ -1,15 +1,15 @@
 --TEST--
 Bug #38710 (data leakage because of nonexisting boundary checking in statements)
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
 include "connect.inc";
 
-$db = new mysqli($host, $user, $passwd, $db, $port, $socket);
+$db = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
 $qry=$db->stmt_init();
 $qry->prepare("SELECT REPEAT('a',100000)");
 $qry->execute();
@@ -20,5 +20,5 @@ if ($text !== str_repeat('a', ($IS_MYSQLND || mysqli_get_server_version($db) > 5
 }
 echo "Done";
 ?>
---EXPECTF--    
+--EXPECTF--
 Done
\ No newline at end of file
index 1667eb47d06da14cd3eca2466d77d89762075cdc..b3fd7ca524191f656921f88cbe17d500fda4aaf9 100644 (file)
@@ -152,7 +152,7 @@ memory_limit=83886080
                return true;
        }
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect - [%d] %s\n",
                        mysqli_connect_errno(),
                        mysqli_connect_error());
index 418de89d9a13b66e1b94c48b1394acdeec3cfbf6..c9950be3a169698da2fc809a574a853e23a74570 100644 (file)
@@ -5,7 +5,7 @@ Bug #42548 PROCEDURE xxx can't return a result set in the given context (works i
 require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
        die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
 }
 if (mysqli_get_server_version($link) <= 50000) {
@@ -53,7 +53,7 @@ print "done!";
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 mysqli_query($link, "DROP PROCEDURE IF EXISTS p1");
index 22849aa5d17ef9fb004073205461df14b36ee854..92fc0a2e27ca53de0c2e6bc089682f512a46fac9 100644 (file)
@@ -10,7 +10,7 @@ if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
 require_once('skipifconnectfailure.inc');
 require_once('connect.inc');
 
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
        die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
 }
 if (mysqli_get_server_version($link) <= 50000) {
@@ -75,7 +75,7 @@ if (mysqli_get_server_version($link) <= 50000) {
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
index ae5301f73a51c5d1606a69de9252445bede4fef7..b8828c7428326d98bffdb0897a0948a4ba8b7de6 100644 (file)
@@ -33,103 +33,20 @@ require_once('skipifconnectfailure.inc');
 
        $index = 0;
        while ($stmt->fetch()) {
+               /* NOTE: libmysql - http://bugs.mysql.com/bug.php?id=47483 */
                if ($data[$index] != $column1) {
-                       printf("[004] Row %d, expecting %s/%s got %s/%s\n",
-                               $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+                       if ($IS_MYSQLND || $index != 1) {
+                               printf("[004] Row %d, expecting %s/%s got %s/%s\n",
+                                       $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+                       } else {
+                               if ($column1 != "thre")
+                                       printf("[005] Got '%s'. Please check if http://bugs.mysql.com/bug.php?id=47483 has been fixed and adapt tests bug45019.phpt/mysqli_ps_select_union.phpt", $column1);
+                       }
                }
                $index++;
        }
        $stmt->close();
 
-       // Regular (non-prepared) queries
-       print "Mixing CAST('somestring'AS CHAR), integer and CAST(integer AS CHAR)...\n";
-       if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)")))
-               printf("[005] [%d] %s\n", $link->errno, $link->error);
-
-       $data = array();
-       while ($row = $res->fetch_assoc()) {
-               $data[] = $row['column1'];
-       }
-       $res->free();
-
-       // Prepared Statements
-       if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)")))
-               printf("[006] [%d] %s\n", $link->errno, $link->error);
-
-       $column1 = null;
-       if (!$stmt->execute() || !$stmt->bind_result($column1))
-               printf("[007] [%d] %s\n", $stmt->errno, $stmt->error);
-
-       $index = 0;
-       while ($stmt->fetch()) {
-               if ($data[$index] != $column1) {
-                       printf("[008] Row %d, expecting %s/%s got %s/%s\n",
-                               $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
-               }
-               var_dump($column1);
-               $index++;
-       }
-       $stmt->close();
-
-       print "Using integer only...\n";
-       if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2")))
-               printf("[009] [%d] %s\n", $link->errno, $link->error);
-
-       $data = array();
-       while ($row = $res->fetch_assoc()) {
-               $data[] = $row['column1'];
-       }
-       $res->free();
-
-       // Prepared Statements
-       if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2")))
-               printf("[010] [%d] %s\n", $link->errno, $link->error);
-
-       $column1 = null;
-       if (!$stmt->bind_result($column1) || !$stmt->execute())
-               printf("[011] [%d] %s\n", $stmt->errno, $stmt->error);
-
-       $index = 0;
-       while ($stmt->fetch()) {
-               if ($data[$index] != $column1) {
-                       printf("[012] Row %d, expecting %s/%s got %s/%s\n",
-                               $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
-               }
-               var_dump($column1);
-               $index++;
-       }
-       $stmt->close();
-
-       print "Testing bind_param(), strings only...\n";
-       $two = 'two';
-       $three = 'three';
-       if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?")))
-               printf("[013] [%d] %s\n", $stmt->errno, $stmt->error);
-
-       $column1 = null;
-       if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute())
-               printf("[014] [%d] %s\n", $stmt->errno, $stmt->error);
-
-       while ($stmt->fetch()) {
-               var_dump($column1);
-       }
-       $stmt->close();
-
-       print "Testing bind_param(), strings only, with CAST AS CHAR...\n";
-       $two = 'two';
-       $three = 'three beers are more than enough';
-       if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)")))
-               printf("[013] [%d] %s\n", $stmt->errno, $stmt->error);
-
-       $column1 = null;
-       if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute())
-               printf("[014] [%d] %s\n", $stmt->errno, $stmt->error);
-
-       while ($stmt->fetch()) {
-               var_dump($column1);
-       }
-       $stmt->close();
-
        $link->close();
 
        print "done!";
@@ -139,20 +56,4 @@ Using CAST('somestring' AS CHAR)...
 %unicode|string%(3) "one"
 %unicode|string%(5) "three"
 %unicode|string%(3) "two"
-Mixing CAST('somestring'AS CHAR), integer and CAST(integer AS CHAR)...
-%unicode|string%(1) "1"
-%unicode|string%(5) "three"
-%unicode|string%(1) "2"
-Using integer only...
-int(1)
-int(303)
-int(2)
-Testing bind_param(), strings only...
-%unicode|string%(3) "one"
-%unicode|string%(5) "three"
-%unicode|string%(3) "two"
-Testing bind_param(), strings only, with CAST AS CHAR...
-%unicode|string%(3) "one"
-%unicode|string%(32) "three beers are more than enough"
-%unicode|string%(3) "two"
 done!
index 17d1a3b4460252e2bcf5b717623c5e539ceaf160..50775b55cc63fc0833b5f7e7b04aa6be108f1589 100644 (file)
@@ -7,29 +7,34 @@ require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
-       include("connect.inc");
        require('table.inc');
 
+       $link->close();
+
+       $link = mysqli_init();
+       if (!($link->real_connect($host, $user, $passwd, $db, $port, $socket)))
+               printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+                       $host, $user, $db, $port, $socket);
+
        $id = 1;
        if (!($stmt = $link->prepare('SELECT id, label FROM test WHERE id=? LIMIT 1')))
-               printf("[001] [%d] %s\n", $link->errno, $link->error);
+               printf("[002] [%d] %s\n", $link->errno, $link->error);
 
        if (!$stmt->bind_param('i', $id) || !$stmt->execute())
-               printf("[002] [%d] %s\n", $stmt->errno, $stmt->error);
+               printf("[003] [%d] %s\n", $stmt->errno, $stmt->error);
 
        if ($res = $link->store_result()) {
-               printf("[003] Can store result!\n");
+               if ($IS_MYSQLND)
+                       printf("[004] Can store result!\n");
+               else
+                       printf("[004] [007] http://bugs.mysql.com/bug.php?id=47485\n");
        } else {
-               printf("[003] [%d] %s\n", $link->errno, $link->error);
+               printf("[004] [%d] %s\n", $link->errno, $link->error);
        }
-
-       var_dump($res->fetch_assoc());
 ?>
 --CLEAN--
 <?php
        require_once("clean_table.inc");
 ?>
 --EXPECTF--
-[003] [0%s
-
-Fatal error: Call to a member function fetch_assoc() on a non-object in %s on line %d
+[004] [0%s
index 84248b1fbbc23182c661d3580516eebc36457eca..9e7822271300be1611e447be929b5905bdc25e68 100644 (file)
@@ -12,7 +12,7 @@ if (!defined("MYSQLI_ASYNC")) {
 <?php
 class MySQL_Ext extends mysqli{
        protected $fooData = array();
-       
+
        public function isEmpty()
        {
                $this->extData[] = 'Bar';
@@ -20,13 +20,11 @@ class MySQL_Ext extends mysqli{
        }
 }
 
+include ("connect.inc");
+$MySQL_Ext = new MySQL_Ext($host, $user, $passwd, $db, $port, $socket);
 
-
-       include ("connect.inc");
-       $MySQL_Ext = new MySQL_Ext($host, $user, $passwd, $db);
-
-       $isEmpty = $MySQL_Ext->isEmpty();
-       var_dump($isEmpty);
+$isEmpty = $MySQL_Ext->isEmpty();
+var_dump($isEmpty);
 ?>
 --EXPECT--
 bool(false)
index 65b677aed9eb0253ebb8ce338a5c1a8038e4eef3..0358802bac168fafe59472a01493bdc79bcb7144 100644 (file)
@@ -12,7 +12,7 @@ if (!defined("MYSQLI_ASYNC")) {
 <?php
        include ("connect.inc");
 
-       $link1 = mysqli_connect($host, $user, $passwd, null, $port, $socket);
+       $link1 = my_mysqli_connect($host, $user, $passwd, null, $port, $socket);
        mysqli_select_db($link1, $db);
 
        $link1->query("SELECT 'test'", MYSQLI_ASYNC);
diff --git a/ext/mysqli/tests/bug48909.phpt b/ext/mysqli/tests/bug48909.phpt
new file mode 100644 (file)
index 0000000..55c85a6
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+Bug #48909 (Segmentation fault in mysqli_stmt_execute)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+       include "connect.inc";
+
+       if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
+               printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+                       $host, $user, $db, $port, $socket);
+
+       if (!$link->query("DROP TABLE IF EXISTS test") ||
+               !$link->query(sprintf("CREATE TABLE test(id INT, label varchar(255)) ENGINE = %s", $engine)))
+               printf("[002] [%d] %s\n", $link->errno, $link->error);
+
+       if (!$stmt = $link->prepare("INSERT INTO test(id, label) VALUES  (?, ?)"))
+               printf("[003] [%d] %s\n", $link->errno, $link->error);
+
+       if (!$stmt->bind_param("bb",$bvar, $bvar))
+               printf("[004] [%d] %s\n", $stmt->errno, $stmt->error);
+
+       if (!$stmt->execute())
+               printf("[005] [%d] %s\n", $stmt->errno, $stmt->error);
+
+       $stmt->close();
+       $link->close();
+
+       echo "done";
+?>
+--CLEAN--
+<?php
+       require_once("clean_table.inc");
+?>
+--EXPECTF--
+done
\ No newline at end of file
index 9e5a7554cb2d5dde30c62aa773b872f7f24c376f..35434bdd2d1c7631b62158f67d2cdfb9b1cda344 100644 (file)
@@ -9,20 +9,54 @@ require_once('skipifconnectfailure.inc');
 <?php
        include ("connect.inc");
 
-       $link=mysqli_init();
-       if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "SELECT 1")){
-               echo "Broken 2!\n";
-       }
-       if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "SELECT 13")){
-               echo "Broken 2!\n";
+       $link = mysqli_init();
+       if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "SELECT 1")) {
+               printf("[001] Cannot set INIT_COMMAND\n");
        }
 
-       require('table_real_connect.inc');
+       if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+               printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+       }
 
        var_dump($link->query("SELECT 42")->fetch_row());
+
+       if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
+               !mysqli_query($link, sprintf("CREATE TABLE test(id INT) ENGINE=%s", $engine))) {
+               printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+       }
+
+       mysqli_close($link);
+
+       $link = mysqli_init();
+       if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(id) VALUES(1)")) {
+               printf("[004] Cannot set INIT_COMMAND\n");
+       }
+
+       if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+               printf("[005] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+       }
+
+       if (!$res = mysqli_query($link, "SELECT id FROM test"))
+               printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+       var_dump(mysqli_fetch_assoc($res));
+
+       mysqli_free_result($res);
+       mysqli_close($link);
+
+       print "done!";
+?>
+--CLEAN--
+<?php
+       require_once("clean_table.inc");
 ?>
 --EXPECTF--
 array(1) {
   [0]=>
   %unicode|string%(2) "42"
 }
+array(1) {
+  [%u|b%"id"]=>
+  %unicode|string%(1) "1"
+}
+done!
diff --git a/ext/mysqli/tests/bug49442.phpt b/ext/mysqli/tests/bug49442.phpt
new file mode 100644 (file)
index 0000000..5323a28
--- /dev/null
@@ -0,0 +1,119 @@
+--TEST--
+Bug #49422 (mysqlnd: mysqli_real_connect() and LOAD DATA INFILE crash)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--INI--
+mysqli.allow_local_infile=1
+mysqli.allow_persistent=1
+mysqli.max_persistent=1
+--FILE--
+<?php
+       include ("connect.inc");
+
+       $link = mysqli_init();
+       if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+               printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+       }
+
+       if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
+               printf("[002] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+       }
+
+       if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine)) {
+               printf("[003] Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+       }
+
+       include("local_infile_tools.inc");
+       $file = create_standard_csv(4);
+
+       if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s'
+                       INTO TABLE test
+                       FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\''
+                       LINES TERMINATED BY '\n'",
+                       mysqli_real_escape_string($link, $file)))) {
+                       printf("[005] [%d] %s\n",  mysqli_errno($link), mysqli_error($link));
+       }
+
+       if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id"))
+               printf("[006] [%d] %s\n",  mysqli_errno($link), mysqli_error($link));
+
+       $rows = array();
+       while ($row = mysqli_fetch_assoc($res)) {
+               var_dump($row);
+               $rows[] = $row;
+       }
+
+       mysqli_free_result($res);
+
+       mysqli_query($link, "DELETE FROM test");
+       mysqli_close($link);
+
+       if ($IS_MYSQLND) {
+               /*
+                       mysqlnd makes a connection created through mysql_init()/mysqli_real_connect() always a 'persistent' one.
+                       At this point 'persistent' is not to be confused with what a user calls a 'persistent' - in this case
+                       'persistent' means that mysqlnd uses malloc() instead of emalloc(). nothing else. ext/mysqli will
+                       not consider it as a 'persistent' connection in a user sense, ext/mysqli will not appy max_persistent etc.
+                       Its only about malloc() vs. emalloc().
+
+                       However, the bug is about malloc() and efree(). You can make make mysqlnd use malloc() by either using
+                       pconnect or mysql_init() - so we should test pconnect as well..
+               */
+               $host = 'p:' . $host;
+               if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+                       printf("[007] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+               }
+
+               /* bug happened during query processing */
+               if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s'
+                       INTO TABLE test
+                       FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\''
+                       LINES TERMINATED BY '\n'",
+                       mysqli_real_escape_string($link, $file)))) {
+                       printf("[008] [%d] %s\n",  mysqli_errno($link), mysqli_error($link));
+               }
+
+               /* we survived? that's good enough... */
+
+               if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id"))
+                       printf("[009] [%d] %s\n",  mysqli_errno($link), mysqli_error($link));
+
+               $i = 0;
+               while ($row = mysqli_fetch_assoc($res)) {
+                       if (($row['id'] != $rows[$i]['id']) || ($row['label'] != $rows[$i]['label'])) {
+                               printf("[010] Wrong values, check manually!\n");
+                       }
+                       $i++;
+               }
+               mysqli_close($link);
+       }
+
+       print "done!";
+?>
+--CLEAN--
+<?php
+       require_once("clean_table.inc");
+?>
+--EXPECTF--
+array(2) {
+  [%u|b%"id"]=>
+  %unicode|string%(2) "97"
+  [%u|b%"label"]=>
+  %unicode|string%(1) "x"
+}
+array(2) {
+  [%u|b%"id"]=>
+  %unicode|string%(2) "98"
+  [%u|b%"label"]=>
+  %unicode|string%(1) "y"
+}
+array(2) {
+  [%u|b%"id"]=>
+  %unicode|string%(2) "99"
+  [%u|b%"label"]=>
+  %unicode|string%(1) "z"
+}
+done!
\ No newline at end of file
index 8ea74aecdf5d704662d3c2cc54d649ad6b8643be..716cc84416b1a09ad17c0c17761796d208937b07 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP
 require_once('connect.inc');
 
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
        printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                $host, $user, $db, $port, $socket);
 }
index f8cd71c2b7ba240c5420a042d039fe543336eb59..ad2428647c85473c5e66534ed1a08317198bde0d 100644 (file)
@@ -16,6 +16,7 @@
        $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))) ?
@@ -50,6 +51,7 @@
                        /* unknown */
                        $MYSQLND_VERSION = -1;
                }
+
        }
 
        if (!function_exists('sys_get_temp_dir')) {
                        return FALSE;
                }
        }
+
+       /**
+       * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
+       *
+       * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)?
+       */
+       function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+               global $connect_flags;
+
+               $flags = ($enable_env_flags) ? $connect_flags : false;
+
+               if ($flags !== false) {
+                       $link = mysqli_init();
+                       if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags))
+                               $link = false;
+               } else {
+                       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+               }
+
+               return $link;
+       }
+
+       /**
+       * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
+       *
+       * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)
+       */
+       function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) {
+               global $connect_flags;
+
+               if ($enable_env_flags)
+                       $flags & $connect_flags;
+
+               return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags);
+       }
+
+       class my_mysqli extends mysqli {
+               public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+                       global $connect_flags;
+
+                       $flags = ($enable_env_flags) ? $connect_flags : false;
+
+                       if ($flags !== false) {
+                               parent::init();
+                               $this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags);
+                       } else {
+                               parent::__construct($host, $user, $passwd, $db, $port, $socket);
+                       }
+               }
+       }
 ?>
\ No newline at end of file
index a09ed2274226782865c53793e752eb9f5adbbeda..6cb5451c0b1e5692bbcd425409af73230bd00120 100644 (file)
@@ -22,7 +22,7 @@ mysqli_affected_rows()
        if (!is_null($tmp = @mysqli_affected_rows($link, $link)))
                printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 9fbce3eb0127606f3aeed2b4eb71086bc406dc67..07b7bcb4866a658dd77bd044abbb794587e7d44b 100644 (file)
@@ -14,7 +14,7 @@ mysqli->affected_rows
        if (NULL !== ($tmp = @$mysqli->affected_rows))
                printf("[000a] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        }
index d94e0dbbe352a958ccd5ab8136c648ba25ae7778..cdd5559767e9e1dcafd90e4edae6158e6c627b3a 100644 (file)
@@ -7,7 +7,7 @@ mysqli_autocommit()
        require_once('connect.inc');
        require_once('skipifconnectfailure.inc');
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket));
        }
@@ -40,7 +40,7 @@ mysqli_autocommit()
        if (!is_null($tmp = @mysqli_autocommit($link, $link, $link)))
                printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        }
index a0c5f1f8d4bdd66a1b72b5bd26c6113a288ae4eb..8f2c4b472fb2dc7b4b47ff3afef0321f31c7e297 100644 (file)
@@ -7,7 +7,7 @@ mysqli->autocommit()
        require_once('skipifconnectfailure.inc');
        require_once('connect.inc');
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
                printf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
                exit(1);
@@ -31,7 +31,7 @@ mysqli->autocommit()
 <?php
        include "connect.inc";
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        }
index dce00eba6e99ac099171de6cf559593c319b6937..d889ec8202ee7a591cd6a59a1ae6ef14f379186f 100644 (file)
@@ -2,7 +2,7 @@
 mysqli_change_user()
 --SKIPIF--
 <?php
-require_once('skipif.inc'); 
+require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
@@ -28,7 +28,7 @@ require_once('skipifconnectfailure.inc');
        if (!is_null($tmp = @mysqli_change_user($link, $link, $link, $link, $link)))
                printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 8ca387ab394865afa7614c5132d9705ef0b022dd..4cc071d7ab6317559cf84250607662b34b8a734f 100644 (file)
@@ -70,7 +70,7 @@ sleep(5);
 
        /* Ok, let's try a NEW connection and a NEW lock! */
        mysqli_close($link);
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[010] Cannot open new connection, [%d] %s\n",
                        mysqli_connect_errno(), mysqli_connect_error());
 
index b3235092a0429971163228bdf8a8669b75c91b2e..83efb51492352880ed2c35305f652586581877c7 100644 (file)
@@ -7,7 +7,7 @@ require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 require_once('connect.inc');
 if (!$IS_MYSQLND) {
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                die("skip Can't test server version, might hit known bugs http://bugs.mysql.com/bug.php?id=30472, http://bugs.mysql.com/bug.php?id=45184");
        if (mysqli_get_client_version($link) <= 50135)
                /* TODO - check wich version got the patch */
@@ -20,7 +20,7 @@ if (!$IS_MYSQLND) {
 <?php
        require_once('connect.inc');
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        if (!mysqli_query($link, 'DROP TABLE IF EXISTS test'))
index 515a2107aa4405e38e8364121ebe43783202d9fe..e40154ce10ea841871699061e6b17a7d25333a52 100644 (file)
@@ -12,7 +12,7 @@ die("skip - is the server still buggy?");
        require_once('connect.inc');
        require_once('table.inc');
 
-       if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot create second connection handle, [%d] %s\n",
                        mysqli_connect_errno(), mysqli_connect_error());
 
index cb7bcf7e8fedb282d6266538a453ec84c495a0c3..61444ae2350b67c2e16bd51cadeff8b77441383e 100644 (file)
@@ -18,7 +18,7 @@ if (!$IS_MYSQLND && (mysqli_get_server_version($link) < 50118 && mysqli_get_serv
        $link   = NULL;
        $tmp    = NULL;
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index aa8eb4176592797d80c274f475adb7445ab9ce03..6a37b6b44afe8f5c5812dffeb888dec40b8425fd 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
 <?php
        require_once('connect.inc');
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        if (!$stmt = mysqli_prepare($link, "SELECT 'prepared statements should be released'"))
index 600c7af7e1e36863ed2914b4432890dd31c174c0..a57f80b676154435f067441732b08e3164f5436b 100644 (file)
@@ -6,7 +6,7 @@ require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 require_once('connect.inc');
-$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 $result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
 $row = mysqli_fetch_row($result);
 mysqli_free_result($result);
index d734ee886b693f278e3802061d249ae2dd1fcf5c..362873c84247048a2835c74730f981cf58b5dd38 100644 (file)
@@ -6,7 +6,7 @@ require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
        die(sprintf("skip [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
 
 if (!$res = mysqli_query($link, 'SELECT version() AS server_version'))
@@ -25,7 +25,7 @@ if ($version[0] <= 4 && $version[1] < 1)
 <?php
        require_once('connect.inc');
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        if (!$res = mysqli_query($link, "SHOW CHARACTER SET LIKE 'latin%'"))
index e6e1037a9cb603ad91a8fbce30440756a533d0bd..11c92ce63e3f88b033d725c6ab6e9fb1a2a8026d 100644 (file)
@@ -20,7 +20,7 @@ if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
 
        $tmp    = NULL;
        $link   = NULL;
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 03bc31159e32eced5bd28e3b9bc95142b514a6d6..9a40099fe13044bc8b92f752aef1b250e26cf882 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 mysqli_chararcter_set_name(), mysql_client_encoding() [alias]
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
@@ -23,7 +23,7 @@ require_once('skipifconnectfailure.inc');
        if (!is_null($tmp = @mysqli_character_set_name($link, $link, $link)))
                printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 018a90ad8c8df0820b4a90332d5d909d71da77a0..a56cf6ae8dd8c2bcc3a5918bc0fa0c4957e0735d 100644 (file)
@@ -1,7 +1,7 @@
 --TEST--
 mysqli_chararcter_set_name(), mysql_client_encoding() [alias]
 --SKIPIF--
-<?php 
+<?php
        require_once('skipif.inc');
        require_once('skipifemb.inc');
        require_once('skipifconnectfailure.inc');
@@ -14,7 +14,7 @@ mysqli_chararcter_set_name(), mysql_client_encoding() [alias]
        $tmp    = NULL;
        $link   = NULL;
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 9141469967e6c9e295dd2246a2f9485684c3acfb..2e6d9c2fd1c723f903e8d4547919fa2ae07074ad 100644 (file)
@@ -15,8 +15,6 @@ Those tests go into the details and are aimed to be a development tool, no more.
 */
 if (!$IS_MYSQLND)
        die("skip Test has been written for the latest version of mysqlnd only");
-if ($MYSQLND_VERSION < 50005)
-       die("skip Test requires mysqlnd Revision 5.0.4 or newer");
 ?>
 --FILE--
 <?php
index b0c732a0d5d9fe73ebbd8b054832d865004e9966..ad914b734329a60801931bb12dac0e8c5b1e5dde 100644 (file)
@@ -11,7 +11,7 @@ require_once('skipifconnectfailure.inc');
        require('connect.inc');
 
        $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        printf("Parent class:\n");
        var_dump(get_parent_class($mysqli));
@@ -194,7 +194,7 @@ require_once('skipifconnectfailure.inc');
        @$mysqli->unknown = $unknown;
        printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown);
 
-       $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
        printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n");
        assert(mysqli_connect_error() === $mysqli->connect_error);
        printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n",
index de4fb87ca4385a6bb57d5276c9fa55cab7bcc743..b327fe656c5d07aafeeabd00c60a41a2920f20e2 100644 (file)
@@ -11,11 +11,11 @@ require_once('skipifconnectfailure.inc');
        require('connect.inc');
        require('table.inc');
 
-       $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
        $mysqli_result = $mysqli->query('SELECT * FROM test');
        $row = $mysqli_result->fetch_row();
 
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        $res = mysqli_query($link, 'SELECT * FROM test');
        assert(mysqli_fetch_row($res) === $row);
 
index 45cc38a704388cea7b147735eca0f6660165389c..9ddb26e89e84e8541696a0560068539878398743 100644 (file)
@@ -11,7 +11,7 @@ Interface of the class mysqli_stmt
        require('connect.inc');
        require('table.inc');
 
-       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        $stmt = new mysqli_stmt($link);
 
        printf("Parent class:\n");
index c1d66871819cb3b58ad5f38d534d04b359161e92..62f01cac6aa5023a6ed6f71b9041c7880c6b113b 100644 (file)
@@ -21,7 +21,7 @@ if (!$TEST_EXPERIMENTAL)
        $mysqli = new mysqli();
        $warning = new mysqli_warning($mysqli);
 
-       $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
        $stmt = new mysqli_stmt($mysqli);
        $warning = new mysqli_warning($stmt);
 
@@ -32,7 +32,7 @@ if (!$TEST_EXPERIMENTAL)
        $warning = new mysqli_warning($obj);
 
        include("table.inc");
-       $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
+       $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
        $res = $mysqli->query('INSERT INTO test(id, label) VALUES (1, "zz")');
        $warning = mysqli_get_warnings($mysqli);
 
index 24e4a35c983b4c3aac39594d6ca0273e6167def4..713c6e157e64376e914682dec59fb27f03995c77 100644 (file)
@@ -1,9 +1,9 @@
 --TEST--
 mysqli_close()
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
-require_once('skipifemb.inc'); 
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -19,7 +19,7 @@ require_once('skipifconnectfailure.inc');
        if (!is_null($tmp = @mysqli_close($link, $link)))
                printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 706767458a44257babc4be010c7416501f35e292..c3d6a93974db02e3e2fabe76e4151f58114d562d 100644 (file)
@@ -1,9 +1,9 @@
 --TEST--
 mysqli_close()
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
-require_once('skipifemb.inc'); 
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -13,7 +13,7 @@ require_once('skipifconnectfailure.inc');
        $tmp    = NULL;
        $link   = NULL;
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 1aecd16e48600dce919b5ac98215836ed7c382ae..6a3c1e86c956e16cc7941b4dce712b957da484b5 100644 (file)
@@ -6,7 +6,7 @@ require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
        die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                $host, $user, $db, $port, $socket));
 }
@@ -39,7 +39,7 @@ if ($row[1] == "DISABLED" || $row[1] == "NO") {
        if (!is_null($tmp = @mysqli_commit($link, $link)))
                printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index d302e38cee0b2bbf1b33dcca293bc69541354901..8d072999cb2f215cfd5a479db863f1ec8da5202a 100644 (file)
@@ -5,7 +5,7 @@ mysqli_commit()
 require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
-if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) {
+if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
        die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                $host, $user, $db, $port, $socket));
 }
@@ -33,7 +33,7 @@ if ($row[1] == "DISABLED" || $row[1] == "NO") {
        if (!is_null($tmp = @$mysqli->commit()))
                printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index f1b1d7b01aa63885bf62d9f39f61a554638e6860..b48a75ef8c0bf900fce6752acf1c94d39abf771e 100644 (file)
@@ -1,9 +1,9 @@
 --TEST--
 mysqli_connect_errno()
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
-require_once('skipifemb.inc'); 
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -17,7 +17,7 @@ require_once('skipifconnectfailure.inc');
        if (0 !== ($tmp = @mysqli_connect_errno($link)))
                printf("[001] Expecting integer/0, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
@@ -26,10 +26,10 @@ require_once('skipifconnectfailure.inc');
 
        mysqli_close($link);
 
-       $link = @mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket);
+       $link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket);
        if (false !== $link)
                printf("[004] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s, expecting boolean/false, got %s/%s\n",
-                       $host, $user . 'unknown_really', $db, $port, $socket, gettype($link), $link);
+                       $host, $user . 'unknown_really', $db, $port, $socket, gettype($link), var_export($link, true));
 
        if (0 === ($tmp = mysqli_connect_errno()))
                printf("[005] Expecting integer/any non-zero, got %s/%s\n", gettype($tmp), $tmp);
index 5016acf247a6a48f9d1102be73d3e2ded819d1f6..e65dc0eb075b1573e112c3920617f4de0f7f8da0 100644 (file)
@@ -1,9 +1,9 @@
 --TEST--
 mysqli_connect_error()
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
-require_once('skipifemb.inc'); 
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -17,7 +17,7 @@ require_once('skipifconnectfailure.inc');
        if (!is_null($tmp = @mysqli_connect_error($link)))
                printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
@@ -26,7 +26,7 @@ require_once('skipifconnectfailure.inc');
 
        mysqli_close($link);
 
-       if ($link = @mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+       if ($link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
                printf("[003] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
                        $host, $user . 'unknown_really', $db, $port, $socket);
 
index debc435b0ef2dda71fcfe546f1fc5c3d5d4de638..7c6a726b298e92624d588fe9b124c82c755f7a83 100644 (file)
@@ -10,14 +10,14 @@ require_once('skipifconnectfailure.inc');
 <?php
        include "connect.inc";
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
        if (!$thread_id = mysqli_thread_id($link))
                printf("[002] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
-       if (true !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
+       if (true !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
                printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
 
        if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0))
@@ -35,7 +35,7 @@ require_once('skipifconnectfailure.inc');
 
        mysqli_close($link);
 
-       if (!$link = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index d918cc40305b0c97f51f1a7c3b00be6809f04a4b..79f081f50f359f901bb899dc83a505e6577f1980 100644 (file)
@@ -23,7 +23,7 @@ if (!function_exists('mysqli_disable_reads_from_master')) {
        if (NULL !== ($tmp = @mysqli_disable_reads_from_master($link)))
                printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        }
index 765fee527cbd76cb2c94db164a267aeae3efdb10..a2d1437a2a1ee9d51cd4b1dd0be19b01da38973c 100644 (file)
@@ -46,7 +46,7 @@ require_once('skipifconnectfailure.inc');
        $ok = false;
        try {
 
-               if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+               if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
                        printf("[007] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
                        $host, $user . 'unknown_really', $db, $port, $socket);
                        mysqli_close($link);
@@ -75,14 +75,14 @@ require_once('skipifconnectfailure.inc');
 
 
        $driver->report_mode = MYSQLI_REPORT_OFF;
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[016] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
        mysqli_query($link, "NO_SQL");
        mysqli_close($link);
 
        $driver->report_mode = MYSQLI_REPORT_ERROR;
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
        mysqli_query($link, "NO_SQL");
        mysqli_close($link);
index d93738edc8d8d92fc409c071e334f023c549dd85..fe253e1cf70f23f75bf03e7c186f491f548bfad0 100644 (file)
@@ -19,7 +19,7 @@ require_once('skipifconnectfailure.inc');
        if (NULL !== ($tmp = @mysqli_dump_debug_info($link)))
                printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
                exit(1);
index 2228f3d6c534409906e3b769bebe5f5f3c624696..171ed565056ef762f386a487df5ae2146066f114 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 mysqli_enable_reads_from_master()
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 
@@ -23,7 +23,7 @@ if (!function_exists('mysqli_enable_reads_from_master')) {
        if (NULL !== ($tmp = @mysqli_enable_reads_from_master($link)))
                printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        }
index 786a716e3520aee247fff8626842843d8463412e..48acbb62353d150744f070af740b3791d595e870 100644 (file)
@@ -19,7 +19,7 @@ require_once('skipifconnectfailure.inc');
        if (!is_null($tmp = @mysqli_errno($link)))
                printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 }
index 8a2a749a60415bdcfcc756458508f396b7d551b6..51738804576b57e04cf84beaa8c4e6c311f8c314 100644 (file)
@@ -1,8 +1,8 @@
 --TEST--
 mysqli_error()
 --SKIPIF--
-<?php 
-require_once('skipif.inc'); 
+<?php
+require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
@@ -19,7 +19,7 @@ require_once('skipifconnectfailure.inc');
        if (!is_null($tmp = @mysqli_error($link)))
                printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        }
index 9d3032cbb9cd3d27cc0da0780c57af24d4703e6e..297d92ac7da49d837b997052644afedd4cb04c2c 100644 (file)
@@ -18,7 +18,7 @@ if (!function_exists('mysqli_fetch_all'))
 
        $mysqli = new mysqli();
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
diff --git a/ext/mysqli/tests/mysqli_fetch_array_large.phpt b/ext/mysqli/tests/mysqli_fetch_array_large.phpt
new file mode 100644 (file)
index 0000000..aa8c768
--- /dev/null
@@ -0,0 +1,150 @@
+--TEST--
+mysqli_fetch_array() - large packages (to test compression)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+       include "connect.inc";
+
+       function mysqli_fetch_array_large($offset, $link, $package_size) {
+
+               /* we are aiming for maximum compression to test MYSQLI_CLIENT_COMPRESS */
+               $random_char = str_repeat('a', 255);
+               $sql = "INSERT INTO test(label) VALUES ";
+
+               while (strlen($sql) < ($package_size - 259))
+                       $sql .= sprintf("('%s'), ", $random_char);
+
+               $sql = substr($sql, 0, -2);
+               assert(strlen($sql) < $package_size);
+
+               if (!@mysqli_query($link, $sql)) {
+                       if (1153 == mysqli_errno($link) || stristr(mysqli_error($link), 'max_allowed_packet'))
+                               /* [1153] Got a packet bigger than 'max_allowed_packet' bytes */
+                               return false;
+
+                       printf("[%03d + 1] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+                       return false;
+               }
+
+               /* buffered result set - let's hope we do not run into PHP memory limit... */
+               if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
+                       printf("[%03d + 2] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+                       return false;
+               }
+
+               while ($row = mysqli_fetch_assoc($res)) {
+                       if ($row['label'] != $random_char) {
+                               printf("[%03d + 3] Wrong results - expecting '%s' got '%s', [%d] %s\n",
+                                       $offset, $random_char, $row['label'], mysqli_errno($link), mysqli_error($link));
+                               return false;
+                       }
+               }
+               mysqli_free_result($res);
+
+               if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test")) {
+                       printf("[%03d + 4] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+                       return false;
+               }
+
+               /* unbuffered result set */
+               if (!mysqli_stmt_execute($stmt)) {
+                       printf("[%03d + 5] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                       return false;
+               }
+
+               $id = $label = NULL;
+               if (!mysqli_stmt_bind_result($stmt, $id, $label)) {
+                       printf("[%03d + 6] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                       return false;
+               }
+
+               while (mysqli_stmt_fetch($stmt)) {
+                       if ($label != $random_char) {
+                               printf("[%03d + 7] Wrong results - expecting '%s' got '%s', [%d] %s\n",
+                                       $offset, $random_char, $label, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                               return false;
+                       }
+               }
+
+               mysqli_stmt_free_result($stmt);
+               mysqli_stmt_close($stmt);
+
+               return true;
+       }
+
+       function parse_memory_limit($limit) {
+
+               $val = trim($limit);
+               $last = strtolower($val[strlen($val)-1]);
+
+               switch($last) {
+                               // The 'G' modifier is available since PHP 5.1.0
+                               case 'g':
+                                       $val *= 1024;
+                               case 'm':
+                                       $val *= 1024;
+                               case 'k':
+                                       $val *= 1024;
+                               default:
+                                       break;
+       }
+                       return $val;
+       }
+
+
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+               printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+               $host, $user, $db, $port, $socket);
+       }
+
+       if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
+                       !mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255)) ENGINE = %s", $engine)))
+               printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+       $package_size = 524288;
+       $offset = 3;
+       $limit = (ini_get('memory_limit') > 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32);
+
+       /* try to respect php.ini but make run time a soft limit */
+       $max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30;
+       set_time_limit(0);
+
+       do {
+               if ($package_size > $limit) {
+                       printf("stop: memory limit - %s vs. %s\n", $package_size, $limit);
+                       break;
+               }
+
+               $start = microtime(true);
+               if (!mysqli_fetch_array_large($offset++, $link, $package_size)) {
+                       printf("stop: packet size - %d\n", $package_size);
+                       break;
+               }
+
+               $duration = microtime(true) - $start;
+               $max_runtime -= $duration;
+               if ($max_runtime < ($duration * 3)) {
+                       /* likely the next iteration will not be within max_execution_time */
+                       printf("stop: time limit - %2.2fs\n", $max_runtime);
+                       break;
+               }
+
+               $package_size += $package_size;
+
+       } while (true);
+
+
+       mysqli_close($link);
+       print "done!";
+?>
+--CLEAN--
+<?php
+       require_once("clean_table.inc");
+?>
+--EXPECTF--
+stop: %s
+done!
\ No newline at end of file
index e8b2618f70d9f9cca45580bd606dad1959434976..fcabb59030a0cc9e5e785415e6259e2b54347c38 100644 (file)
@@ -14,7 +14,7 @@ require_once('skipifconnectfailure.inc');
        $link   = NULL;
 
        require('table.inc');
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 9bbc802c23b73bd0d07d823b2acf85579f3b689d..d9bdcfad3727797be1651ed16bc2705ccd13fb1b 100644 (file)
@@ -34,7 +34,7 @@ mysqli_fetch_assoc() - BIT
                return $bin;
        }
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 5106bb7e84a94946a98475b146cfa705b050429e..e9a746ec011fcfd9cd8e4cc8726e69415b3ea16d 100644 (file)
@@ -20,7 +20,7 @@ require_once('skipifconnectfailure.inc');
                printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
        require('table.inc');
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 81328e621bb55b0a038836a449b378f1b0f83d9a..f1075139e3d8224ce60d89c8a3cd402ce8e867c4 100644 (file)
@@ -20,7 +20,7 @@ require_once('skipifconnectfailure.inc');
 
        require('table.inc');
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 6c0a9a51e0a321978d44f878d28f401a5708de28..6f1cea20c4e4b115515f33d7d33eb81c215b8126 100644 (file)
@@ -7,7 +7,7 @@ require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 
 require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
 
 if (mysqli_get_server_version($link) < 50041)
@@ -101,7 +101,7 @@ mysqli_close($link);
                return array($expected_flags, $unexpected_flags, $found_flags);
        }
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        foreach ($columns as $column_def => $expected_flags) {
index d5422dccaced3e9ef9d1519b6c602302257d7f73..ef7d7622fdb701e5b71c8276c6c9e8c18d5a0bf7 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
 <?php
        include "connect.inc";
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect\n");
 
        require('table.inc');
index 552c24b11d8bdb7789cffc9ca026a38f72d49d40..10b39e2ecdfb1156771e146f7ca227764c630427 100644 (file)
@@ -19,7 +19,7 @@ require_once('skipifconnectfailure.inc');
                printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
        require('table.inc');
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 56df324251e7f0be3f1a39805c8dc595ece406f8..7e5aac928a669d2e40274ece2bb2617d1ddf348d 100644 (file)
@@ -13,7 +13,7 @@ if (!function_exists('posix_getpid'))
        die("skip POSIX functions not available");
 
 require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
        die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                $host, $user, $db, $port, $socket));
 }
@@ -68,7 +68,7 @@ if ($row[1] == "DISABLED" || $row[1] == "NO") {
                        gettype($errno), $errno, gettype($error), $error);
 
        mysqli_close($link);
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
@@ -97,7 +97,7 @@ if ($row[1] == "DISABLED" || $row[1] == "NO") {
 
                case 0:
                        /* child */
-                       if (!($plink = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) || !mysqli_autocommit($plink, true))
+                       if (!($plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) || !mysqli_autocommit($plink, true))
                                exit(mysqli_errno($plink));
 
                        $sql = sprintf("INSERT INTO messages(pid, sender, msg) VALUES (%d, 'child', '%%s')", posix_getpid());
@@ -141,7 +141,7 @@ if ($row[1] == "DISABLED" || $row[1] == "NO") {
 
                default:
                        /* parent */
-                       if (!$plink = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+                       if (!$plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                                        printf("[010] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                                        $host, $user, $db, $port, $socket);
 
@@ -221,7 +221,7 @@ if ($row[1] == "DISABLED" || $row[1] == "NO") {
        mysqli_free_result($res);
        mysqli_close($link);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[018] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
@@ -237,7 +237,7 @@ if ($row[1] == "DISABLED" || $row[1] == "NO") {
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
index 8f9fcc7f2df5227870423e67b8c0892b409e8a9c..4b0bab2406b0751778231478e56bbd5edf100986 100644 (file)
@@ -33,10 +33,15 @@ if (!function_exists('mysqli_get_cache_stats')) {
                ;
 
        $after = mysqli_get_cache_stats();
-       if ($before !== $after) {
-               printf("[004] Statistics have changed\n");
-               var_dump($before);
-               var_dump($after);
+       /* references has to be maintained - it is used for memory management */
+       $ignore = array('references' => true);
+       foreach ($before as $k => $v) {
+               if (isset($ignore[$k]))
+                       continue;
+
+               if ($before[$k] != $after[$k])
+                       printf("[004] Statistics have changed - %s: %s => %s\n", $
+                               $k, $before[$k], $after[$k]);
        }
 
        $ignore = array("size" => true, "free_items" => true, "references" => true);
index 9c1a0c6714f0c0e9c6d915fb7ce9d265a50fe91a..ed75f7bc54d0ce5305ba498d7cf8924d06a54cb9 100644 (file)
@@ -91,7 +91,7 @@ mysqlnd.collect_memory_statistics=1
 
        var_dump($info);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
                exit(1);
@@ -840,6 +840,8 @@ mysqlnd.collect_memory_statistics=1
        mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, (string)($info['buffered_sets'] + 1), $test_counter, 'mysqli_use_result()');
        $info = $new_info;
 
+       mysqli_close($link);
+
 
        /*
        no_index_used
@@ -861,7 +863,7 @@ mysqlnd.collect_memory_statistics=1
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
@@ -885,7 +887,7 @@ if (!mysqli_query($link, "DROP SERVER IF EXISTS myself"))
 mysqli_close($link);
 ?>
 --EXPECTF--
-array(119) {
+array(121) {
   [%u|b%"bytes_sent"]=>
   %unicode|string%(1) "0"
   [%u|b%"bytes_received"]=>
@@ -1031,9 +1033,9 @@ array(119) {
   [%u|b%"mem_malloc_ammount"]=>
   %unicode|string%(1) "0"
   [%u|b%"mem_calloc_count"]=>
-  %unicode|string%(1) "0"
+  %unicode|string%(%d) "%d"
   [%u|b%"mem_calloc_ammount"]=>
-  %unicode|string%(1) "0"
+  %unicode|string%(%d) "%d"
   [%u|b%"mem_realloc_count"]=>
   %unicode|string%(1) "0"
   [%u|b%"mem_realloc_ammount"]=>
@@ -1124,6 +1126,10 @@ array(119) {
   %unicode|string%(1) "0"
   [%u|b%"proto_binary_fetched_other"]=>
   %unicode|string%(1) "0"
+  [%u|b%"init_command_executed_count"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"init_command_failed_count"]=>
+  %unicode|string%(1) "0"
 }
 Testing buffered normal...
 Testing buffered normal... - SELECT id, label FROM test
index 8c2926a0b80c0da648db56a2838e1f0f5e47ee5c..698a4684ff9c90d9df35efbfdaa1bca3d05ac879 100644 (file)
@@ -47,18 +47,33 @@ if (!function_exists('mysqli_get_connection_stats')) {
                var_dump($info2);
        }
 
+       if (!is_array($info = $link->get_connection_stats()) || empty($info))
+               printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
+
+       foreach ($info as $k => &$v) {
+               if (strpos($k, "mem_") === 0) {
+                       $v = 0;
+               }
+       }
+
+       if ($info !== $info2) {
+               printf("[007] The hashes should be identical except of the memory related fields\n");
+               var_dump($info);
+               var_dump($info2);
+       }
+
        mysqli_close($link);
        include "table.inc";
 
        if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info))
-               printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
+               printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
 
        if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2))
-               printf("[007] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2);
+               printf("[009] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2);
 
        // assuming the test is run in a plain-vanilla CLI environment
        if ($info === $info2) {
-               printf("[008] The hashes should not be identical\n");
+               printf("[010] The hashes should not be identical\n");
                var_dump($info);
                var_dump($info2);
        }
index 4c5a7b71d6c4e349591e6d4c160b9c30e8134ca7..4897063c12b1c4dec92470b0cb52d48512af8f69 100644 (file)
@@ -17,7 +17,7 @@ if (!function_exists('mysqli_get_connection_stats')) {
        // connect and table inc connect to mysql and create tables
        require_once('connect.inc');
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        }
@@ -28,7 +28,7 @@ if (!function_exists('mysqli_get_connection_stats')) {
        }
 
        mysqli_close($link);
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        }
index a8b632c67ae9a717faa6ac2edfd6d17f820a9f7a..1472f297f3e645b349f39d74bfc652ed9358b6d1 100644 (file)
@@ -25,7 +25,7 @@ if (!$TEST_EXPERIMENTAL)
        if (!is_null($tmp = @mysqli_get_warnings('')))
                printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[003] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
        }
 
@@ -84,7 +84,7 @@ if (!$TEST_EXPERIMENTAL)
        mysqli_close($link);
 
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[021] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        if (!$mysqli->query("DROP TABLE IF EXISTS t1"))
@@ -103,7 +103,7 @@ if (!$TEST_EXPERIMENTAL)
                printf("[026] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
        /* Yes, I really want to check if the object property is empty */
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[027] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        $warning = new mysqli_warning($mysqli);
@@ -113,7 +113,7 @@ if (!$TEST_EXPERIMENTAL)
        if ('' != ($tmp = $warning->message))
                printf("[029] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[030] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        if (!$mysqli->query("DROP TABLE IF EXISTS t1"))
@@ -145,7 +145,7 @@ if (!$TEST_EXPERIMENTAL)
 ?>
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
index 5094b9a8d3571f47c168c98440d3949c0c3e25f3..caa7c9010353c525183bb24db7a9d981fbe6e345 100644 (file)
@@ -85,7 +85,7 @@ require_once('skipifconnectfailure.inc');
                        }
 
                        if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
-                               printf("[015] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
+                               printf("[016] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
 
                        unlink($file);
                } while (false);
index ec5060f4f6c5f9cbf47b1e275523a3d4de0b7c2e..1717b309c1ad2ba357f9982d4c32aefeb6e5b90b 100644 (file)
@@ -9,7 +9,7 @@ require_once('skipifconnectfailure.inc');
 <?php
 include "connect.inc";
 
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
     printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                         $host, $user, $db, $port, $socket);
 
@@ -91,7 +91,7 @@ echo "DONE";
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_insert_id_var"))
index 661c12dcac17122dffcf87b3c23c7cb2ace352a8..64daad88eb7f1655d4d495eac969e9f2fb2e5d16 100644 (file)
@@ -52,7 +52,7 @@ require_once('skipifconnectfailure.inc');
 
        mysqli_close($link);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[009] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        mysqli_kill($link, -1);
@@ -64,7 +64,7 @@ require_once('skipifconnectfailure.inc');
        mysqli_free_result($res);
        mysqli_close($link);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[011] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db);      mysqli_kill($link, -1);
index bf74381788b5a8768bb5c69aed5a742a694b4c3a..7f49419401d32327d4372422352e4f7cc7f9fabe 100644 (file)
@@ -20,7 +20,7 @@ mysqli.max_links=1
 
        $links = array();
        for ($i = 1; $i <= 5; $i++)
-               if ($links[$i] = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+               if ($links[$i] = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                        printf("[%03d] One link is already open, it should not be possible to open more, [%d] %s, [%d] %s\n",
                                $i, mysqli_connect_errno(), mysqli_connect_error(),
                                mysqli_errno($links[$i]), mysqli_error($links[$i]));
@@ -44,15 +44,15 @@ mysqli.max_links=1
 bool(true)
 int(1)
 
-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
 
-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
 
-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
 
-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
 
-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
 
 Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d
 
diff --git a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt
new file mode 100644 (file)
index 0000000..67a5ab6
--- /dev/null
@@ -0,0 +1,36 @@
+--TEST--
+mysqlnd.net_read_timeout limit check
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+require_once('connect.inc');
+if (!$IS_MYSQLND)
+       /* The libmysql read_timeout limit default is 365 * 24 * 3600 seconds. It cannot be altered through PHP API calls */
+       die("skip mysqlnd only test");
+?>
+--INI--
+default_socket_timeout=60
+max_execution_time=60
+mysqlnd.net_read_timeout=1
+--FILE--
+<?php
+       include ("connect.inc");
+
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+               printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+       }
+
+       if (!$res = mysqli_query($link, "SELECT SLEEP(5)"))
+               printf("[002] [%d] %s\n",  mysqli_errno($link), mysqli_error($link));
+
+       mysqli_close($link);
+
+       print "done!";
+?>
+--EXPECTF--
+Warning: mysqli_query(): MySQL server has gone away in %s on line %d
+
+Warning: mysqli_query(): Error reading result set's header in %s on line %d
+[002] [%d] %s
+done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt
new file mode 100644 (file)
index 0000000..637fd16
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+mysqlnd.net_read_timeout > default_socket_timeout
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+require_once('connect.inc');
+?>
+--INI--
+default_socket_timeout=1
+mysqlnd.net_read_timeout=12
+max_execution_time=12
+--FILE--
+<?php
+       set_time_limit(12);
+       include ("connect.inc");
+
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+               printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+       }
+
+       if (!$res = mysqli_query($link, "SELECT SLEEP(6)"))
+               printf("[002] [%d] %s\n",  mysqli_errno($link), mysqli_error($link));
+
+       var_dump($res->fetch_assoc());
+
+       mysqli_free_result($res);
+       mysqli_close($link);
+
+       print "done!";
+?>
+--EXPECTF--
+array(1) {
+  [%u|b%"SLEEP(6)"]=>
+  %unicode|string%(1) "0"
+}
+done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_zero.phpt b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_zero.phpt
new file mode 100644 (file)
index 0000000..f5a13c5
--- /dev/null
@@ -0,0 +1,36 @@
+--TEST--
+mysqlnd.net_read_timeout = 0
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+require_once('connect.inc');
+?>
+--INI--
+default_socket_timeout=10
+max_execution_time=10
+mysqlnd.net_read_timeout=0
+--FILE--
+<?php
+       include ("connect.inc");
+
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+               printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+       }
+
+       if (!$res = mysqli_query($link, "SELECT SLEEP(2)"))
+               printf("[002] [%d] %s\n",  mysqli_errno($link), mysqli_error($link));
+
+       var_dump($res->fetch_assoc());
+
+       mysqli_free_result($res);
+       mysqli_close($link);
+
+       print "done!";
+?>
+--EXPECTF--
+array(1) {
+  [%u|b%"SLEEP(2)"]=>
+  %unicode|string%(1) "0"
+}
+done!
\ No newline at end of file
index d392b5a1cf6bd2d09da551912cc456de49c405f1..aa7b1c3b51f5812ccc5299b4f003d664162759fb 100644 (file)
@@ -13,7 +13,7 @@ mysqli.reconnect=0
        require_once("connect.inc");
        require_once("table.inc");
 
-       if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot create second database connection, [%d] %s\n",
                        mysqli_connect_errno(), mysqli_connect_error());
 
@@ -73,7 +73,7 @@ mysqli.reconnect=0
                printf("[011] Executing a query should not be possible, connection should be closed, [%d] %s\n",
                        mysqli_errno($link), mysqli_error($link));
 
-       if (!$link = @mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[012] Cannot create database connection, [%d] %s\n",
                        mysqli_connect_errno(), mysqli_connect_error());
 
index 2a1e25c290010dc6f268acf5776565d10e3e9350..670f9aca750918df5dd9793609889d2a9441edcf 100644 (file)
@@ -43,7 +43,7 @@ already through other measures.
                $valid_options[] = constant('MYSQLI_OPT_INT_AND_FLOAT_NATIVE');
        if (defined('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE'))
                $valid_options[] = constant('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE');
-       
+
        $tmp    = NULL;
        $link   = NULL;
 
@@ -85,11 +85,14 @@ already through other measures.
                !($tmp = mysqli_options($link, constant('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE'), true)))
                printf("[006] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
 
-       for ($flag = -10000; $flag < 10000; $flag++) {
-               if (in_array($flag, $valid_options))
-                       continue;
-               if (FALSE !== ($tmp = mysqli_options($link, $flag, 'definetely not an mysqli_option'))) {
-                       var_dump("SOME_FLAG", $flag, $tmp);
+       if ($IS_MYSQLND) {
+               /* Don't do this with libmysql. You may hit options not exported to PHP and cause false positives */
+               for ($flag = -10000; $flag < 10000; $flag++) {
+                       if (in_array($flag, $valid_options))
+                               continue;
+                       if (FALSE !== ($tmp = mysqli_options($link, $flag, 'definetely not an mysqli_option'))) {
+                               var_dump(array("SOME_FLAG" => $flag, "ret" => $tmp));
+                       }
                }
        }
 
@@ -97,7 +100,6 @@ already through other measures.
 
        echo "Link closed";
        var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=1'));
-       var_dump("SOME_RANDOM_FLAG", mysqli_options($link, $flag, 'definetly not an mysqli_option'));
        print "done!";
 ?>
 --EXPECTF--
@@ -127,8 +129,4 @@ Link closed
 Warning: mysqli_options(): Couldn't fetch mysqli in %s line %d
 %s(19) "MYSQLI_INIT_COMMAND"
 NULL
-
-Warning: mysqli_options(): Couldn't fetch mysqli in %s line %d
-%s(16) "SOME_RANDOM_FLAG"
-NULL
 done!
index 667b581753b7ae39cac49b92b4c73c45fe338681..2ba2ce4616019c0e9795007b15fcce0e2b6510b8 100644 (file)
@@ -1,19 +1,78 @@
 --TEST--
 mysqli_options()
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
-
-die("skip - STUB - TODO - this is a stub to remind me that we should also actually test the options");
 ?>
 <?php require_once('skipifemb.inc'); ?>
 --FILE--
 <?php
        /* see mysqli.c for details */
        include "connect.inc";
+
+       if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
+               printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+                       $host, $user, $db, $port, $socket);
+
+       /* TODO: test more options */
+       if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
+               !mysqli_query($link, sprintf("CREATE TABLE test(id INT) ENGINE = %s\n", $engine)) ||
+               !mysqli_query($link, "INSERT INTO test(id) VALUES (1)"))
+               printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+       if (!$res = mysqli_query($link, "SELECT COUNT(id) AS _num_rows FROM test"))
+               printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+       $row = mysqli_fetch_assoc($res);
+       mysqli_free_result($res);
+
+       if ($row['_num_rows'] != 1)
+               printf("[003] Expecting 1 got %s\n", $row['_num_rows']);
+
+       mysqli_close($link);
+
+       $link = mysqli_init();
+       if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(id) VALUES (2)"))
+               printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+       if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+               printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+                       $host, $user, $db, $port, $socket);
+
+       if (!$res = mysqli_query($link, "SELECT COUNT(id) AS _num_rows FROM test"))
+               printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+       $row = mysqli_fetch_assoc($res);
+       mysqli_free_result($res);
+
+       if ($row['_num_rows'] != 2)
+               printf("[007] Expecting 1 got %s\n", $row['_num_rows']);
+
+       mysqli_close($link);
+
+       $link = mysqli_init();
+       if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(i_do_no_exist) VALUES (2)"))
+               printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+       mysqli_close($link);
+
+       $link = mysqli_init();
+       if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(i_do_no_exist) VALUES (2)"))
+               printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+       if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+               printf("[010] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+                       $host, $user, $db, $port, $socket);
+
        print "done!";
 ?>
+--CLEAN--
+<?php
+       require_once("clean_table.inc");
+?>
 --EXPECTF--
-done!
+Warning: mysqli_real_connect(): (%s/%d): %s in %s on line %d
+[010] Cannot connect to the server using %s
+done!
\ No newline at end of file
index d5a5bf45cabeec7cad26e73828e7e101d95bf6ab..81d8ffef64debf0710e0bac49d5a88650f8aadb9 100644 (file)
@@ -11,7 +11,7 @@ open_basedir="."
 --FILE--
 <?php
        require_once('connect.inc');
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        if (false !== mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1))
index 609361c5c151f7ffe10ea13ae370f88d8fd8b8a9..ee0efc4e53bb2254083b3c09a4727bd6e68ea1fc 100644 (file)
@@ -20,7 +20,7 @@ mysqli.max_links=2
        include "connect.inc";
 
        $host = 'p:' . $host;
-       if (!$link1 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                // automatic downgrade to normal connections has failed
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
                        $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
@@ -29,7 +29,7 @@ mysqli.max_links=2
                printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
                        mysqli_errno($link1), mysqli_error($link1));
 
-       if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                // automatic downgrade to normal connections has failed
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
                        $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
@@ -57,9 +57,9 @@ mysqli.max_links=2
        print "done!";
 ?>
 --EXPECTF--
-Warning: mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
+Warning: my_mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
 
-Warning: mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
+Warning: my_mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
 Connecction 1 - SELECT @pcondisabled -> 'Connection 1'
 Connecction 2 - SELECT @pcondisabled -> ''
 done!
\ No newline at end of file
index 01c37e309ac215223cd71b1407c63efc18c11853..297dd4cb63242eb10c0eff4fe2cf454812d79149 100755 (executable)
@@ -18,7 +18,7 @@ mysqli.max_persistent=2
        require_once("table.inc");
 
        $host = 'p:' . $host;
-       if (!$plink = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
@@ -66,7 +66,7 @@ mysqli.max_persistent=2
        // On PHP side this should do nothing. PHP should not try to close the connection or something.
        @mysqli_close($plink);
 
-       if (!$plink = @mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$plink = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[011] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        if (!$res3 = @mysqli_query($plink, 'SELECT id FROM test ORDER BY id LIMIT 1')) {
@@ -79,7 +79,7 @@ mysqli.max_persistent=2
 
        // remove the "p:<host>" from the host variable
        $host = substr($host, 2);
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[013] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        if (!$res4 = mysqli_query($link, 'SELECT id FROM test ORDER BY id LIMIT 1'))
index 13beb69fbf6cdd82b61b456ff77ae13130daf851..84cd11e59959544c577e0c8aee33ebba8db63745 100644 (file)
@@ -28,7 +28,7 @@ mysqli.max_links=-1
        mysqli_free_result($res);
        printf("Regular connection 1 - '%s'\n", $row['_desc']);
 
-       if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[002] Cannot open second regular connection, [%d] %s\n",
                        mysqli_connect_errno(), mysqli_connect_error());
 
@@ -41,7 +41,7 @@ mysqli.max_links=-1
        printf("Regular connection 2 - '%s'\n", $row['_desc']);
 
        $host = 'p:' . $host;
-       if (!$plink = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[004] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
                        $host, $user, $db, $port, $socket,
                        mysqli_connect_errno(), mysqli_connect_error());
@@ -54,7 +54,7 @@ mysqli.max_links=-1
        mysqli_free_result($res);
        printf("Persistent connection 1 - '%s'\n", $row['_desc']);
 
-       if (!$plink2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$plink2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[006] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
                        $host, $user, $db, $port, $socket,
                        mysqli_connect_errno(), mysqli_connect_error());
@@ -68,7 +68,7 @@ mysqli.max_links=-1
        printf("Persistent connection 2 - '%s'\n", $row['_desc']);
 
        $plink3 = mysqli_init();
-       if (!mysqli_real_connect($plink3, $host, $user, $passwd, $db, $port, $socket))
+       if (!my_mysqli_real_connect($plink3, $host, $user, $passwd, $db, $port, $socket))
                printf("[008] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
                        $host, $user, $db, $port, $socket,
                        mysqli_connect_errno(), mysqli_connect_error());
index a6cb0ed8d5f3034b12cebbbec88479033eb9aa91..3ccb761360f7699a5ab074bb39b65c0d10b759d2 100644 (file)
@@ -11,7 +11,7 @@ Persistent connections and mysqli.max_links
                die("skip mysqlnd only test");
 
        // we need a second DB user to test for a possible flaw in the ext/mysql[i] code
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                die(sprintf("skip Cannot connect [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
 
        mysqli_query($link, 'DROP USER pcontest');
@@ -36,7 +36,7 @@ Persistent connections and mysqli.max_links
                die("skip GRANT failed");
        }
 
-       if (!($link_pcontest = @mysqli_connect($host, 'pcontest', 'pcontest', $db, $port, $socket))) {
+       if (!($link_pcontest = @my_mysqli_connect($host, 'pcontest', 'pcontest', $db, $port, $socket))) {
                mysqli_query($link, 'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest');
                mysqli_query($link, 'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@localhost');
                mysqli_query($link, 'DROP USER pcontest@localhost');
@@ -54,7 +54,7 @@ mysqli.max_persistent=2
        require_once("connect.inc");
        require_once('table.inc');
 
-       if (!$plink = mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
+       if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
                printf("[001] Cannot connect using the second DB user created during SKIPIF, [%d] %s\n",
                        mysqli_connect_errno(), mysqli_connect_error());
 
@@ -107,7 +107,7 @@ mysqli.max_persistent=2
                printf("[009] Persistent connection has not been killed\n");
 
        // this fails and we have 0 (<= $num_plinks) connections
-       if ($plink = @mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
+       if ($plink = @my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
                printf("[010] Can connect using the old password, [%d] %s\n",
                        mysqli_connect_errno($link), mysqli_connect_error($link));
 
@@ -123,7 +123,7 @@ mysqli.max_persistent=2
        if ($num_plinks_kill > $num_plinks)
                printf("[011] Expecting Active Persistent Links < %d, got %d\n", $num_plinks, $num_plinks_kill);
 
-       if (!$plink = mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket))
+       if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket))
                printf("[012] Cannot connect using the new password, [%d] %s\n",
                        mysqli_connect_errno(), mysqli_connect_error());
 
@@ -137,7 +137,7 @@ mysqli.max_persistent=2
        mysqli_free_result($res);
        var_dump($row);
 
-       if ($plink2 = mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket))
+       if ($plink2 = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket))
                printf("[015] Can open more persistent connections than allowed, [%d] %s\n",
                        mysqli_connect_errno(), mysqli_connect_error());
 
@@ -161,7 +161,7 @@ mysqli.max_persistent=2
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
@@ -188,5 +188,5 @@ array(2) {
   %unicode|string%(1) "a"
 }
 
-Warning: mysqli_connect(): Too many open persistent links (%d) in %s on line %d
+Warning: my_mysqli_connect(): Too many open persistent links (%d) in %s on line %d
 done!
\ No newline at end of file
index c2808579ac08d77234feca3e122e8475db52e04e..8a43e7c305bec3d64c4c88ab8aad4460a9e8225b 100644 (file)
@@ -20,7 +20,7 @@ mysqli.max_links=2
        include "connect.inc";
 
        $host = 'p:' . $host;
-       if (!$link1 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
                        $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
        }
@@ -28,7 +28,7 @@ mysqli.max_links=2
                printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
                        mysqli_errno($link1), mysqli_error($link1));
 
-       if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
                        $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
        }
@@ -63,7 +63,7 @@ mysqli.max_links=2
        mysqli_close($link2);
 
        /* reuse of existing persistent connection expected! */
-       if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[008] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
                        $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
        }
index c499cffbaeb2dd8b7f12082197edded3ec2170e8..57b44ebaf2fff1b98597997947a84ba68089407c 100644 (file)
@@ -14,7 +14,7 @@ if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
        include "connect.inc";
 
        $host = 'p:' . $host;
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
@@ -23,7 +23,7 @@ if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
        $num = 20;
        $connections = array();
        for ($i = 0; $i < $num; $i++) {
-               if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+               if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                        printf("[003] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
                $connections[] = $link;
        }
@@ -39,7 +39,7 @@ if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
        $connections = array();
        $num = 20;
        for ($i = 0; $i < $num; $i++) {
-               if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+               if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                        printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
                $connections[] = $link;
        }
@@ -55,7 +55,7 @@ if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
                        unset($connections[$index]);
                } else {
                        $left--;
-                       if (!$connections[$index] = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+                       if (!$connections[$index] = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                                printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
                }
                flush();
index ff55bc29f5cad7d88e5ed831a72510af19f63309..80a2a20a2867d8b8d426fa71828c6d23acf8d77c 100644 (file)
@@ -1,9 +1,9 @@
 --TEST--
 mysqli_ping()
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
index 1bfae4bdbe95c24727a56aee8b42255f36aacffe..c691835f329c36781e0d345459fc4053b4f13f21 100644 (file)
@@ -17,7 +17,7 @@ if (!$IS_MYSQLND)
        function get_connection() {
                global $host, $user, $passwd, $db, $port, $socket;
 
-               if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+               if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                        printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
                return $link;
        }
@@ -53,14 +53,25 @@ if (!$IS_MYSQLND)
                printf("[009] Expecting int/0 got %s/%s\n", gettype($tmp), var_export($tmp, true));
 
 
-       function poll_async($offset, $links, $errors, $reject, $exp_ready) {
+       function poll_async($offset, $link, $links, $errors, $reject, $exp_ready, $use_oo_syntax) {
 
-               if ($exp_ready !== ($tmp = mysqli_poll($links, $errors, $reject, 0, 1000)))
-                       printf("[%03d + 1] There should be %d links ready to read from, %d ready\n",
-                               $exp_ready, $tmp);
+               if ($use_oo_syntax) {
+                       if ($exp_ready !== ($tmp = $link->poll($links, $errors, $reject, 0, 1000)))
+                               printf("[%03d + 1] There should be %d links ready to read from, %d ready\n",
+                                       $exp_ready, $tmp);
+               } else {
+                       if ($exp_ready !== ($tmp = mysqli_poll($links, $errors, $reject, 0, 1000)))
+                               printf("[%03d + 1] There should be %d links ready to read from, %d ready\n",
+                                       $exp_ready, $tmp);
+               }
 
                foreach ($links as $mysqli) {
-                       if (is_object($res = mysqli_reap_async_query($mysqli))) {
+                       if ($use_oo_syntax) {
+                               $res = $mysqli->reap_async_query();
+                       } else {
+                               $res = mysqli_reap_async_query($mysqli);
+                       }
+                       if (is_object($res)) {
                                printf("[%03d + 2] Can fetch resultset although no query has been run!\n", $offset);
                        } else if (mysqli_errno($mysqli) > 0) {
                                printf("[%03d + 3] Error indicated through links array: %d/%s",
@@ -85,7 +96,14 @@ if (!$IS_MYSQLND)
        $links = array($link);
        $errors = array($link);
        $reject = array($link);
-       poll_async(10, $links, $errors, $reject, 0);
+       poll_async(10, $link, $links, $errors, $reject, 0, false);
+       mysqli_close($link);
+
+       $link = get_connection();
+       $links = array($link);
+       $errors = array($link);
+       $reject = array($link);
+       poll_async(11, $link, $links, $errors, $reject, 0, true);
        mysqli_close($link);
 
        // Connections on which no query has been send - 2
@@ -94,7 +112,7 @@ if (!$IS_MYSQLND)
        $links = array($link, $link);
        $errors = array($link, $link);
        $reject = array();
-       poll_async(11, $links, $errors, $reject, 0);
+       poll_async(12, $link, $links, $errors, $reject, 0, false);
 
        // Connections on which no query has been send - 3
        // Difference: pass two connections
@@ -102,7 +120,7 @@ if (!$IS_MYSQLND)
        $links = array($link, get_connection());
        $errors = array($link, $link);
        $reject = array();
-       poll_async(12, $links, $errors, $reject, 0);
+       poll_async(13, $link, $links, $errors, $reject, 0, false);
 
        // Reference mess...
        $link = get_connection();
@@ -110,15 +128,16 @@ if (!$IS_MYSQLND)
        $errors = array($link);
        $ref_errors =& $errors;
        $reject = array();
-       poll_async(13, $links, $ref_errors, $reject, 0);
+       poll_async(14, $link, $links, $ref_errors, $reject, 0, false);
 
        print "done!";
 ?>
 --EXPECTF--
 [010 + 6] Rejecting thread %d: 0/
 [011 + 6] Rejecting thread %d: 0/
-[011 + 6] Rejecting thread %d: 0/
 [012 + 6] Rejecting thread %d: 0/
 [012 + 6] Rejecting thread %d: 0/
 [013 + 6] Rejecting thread %d: 0/
+[013 + 6] Rejecting thread %d: 0/
+[014 + 6] Rejecting thread %d: 0/
 done!
index 2b31ef7b99e9020e661aaa464af4de88db3471f5..73382b7301242d8ec939702bb633b29234f1fbc8 100644 (file)
@@ -17,7 +17,7 @@ if (!$IS_MYSQLND)
        function get_connection() {
                global $host, $user, $passwd, $db, $port, $socket;
 
-               if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+               if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                        printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
                return $link;
        }
index d95a7b41ba97c41ef59f3dc89493db9c64e440fd..56f9182f48a7c8a3c71e8057bfb0450608ae372f 100644 (file)
@@ -17,7 +17,7 @@ if (!$IS_MYSQLND)
        function get_connection() {
                global $host, $user, $passwd, $db, $port, $socket;
 
-               if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+               if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                        printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
                return $link;
        }
@@ -156,7 +156,7 @@ if (!$IS_MYSQLND)
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
index eb14e740447bbaafc70a041205ee67527bd192e5..332f871afcfac9101716950613f5a590e0ed36c1 100644 (file)
@@ -10,13 +10,12 @@ require_once('skipifconnectfailure.inc');
 if (!$IS_MYSQLND)
        die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
 
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
        die("skip cannot connect");
 
-if (mysqli_server_version($link) < 50012))
+if (mysqli_server_version($link) < 50012)
        die("skip Test needs SQL function SLEEP() available as of MySQL 5.0.12");
 
-mysqli_close($link);
 ?>
 --FILE--
 <?php
@@ -25,7 +24,7 @@ mysqli_close($link);
        function get_connection() {
                global $host, $user, $passwd, $db, $port, $socket;
 
-               if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+               if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                        printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
                return $link;
        }
index 162ca86b43172fc8eb0b55ab977305508e5c6815..0737aba83d29965f31b9ffc393044d8c479ea60f 100644 (file)
@@ -119,7 +119,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
index 33961d40861b96ec8764523361af34df348abd28..3d022f440b5fdd2160cf608695edd69c533cb4d9 100644 (file)
@@ -21,7 +21,7 @@ require_once('skipifconnectfailure.inc');
 
        mysqli_close($link);
 
-       if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+       if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
diff --git a/ext/mysqli/tests/mysqli_ps_select_union.phpt b/ext/mysqli/tests/mysqli_ps_select_union.phpt
new file mode 100644 (file)
index 0000000..fed81b3
--- /dev/null
@@ -0,0 +1,275 @@
+--TEST--
+Prepared Statements and SELECT UNION
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+       require_once("connect.inc");
+       require_once("table.inc");
+
+       // Regular (non-prepared) queries
+       print "Using CAST('somestring' AS CHAR)...\n";
+       if (!($res = $link->query("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)")))
+               printf("[001] [%d] %s\n", $link->errno, $link->error);
+
+       $data = array();
+       while ($row = $res->fetch_assoc()) {
+               $data[] = $row['column1'];
+               var_dump($row['column1']);
+       }
+       $res->free();
+
+       // Prepared Statements
+       if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)")))
+               printf("[002] [%d] %s\n", $link->errno, $link->error);
+
+       $column1 = null;
+       if (!$stmt->execute() || !$stmt->bind_result($column1))
+               printf("[003] [%d] %s\n", $stmt->errno, $stmt->error);
+
+       $index = 0;
+       while ($stmt->fetch()) {
+               if ($data[$index] != $column1) {
+                       printf("[004] Row %d, expecting %s/%s got %s/%s\n",
+                               $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+               }
+               $index++;
+       }
+       $stmt->close();
+
+       if ($IS_MYSQLND) {
+               /*
+               Advantage mysqlnd -
+               The metadata mysqlnd has availabe after prepare is better than
+               the one made availabe by the MySQL Client Library (libmysql).
+               "libmysql" will give wrong results and that is OK -
+               http://bugs.mysql.com/bug.php?id=47483
+               */
+               if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)")))
+                       printf("[005] [%d] %s\n", $link->errno, $link->error);
+
+               $column1 = null;
+               /* Note: bind_result before execute */
+               if (!$stmt->bind_result($column1) || !$stmt->execute())
+                       printf("[006] [%d] %s\n", $stmt->errno, $stmt->error);
+
+               $index = 0;
+               while ($stmt->fetch()) {
+                       if ($data[$index] != $column1) {
+                               printf("[007] Row %d, expecting %s/%s got %s/%s\n",
+                                       $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+                       }
+                       $index++;
+               }
+               $stmt->close();
+       }
+
+       // Regular (non-prepared) queries
+       print "Mixing CAST('somestring'AS CHAR), integer and CAST(integer AS CHAR)...\n";
+       if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)")))
+               printf("[008] [%d] %s\n", $link->errno, $link->error);
+
+       $data = array();
+       while ($row = $res->fetch_assoc()) {
+               $data[] = $row['column1'];
+       }
+       $res->free();
+
+       // Prepared Statements
+       if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)")))
+               printf("[009] [%d] %s\n", $link->errno, $link->error);
+
+       $column1 = null;
+       if (!$stmt->execute() || !$stmt->bind_result($column1))
+               printf("[010] [%d] %s\n", $stmt->errno, $stmt->error);
+
+       $index = 0;
+       while ($stmt->fetch()) {
+               if ($data[$index] != $column1) {
+                       printf("[011] Row %d, expecting %s/%s got %s/%s\n",
+                               $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+               }
+               var_dump($column1);
+               $index++;
+       }
+       $stmt->close();
+
+       if ($IS_MYSQLND) {
+               /* Advantage mysqlnd - see above... */
+               if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)")))
+                       printf("[012] [%d] %s\n", $link->errno, $link->error);
+
+               $column1 = null;
+               if (!$stmt->bind_result($column1) || !$stmt->execute())
+                       printf("[013] [%d] %s\n", $stmt->errno, $stmt->error);
+
+               $index = 0;
+               while ($stmt->fetch()) {
+                       if ($data[$index] != $column1) {
+                               printf("[014] Row %d, expecting %s/%s got %s/%s\n",
+                                       $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+                       }
+                       $index++;
+               }
+               $stmt->close();
+       }
+
+       print "Using integer only...\n";
+       if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2")))
+               printf("[015] [%d] %s\n", $link->errno, $link->error);
+
+       $data = array();
+       while ($row = $res->fetch_assoc()) {
+               $data[] = $row['column1'];
+       }
+       $res->free();
+
+       // Prepared Statements
+       if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2")))
+               printf("[016] [%d] %s\n", $link->errno, $link->error);
+
+       $column1 = null;
+       if (!$stmt->execute() || !$stmt->bind_result($column1))
+               printf("[017] [%d] %s\n", $stmt->errno, $stmt->error);
+
+       $index = 0;
+       while ($stmt->fetch()) {
+               if ($data[$index] != $column1) {
+                       printf("[018] Row %d, expecting %s/%s got %s/%s\n",
+                               $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+               }
+               var_dump($column1);
+               $index++;
+       }
+       $stmt->close();
+
+       if ($IS_MYSQLND) {
+               /* Advantage mysqlnd - see above */
+               if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2")))
+                       printf("[019] [%d] %s\n", $link->errno, $link->error);
+
+               $column1 = null;
+               if (!$stmt->bind_result($column1) || !$stmt->execute())
+                       printf("[020] [%d] %s\n", $stmt->errno, $stmt->error);
+
+               $index = 0;
+               while ($stmt->fetch()) {
+                       if ($data[$index] != $column1) {
+                               printf("[021] Row %d, expecting %s/%s got %s/%s\n",
+                                       $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+                       }
+                       $index++;
+               }
+               $stmt->close();
+       }
+
+       print "Testing bind_param(), strings only...\n";
+       $two = 'two';
+       $three = 'three';
+       if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?")))
+               printf("[022] [%d] %s\n", $stmt->errno, $stmt->error);
+
+       $column1 = null;
+       if (!$stmt->bind_param('ss', $three, $two) || !$stmt->execute() || !$stmt->bind_result($column1))
+               printf("[023] [%d] %s\n", $stmt->errno, $stmt->error);
+
+       $index = 0;
+       $data = array();
+       while ($stmt->fetch()) {
+               $data[$index++] = $column1;
+               var_dump($column1);
+       }
+       $stmt->close();
+
+       if ($IS_MYSQLND) {
+               /* Advantage mysqlnd - see above */
+               $two = 'two';
+               $three = 'three';
+               if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?")))
+                       printf("[024] [%d] %s\n", $stmt->errno, $stmt->error);
+
+               $column1 = null;
+               if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute())
+                       printf("[025] [%d] %s\n", $stmt->errno, $stmt->error);
+
+               $index = 0;
+               while ($stmt->fetch()) {
+                       if ($data[$index] != $column1) {
+                               printf("[26] Row %d, expecting %s/%s, got %s/%s\n",
+                                       $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+                       }
+                       $index++;
+               }
+               $stmt->close();
+       }
+
+       print "Testing bind_param(), strings only, with CAST AS CHAR...\n";
+       $two = 'two';
+       $three = 'three beers are more than enough';
+       if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)")))
+               printf("[027] [%d] %s\n", $stmt->errno, $stmt->error);
+
+       $column1 = null;
+       if (!$stmt->bind_param('ss', $three, $two) || !$stmt->execute() || !$stmt->bind_result($column1))
+               printf("[028] [%d] %s\n", $stmt->errno, $stmt->error);
+
+       $index = 0;
+       $data = array();
+       while ($stmt->fetch()) {
+               $data[$index++] = $column1;
+               var_dump($column1);
+       }
+       $stmt->close();
+
+       if ($IS_MYSQLND) {
+               /* Advantage mysqlnd - see above */
+               $two = 'two';
+               $three = 'three beers are more than enough';
+               if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)")))
+                       printf("[029] [%d] %s\n", $stmt->errno, $stmt->error);
+
+               $column1 = null;
+               if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute())
+                       printf("[030] [%d] %s\n", $stmt->errno, $stmt->error);
+
+               $index = 0;
+               while ($stmt->fetch()) {
+                       if ($data[$index] != $column1) {
+                               printf("[31] Row %d, expecting %s/%s, got %s/%s\n",
+                                       $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+                       }
+                       $index++;
+               }
+               $stmt->close();
+       }
+
+       $link->close();
+
+       print "done!";
+?>
+--EXPECTF--
+Using CAST('somestring' AS CHAR)...
+%unicode|string%(3) "one"
+%unicode|string%(5) "three"
+%unicode|string%(3) "two"
+Mixing CAST('somestring'AS CHAR), integer and CAST(integer AS CHAR)...
+%unicode|string%(1) "1"
+%unicode|string%(5) "three"
+%unicode|string%(1) "2"
+Using integer only...
+int(1)
+int(303)
+int(2)
+Testing bind_param(), strings only...
+%unicode|string%(3) "one"
+%unicode|string%(5) "three"
+%unicode|string%(3) "two"
+Testing bind_param(), strings only, with CAST AS CHAR...
+%unicode|string%(3) "one"
+%unicode|string%(32) "three beers are more than enough"
+%unicode|string%(3) "two"
+done!
index 973a447e13d09fc2d2c6fa55ffd85e69d1814d89..0e45f03882e47effde60b1346d037e8978aa3818 100644 (file)
@@ -115,7 +115,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
index 723013f552c5735f9da3082c7c50bffffe8685b1..306dfceab637771d84f24eaa934e425c66f4955a 100644 (file)
@@ -5,6 +5,8 @@ mysql_query(LOAD DATA LOCAL INFILE) with large data set (10MB)
 require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 ?>
+--INI--
+mysqli.allow_local_infile=1
 --FILE--
 <?php
        // Create a large CVS file
@@ -30,7 +32,7 @@ require_once('skipifconnectfailure.inc');
        printf("Filesize in bytes: %d\nRows: %d\n", $bytes, $rowno);
 
        include "connect.inc";
-       if (!($link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
+       if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
                printf("[002] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
@@ -40,18 +42,22 @@ require_once('skipifconnectfailure.inc');
        if (!mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';'", mysqli_real_escape_string($link, $file))))
                printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
+       if ((!is_string(mysqli_info($link))) || ('' == mysqli_info($link))) {
+               printf("[005] [%d] %s, mysqli_info not set \n", mysqli_errno($link), mysqli_error($link));
+       }
+
        if (!($res = mysqli_query($link, "SELECT COUNT(*) AS _num FROM test")))
-               printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+               printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
        $row = mysqli_fetch_assoc($res);
        if (($row["_num"] != $rowno))
-               printf("[006] Expecting %d rows, found %d\n", $rowno, $row["_num"]);
+               printf("[007] Expecting %d rows, found %d\n", $rowno, $row["_num"]);
 
        mysqli_free_result($res);
 
        $random = mt_rand(1, $rowno);
        if (!$res = mysqli_query($link, "SELECT id, col1, col2 FROM test WHERE id = " . $random))
-                       printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+                       printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
        $row = mysqli_fetch_assoc($res);
        var_dump($row);
@@ -67,7 +73,7 @@ if (file_exists($file))
        unlink($file);
 
 include "connect.inc";
-if (!($link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
+if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
        printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
index 1dda1dc205e148d8674a34dd3379ef8b95d2f0f6..0ca71a40b5d693907d21976d3d3f13fff1ceca92 100644 (file)
@@ -5,7 +5,7 @@ mysqli_query() - Stored Procedures
 require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
        die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
 }
 if (mysqli_get_server_version($link) <= 50000) {
@@ -153,7 +153,7 @@ END;')) {
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
index effae2bc24957046b1eb7fa3a163f2ed1be00626..5e474d6d2f304416db29bf4dda42b9ddcfaa5d4e 100644 (file)
@@ -161,12 +161,13 @@ require_once('skipifconnectfailure.inc');
                        printf("[025] Usage of mysqli.default_host=p: did not fail\n") ;
                        mysqli_close($link);
                }
+               @mysqli_close($link);
        }
 
        @var_dump($link);
 
-       if (NULL === ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
-               printf("[026] Expecting not NULL, got %s/%s\n", gettype($tmp), $tmp);
+       if (NULL !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
+               printf("[026] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
        print "done!";
 ?>
@@ -180,17 +181,17 @@ object(mysqli)#%d (%d) {
   [%u|b%"affected_rows"]=>
   NULL
   [%u|b%"client_info"]=>
-  %unicode|string%(%d) "%s"
+  %s
   [%u|b%"client_version"]=>
   int(%d)
   [%u|b%"connect_errno"]=>
   int(%d)
   [%u|b%"connect_error"]=>
-  %unicode|string%(%d) "%s"
+  %unicode|string%(%d) "%s
   [%u|b%"errno"]=>
-  int(%d)
+  %s
   [%u|b%"error"]=>
-  %unicode|string%(%d) "%s"
+  %s
   [%u|b%"field_count"]=>
   NULL
   [%u|b%"host_info"]=>
@@ -212,4 +213,6 @@ object(mysqli)#%d (%d) {
   [%u|b%"warning_count"]=>
   NULL
 }
-done!
+
+Warning: mysqli_real_connect(): Couldn't fetch mysqli in %s on line %d
+done!
\ No newline at end of file
index 68cffc3b2b1b47cbf9c24b52d653f64d7b240752..7f05a20d2f5e708cebf61606192130cbae7c3823 100644 (file)
@@ -15,7 +15,7 @@ mysqli.reconnect=1
        require_once("connect.inc");
        require_once("table.inc");
 
-       if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot create second database connection, [%d] %s\n",
                        mysqli_connect_errno(), mysqli_connect_error());
 
index 525921f4c3dfbaf9e493265f6f6e7eae95a7ba3d..dc927997f388474d32d5bcaf449d492b098d6a89 100644 (file)
@@ -85,7 +85,7 @@ require_once('skipifconnectfailure.inc');
        mysqli_close($link);
 
        /* mysqli_stmt_execute() = mysql_stmt_execute cannot be tested from PHP */
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                        printf("[008] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
        $stmt = mysqli_stmt_init($link);
        mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
@@ -105,7 +105,7 @@ require_once('skipifconnectfailure.inc');
        // Check
        mysqli_report(MYSQLI_REPORT_OFF);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[010] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
        $stmt = mysqli_stmt_init($link);
        mysqli_stmt_prepare($stmt, "FOO");
@@ -118,7 +118,7 @@ require_once('skipifconnectfailure.inc');
        mysqli_stmt_close($stmt);
        mysqli_close($link);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[011] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
        $stmt = mysqli_stmt_init($link);
        mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
@@ -139,8 +139,8 @@ require_once('skipifconnectfailure.inc');
                        already tested
 
        php_mysqli_throw_sql_exception() ->
-               mysqli_real_connect()
-               mysqli_connect()
+               my_mysqli_real_connect()
+               my_mysqli_connect()
 
        can't be tested: mysqli_query() via mysql_use_result()/mysql_store_result()
        */
@@ -149,7 +149,7 @@ require_once('skipifconnectfailure.inc');
 
        try {
 
-               if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+               if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
                        printf("[012] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
                                $host, $user . 'unknown_really', $db, $port, $socket);
                mysqli_close($link);
@@ -162,7 +162,7 @@ require_once('skipifconnectfailure.inc');
                if (!$link = mysqli_init())
                        printf("[014] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
-               if ($link = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+               if ($link = my_mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
                        printf("[015] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
                                $host, $user . 'unknown_really', $db, $port, $socket);
                mysqli_close($link);
@@ -191,7 +191,7 @@ require_once('skipifconnectfailure.inc');
        mysqli_report(MYSQLI_REPORT_OFF);
        mysqli_report(MYSQLI_REPORT_INDEX);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        // this might cause a warning - no index used
@@ -235,7 +235,7 @@ require_once('skipifconnectfailure.inc');
        // mysqli_use_result(), mysqli_thread_safe(), mysqli_thread_id()
        mysqli_report(MYSQLI_REPORT_OFF);
        mysqli_close($link);
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[024] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        if (!$stmt = mysqli_stmt_init($link))
index f4b8fd9c17ca6c327b13e051363df8865d8c41c5..08909264a7a7d7746c81d0721e8f8903e4246b5b 100644 (file)
@@ -69,7 +69,7 @@ require_once('skipifconnectfailure.inc');
 
        try {
 
-               if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+               if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
                        printf("[010] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
                                $host, $user . 'unknown_really', $db, $port, $socket);
                mysqli_close($link);
@@ -82,7 +82,7 @@ require_once('skipifconnectfailure.inc');
                if (!$link = mysqli_init())
                        printf("[012] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
-               if ($link = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+               if ($link = my_mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
                        printf("[013] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
                                $host, $user . 'unknown_really', $db, $port, $socket);
                mysqli_close($link);
index ea1f276b1ac6de2bb4f6f93ff96f1b4e7a7cae74..b6bce0d9819ddf5d616b5575dcc6d4826959d689 100644 (file)
@@ -39,7 +39,7 @@ require_once('skipifconnectfailure.inc');
 
        mysqli_free_result($res);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 07dac9ba8cfd71139bd7d4e7246cb5ceb542fa30..384f85fbbd67fd4765640fa318f685d927451245 100644 (file)
@@ -9,6 +9,9 @@ require_once('skipifconnectfailure.inc');
 require_once('connect.inc');
 if (!$IS_MYSQLND)
        die("skip Test for mysqlnd only");
+
+if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1))
+       die("skip (TODO) PHP 6.0 has a difference debug_zval_dump output format");
 ?>
 <?php require_once('skipifemb.inc'); ?>
 --FILE--
@@ -30,6 +33,8 @@ if (!$IS_MYSQLND)
                $references[$idx]['id_ref']             = &$row['id'];
                $references[$idx++]['id_copy']  = $row['id'];
        }
+
+       debug_zval_dump($references);
        mysqli_free_result($res);
 
        if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) ||
@@ -52,7 +57,7 @@ if (!$IS_MYSQLND)
        print "done!";
 ?>
 --EXPECTF--
-array(2) refcount(2){
+array(1) refcount(2){
   [0]=>
   array(4) refcount(1){
     [%u|b%"row_ref"]=>
@@ -69,6 +74,24 @@ array(2) refcount(2){
     [%u|b%"id_copy"]=>
     %unicode|string%(1) "1" refcount(1)
   }
+}
+array(2) refcount(2){
+  [0]=>
+  array(4) refcount(1){
+    [%u|b%"row_ref"]=>
+    &NULL refcount(2)
+    [%u|b%"row_copy"]=>
+    array(2) refcount(1){
+      [%u|b%"id"]=>
+      %unicode|string%(1) "1" refcount(1)
+      [%u|b%"label"]=>
+      %unicode|string%(1) "a" refcount(1)
+    }
+    [%u|b%"id_ref"]=>
+    %unicode|string%(1) "1" refcount(1)
+    [%u|b%"id_copy"]=>
+    %unicode|string%(1) "1" refcount(1)
+  }
   [1]=>
   array(5) refcount(1){
     [%u|b%"row_ref"]=>
@@ -76,14 +99,14 @@ array(2) refcount(2){
       [%u|b%"id"]=>
       &%unicode|string%(1) "2" refcount(2)
       [%u|b%"label"]=>
-      %unicode|string%(1) "b" refcount(3)
+      %unicode|string%(1) "b" refcount(2)
     }
     [%u|b%"row_copy"]=>
     array(2) refcount(1){
       [%u|b%"id"]=>
-      %unicode|string%(1) "2" refcount(2)
+      %unicode|string%(1) "2" refcount(1)
       [%u|b%"label"]=>
-      %unicode|string%(1) "b" refcount(3)
+      %unicode|string%(1) "b" refcount(2)
     }
     [%u|b%"id_ref"]=>
     &%unicode|string%(1) "2" refcount(2)
index 93cf66321959c30cc6960ff832c6e7bec10f12d3..dfde9a78c5e83511886c75fcf8c0d56971531d78 100644 (file)
@@ -1,16 +1,16 @@
 --TEST--
 Trying to clone mysqli_result object
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
 <?php
        include "connect.inc";
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index cadf92c10736f5ff8001b9efe7899b1bcd200996..616f50da84eda7d974663acf2a2dbbcec0542778 100644 (file)
@@ -10,7 +10,7 @@ mysqli_rollback()
 
        require_once('connect.inc');
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket));
        }
@@ -40,7 +40,7 @@ mysqli_rollback()
        if (!is_null($tmp = @mysqli_rollback($link)))
                printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index c121d66504d4b18433aa4ba5f28883ca5aea442c..bc774cfec958e0ecf93a2bf4006f0b12ce95d982 100644 (file)
@@ -1,9 +1,9 @@
 --TEST--
 mysqli_select_db()
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -19,7 +19,7 @@ require_once('skipifconnectfailure.inc');
        if (!is_null($tmp = @mysqli_select_db($link)))
                printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index ccddfd2339ab05a948f6201cd8e8f57bbfe36166..53cf25093ec0e7980f0181496cf5b45dc1a5aa46 100755 (executable)
@@ -26,7 +26,7 @@ if (!$TEST_EXPERIMENTAL)
        if (NULL !== ($tmp = @mysqli_send_query($link)))
                printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        }
index 27ec10f209da0d1d899270145a06091d0146ac84..baf97bd3d33829dd07fb923de234fc016393d6c8 100644 (file)
@@ -14,7 +14,7 @@ if (!function_exists('mysqli_set_charset'))
        die("skip Function not available");
 
 require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
        die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
 
 if (!($res = mysqli_query($link, 'SELECT version() AS server_version')) ||
@@ -84,7 +84,7 @@ if ((($res = mysqli_query($link, 'SHOW CHARACTER SET LIKE "latin1"', MYSQLI_STOR
                printf("[011] Expecting boolean/false because of invalid character set, got %s/%s\n", gettype($ret), $ret);
 
        mysqli_close($link);
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[012] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 929587dafa5387fe246485102b25c6a96525fc68..5cb1459d852ab7056335e4adfc3017217878c770 100644 (file)
@@ -10,7 +10,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
        die("skip - function not available.");
 
 require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index ddcfdc8b87f747829f8e8d74c0ad31c6d02a4450..ec097fe2b65f57e27d6becc53f40b05b77b62de0 100644 (file)
@@ -13,7 +13,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
 if (!$TEST_EXPERIMENTAL)
     die("skip - experimental (= unsupported) feature");
 
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index bcc60d772106c3f8078f1b847e3420db9969f5a5..03f4288825ee2499d8cec94441310fd9a5fcbf95 100644 (file)
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
        die("skip - experimental (= unsupported) feature");
 
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index 8f06630e5ce25bcc82a7a9035f853cd16c16c6ca..cb8162db70c309ac2559c1472e02273e957ef18e 100644 (file)
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
        die("skip - experimental (= unsupported) feature");
 
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index 71d768f2907bf5f7f92edbbe18399f8192b4bd0b..7498e64f435f78a80d635dda49f172e37900a0b1 100644 (file)
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
        die("skip - experimental (= unsupported) feature");
 
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index 1732a1c9d1990f0e060a3ce9964157207dcf3eb2..7e24458890947ec46b95b1beede816cab80e3374 100755 (executable)
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
        die("skip - experimental (= unsupported) feature");
 
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index 1aa2878dd3220c7cec94f0be5003b46355f9265e..3757b61d95541e25f6e4f48c1ca64531fd29dfad 100644 (file)
@@ -10,7 +10,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
        die("skip - function not available.");
 
 require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index eb39a917350673d468d6ee4c253671120e9129b5..30a3bcc0358a4f9258b69734a488784dc904c273 100644 (file)
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
        die("skip - experimental (= unsupported) feature");
 
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index d822e0a52b4a5ba1375e81e7ec9c2a64eb40e992..465dcdb9d6178543b0da470f56f5aa039ceda9b8 100644 (file)
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
        die("skip - experimental (= unsupported) feature");
 
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index 464519d0f8146d04e7b2b025e353d39fe50a38db..5ea82e93f255ffbc1ea70362850279e61bcc99f6 100644 (file)
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
        die("skip - experimental (= unsupported) feature");
 
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index 3912f527880e44c6f5953aa32e4cd5629b901ba0..6354630c08c0d8a3c5aeaf8d4ebd71020cfff56f 100644 (file)
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
        die("skip - experimental (= unsupported) feature");
 
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index 1d75d5ae82ecc637788cf23b9d2cb703e5a1a5d5..c30f6ea9163c8fe518672ff2eeeb788022a907a7 100644 (file)
@@ -10,7 +10,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
        die("skip - function not available.");
 
 require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index caee2be4295369f051ff537a4cdb9c19f1b571ba..cde8f4b1296f0bc4a41e99e0b08faf089c574d95 100644 (file)
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
        die("skip - experimental (= unsupported) feature");
 
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index 7d781d6c9e20fe59fe89777edf655ff502c5e7e6..a793ac662391b9b7c55dc4602b9bc79d06f1e2ab 100644 (file)
@@ -13,7 +13,7 @@ require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
        die("skip - experimental (= unsupported) feature");
 
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index 38b3c00bef6f124c3127304b5cc6d7a46daeee89..c89fc2152c41358203455df007d84155ccd24cda 100644 (file)
@@ -10,7 +10,7 @@ if (!function_exists('mysqli_set_local_infile_handler'))
        die("skip - function not available.");
 
 require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
        die("skip Cannot connect to MySQL");
 
 if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
index d5c41827c3177779cc45e4dd324594058ef39204..21aacd25ff0d1e3ed4babf087b8254ece40b373b 100644 (file)
@@ -1,9 +1,9 @@
 --TEST--
 mysqli_set_opt()
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
 --FILE--
@@ -36,7 +36,7 @@ require_once('skipifconnectfailure.inc');
        var_dump(mysqli_set_opt($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10));
        var_dump(mysqli_set_opt($link, MYSQLI_OPT_LOCAL_INFILE, 1));
        var_dump(mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0'));
-       var_dump(mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket));
+       var_dump(my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket));
        var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf'));
        var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf'));
        var_dump(mysqli_set_opt($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10));
index c53cdf138488c7d85322454870574bda6bc738cd..e868f34f190d7d2262cd3b6af60afd3f9a473f56 100644 (file)
@@ -1,9 +1,9 @@
 --TEST--
 mysqli_ssl_set() - test is a stub!
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
+require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 if (!function_exists('mysqli_ssl_set'))
        die("skip function not available");
@@ -47,12 +47,12 @@ if (!function_exists('mysqli_ssl_set'))
                printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
 
 
-       If SSL setup is incorrect mysqli_real_connect()
+       If SSL setup is incorrect my_mysqli_real_connect()
        will return an error when you attempt to connect.
 
        ... and the above SSL setup should be always incorrect.
 
-       if (false !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
+       if (false !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
                printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
        */
        print "done!\n";
index 07d565dafe15eee68203930d4d8587d6accdd2dc..d4761dd6b83d551a7042c8e99fa82ed3b97a2ef3 100644 (file)
@@ -19,7 +19,7 @@ require_once('skipifconnectfailure.inc');
        if (!is_null($tmp = @mysqli_stmt_affected_rows($link)))
                printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
        }
index 810f19fdaaa2dd0cfd1aeb0303e0e2d098002161..7bc9882f8a412c87601fe2d8b5a1e1067d8c0688 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-mysqli_stmt_attr_set() - KNOWN ISSUE: mysqlnd does not check for invalid codes
+mysqli_stmt_attr_set() - mysqlnd does not check for invalid codes
 --SKIPIF--
 <?php
 require_once('skipif.inc');
@@ -50,16 +50,19 @@ require_once('skipifconnectfailure.inc');
                if (in_array($i, $valid_attr))
                        continue;
                $invalid_attr = $i;
-               if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0)))
+               if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) {
                        printf("[006a] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp);
+               }
        }
 
        for ($i = 0; $i < 10; $i++) {
                do {
-                       $invalid_attr = mt_rand(-1 * PHP_INT_MAX + 1, PHP_INT_MAX);
+                       $invalid_attr = mt_rand(-1 * (min(4294967296, PHP_INT_MAX) + 1), min(4294967296, PHP_INT_MAX));
                } while (in_array($invalid_attr, $valid_attr));
-               if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0)))
-                       printf("[006b] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp);
+               if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) {
+                       /* Although it may be desired to get false neither the MySQL Client Library nor mysqlnd are supposed to detect invalid codes */
+                       printf("[006b] Expecting boolean/true for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp);
+               }
        }
        $stmt->close();
 
@@ -264,4 +267,4 @@ require_once('skipifconnectfailure.inc');
        require_once("clean_table.inc");
 ?>
 --EXPECTF--
-done!
\ No newline at end of file
+done!
index 07a0ff34d6b7a272411194620c5bf924c54d37db..24d4314f1f8320e8590572e74332063ab0fe8023 100644 (file)
@@ -151,12 +151,13 @@ require_once('skipifconnectfailure.inc');
                printf("[025] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        findRow(26, $link, $id_ref_ref, $label_ref_ref);
 
+       unset($id);
+       unset($label);
        $id = 102;
        $label = new stdClass();
        $label->label = 'y';
        $id_ref = &$GLOBALS['id'];
        $label_ref = &$label->label;
-
        if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref, $label_ref)))
                printf("[027] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
        if (true !== @mysqli_stmt_execute($stmt))
index 00750ee7d450e442284d3a3a71225bd23856b51e..f5756740e03b12a879edce1ea38b61625cf34544 100644 (file)
@@ -282,8 +282,12 @@ require_once('skipifconnectfailure.inc');
        func_mysqli_stmt_bind_result($link, $engine, "b", "MEDIUMTEXT", "", 1640, $hint_str_or_unicode);
 
        /* Is this one related? http://bugs.php.net/bug.php?id=35759 */
-       func_mysqli_stmt_bind_result($link, $engine, "b", "LONGBLOB", "", 1660);
-       func_mysqli_stmt_bind_result($link, $engine, "b", "LONGTEXT", "", 1680, $hint_str_or_unicode);
+       if (($IS_MYSQLND) || (!$IS_MYSQLND && (ini_get('memory_limit') > 4294967296))) {
+               /* NOTE: the MySQL Client Library - not mysqlnd - will allocate
+               a hugge max_length(type) = 4GB bind buffer */
+               func_mysqli_stmt_bind_result($link, $engine, "b", "LONGBLOB", "", 1660);
+               func_mysqli_stmt_bind_result($link, $engine, "b", "LONGTEXT", "", 1680, $hint_str_or_unicode);
+       }
 
        func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", "a", 1700, $hint_str_or_unicode);
        func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", NULL, 1720, $hint_str_or_unicode);
index bb8e87ffb5b0ad2f224df76bdc98c5129d1c3fd1..1eef7674781cc803619628f2209d003e50686b2d 100644 (file)
@@ -25,11 +25,11 @@ require_once('skipifconnectfailure.inc');
                return $bin;
        }
 
-       if (!$link_ins = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link_ins = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
-       if (!$link_sel = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link_sel = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 6fcbcd31b19e6c9ae5e310e47d7e24f3b5b0e291..dee5a7e0f0fa6cca514c1cf8f2ad3ecaa5a28ab0 100644 (file)
@@ -138,7 +138,7 @@ memory_limit=83886080
                return true;
        }
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect - [%d] %s\n",
                        mysqli_connect_errno(),
                        mysqli_connect_error());
index 3418f68e03e6004044477929567e7edfa3ba588d..25c183a2a1da1c14e64218e0e766fe78b50ed7c0 100644 (file)
@@ -9,12 +9,12 @@ require_once('skipifconnectfailure.inc');
 --FILE--
 <?php
        include "connect.inc";
-       if (!$c1 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$c1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
                exit(1);
        }
-       if (!$c2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+       if (!$c2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
                printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
                exit(1);
@@ -57,7 +57,7 @@ require_once('skipifconnectfailure.inc');
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS type_change"))
index 19c228d210f1d4d0958108357acaaec905469085..afedea42df0479a599af9c8ca453ca016b6edfda 100644 (file)
@@ -5,7 +5,7 @@ mysqli_stmt_execute() - Stored Procedures
 require_once('skipif.inc');
 require_once('skipifconnectfailure.inc');
 require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
        die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
 }
 if (mysqli_get_server_version($link) <= 50000) {
@@ -184,7 +184,7 @@ if (mysqli_get_server_version($link) <= 50000) {
 --CLEAN--
 <?php
 include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
 if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
index 980deee2b1b3f8e4502be9ba67b887d83c35f2a5..2a2914ad88b9b744bbe9f7df8cd66a52ce1b4c1b 100644 (file)
@@ -18,11 +18,12 @@ Fetching BIT column values using the PS API
 <?php
        require('connect.inc');
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
-       for ($bits = 1; $bits < 64; $bits++) {
+       /* NOTE: works only for up to 31 bits! This limitation should be documented. */
+       for ($bits = 1; $bits < 32; $bits++) {
                $max_value = pow(2, $bits) - 1;
                $tests = 0;
                if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
diff --git a/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt b/ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt
new file mode 100644 (file)
index 0000000..84998b9
--- /dev/null
@@ -0,0 +1,141 @@
+--TEST--
+mysqli_stmt_fetch - geometry / spatial types
+--SKIPIF--
+<?php
+       require_once('skipif.inc');
+       require_once('skipifemb.inc');
+       require_once('skipifconnectfailure.inc');
+
+       if (!defined("MYSQLI_TYPE_GEOMETRY"))
+               die("skip MYSQLI_TYPE_GEOMETRY not defined");
+?>
+--FILE--
+<?php
+       require('connect.inc');
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+               printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+
+       function func_mysqli_stmt_fetch_geom($link, $engine, $sql_type, $bind_value, $offset) {
+
+               if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+                       printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+                       return false;
+               }
+
+               if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
+                       // don't bail - column type might not be supported by the server, ignore this
+                       return false;
+               }
+
+               for ($id = 1; $id < 4; $id++) {
+                       $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, %s)", $id, $bind_value);
+                       if (!mysqli_query($link, $sql)) {
+                               printf("[%04d] [%d] %s\n", $offset + 2 + $id, mysqli_errno($link), mysqli_error($link));
+                       }
+               }
+
+               if (!$stmt = mysqli_stmt_init($link)) {
+                       printf("[%04d] [%d] %s\n", $offset + 6, mysqli_errno($link), mysqli_error($link));
+                       return false;
+               }
+
+               if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) {
+                       printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                       mysqli_stmt_close($stmt);
+                       return false;
+               }
+
+               if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_store_result($stmt)) {
+                       printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                       mysqli_stmt_close($stmt);
+                       return false;
+               }
+
+               if (!mysqli_stmt_bind_result($stmt, $id, $bind_res)) {
+                       printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                       mysqli_stmt_close($stmt);
+                       return false;
+               }
+
+               $result = mysqli_stmt_result_metadata($stmt);
+               $fields = mysqli_fetch_fields($result);
+               if ($fields[1]->type != MYSQLI_TYPE_GEOMETRY) {
+                       printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type);
+               }
+
+               $num = 0;
+               $rows = array();
+               while (true === @mysqli_stmt_fetch($stmt)) {
+                       $rows[] = array('id' => $id, 'label' => $bind_res);
+                       $num++;
+               }
+
+               if ($num != 3) {
+                       printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n",
+                               $offset + 17, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num);
+                       return false;
+               }
+               mysqli_stmt_close($stmt);
+
+               foreach ($rows as $row) {
+                       if (!$stmt = mysqli_stmt_init($link)) {
+                               printf("[%04d] [%d] %s\n", $offset + 10, mysqli_errno($link), mysqli_error($link));
+                               return false;
+                       }
+
+                       if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) {
+                               printf("[%04d] [%d] %s\n", $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                               return false;
+                       }
+
+                       $new_id = $row['id'] + 10;
+                       if (!mysqli_stmt_bind_param($stmt, "is", $new_id, $row['label'])) {
+                               printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                               return false;
+                       }
+
+                       if (!mysqli_stmt_execute($stmt)) {
+                               printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                               return false;
+                       }
+                       mysqli_stmt_close($stmt);
+
+                       if (!$res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test WHERE id = %d",
+                                       $new_id))) {
+                               printf("[%04d] [%d] %s\n", $offset + 14, mysqli_errno($link), mysqli_error($link));
+                               return false;
+                       }
+
+                       if (!$row_normal = mysqli_fetch_assoc($res_normal)) {
+                               printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link));
+                               return false;
+                       }
+
+                       if ($row_normal['label'] != $row['label']) {
+                               printf("[%04d] PS and non-PS return different data.\n", $offset + 16);
+                               return false;
+                       }
+                       mysqli_free_result($res_normal);
+               }
+
+               return true;
+       }
+
+       func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRY", "GeomFromText('POINT(2 2)')", 20);
+       func_mysqli_stmt_fetch_geom($link, $engine, "POINT", "GeomFromText('POINT(1 1)')", 40);
+       func_mysqli_stmt_fetch_geom($link, $engine, "LINESTRING", "GeomFromText('LINESTRING(0 0,1 1,2 2)')", 60);
+       func_mysqli_stmt_fetch_geom($link, $engine, "POLYGON", "GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80);
+       func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOINT", "GeomFromText('MULTIPOINT(1 1, 2 2)')", 100);
+       func_mysqli_stmt_fetch_geom($link, $engine, "MULTILINESTRING", "GeomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120);
+       func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOLYGON", "GeomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140);
+       func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRYCOLLECTION", "GeomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160);
+
+       mysqli_close($link);
+       print "done!";
+?>
+--CLEAN--
+<?php
+       require_once("clean_table.inc");
+?>
+--EXPECTF--
+done!
\ No newline at end of file
index b4bb34a6750acf2e1691380abb01515e7a6d162c..6c476f7e9d36350d8e16d56b52914990f1e11e3e 100644 (file)
@@ -37,7 +37,7 @@ Fetching BIT column values using the PS API
                return $bin;
        }
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_geom.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_geom.phpt
new file mode 100644 (file)
index 0000000..c86a385
--- /dev/null
@@ -0,0 +1,143 @@
+--TEST--
+mysqli_stmt_get_result - geometry / spatial types
+--SKIPIF--
+<?php
+       require_once('skipif.inc');
+       require_once('skipifemb.inc');
+       require_once('skipifconnectfailure.inc');
+
+       if (!function_exists('mysqli_stmt_get_result'))
+               die("skip mysqli_stmt_get_result() not available");
+
+       if (!defined("MYSQLI_TYPE_GEOMETRY"))
+               die("skip MYSQLI_TYPE_GEOMETRY not defined");
+?>
+--FILE--
+<?php
+       require('connect.inc');
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+               printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+
+       function func_mysqli_stmt_get_result_geom($link, $engine, $sql_type, $bind_value, $offset) {
+
+               if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+                       printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+                       return false;
+               }
+
+               if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
+                       // don't bail - column type might not be supported by the server, ignore this
+                       return false;
+               }
+
+               for ($id = 1; $id < 4; $id++) {
+                       $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, %s)", $id, $bind_value);
+                       if (!mysqli_query($link, $sql)) {
+                               printf("[%04d] [%d] %s\n", $offset + 2 + $id, mysqli_errno($link), mysqli_error($link));
+                       }
+               }
+
+               if (!$stmt = mysqli_stmt_init($link)) {
+                       printf("[%04d] [%d] %s\n", $offset + 6, mysqli_errno($link), mysqli_error($link));
+                       return false;
+               }
+
+               if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) {
+                       printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                       mysqli_stmt_close($stmt);
+                       return false;
+               }
+
+               if (!mysqli_stmt_execute($stmt)) {
+                       printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                       mysqli_stmt_close($stmt);
+                       return false;
+               }
+               if (!$res = mysqli_stmt_get_result($stmt)) {
+                       printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+                       mysqli_stmt_close($stmt);
+                       return false;
+               }
+
+               $result = mysqli_stmt_result_metadata($stmt);
+               $fields = mysqli_fetch_fields($result);
+               if ($fields[1]->type != MYSQLI_TYPE_GEOMETRY) {
+                       printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type);
+               }
+
+               $num = 0;
+               while ($row = mysqli_fetch_assoc($res)) {
+                       $bind_res = &$row['label'];
+
+                       if (!$stmt2 = mysqli_stmt_init($link)) {
+                               printf("[%04d] [%d] %s\n", $offset + 11, mysqli_errno($link), mysqli_error($link));
+                               return false;
+                       }
+
+                       if (!mysqli_stmt_prepare($stmt2, "INSERT INTO test(id, label) VALUES (?, ?)")) {
+                               printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
+                               return false;
+                       }
+
+                       $id = $row['id'] + 10;
+                       if (!mysqli_stmt_bind_param($stmt2, "is", $id, $bind_res)) {
+                               printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
+                               return false;
+                       }
+
+                       if (!mysqli_stmt_execute($stmt2)) {
+                               printf("[%04d] [%d] %s\n", $offset + 14, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
+                               return false;
+                       }
+                       mysqli_stmt_close($stmt2);
+
+                       if (!$res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test WHERE id = %d",
+                                       $row['id'] + 10))) {
+                               printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link));
+                               return false;
+                       }
+
+                       if (!$row_normal = mysqli_fetch_assoc($res_normal)) {
+                               printf("[%04d] [%d] %s\n", $offset + 16, mysqli_errno($link), mysqli_error($link));
+                               return false;
+                       }
+
+                       if ($row_normal['label'] != $bind_res) {
+                               printf("[%04d] PS and non-PS return different data.\n", $offset + 17);
+                               return false;
+                       }
+                       mysqli_free_result($res_normal);
+                       $num++;
+               }
+
+               if ($num != 3) {
+                       printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n",
+                               $offset + 18, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num);
+                       mysqli_free_result($res);
+                       mysqli_stmt_close($stmt);
+                       return false;
+               }
+               mysqli_free_result($res);
+               mysqli_stmt_close($stmt);
+
+               return true;
+       }
+
+       func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRY", "GeomFromText('POINT(2 2)')", 20);
+       func_mysqli_stmt_get_result_geom($link, $engine, "POINT", "GeomFromText('POINT(1 1)')", 40);
+       func_mysqli_stmt_get_result_geom($link, $engine, "LINESTRING", "GeomFromText('LINESTRING(0 0,1 1,2 2)')", 60);
+       func_mysqli_stmt_get_result_geom($link, $engine, "POLYGON", "GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80);
+       func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOINT", "GeomFromText('MULTIPOINT(1 1, 2 2)')", 100);
+       func_mysqli_stmt_get_result_geom($link, $engine, "MULTILINESTRING", "GeomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120);
+       func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOLYGON", "GeomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140);
+       func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRYCOLLECTION", "GeomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160);
+
+       mysqli_close($link);
+       print "done!";
+?>
+--CLEAN--
+<?php
+       require_once("clean_table.inc");
+?>
+--EXPECTF--
+done!
\ No newline at end of file
index 50bcf6503f59d33853fbe49ef8ebe00fae6caaf4..724a32a7871df5b7adbd2d92ece539875dd3ee88 100644 (file)
@@ -12,7 +12,7 @@ mysqli_stmt_get_result - data types
 --FILE--
 <?php
        require('connect.inc');
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        $hint_str_or_unicode = (version_compare(PHP_VERSION, '5.9.9', '>') == 1) ? 'unicode' : 'string';
index 4802a98ff6286dcdf19d0b31b73e2e8d936116b2..ee0bf83a8429040455f8b31b10b9a70dd0cdc537 100644 (file)
@@ -42,7 +42,7 @@ require_once('skipifconnectfailure.inc');
                !mysqli_stmt_execute($stmt))
                printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
 
-       if (!$link_buf = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link_buf = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
        if (!$stmt_buf = mysqli_stmt_init($link_buf))
index 5aa93b146b610222fef7f6884107aea01346e873..edddbea9489951b3938d064dd82ac309e67db669 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
 <?php
        include "connect.inc";
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 73894f4f2acb0d6526c9c50c32df647cbf6d8bd9..d21eafa797ec6e9be0791428e4d8c4c3730f80f3 100644 (file)
@@ -10,7 +10,7 @@ require_once('skipifconnectfailure.inc');
 <?php
        include "connect.inc";
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 9bdd246194b8c5eca6b515f76e26e0f4125c3240..57d5de764c5e6ab0b7334fee1032b999882c4929 100644 (file)
@@ -13,7 +13,7 @@ if (!$TEST_EXPERIMENTAL)
 <?php
        include "connect.inc";
 
-       if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                        $host, $user, $db, $port, $socket);
 
index 68a62afe56298f9c07fd749dde9ac41f0b638e11..32a976357c0309e1b3bbcdfc381f2334a99ebb39 100755 (executable)
@@ -2,7 +2,7 @@
 require_once('connect.inc');
 if ($skip_on_connect_failure) {
        include_once('connect.inc');
-       $link = @mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+       $link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        if (!is_object($link))
                die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
        mysqli_close($link);
index b36ba7b306e6f87bd3c2eb069872a95c1a313a7e..aa1207af444bbfc0ac1d2212cafb9607eff1476a 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP
 require_once('connect.inc');
 
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
        printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                $host, $user, $db, $port, $socket);
        exit(1);
index 46b9699b54fda056623723d8e6f56d70ee897219..59fd6c74cc8df65d07ff23abe1b94c43cc365dd9 100644 (file)
@@ -2,7 +2,6 @@ dnl
 dnl $Id$
 dnl config.m4 for mysqlnd driver
 
-
 PHP_ARG_ENABLE(mysqlnd_threading, whether to enable threaded fetch in mysqlnd,
 [  --enable-mysqlnd-threading
                             EXPERIMENTAL: Enable mysqlnd threaded fetch.
@@ -18,18 +17,20 @@ if test "$PHP_MYSQLND_ENABLED" = "yes"; then
 
   PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, no)
   PHP_ADD_BUILD_DIR([ext/mysqlnd], 1)
-  PHP_INSTALL_HEADERS([ext/mysqlnd])
-  PHP_INSTALL_HEADERS([$ext_builddir/php_mysqlnd_config.h])
 
   dnl Windows uses config.w32 thus this code is safe for now
   if test "$PHP_MYSQLND_THREADING" = "yes"; then
     PHP_BUILD_THREAD_SAFE
     AC_DEFINE([MYSQLND_THREADED], 1, [Use mysqlnd internal threading])
   fi
+fi
+
+if test "$PHP_MYSQLND_ENABLED" = "yes" || test "$PHP_MYSQLI" != "no"; then
+  PHP_ADD_BUILD_DIR([ext/mysqlnd], 1)
 
   dnl This creates a file so it has to be after above macros
   PHP_CHECK_TYPES([int8 uint8 int16 uint16 int32 uint32 uchar ulong int8_t uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_t], [
-    $ext_builddir/php_mysqlnd_config.h
+    ext/mysqlnd/php_mysqlnd_config.h
   ],[
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
index b9d3ce05011a2c5084f2d517dbc0b4f2872b2cc3..a3f0abbe225e847d1263fef0a71d570422144d5b 100644 (file)
@@ -96,7 +96,7 @@ MYSQLND_METHOD(mysqlnd_conn, free_options)(MYSQLND *conn TSRMLS_DC)
                unsigned int i;
                for (i = 0; i < conn->options.num_commands; i++) {
                        /* allocated with pestrdup */
-                       pefree(conn->options.init_commands[i], pers);
+                       mnd_pefree(conn->options.init_commands[i], pers);
                }
                mnd_pefree(conn->options.init_commands, pers);
                conn->options.init_commands = NULL;
@@ -508,8 +508,8 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
                                host?host:"", user?user:"", db?db:"", port, mysql_flags,
                                conn? conn->persistent:0, conn? CONN_GET_STATE(conn):-1);
 
-       DBG_INF_FMT("state=%d", CONN_GET_STATE(conn));
        if (conn && CONN_GET_STATE(conn) > CONN_ALLOCED && CONN_GET_STATE(conn) ) {
+               DBG_INF_FMT("state=%d", CONN_GET_STATE(conn));
                DBG_INF("Connecting on a connected handle.");
 
                if (CONN_GET_STATE(conn) < CONN_QUIT_SENT) {
@@ -627,6 +627,10 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
                mnd_efree(hashed_details);
        }
 
+       if (!conn->options.timeout_read) {
+               /* should always happen because read_timeout cannot be set via API */
+               conn->options.timeout_read = (unsigned int) MYSQLND_G(net_read_timeout);
+       }
        if (conn->options.timeout_read)
        {
                tv.tv_sec = conn->options.timeout_read;
@@ -665,7 +669,12 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
 
        conn->greet_charset = mysqlnd_find_charset_nr(greet_packet.charset_no);
        /* we allow load data local infile by default */
-       mysql_flags  |= CLIENT_LOCAL_FILES;
+       mysql_flags  |= CLIENT_LOCAL_FILES | CLIENT_PS_MULTI_RESULTS;
+#ifndef MYSQLND_COMPRESSION_ENABLED
+       if (mysql_flags & CLIENT_COMPRESS) {
+               mysql_flags &= ~CLIENT_COMPRESS;
+       }
+#endif
 
        auth_packet->user               = user;
        auth_packet->password   = passwd;
@@ -748,8 +757,6 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
                SET_EMPTY_ERROR(conn->error_info);
 
                conn->zval_cache = mysqlnd_palloc_get_thd_cache_reference(zval_cache);
-               conn->net.cmd_buffer.length = 128L*1024L;
-               conn->net.cmd_buffer.buffer = mnd_pemalloc(conn->net.cmd_buffer.length, conn->persistent);
 
                mysqlnd_local_infile_default(conn);
                {
@@ -763,13 +770,12 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
                                                                                (char *)&buf_size TSRMLS_CC);                   
                }
 
-               MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_CONNECT_SUCCESS);
+               MYSQLND_INC_CONN_STATISTIC_W_VALUE2(&conn->stats, STAT_CONNECT_SUCCESS, 1, STAT_OPENED_CONNECTIONS, 1);
                if (reconnect) {
                        MYSQLND_INC_GLOBAL_STATISTIC(STAT_RECONNECT);   
                }
-               MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_OPENED_CONNECTIONS);
                if (conn->persistent) {
-                       MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_OPENED_PERSISTENT_CONNECTIONS);
+                       MYSQLND_INC_CONN_STATISTIC_W_VALUE2(&conn->stats, STAT_PCONNECT_SUCCESS, 1, STAT_OPENED_PERSISTENT_CONNECTIONS, 1);
                }
 
                DBG_INF_FMT("connection_id=%llu", conn->thread_id);
@@ -1939,6 +1945,9 @@ MYSQLND_METHOD(mysqlnd_conn, set_client_option)(MYSQLND * const conn,
                        break;
 #endif
                case MYSQLND_OPT_NET_CMD_BUFFER_SIZE:
+                       if (*(unsigned int*) value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) {
+                               DBG_RETURN(FAIL);
+                       }
                        conn->net.cmd_buffer.length = *(unsigned int*) value;
                        if (!conn->net.cmd_buffer.buffer) {
                                conn->net.cmd_buffer.buffer = mnd_pemalloc(conn->net.cmd_buffer.length, conn->persistent);
index 687b98930355d43a817bf0a5b0d95f76a066579e..5da88198376df66a6e8dedcda98c63262ce72bda 100644 (file)
@@ -26,7 +26,7 @@
 #define MYSQLND_VERSION_ID 50005
 
 /* This forces inlining of some accessor functions */
-#define MYSQLND_USE_OPTIMISATIONS 1
+#define MYSQLND_USE_OPTIMISATIONS 0
 
 #define MYSQLND_STRING_TO_INT_CONVERSION
 /*
@@ -228,8 +228,8 @@ PHPAPI unsigned int mysqlnd_get_client_version();
 /*****************************************************************************************************/
 
 
-PHPAPI void mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind);
-PHPAPI void mysqlnd_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind);
+PHPAPI void mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind TSRMLS_DC);
+PHPAPI void mysqlnd_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind TSRMLS_DC);
 
 
 PHPAPI const char * mysqlnd_field_type_name(enum mysqlnd_field_types field_type);
@@ -250,7 +250,7 @@ PHPAPI void mysqlnd_set_local_infile_handler(MYSQLND * const conn, const char *
 #define mysqlnd_select_db(conn, db, db_len)    (conn)->m->select_db((conn), (db), (db_len) TSRMLS_CC)
 #define mysqlnd_ping(conn)                                     (conn)->m->ping((conn) TSRMLS_CC)
 #define mysqlnd_kill(conn, pid)                                (conn)->m->kill_connection((conn), (pid) TSRMLS_CC)
-#define mysqlnd_refresh(conn, options)         (conn)->m->refresh_server((conn), (options) TSRMLS_CC) 
+#define mysqlnd_refresh(conn, options)         (conn)->m->refresh_server((conn), (options) TSRMLS_CC)
 #define mysqlnd_shutdown(conn, level)          (conn)->m->shutdown_server((conn), (level) TSRMLS_CC)
 #define mysqlnd_get_server_version(conn)       (conn)->m->get_server_version((conn))
 #define mysqlnd_set_character_set(conn, cs)    (conn)->m->set_charset((conn), (cs) TSRMLS_CC)
@@ -374,6 +374,7 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqlnd)
 #ifdef MYSQLND_THREADED
        THREAD_T                thread_id;
 #endif
+       long                    net_read_timeout;
 ZEND_END_MODULE_GLOBALS(mysqlnd)
 
 ZEND_EXTERN_MODULE_GLOBALS(mysqlnd);
index fec2261775db211f64e514a9d2636cd24aa02a7d..478088edaefc5d292e5707c7e54b52ca1c8e4f75 100644 (file)
 #define MYSQLND_SQLSTATE_LENGTH                5
 #define MYSQLND_SQLSTATE_NULL          "00000"
 
+
+#define MYSQLND_NET_CMD_BUFFER_MIN_SIZE                        4096
+#define MYSQLND_NET_CMD_BUFFER_MIN_SIZE_STR            "4096"
+
 #define SERVER_STATUS_IN_TRANS                                 1       /* Transaction has started */
 #define SERVER_STATUS_AUTOCOMMIT                               2       /* Server in auto_commit mode */
 #define SERVER_MORE_RESULTS_EXISTS                             8       /* Multi query - next query exists */
@@ -73,6 +77,7 @@
 #define CLIENT_SECURE_CONNECTION       32768   /* New 4.1 authentication */
 #define CLIENT_MULTI_STATEMENTS                (1UL << 16) /* Enable/disable multi-stmt support */
 #define CLIENT_MULTI_RESULTS           (1UL << 17) /* Enable/disable multi-results */
+#define CLIENT_PS_MULTI_RESULTS                (1UL << 18) /* Multi-results in PS-protocol */
 
 typedef enum mysqlnd_extension
 {
index 1b035ed365b9f0f6893761666f11e87c72754dac..9d5104796ca378fa7fd21bb73448393cfcc5d0e1 100644 (file)
@@ -42,7 +42,7 @@ char * mysqlnd_palloc_get_zval_name = "mysqlnd_palloc_get_zval";
 /* {{{ _mysqlnd_palloc_init_cache */
 PHPAPI MYSQLND_ZVAL_PCACHE* _mysqlnd_palloc_init_cache(unsigned int cache_size TSRMLS_DC)
 {
-       MYSQLND_ZVAL_PCACHE *ret = calloc(1, sizeof(MYSQLND_ZVAL_PCACHE));
+       MYSQLND_ZVAL_PCACHE *ret = mnd_calloc(1, sizeof(MYSQLND_ZVAL_PCACHE));
        unsigned int i;
 
        DBG_ENTER("_mysqlnd_palloc_init_cache");
@@ -58,13 +58,13 @@ PHPAPI MYSQLND_ZVAL_PCACHE* _mysqlnd_palloc_init_cache(unsigned int cache_size T
 
        /* 1. First initialize the free list part of the structure */
        /* One more for empty position of last_added - always 0x0, bounds checking */
-       ret->free_list.ptr_line = calloc(ret->max_items + 1, sizeof(mysqlnd_zval *));
+       ret->free_list.ptr_line = mnd_calloc(ret->max_items + 1, sizeof(mysqlnd_zval *));
        ret->free_list.last_added = ret->free_list.ptr_line + ret->max_items;
        ret->free_list.canary1 = (void*)0xBEEF;
        ret->free_list.canary2 = (void*)0xAFFE;
 
        /* 3. Allocate and initialize our zvals and initialize the free list */
-       ret->block = calloc(ret->max_items, sizeof(mysqlnd_zval));
+       ret->block = mnd_calloc(ret->max_items, sizeof(mysqlnd_zval));
        ret->last_in_block = &(ret->block[ret->max_items]);
        for (i = 0; i < ret->max_items; i++) {
                /* 1. Initialize */
@@ -124,7 +124,7 @@ void _mysqlnd_palloc_free_cache(MYSQLND_ZVAL_PCACHE *cache TSRMLS_DC)
 /* {{{ _mysqlnd_palloc_init_thd_cache */
 PHPAPI MYSQLND_THD_ZVAL_PCACHE* _mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * const cache TSRMLS_DC)
 {
-       MYSQLND_THD_ZVAL_PCACHE *ret = calloc(1, sizeof(MYSQLND_THD_ZVAL_PCACHE));
+       MYSQLND_THD_ZVAL_PCACHE *ret = mnd_calloc(1, sizeof(MYSQLND_THD_ZVAL_PCACHE));
        DBG_ENTER("_mysqlnd_palloc_init_thd_cache");
        DBG_INF_FMT("ret = %p", ret);
        
@@ -146,7 +146,7 @@ PHPAPI MYSQLND_THD_ZVAL_PCACHE* _mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCAC
        ret->references = 1;
 
        /* 1. Initialize the GC list */
-       ret->gc_list.ptr_line = calloc(cache->max_items, sizeof(mysqlnd_zval *));
+       ret->gc_list.ptr_line = mnd_calloc(cache->max_items, sizeof(mysqlnd_zval *));
        /* Backward and forward looping is possible */
        ret->gc_list.last_added = ret->gc_list.ptr_line;
        ret->gc_list.canary1 = (void*)0xCAFE;
index ca6f5541c427b08de7ed8ca105c39c34e5731235..43cb505861ffdc2ec967a279a4e38904be0c9fca 100644 (file)
@@ -9,6 +9,9 @@ This file is public domain and comes with NO WARRANTY of any kind */
   were added to improve the header file, to get it more consistent.
 */
 
+#ifndef MYSQLND_PORTABILITY_H
+#define MYSQLND_PORTABILITY_H
+
 /* Comes from global.h as OFFSET, renamed to STRUCT_OFFSET */
 #define STRUCT_OFFSET(t, f)   ((size_t)(char *)&((t *)0)->f)
 
@@ -30,9 +33,9 @@ This file is public domain and comes with NO WARRANTY of any kind */
 #endif /* __CYGWIN__ */
 
 #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
-#  include <ext/mysqlnd/config-win.h>
+#  include "ext/mysqlnd/config-win.h"
 #else 
-#  include "ext/mysqlnd/php_mysqlnd_config.h"
+#  include <ext/mysqlnd/php_mysqlnd_config.h>
 #endif /* _WIN32... */
 
 #ifdef HAVE_SYS_TYPES_H
@@ -497,6 +500,7 @@ typedef union {
 
 #endif /* WORDS_BIGENDIAN */
 
+#endif /* MYSQLND_PORTABILITY_H */
 
 
 /*
index ae3752e6d3a5c9c09ae48dab069a95f1e67a9a83..856b7076c65840ddb10c5804aaf1018bcf92e866 100644 (file)
                if ((buf)) { \
                        pefree((buf), (persistent)); \
                } \
-               (buf) = (message); \
+               if ((message)) { \
+                       (buf) = pestrndup((message), (len), (persistent)); \
+               } else { \
+                       buf = NULL; \
+               } \
                (buf_len) = (len); \
-               /* Transfer ownership*/ \
-               (message) = NULL; \
        }
 
 #define SET_EMPTY_MESSAGE(buf, buf_len, persistent) \
index ba4ea3120f936eee024f5ab91fe0b38ca317169b..a980e960afc94cde47757199842b5c4a39c3a4ef 100644 (file)
@@ -1329,7 +1329,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_parameters)(MYSQLND_STMT * const stmt,
                SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
                DBG_ERR("not prepared");
                if (param_bind && stmt->param_bind_dtor) {
-                       stmt->param_bind_dtor(param_bind);
+                       stmt->param_bind_dtor(param_bind TSRMLS_CC);
                }
                DBG_RETURN(FAIL);
        }
@@ -1362,7 +1362,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_parameters)(MYSQLND_STMT * const stmt,
                                }
                        }
                        if (stmt->param_bind != param_bind && stmt->param_bind_dtor) {
-                               stmt->param_bind_dtor(stmt->param_bind);
+                               stmt->param_bind_dtor(stmt->param_bind TSRMLS_CC);
                        }
                }
 
@@ -1411,7 +1411,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_one_parameter)(MYSQLND_STMT * const stmt, unsi
 
        if (stmt->param_count) {
                if (!stmt->param_bind) {
-                       stmt->param_bind = ecalloc(stmt->param_count, sizeof(MYSQLND_PARAM_BIND));
+                       stmt->param_bind = mnd_ecalloc(stmt->param_count, sizeof(MYSQLND_PARAM_BIND));
                }
                
                /* Prevent from freeing */
@@ -1465,7 +1465,7 @@ MYSQLND_METHOD(mysqlnd_stmt, refresh_bind_param)(MYSQLND_STMT * const stmt TSRML
 /* {{{ mysqlnd_stmt::set_bind_param_dtor */
 static void
 MYSQLND_METHOD(mysqlnd_stmt, set_param_bind_dtor)(MYSQLND_STMT * const stmt,
-                                                                                                 void (*param_bind_dtor)(MYSQLND_PARAM_BIND *dtor) TSRMLS_DC)
+                                                                                                 void (*param_bind_dtor)(MYSQLND_PARAM_BIND * dtor TSRMLS_DC) TSRMLS_DC)
 {
        DBG_ENTER("mysqlnd_stmt::set_bind_param_dtor");
        DBG_INF_FMT("stmt=%p", param_bind_dtor);
@@ -1487,7 +1487,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_result)(MYSQLND_STMT * const stmt,
        if (stmt->state < MYSQLND_STMT_PREPARED) {
                SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
                if (result_bind && stmt->result_bind_dtor) {
-                       stmt->result_bind_dtor(result_bind);
+                       stmt->result_bind_dtor(result_bind TSRMLS_CC);
                }
                DBG_ERR("not prepared");
                DBG_RETURN(FAIL);
@@ -1519,7 +1519,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_result)(MYSQLND_STMT * const stmt,
                        stmt->result_bind[i].bound = TRUE;
                }
        } else if (result_bind && stmt->result_bind_dtor) {
-               stmt->result_bind_dtor(result_bind);
+               stmt->result_bind_dtor(result_bind TSRMLS_CC);
        }
        DBG_INF("PASS");
        DBG_RETURN(PASS);
@@ -1553,9 +1553,9 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_one_result)(MYSQLND_STMT * const stmt, unsigne
                mysqlnd_stmt_separate_one_result_bind(stmt, param_no TSRMLS_CC);
                /* Guaranteed is that stmt->result_bind is NULL */
                if (!stmt->result_bind) {
-                       stmt->result_bind = ecalloc(stmt->field_count, sizeof(MYSQLND_RESULT_BIND));
+                       stmt->result_bind = mnd_ecalloc(stmt->field_count, sizeof(MYSQLND_RESULT_BIND));
                } else {
-                       stmt->result_bind = erealloc(stmt->result_bind, stmt->field_count * sizeof(MYSQLND_RESULT_BIND));
+                       stmt->result_bind = mnd_erealloc(stmt->result_bind, stmt->field_count * sizeof(MYSQLND_RESULT_BIND));
                }
                ALLOC_INIT_ZVAL(stmt->result_bind[param_no].zv);
                /*
@@ -1574,7 +1574,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_one_result)(MYSQLND_STMT * const stmt, unsigne
 /* {{{ mysqlnd_stmt::set_bind_result_dtor */
 static void
 MYSQLND_METHOD(mysqlnd_stmt, set_result_bind_dtor)(MYSQLND_STMT * const stmt,
-                                                                                                  void (*result_bind_dtor)(MYSQLND_RESULT_BIND *dtor) TSRMLS_DC)
+                                                                                                  void (*result_bind_dtor)(MYSQLND_RESULT_BIND * dtor TSRMLS_DC) TSRMLS_DC)
 {
        DBG_ENTER("mysqlnd_stmt::set_bind_param_dtor");
        DBG_INF_FMT("stmt=%p", result_bind_dtor);
@@ -1898,7 +1898,7 @@ void mysqlnd_stmt_separate_result_bind(MYSQLND_STMT * const stmt TSRMLS_DC)
                }
        }
        if (stmt->result_bind_dtor) {
-               stmt->result_bind_dtor(stmt->result_bind);
+               stmt->result_bind_dtor(stmt->result_bind TSRMLS_CC);
        }
        stmt->result_bind = NULL;
 
@@ -1979,7 +1979,7 @@ void mysqlnd_internal_free_stmt_content(MYSQLND_STMT * const stmt TSRMLS_DC)
                        }
                }
                if (stmt->param_bind_dtor) {
-                       stmt->param_bind_dtor(stmt->param_bind);
+                       stmt->param_bind_dtor(stmt->param_bind TSRMLS_CC);
                }
                stmt->param_bind = NULL;
        }
@@ -2177,18 +2177,18 @@ MYSQLND_STMT * _mysqlnd_stmt_init(MYSQLND * const conn TSRMLS_DC)
 
 /* {{{ mysqlnd_efree_param_bind_dtor */
 PHPAPI void
-mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind)
+mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind TSRMLS_DC)
 {
-       efree(param_bind);
+       mnd_efree(param_bind);
 }
 /* }}} */
 
 
 /* {{{ mysqlnd_efree_result_bind_dtor */
 PHPAPI void
-mysqlnd_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind)
+mysqlnd_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind TSRMLS_DC)
 {
-       efree(result_bind);
+       mnd_efree(result_bind);
 }
 /* }}} */
 
index 6fd2e053b28e36a010b002cec8e6d341347d0de1..ec1e05e9a78480e22ca35c6e8d57355b8da8609c 100644 (file)
@@ -580,10 +580,10 @@ void _mysqlnd_init_ps_fetch_subsystem()
 
 /* {{{ mysqlnd_stmt_copy_it */
 static void
-mysqlnd_stmt_copy_it(zval *** copies, zval *original, unsigned int param_count, unsigned int current)
+mysqlnd_stmt_copy_it(zval *** copies, zval *original, unsigned int param_count, unsigned int current TSRMLS_DC)
 {
        if (!*copies) {
-               *copies = ecalloc(param_count, sizeof(zval *));                                 
+               *copies = mnd_ecalloc(param_count, sizeof(zval *));                                     
        }
        MAKE_STD_ZVAL((*copies)[current]);
        *(*copies)[current] = *original;
@@ -643,7 +643,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT *stmt, zend_uchar **buf, zend_uch
                for (j = i + 1; j < stmt->param_count; j++) {
                        if (stmt->param_bind[j].zv == the_var) {
                                /* Double binding of the same zval, make a copy */
-                               mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i);
+                               mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC);
                                break; 
                        }
                }
@@ -653,7 +653,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT *stmt, zend_uchar **buf, zend_uch
                                data_size += 8;
                                if (Z_TYPE_P(the_var) != IS_DOUBLE) {
                                        if (!copies || !copies[i]) {
-                                               mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i);
+                                               mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC);
                                        }
                                }
                                break;
@@ -668,7 +668,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT *stmt, zend_uchar **buf, zend_uch
 #endif
                                if (Z_TYPE_P(the_var) != IS_LONG) {
                                        if (!copies || !copies[i]) {
-                                               mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i);
+                                               mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC);
                                        }
                                }
                                break;
@@ -691,7 +691,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT *stmt, zend_uchar **buf, zend_uch
 #endif
                                {
                                        if (!copies || !copies[i]) {
-                                               mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i);
+                                               mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC);
                                        }
                                        the_var = copies[i];
 #if PHP_MAJOR_VERSION >= 6
@@ -777,7 +777,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT *stmt, zend_uchar **buf, zend_uch
                                zval_ptr_dtor(&copies[i]);
                        }
                }
-               efree(copies);  
+               mnd_efree(copies);      
        }
 }
 /* }}} */
index 56969944aa09f32869b9532f55350479fa5538b0..c2798a09269034ee72b96e629bb91663a3349c76 100644 (file)
@@ -171,7 +171,7 @@ void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result TSRMLS_DC)
                                                                                        STAT_COPY_ON_WRITE_PERFORMED, 0);
                
                /* Free last row's zvals */
-               efree(unbuf->last_row_data);
+               mnd_efree(unbuf->last_row_data);
                unbuf->last_row_data = NULL;
        }
        if (unbuf->last_row_buffer) {
@@ -223,11 +223,11 @@ void mysqlnd_free_buffered_data(MYSQLND_RES *result TSRMLS_DC)
        }
        DBG_INF("Freeing data & row_buffer");
        if (set->data) {
-               pefree(set->data, set->persistent);
+               mnd_pefree(set->data, set->persistent);
                set->data = NULL;
        }
        if (set->row_buffers) {
-               pefree(set->row_buffers, set->persistent);
+               mnd_pefree(set->row_buffers, set->persistent);
                set->row_buffers        = NULL;
        }
        set->data_cursor = NULL;
@@ -237,7 +237,7 @@ void mysqlnd_free_buffered_data(MYSQLND_RES *result TSRMLS_DC)
        }
 
        DBG_INF("Freeing set");
-       pefree(set, set->persistent);
+       mnd_pefree(set, set->persistent);
 
        DBG_INF_FMT("after: real_usage=%lu  usage=%lu", zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC));
        DBG_VOID_RETURN;
@@ -295,13 +295,13 @@ void mysqlnd_free_background_buffered_data(MYSQLND_RES *result TSRMLS_DC)
 #if MYSQLND_DEBUG_MEMORY
                        DBG_INF("Freeing current_row & current_buffer");
 #endif
-                       pefree(current_row, set->persistent);
+                       mnd_pefree(current_row, set->persistent);
                }
                current_buffer->free_chunk(current_buffer, TRUE TSRMLS_CC);
        }
        DBG_INF("Freeing data & row_buffer");
-       pefree(set->data, set->persistent);
-       pefree(set->row_buffers, set->persistent);
+       mnd_pefree(set->data, set->persistent);
+       mnd_pefree(set->row_buffers, set->persistent);
        set->data                       = NULL;
        set->row_buffers        = NULL;
        set->data_cursor        = NULL;
@@ -315,7 +315,7 @@ void mysqlnd_free_background_buffered_data(MYSQLND_RES *result TSRMLS_DC)
        }
 
        DBG_INF("Freeing set");
-       pefree(set, set->persistent);
+       mnd_pefree(set, set->persistent);
 
        DBG_INF_FMT("after: real_usage=%lu  usage=%lu", zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC));
        DBG_VOID_RETURN;
@@ -333,7 +333,7 @@ MYSQLND_METHOD(mysqlnd_res, free_result_buffers)(MYSQLND_RES *result TSRMLS_DC)
 
        if (result->unbuf) {
                mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
-               efree(result->unbuf);
+               mnd_efree(result->unbuf);
                result->unbuf = NULL;
        } else if (result->stored_data) {
                mysqlnd_free_buffered_data(result TSRMLS_CC);
@@ -347,7 +347,7 @@ MYSQLND_METHOD(mysqlnd_res, free_result_buffers)(MYSQLND_RES *result TSRMLS_DC)
 #endif
 
        if (result->lengths) {
-               efree(result->lengths);
+               mnd_efree(result->lengths);
                result->lengths = NULL;
        }
 
@@ -398,7 +398,7 @@ void mysqlnd_internal_free_result(MYSQLND_RES *result TSRMLS_DC)
                result->conn = NULL;
        }
 
-       efree(result);
+       mnd_efree(result);
 
        DBG_VOID_RETURN;
 }
@@ -575,7 +575,7 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
                                if (FAIL == (ret = result->m.read_result_metadata(result, conn TSRMLS_CC))) {
                                        /* For PS, we leave them in Prepared state */
                                        if (!stmt) {
-                                               efree(conn->current_result);
+                                               mnd_efree(conn->current_result);
                                                conn->current_result = NULL;
                                        }
                                        DBG_ERR("Error ocurred while reading metadata");
@@ -587,7 +587,7 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT *stmt TSRMLS_DC
                                if (FAIL == (ret = PACKET_READ_ALLOCA(fields_eof, conn))) {
                                        DBG_ERR("Error ocurred while reading the EOF packet");
                                        result->m.free_result_contents(result TSRMLS_CC);
-                                       efree(result);
+                                       mnd_efree(result);
                                        if (!stmt) {
                                                conn->current_result = NULL;
                                        } else {
@@ -901,13 +901,8 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flag
                                        lengths[i] = len;
                                }
 
-                               /* Forbid ZE to free it, we will clean it */
-                               Z_ADDREF_P(data);
-
-                               if ((flags & MYSQLND_FETCH_BOTH) == MYSQLND_FETCH_BOTH) {
-                                       Z_ADDREF_P(data);
-                               }
                                if (flags & MYSQLND_FETCH_NUM) {
+                                       Z_ADDREF_P(data);
                                        zend_hash_next_index_insert(row_ht, &data, sizeof(zval *), NULL);
                                }
                                if (flags & MYSQLND_FETCH_ASSOC) {
@@ -918,6 +913,7 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flag
                                          the index is a numeric and convert it to it. This however means constant
                                          hashing of the column name, which is not needed as it can be precomputed.
                                        */
+                                       Z_ADDREF_P(data);
                                        if (zend_hash_key->is_numeric == FALSE) {
 #if PHP_MAJOR_VERSION >= 6
                                                zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE,
@@ -1128,16 +1124,8 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags,
                for (i = 0; i < result->field_count; i++, field++, zend_hash_key++) {
                        zval *data = current_row[i];
 
-                       /*
-                         Let us later know what to do with this zval. If ref_count > 1, we will just
-                         decrease it, otherwise free it. zval_ptr_dtor() make this very easy job.
-                       */
-                       Z_ADDREF_P(data);
-                       
-                       if ((flags & MYSQLND_FETCH_BOTH) == MYSQLND_FETCH_BOTH) {
-                               Z_ADDREF_P(data);
-                       }
                        if (flags & MYSQLND_FETCH_NUM) {
+                               Z_ADDREF_P(data);
                                zend_hash_next_index_insert(Z_ARRVAL_P(row), &data, sizeof(zval *), NULL);
                        }
                        if (flags & MYSQLND_FETCH_ASSOC) {
@@ -1148,6 +1136,7 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags,
                                  the index is a numeric and convert it to it. This however means constant
                                  hashing of the column name, which is not needed as it can be precomputed.
                                */
+                               Z_ADDREF_P(data);
                                if (zend_hash_key->is_numeric == FALSE) {
 #if PHP_MAJOR_VERSION >= 6
                                        zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE,
@@ -1893,9 +1882,9 @@ MYSQLND_METHOD(mysqlnd_res, fetch_row_c)(MYSQLND_RES *result TSRMLS_DC)
 
        if (result->m.fetch_row) {
                if (result->m.fetch_row == result->m.fetch_row_normal_buffered) {
-                       return mysqlnd_fetch_row_buffered_c(result TSRMLS_CC);
+                       DBG_RETURN(mysqlnd_fetch_row_buffered_c(result TSRMLS_CC));
                } else if (result->m.fetch_row == result->m.fetch_row_normal_unbuffered) {
-                       return mysqlnd_fetch_row_unbuffered_c(result TSRMLS_CC);
+                       DBG_RETURN(mysqlnd_fetch_row_unbuffered_c(result TSRMLS_CC));
                } else {
                        *((int*)NULL) = 1;
                }
index 7a750039278c501c88f33f3862f7cbff836452c1..95ef93a65b7ea6d4ccea468780d7a9267e038464 100644 (file)
@@ -165,8 +165,15 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met
                        PACKET_FREE_ALLOCA(field_packet);
                        DBG_RETURN(FAIL);
                }
+               if (field_packet.error_info.error_no) {
+                       conn->error_info = field_packet.error_info;
+                       /* Return back from CONN_QUERY_SENT */
+                       PACKET_FREE_ALLOCA(field_packet);
+                       DBG_RETURN(FAIL);
+               }
+               
                if (field_packet.stupid_list_fields_eof == TRUE) {
-                       meta->field_count = i + 1;
+                       meta->field_count = i;
                        break;
                }
 
index ddb7b40da6a80095be49285d6a600b549aef0126..9612fa3fce9369fa716ef96b747c2fcd85face2b 100644 (file)
@@ -360,10 +360,10 @@ struct st_mysqlnd_stmt_methods
        enum_func_status        (*bind_parameters)(MYSQLND_STMT * const stmt, MYSQLND_PARAM_BIND * const param_bind TSRMLS_DC);
        enum_func_status        (*bind_one_parameter)(MYSQLND_STMT * const stmt, unsigned int param_no, zval * const zv, zend_uchar     type TSRMLS_DC);
        enum_func_status        (*refresh_bind_param)(MYSQLND_STMT * const stmt TSRMLS_DC);
-       void                            (*set_param_bind_dtor)(MYSQLND_STMT * const stmt, void (*param_bind_dtor)(MYSQLND_PARAM_BIND * TSRMLS_DC);
+       void                            (*set_param_bind_dtor)(MYSQLND_STMT * const stmt, void (*param_bind_dtor)(MYSQLND_PARAM_BIND * TSRMLS_DC) TSRMLS_DC);
        enum_func_status        (*bind_result)(MYSQLND_STMT * const stmt, MYSQLND_RESULT_BIND * const result_bind TSRMLS_DC);
        enum_func_status        (*bind_one_result)(MYSQLND_STMT * const stmt, unsigned int param_no TSRMLS_DC);
-       void                            (*set_result_bind_dtor)(MYSQLND_STMT * const stmt, void (*result_bind_dtor)(MYSQLND_RESULT_BIND *) TSRMLS_DC);
+       void                            (*set_result_bind_dtor)(MYSQLND_STMT * const stmt, void (*result_bind_dtor)(MYSQLND_RESULT_BIND * TSRMLS_DC) TSRMLS_DC);
        enum_func_status        (*send_long_data)(MYSQLND_STMT * const stmt, unsigned int param_num,
                                                                                  const char * const data, unsigned long length TSRMLS_DC);
        MYSQLND_RES *           (*get_parameter_metadata)(MYSQLND_STMT * const stmt);
@@ -625,8 +625,8 @@ struct st_mysqlnd_stmt
        MYSQLND_CMD_BUFFER                      execute_cmd_buffer;
        unsigned int                            execute_count;/* count how many times the stmt was executed */
 
-       void                                            (*param_bind_dtor)(MYSQLND_PARAM_BIND *);
-       void                                            (*result_bind_dtor)(MYSQLND_RESULT_BIND *);
+       void                                            (*param_bind_dtor)(MYSQLND_PARAM_BIND * TSRMLS_DC);
+       void                                            (*result_bind_dtor)(MYSQLND_RESULT_BIND * TSRMLS_DC);
 
        struct st_mysqlnd_stmt_methods  *m;
 };
index 989cc87ed01206be185c7df1b4e805fa3a593399..cc0697cd0b0280f01951596f37e8c3f029db1c9b 100644 (file)
@@ -813,7 +813,7 @@ php_mysqlnd_ok_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 
        /* There is a message */
        if (packet->header.size > p - buf && (i = php_mysqlnd_net_field_length(&p))) {
-               packet->message = pestrndup((char *)p, MIN(i, sizeof(buf) - (p - buf)), conn->persistent);
+               packet->message = estrndup((char *)p, MIN(i, sizeof(buf) - (p - buf)));
                packet->message_len = i;
        } else {
                packet->message = NULL;
@@ -1032,7 +1032,7 @@ php_mysqlnd_rset_header_read(void *_packet, MYSQLND *conn TSRMLS_DC)
                          Thus, the name is size - 1. And we add 1 for a trailing \0.
                        */
                        len = packet->header.size - 1;
-                       packet->info_or_local_file = mnd_pemalloc(len + 1, conn->persistent);
+                       packet->info_or_local_file = mnd_emalloc(len + 1);
                        memcpy(packet->info_or_local_file, p, len);
                        packet->info_or_local_file[len] = '\0';
                        packet->info_or_local_file_len = len;
@@ -1047,7 +1047,7 @@ php_mysqlnd_rset_header_read(void *_packet, MYSQLND *conn TSRMLS_DC)
                        p+=2;
                        /* Check for additional textual data */
                        if (packet->header.size  > (p - buf) && (len = php_mysqlnd_net_field_length(&p))) {
-                               packet->info_or_local_file = mnd_pemalloc(len + 1, conn->persistent);
+                               packet->info_or_local_file = mnd_emalloc(len + 1);
                                memcpy(packet->info_or_local_file, p, len);
                                packet->info_or_local_file[len] = '\0';
                                packet->info_or_local_file_len = len;
@@ -1126,7 +1126,16 @@ php_mysqlnd_rset_field_read(void *_packet, MYSQLND *conn TSRMLS_DC)
        if (packet->skip_parsing) {
                DBG_RETURN(PASS);
        }
-       if (*p == 0xFE && packet->header.size < 8) {
+       if (*p == 0xFF) {
+               /* Error */
+               p++;
+               php_mysqlnd_read_error_from_line(p, packet->header.size - 1,
+                                                                                packet->error_info.error, sizeof(packet->error_info.error),
+                                                                                &packet->error_info.error_no, packet->error_info.sqlstate
+                                                                                TSRMLS_CC);
+               DBG_ERR_FMT("Server error : (%d) %s", packet->error_info.error_no, packet->error_info.error);
+               DBG_RETURN(PASS);
+       } else if (*p == 0xFE && packet->header.size < 8) {
                /* Premature EOF. That should be COM_FIELD_LIST */
                DBG_INF("Premature EOF. That should be COM_FIELD_LIST");
                packet->stupid_list_fields_eof = TRUE;
@@ -1364,8 +1373,10 @@ void php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffe
        zend_uchar *null_ptr, bit;
        zval **current_field, **end_field, **start_field;
        zend_bool as_unicode = conn->options.numeric_and_datetime_as_unicode;
+#ifdef USE_ZVAL_CACHE
        zend_bool allocated;
        void *obj;
+#endif
 
        DBG_ENTER("php_mysqlnd_rowp_read_binary_protocol");
 
@@ -1858,7 +1869,7 @@ php_mysqlnd_stats_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 
        PACKET_READ_HEADER_AND_BODY(packet, conn, buf, sizeof(buf), "statistics", PROT_STATS_PACKET);
 
-       packet->message = mnd_pemalloc(packet->header.size + 1, conn->persistent);
+       packet->message = mnd_emalloc(packet->header.size + 1);
        memcpy(packet->message, buf, packet->header.size);
        packet->message[packet->header.size] = '\0';
        packet->message_len = packet->header.size;
index cd9d1a465f6f2a69fc98e524aa18ba95cc6b877e..77ee795c35a1be7449c1fa5ab30adce6e870dea5 100644 (file)
@@ -242,6 +242,8 @@ typedef struct st_php_mysql_packet_res_field {
        /* For table definitions, empty for result sets */
        zend_bool                               skip_parsing;
        zend_bool                               stupid_list_fields_eof;
+
+       mysqlnd_error_info              error_info;
 } php_mysql_packet_res_field;
 
 
index 7ebb748024d0f91f2debd86afab62746b99d353f..74b3e9beaf653b62c1d74d61e9555495470d7520 100644 (file)
@@ -26,7 +26,6 @@
 #include "mysqlnd_debug.h"
 #include "ext/standard/info.h"
 
-
 /* {{{ mysqlnd_functions[]
  *
  * Every user visible function must have an entry in mysqlnd_functions[].
@@ -107,6 +106,8 @@ PHP_MINFO_FUNCTION(mysqlnd)
        php_info_print_table_row(2, "Command buffer size", buf);
        snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_buffer_size));
        php_info_print_table_row(2, "Read buffer size", buf);
+       snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_timeout));
+       php_info_print_table_row(2, "Read timeout", buf);
        php_info_print_table_row(2, "Collecting statistics", MYSQLND_G(collect_statistics)? "Yes":"No");
        php_info_print_table_row(2, "Collecting memory statistics", MYSQLND_G(collect_memory_statistics)? "Yes":"No");
        php_info_print_table_end();
@@ -134,21 +135,34 @@ static PHP_GINIT_FUNCTION(mysqlnd)
        mysqlnd_globals->collect_memory_statistics = FALSE;
        mysqlnd_globals->debug = NULL;  /* The actual string */
        mysqlnd_globals->dbg = NULL;    /* The DBG object*/
-       mysqlnd_globals->net_cmd_buffer_size = 2048;
+       mysqlnd_globals->net_cmd_buffer_size = MYSQLND_NET_CMD_BUFFER_MIN_SIZE;
        mysqlnd_globals->net_read_buffer_size = 32768;
+       mysqlnd_globals->net_read_timeout = 31536000;
        mysqlnd_globals->log_mask = 0;
 }
 /* }}} */
 
 
+static PHP_INI_MH(OnUpdateNetCmdBufferSize)
+{
+       long long_value = atol(new_value);
+       if (long_value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) {
+               return FAILURE;
+       }
+       MYSQLND_G(net_cmd_buffer_size) = long_value;
+
+       return SUCCESS;
+}
+
 /* {{{ PHP_INI_BEGIN
 */
 PHP_INI_BEGIN()
        STD_PHP_INI_BOOLEAN("mysqlnd.collect_statistics",       "1",    PHP_INI_ALL, OnUpdateBool,      collect_statistics, zend_mysqlnd_globals, mysqlnd_globals)
        STD_PHP_INI_BOOLEAN("mysqlnd.collect_memory_statistics",        "0",    PHP_INI_SYSTEM, OnUpdateBool,   collect_memory_statistics, zend_mysqlnd_globals, mysqlnd_globals)
        STD_PHP_INI_ENTRY("mysqlnd.debug",                                      NULL,   PHP_INI_SYSTEM, OnUpdateString, debug, zend_mysqlnd_globals, mysqlnd_globals)
-       STD_PHP_INI_ENTRY("mysqlnd.net_cmd_buffer_size",        "2048", PHP_INI_ALL,    OnUpdateLong,   net_cmd_buffer_size,    zend_mysqlnd_globals,           mysqlnd_globals)
+       STD_PHP_INI_ENTRY("mysqlnd.net_cmd_buffer_size",        MYSQLND_NET_CMD_BUFFER_MIN_SIZE_STR,    PHP_INI_ALL,    OnUpdateNetCmdBufferSize,       net_cmd_buffer_size,    zend_mysqlnd_globals,           mysqlnd_globals)
        STD_PHP_INI_ENTRY("mysqlnd.net_read_buffer_size",       "32768",PHP_INI_ALL,    OnUpdateLong,   net_read_buffer_size,   zend_mysqlnd_globals,           mysqlnd_globals)
+       STD_PHP_INI_ENTRY("mysqlnd.net_read_timeout",   "31536000",     PHP_INI_SYSTEM, OnUpdateLong,   net_read_timeout, zend_mysqlnd_globals, mysqlnd_globals)
        STD_PHP_INI_ENTRY("mysqlnd.log_mask",                           "0",    PHP_INI_ALL,    OnUpdateLong,   log_mask, zend_mysqlnd_globals, mysqlnd_globals)
 PHP_INI_END()
 /* }}} */
index 2a64c0e4753ce6797e09f23e8c1a4251587ac4ce..d49b046acffcf690138ff2812c31df0313112f8c 100755 (executable)
@@ -620,8 +620,9 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
        if (driver_options) {
                long connect_timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
                long local_infile = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0 TSRMLS_CC);
+               char *init_cmd = NULL;
 #ifndef PDO_USE_MYSQLND
-               char *init_cmd = NULL, *default_file = NULL, *default_group = NULL;
+               char *default_file = NULL, *default_group = NULL;
                long compress = 0;
 #endif
                H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);
@@ -670,7 +671,6 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
                        mysql_options(H->server, MYSQL_OPT_RECONNECT, (const char*)&reconnect);
                }
 #endif
-#ifndef PDO_USE_MYSQLND
                init_cmd = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_INIT_COMMAND, NULL TSRMLS_CC);
                if (init_cmd) {
                        if (mysql_options(H->server, MYSQL_INIT_COMMAND, (const char *)init_cmd)) {
@@ -680,7 +680,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
                        }
                        efree(init_cmd);
                }
-               
+#ifndef PDO_USE_MYSQLND                
                default_file = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_READ_DEFAULT_FILE, NULL TSRMLS_CC);
                if (default_file) {
                        if (mysql_options(H->server, MYSQL_READ_DEFAULT_FILE, (const char *)default_file)) {
index 044102356bfa72015c6ee762bb5bff38ae7394f2..7ab568f8ecbb3ae51c1499ee4469e72789161536 100755 (executable)
@@ -75,9 +75,9 @@ static PHP_MINIT_FUNCTION(pdo_mysql)
 
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY);
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE", (long)PDO_MYSQL_ATTR_LOCAL_INFILE);    
+       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND);
 #ifndef PDO_USE_MYSQLND
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_MAX_BUFFER_SIZE", (long)PDO_MYSQL_ATTR_MAX_BUFFER_SIZE);
-       REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND);
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_FILE", (long)PDO_MYSQL_ATTR_READ_DEFAULT_FILE);
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_GROUP", (long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP);
        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_COMPRESS", (long)PDO_MYSQL_ATTR_COMPRESS);
index 16e44dc4338cd29d62501ad8d766229552f4ae0b..00a56ffe75dd71c71303a36ec20fb766789667a2 100755 (executable)
@@ -153,8 +153,8 @@ extern struct pdo_stmt_methods mysql_stmt_methods;
 enum {
        PDO_MYSQL_ATTR_USE_BUFFERED_QUERY = PDO_ATTR_DRIVER_SPECIFIC,
        PDO_MYSQL_ATTR_LOCAL_INFILE,
-#ifndef PDO_USE_MYSQLND
        PDO_MYSQL_ATTR_INIT_COMMAND,
+#ifndef PDO_USE_MYSQLND
        PDO_MYSQL_ATTR_READ_DEFAULT_FILE,
        PDO_MYSQL_ATTR_READ_DEFAULT_GROUP,
        PDO_MYSQL_ATTR_MAX_BUFFER_SIZE,
index fb955ac2aabb3ca3502454a8ed692bc0edae8d1f..8d086b7cc1cfa7e8e55b0ce81417f2b0179342f9 100644 (file)
@@ -6,8 +6,6 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
 MySQLPDOTest::skip();
 $db = MySQLPDOTest::factory();
-if (MySQLPDOTest::isPDOMySQLnd())
-       die("skip PDO::MYSQL_ATTR_MAX_INIT_COMMAND not supported with mysqlnd");
 ?>
 --INI--
 error_reporting=E_ALL
@@ -27,7 +25,8 @@ error_reporting=E_ALL
        var_dump($create);
        $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => $create));
 
-       var_dump($db->errorInfo());
+       $info = $db->errorInfo();
+       var_dump($info[0]);
 
        $db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table));
        $stmt = $db->query(sprintf('SELECT id FROM %s', $table));
@@ -35,22 +34,14 @@ error_reporting=E_ALL
 
        $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
        print "done!\n";
-?>
 --EXPECTF--
-string(58) "CREATE TABLE test_%s(id INT)"
-array(3) {
-  [0]=>
-  string(5) "00000"
-  [1]=>
-  NULL
-  [2]=>
-  NULL
-}
+%unicode|string%(58) "CREATE TABLE test_%s(id INT)"
+%unicode|string%(5) "00000"
 array(1) {
   [0]=>
   array(1) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
   }
 }
 done!