List:Commits« Previous MessageNext Message »
From:uwendel Date:July 19 2007 3:52pm
Subject:PHP mysqlnd svn commit: r804 - trunk/tests/ext/mysqli
View as plain text  
Author: uwendel
Date: 2007-07-19 17:52:37 +0200 (Thu, 19 Jul 2007)
New Revision: 804

Modified:
   trunk/tests/ext/mysqli/mysqli_report.phpt
   trunk/tests/ext/mysqli/mysqli_report_wo_ps.phpt
   trunk/tests/ext/mysqli/mysqli_rollback.phpt
   trunk/tests/ext/mysqli/mysqli_select_db.phpt
   trunk/tests/ext/mysqli/mysqli_set_charset.phpt
   trunk/tests/ext/mysqli/mysqli_set_local_infile_default.phpt
   trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_unregister.phpt
Log:
Space2Tab for php.net


Modified: trunk/tests/ext/mysqli/mysqli_report.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_report.phpt	2007-07-19 15:31:56 UTC (rev 803)
+++ trunk/tests/ext/mysqli/mysqli_report.phpt	2007-07-19 15:52:37 UTC (rev 804)
@@ -5,225 +5,225 @@
 <?php require_once('skipifemb.inc'); ?>
 --FILE--
 <?php
-    include "connect.inc";  
-    
-    $tmp    = NULL;   
-    $link   = NULL;    
-    
-    if (NULL !== ($tmp = @mysqli_report()))
-        printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);        
+	include "connect.inc";
 
-    if (true !== ($tmp = mysqli_report(-1)))
-        printf("[002] Expecting boolean/true even for invalid flags, got %s/%s\n",
gettype($tmp), $tmp);
-        
-    if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ERROR)))
-        printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
-        
-    if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_STRICT)))
-        printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);        
-        
-    if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_INDEX)))
-        printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);    
-        
-    if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ALL)))
-        printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
-        
-    if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_OFF)))
-        printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);        
-        
-    require('table.inc');   
-      
-    /*    
-    Internal macro MYSQL_REPORT_ERROR    
-    */    
-    mysqli_report(MYSQLI_REPORT_ERROR);
-       
-    mysqli_multi_query($link, "BAR; FOO;");
-    mysqli_query($link, "FOO");
-    /* This might work if you accept anonymous users in your setup */
-    mysqli_change_user($link,
"0123456789-10-456789-20-456789-30-456789-40-456789-50-456789-60-456789-70-456789-80-456789-90-456789",
"password", $db);
-    mysqli_kill($link, -1);
-    
-    // mysqli_ping() cannot be tested, because one would need to cause an error inside
the C function to test it
-    mysqli_prepare($link, "FOO");
-    mysqli_real_query($link, "FOO");
-    if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name"))
-    	printf("[009] select_db should have failed\n");
-    // mysqli_store_result() and mysqli_use_result() cannot be tested, because one would
need to cause an error inside the C function to test it
-    
-    
-    // Check that none of the above would have caused any error messages if
MYSQL_REPORT_ERROR would
-    // not have been set. If that would be the case, the test would be broken.
-    mysqli_report(MYSQLI_REPORT_OFF);
-    
-    mysqli_multi_query($link, "BAR; FOO;");
-    mysqli_query($link, "FOO");
-    mysqli_change_user($link, "This might work if you accept anonymous users in your
setup", "password", $db);
-    mysqli_kill($link, -1);    
-    mysqli_prepare($link, "FOO");
-    mysqli_real_query($link, "FOO");
-    mysqli_select_db($link, "Oh lord, let this be an unknown database name");
-    
-    /*
-    Internal macro MYSQL_REPORT_STMT_ERROR   
-    */
-    
-    mysqli_report(MYSQLI_REPORT_ERROR);
-    
-    $stmt = mysqli_stmt_init($link);    
-    mysqli_stmt_prepare($stmt, "FOO");
-    
-    $stmt = mysqli_stmt_init($link);    
-    mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
-    $id = 1;
-    mysqli_kill($link, mysqli_thread_id($link));
-    mysqli_stmt_bind_param($stmt, "i", $id);
-    mysqli_stmt_close($stmt);
-    mysqli_close($link);
-    
-    /* mysqli_stmt_execute() = mysql_stmt_execute cannot be tested from PHP */
-    if (!$link = 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 > ?");
-    $id = 1;
-    mysqli_stmt_bind_param($stmt, "i", $id);
-    // mysqli_kill($link, mysqli_thread_id($link));
-    mysqli_stmt_execute($stmt);
-    mysqli_stmt_close($stmt);
-    mysqli_close($link);
+	$tmp    = NULL;
+	$link   = NULL;
 
-    /* mysqli_kill() "trick" does not work for any of the following because of an
E_COMMANDS_OUT_OF_SYNC */
-    /* mysqli_stmt_bind_result() = mysql_stmt_bind_result() cannot be tested from PHP */ 
  
-    /* mysqli_stmt_fetch() = mysql_stmt_fetch() cannot be tested from PHP */    
-    /* mysqli_stmt_result_metadata() = mysql_stmt_result_metadata() cannot be tested from
PHP */    
-    /* mysqli_stmt_store_result() = mysql_stmt_store_result() cannot be tested from PHP
*/
-        
-    // Check
-    mysqli_report(MYSQLI_REPORT_OFF);
-    
-    if (!$link = 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");
-    
-    $stmt = mysqli_stmt_init($link);    
-    mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
-    $id = 1;
-    mysqli_kill($link, mysqli_thread_id($link));
-    mysqli_stmt_bind_param($stmt, "i", $id);
-    mysqli_stmt_close($stmt);
-    mysqli_close($link);
-    
-    if (!$link = 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 > ?");
-    $id = 1;
-    mysqli_stmt_bind_param($stmt, "i", $id);
-    mysqli_kill($link, mysqli_thread_id($link));
-    mysqli_stmt_execute($stmt);
-    mysqli_stmt_close($stmt);
-    mysqli_close($link);
-    
-    /*
-    MYSQLI_REPORT_STRICT
-    
-    MYSQLI_REPORT_STRICT --->
-    php_mysqli_report_error() -> 
-      MYSQLI_REPORT_MYSQL_ERROR, 
-      MYSQLI_REPORT_STMT_ERROR ->
-       already tested
-    
-    php_mysqli_throw_sql_exception() ->
-      mysqli_real_connect()
-      mysqli_connect()
-    
-    can't be tested: mysqli_query() via mysql_use_result()/mysql_store_result()   
-    */
-    mysqli_report(MYSQLI_REPORT_OFF);
-    mysqli_report(MYSQLI_REPORT_STRICT);
-    
-    try {
-    
-        if ($link = 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);
-        
-    } catch (mysqli_sql_exception $e) {
-        printf("[013] %s\n", $e->getMessage());
-    } 
-        
-    try {
-        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))
-            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);
-    } catch (mysqli_sql_exception $e) {
-        printf("[016] %s\n", $e->getMessage());
-    }       
-    
-    /*
-    MYSQLI_REPORT_INDEX --->
-    mysqli_query()
-    mysqli_stmt_execute()
-    mysqli_prepare()
-    mysqli_real_query()
-    mysqli_store_result()
-    mysqli_use_result()    
-    
-    No test, because of to many prerequisites:
-      - Server needs to be started with and 
-        --log-slow-queries --log-queries-not-using-indexes
-      - query must cause the warning on all MySQL versions
-      
-    TODO:
-    */    
-    $log_slow_queries = false;
-    $log_queries_not_using_indexes = false;
-    
-    if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
-        printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
-        
-    if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'log_slow_queries'"))
-        printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-        
-    if (!$row = mysqli_fetch_assoc($res))
-        printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-        
-    $log_slow_query = ('ON' == $row['Value']);
-        
-    if (mysqli_get_server_version($link) >= 51011) {
-        if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE
'log_queries_not_using_indexes'"))
-            printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-        
-        if (!$row = mysqli_fetch_assoc($res))
-            printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-        
-        $log_queries_not_using_indexes = ('ON' == $row['Value']);
-    
-        if ($log_slow_queries && $log_queries_not_using_indexes) {
-        
-            for ($i = 100; $i < 20000; $i++) {
-                if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES ($i, 'z')"))
-                    printf("[022 - %d] [%d] %s\n", $i - 99, mysqli_errno($link),
mysqli_error($link)); 
-            }
-        
-            if (!$res = @mysqli_query($link, "SELECT id, label FROM test WHERE id =
1323"))
-            printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 
-           
-            mysqli_free_result($res);
-        
-            mysqli_report(MYSQLI_REPORT_OFF);
-            mysqli_report(MYSQLI_REPORT_INDEX);
-        }
-    }
-    
-    print "done!";
+	if (NULL !== ($tmp = @mysqli_report()))
+		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(-1)))
+		printf("[002] Expecting boolean/true even for invalid flags, got %s/%s\n",
gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ERROR)))
+		printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_STRICT)))
+		printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_INDEX)))
+		printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ALL)))
+		printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_OFF)))
+		printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+	require('table.inc');
+
+	/*
+	Internal macro MYSQL_REPORT_ERROR
+	*/
+	mysqli_report(MYSQLI_REPORT_ERROR);
+
+	mysqli_multi_query($link, "BAR; FOO;");
+	mysqli_query($link, "FOO");
+	/* This might work if you accept anonymous users in your setup */
+	mysqli_change_user($link,
"0123456789-10-456789-20-456789-30-456789-40-456789-50-456789-60-456789-70-456789-80-456789-90-456789",
"password", $db);
+	mysqli_kill($link, -1);
+
+	// mysqli_ping() cannot be tested, because one would need to cause an error inside the C
function to test it
+	mysqli_prepare($link, "FOO");
+	mysqli_real_query($link, "FOO");
+	if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name"))
+		printf("[009] select_db should have failed\n");
+	// mysqli_store_result() and mysqli_use_result() cannot be tested, because one would
need to cause an error inside the C function to test it
+
+
+	// Check that none of the above would have caused any error messages if
MYSQL_REPORT_ERROR would
+	// not have been set. If that would be the case, the test would be broken.
+	mysqli_report(MYSQLI_REPORT_OFF);
+
+	mysqli_multi_query($link, "BAR; FOO;");
+	mysqli_query($link, "FOO");
+	mysqli_change_user($link, "This might work if you accept anonymous users in your setup",
"password", $db);
+	mysqli_kill($link, -1);
+	mysqli_prepare($link, "FOO");
+	mysqli_real_query($link, "FOO");
+	mysqli_select_db($link, "Oh lord, let this be an unknown database name");
+
+	/*
+	Internal macro MYSQL_REPORT_STMT_ERROR
+	*/
+
+	mysqli_report(MYSQLI_REPORT_ERROR);
+
+	$stmt = mysqli_stmt_init($link);
+	mysqli_stmt_prepare($stmt, "FOO");
+
+	$stmt = mysqli_stmt_init($link);
+	mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
+	$id = 1;
+	mysqli_kill($link, mysqli_thread_id($link));
+	mysqli_stmt_bind_param($stmt, "i", $id);
+	mysqli_stmt_close($stmt);
+	mysqli_close($link);
+
+	/* mysqli_stmt_execute() = mysql_stmt_execute cannot be tested from PHP */
+	if (!$link = 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 > ?");
+	$id = 1;
+	mysqli_stmt_bind_param($stmt, "i", $id);
+	// mysqli_kill($link, mysqli_thread_id($link));
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_close($stmt);
+	mysqli_close($link);
+
+	/* mysqli_kill() "trick" does not work for any of the following because of an
E_COMMANDS_OUT_OF_SYNC */
+	/* mysqli_stmt_bind_result() = mysql_stmt_bind_result() cannot be tested from PHP */
+	/* mysqli_stmt_fetch() = mysql_stmt_fetch() cannot be tested from PHP */
+	/* mysqli_stmt_result_metadata() = mysql_stmt_result_metadata() cannot be tested from
PHP */
+	/* mysqli_stmt_store_result() = mysql_stmt_store_result() cannot be tested from PHP */
+
+	// Check
+	mysqli_report(MYSQLI_REPORT_OFF);
+
+	if (!$link = 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");
+
+	$stmt = mysqli_stmt_init($link);
+	mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
+	$id = 1;
+	mysqli_kill($link, mysqli_thread_id($link));
+	mysqli_stmt_bind_param($stmt, "i", $id);
+	mysqli_stmt_close($stmt);
+	mysqli_close($link);
+
+	if (!$link = 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 > ?");
+	$id = 1;
+	mysqli_stmt_bind_param($stmt, "i", $id);
+	mysqli_kill($link, mysqli_thread_id($link));
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_close($stmt);
+	mysqli_close($link);
+
+	/*
+	MYSQLI_REPORT_STRICT
+
+	MYSQLI_REPORT_STRICT --->
+	php_mysqli_report_error() ->
+		MYSQLI_REPORT_MYSQL_ERROR,
+		MYSQLI_REPORT_STMT_ERROR ->
+			already tested
+
+	php_mysqli_throw_sql_exception() ->
+		mysqli_real_connect()
+		mysqli_connect()
+
+	can't be tested: mysqli_query() via mysql_use_result()/mysql_store_result()
+	*/
+	mysqli_report(MYSQLI_REPORT_OFF);
+	mysqli_report(MYSQLI_REPORT_STRICT);
+
+	try {
+
+		if ($link = 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);
+
+	} catch (mysqli_sql_exception $e) {
+		printf("[013] %s\n", $e->getMessage());
+	}
+
+	try {
+		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))
+			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);
+	} catch (mysqli_sql_exception $e) {
+		printf("[016] %s\n", $e->getMessage());
+	}
+
+	/*
+	MYSQLI_REPORT_INDEX --->
+	mysqli_query()
+	mysqli_stmt_execute()
+	mysqli_prepare()
+	mysqli_real_query()
+	mysqli_store_result()
+	mysqli_use_result()
+
+	No test, because of to many prerequisites:
+		- Server needs to be started with and
+			--log-slow-queries --log-queries-not-using-indexes
+		- query must cause the warning on all MySQL versions
+
+	TODO:
+	*/
+	$log_slow_queries = false;
+	$log_queries_not_using_indexes = false;
+
+	if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+		printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+
+	if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'log_slow_queries'"))
+		printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if (!$row = mysqli_fetch_assoc($res))
+		printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	$log_slow_query = ('ON' == $row['Value']);
+
+	if (mysqli_get_server_version($link) >= 51011) {
+		if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'log_queries_not_using_indexes'"))
+			printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+		if (!$row = mysqli_fetch_assoc($res))
+			printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+		$log_queries_not_using_indexes = ('ON' == $row['Value']);
+
+		if ($log_slow_queries && $log_queries_not_using_indexes) {
+
+			for ($i = 100; $i < 20000; $i++) {
+				if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES ($i, 'z')"))
+					printf("[022 - %d] [%d] %s\n", $i - 99, mysqli_errno($link), mysqli_error($link));
+			}
+
+			if (!$res = @mysqli_query($link, "SELECT id, label FROM test WHERE id = 1323"))
+				printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+			mysqli_free_result($res);
+
+			mysqli_report(MYSQLI_REPORT_OFF);
+			mysqli_report(MYSQLI_REPORT_INDEX);
+		}
+	}
+
+	print "done!";
 ?>
 --EXPECTF--
 Warning: mysqli_multi_query(): (%d/%d): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax to use near
'BAR; FOO' at line 1 in %s on line %d

Modified: trunk/tests/ext/mysqli/mysqli_report_wo_ps.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_report_wo_ps.phpt	2007-07-19 15:31:56 UTC (rev 803)
+++ trunk/tests/ext/mysqli/mysqli_report_wo_ps.phpt	2007-07-19 15:52:37 UTC (rev 804)
@@ -5,91 +5,89 @@
 <?php require_once('skipifemb.inc'); ?>
 --FILE--
 <?php
-    include "connect.inc";  
-    
-    $tmp    = NULL;   
-    $link   = NULL;    
-    
-    if (NULL !== ($tmp = @mysqli_report()))
-        printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);        
+	include "connect.inc";
 
-    if (true !== ($tmp = mysqli_report(-1)))
-        printf("[002] Expecting boolean/true even for invalid flags, got %s/%s\n",
gettype($tmp), $tmp);
-        
-    if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ERROR)))
-        printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
-        
-    if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_STRICT)))
-        printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);        
-        
-    if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_INDEX)))
-        printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);    
-        
-    if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ALL)))
-        printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
-        
-    if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_OFF)))
-        printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);        
-        
-    require('table.inc');   
-      
-    /*    
-    Internal macro MYSQL_REPORT_ERROR    
-    */    
-    mysqli_report(MYSQLI_REPORT_ERROR);
-       
-    mysqli_multi_query($link, "BAR; FOO;");
-    mysqli_query($link, "FOO");
-    mysqli_change_user($link,
"0123456789-10-456789-20-456789-30-456789-40-456789-50-456789-60-456789-70-456789-80-456789-90-456789",
"password", $db);
-    mysqli_kill($link, -1);
-    
-    // mysqli_ping() cannot be tested, because one would need to cause an error inside
the C function to test it    
-    mysqli_real_query($link, "FOO");
-    if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name"))
-    	printf("[009] select_db should have failed\n");
-    // mysqli_store_result() and mysqli_use_result() cannot be tested, because one would
need to cause an error inside the C function to test it
-    
-    
-    // Check that none of the above would have caused any error messages if
MYSQL_REPORT_ERROR would
-    // not have been set. If that would be the case, the test would be broken.
-    mysqli_report(MYSQLI_REPORT_OFF);
-    
-    mysqli_multi_query($link, "BAR; FOO;");
-    mysqli_query($link, "FOO");
-    mysqli_change_user($link, "This might work if you accept anonymous users in your
setup", "password", $db);
-    mysqli_kill($link, -1);        
-    mysqli_real_query($link, "FOO");
-    mysqli_select_db($link, "Oh lord, let this be an unknown database name");
-          
-    
-    mysqli_report(MYSQLI_REPORT_OFF);
-    mysqli_report(MYSQLI_REPORT_STRICT);
-    
-    try {
-    
-        if ($link = 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);
-        
-    } catch (mysqli_sql_exception $e) {
-        printf("[011] %s\n", $e->getMessage());
-    } 
-        
-    try {
-        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))
-            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);
-    } catch (mysqli_sql_exception $e) {
-        printf("[014] %s\n", $e->getMessage());
-    }  
-    
-    
-    print "done!";
+	$tmp    = NULL;
+	$link   = NULL;
+
+	if (NULL !== ($tmp = @mysqli_report()))
+		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(-1)))
+		printf("[002] Expecting boolean/true even for invalid flags, got %s/%s\n",
gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ERROR)))
+		printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_STRICT)))
+		printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_INDEX)))
+		printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ALL)))
+		printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_OFF)))
+		printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+	require('table.inc');
+
+	/*
+	Internal macro MYSQL_REPORT_ERROR
+	*/
+	mysqli_report(MYSQLI_REPORT_ERROR);
+
+	mysqli_multi_query($link, "BAR; FOO;");
+	mysqli_query($link, "FOO");
+	mysqli_change_user($link,
"0123456789-10-456789-20-456789-30-456789-40-456789-50-456789-60-456789-70-456789-80-456789-90-456789",
"password", $db);
+	mysqli_kill($link, -1);
+
+	// mysqli_ping() cannot be tested, because one would need to cause an error inside the C
function to test it
+	mysqli_real_query($link, "FOO");
+	if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name"))
+		printf("[009] select_db should have failed\n");
+	// mysqli_store_result() and mysqli_use_result() cannot be tested, because one would
need to cause an error inside the C function to test it
+
+
+	// Check that none of the above would have caused any error messages if
MYSQL_REPORT_ERROR would
+	// not have been set. If that would be the case, the test would be broken.
+	mysqli_report(MYSQLI_REPORT_OFF);
+
+	mysqli_multi_query($link, "BAR; FOO;");
+	mysqli_query($link, "FOO");
+	mysqli_change_user($link, "This might work if you accept anonymous users in your setup",
"password", $db);
+	mysqli_kill($link, -1);
+	mysqli_real_query($link, "FOO");
+	mysqli_select_db($link, "Oh lord, let this be an unknown database name");
+
+	mysqli_report(MYSQLI_REPORT_OFF);
+	mysqli_report(MYSQLI_REPORT_STRICT);
+
+	try {
+
+		if ($link = 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);
+
+	} catch (mysqli_sql_exception $e) {
+		printf("[011] %s\n", $e->getMessage());
+	}
+
+	try {
+		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))
+			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);
+	} catch (mysqli_sql_exception $e) {
+		printf("[014] %s\n", $e->getMessage());
+	}
+
+	print "done!";
 ?>
 --EXPECTF--
 Warning: mysqli_multi_query(): (%d/%d): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax to use near
'BAR; FOO' at line 1 in %s on line %d
@@ -105,4 +103,4 @@
 Warning: mysqli_kill(): processid should have positive value in %s on line %d
 [011] Access denied for user '%s'@'%s' (using password: YES)
 [014] Access denied for user '%s'@'%s' (using password: YES)
-done!
+done!
\ No newline at end of file

Modified: trunk/tests/ext/mysqli/mysqli_rollback.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_rollback.phpt	2007-07-19 15:31:56 UTC (rev 803)
+++ trunk/tests/ext/mysqli/mysqli_rollback.phpt	2007-07-19 15:52:37 UTC (rev 804)
@@ -1,81 +1,82 @@
 --TEST--
 mysqli_rollback()
 --SKIPIF--
-<?php require_once('skipif.inc'); ?>
-<?php require_once('skipifemb.inc'); ?>
+<?php  ?>
+<?php  ?>
 <?PHP
+	require_once('skipif.inc');
+	require_once('skipifemb.inc');
+	require_once('connect.inc');
+
 	if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
-        printf("[s001] 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);            
+		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));
 	}
-            
+
 	if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) {
-	   printf("[s002] SKIP: Cannot fetch have_innodb variable\n");
-	   exit(1);	   
+		die(sprintf("skip Cannot fetch have_innodb variable\n"));
 	}
-	
+
 	$row = mysqli_fetch_row($res);
 	mysqli_free_result($res);
 	mysqli_close($link);
-	
+
 	if ($row[1] == "DISABLED" || $row[1] == "NO") {
-		printf ("[s003] SKIP: Innodb support is not installed or enabled.");
-		exit(1);
+		die(sprintf("skip Innodb support is not installed or enabled."));
 	}
 ?>
 --FILE--
 <?php
-    include "connect.inc";
-        
-    $tmp    = NULL;   
-    $link   = NULL;    
-    
-    if (!is_null($tmp = @mysqli_rollback()))
-        printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-        
-    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))
-        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);
-            
-    if (!is_null($tmp = @mysqli_rollback($link, 'foo')))
-        printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-        
-    if (true !== ($tmp = mysqli_autocommit($link, false)))
-        printf("[005] Cannot turn off autocommit, expecting true, got %s/%s\n",
gettype($tmp), $tmp);
+	include "connect.inc";
 
-    if (!mysqli_query($link, 'DROP TABLE IF EXISTS test'))    
-        printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-        
-    if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB'))
-        printf("[007] Cannot create test table, [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+	$tmp    = NULL;
+	$link   = NULL;
 
-    if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)'))
-        printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	if (!is_null($tmp = @mysqli_rollback()))
+		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-    $tmp = mysqli_rollback($link);
-    if ($tmp !== true) 
-        printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);   
-        
-    if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test'))
-        printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-    $tmp = mysqli_fetch_assoc($res);    
-    if (0 != $tmp['num'])
-        printf("[12] Expecting 0 rows in table test, found %d rows\n", $tmp['num']);
-    mysqli_free_result($res);
-    
-    if (!mysqli_query($link, 'DROP TABLE IF EXISTS test'))
-        printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-       
-    mysqli_close($link);
-    
-    if (!is_null($tmp = mysqli_rollback($link)))
-        printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);    
-    
-    print "done!\n";  
+	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))
+		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);
+
+	if (!is_null($tmp = @mysqli_rollback($link, 'foo')))
+		printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (true !== ($tmp = mysqli_autocommit($link, false)))
+		printf("[005] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp),
$tmp);
+
+	if (!mysqli_query($link, 'DROP TABLE IF EXISTS test'))
+		printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB'))
+		printf("[007] Cannot create test table, [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+
+	if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)'))
+		printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	$tmp = mysqli_rollback($link);
+	if ($tmp !== true)
+		printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS num FROM test'))
+		printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	$tmp = mysqli_fetch_assoc($res);
+	if (0 != $tmp['num'])
+		printf("[12] Expecting 0 rows in table test, found %d rows\n", $tmp['num']);
+	mysqli_free_result($res);
+
+	if (!mysqli_query($link, 'DROP TABLE IF EXISTS test'))
+		printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	mysqli_close($link);
+
+	if (!is_null($tmp = mysqli_rollback($link)))
+		printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+	print "done!\n";
 ?>
 --EXPECTF--
 Warning: mysqli_rollback(): Couldn't fetch mysqli in %s on line %d

Modified: trunk/tests/ext/mysqli/mysqli_select_db.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_select_db.phpt	2007-07-19 15:31:56 UTC (rev 803)
+++ trunk/tests/ext/mysqli/mysqli_select_db.phpt	2007-07-19 15:52:37 UTC (rev 804)
@@ -5,67 +5,67 @@
 <?php require_once('skipifemb.inc'); ?>
 --FILE--
 <?php
-    include "connect.inc";
+	include "connect.inc";
 
-    $tmp    = NULL;   
-    $link   = NULL;    
-    
-    if (!is_null($tmp = @mysqli_select_db()))
-        printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-        
-    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))
-        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);
-            
-    if (!is_null($tmp = @mysqli_select_db($link, $db, "foo")))
-        printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-        
-    /* does not make too much sense, unless we have access to at least one more database
than $db */
-    if (!mysqli_select_db($link, $db))
-        printf("[005] Cannot select DB %s, [%d] %s\n", $db, mysqli_errno($link),
mysqli_error($link));
-        
-    if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
-        printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	$tmp    = NULL;
+	$link   = NULL;
 
-    if (!$row = mysqli_fetch_assoc($res))
-        printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-        
-    if ($row['dbname'] !== (string)$db)
-        printf("[008] Expecting database '%s', found '%s'\n", $db, $row['dbname']);
-    mysqli_free_result($res);
-    
-    if (mysqli_select_db($link, 'mysql')) {
-        // Yippie, a second database to play with - that's great because mysqli_select_db
-        // ($db) was done by mysqli__connect() already and the previous test 
-        // was quite useless
-        if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
-            printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	if (!is_null($tmp = @mysqli_select_db()))
+		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-        if (!$row = mysqli_fetch_assoc($res))
-            printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-        
-        if (strtolower($row['dbname']) !== 'mysql')
-            printf("[011] Expecting database 'mysql', found '%s'\n", $row['dbname']);
-        mysqli_free_result($res);
-    }
-    
-    mysqli_report(MYSQLI_REPORT_OFF);
-    mysqli_select_db($link, 'I can not imagine that this database exists');
-    mysqli_report(MYSQLI_REPORT_ERROR);
-    mysqli_select_db($link, 'I can not imagine that this database exists');
-        
-    mysqli_close($link);
-    
-    if (NULL !== ($tmp = mysqli_select_db($link, $db)))
-        printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-        
-    print "done!\n";  
+	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))
+		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);
+
+	if (!is_null($tmp = @mysqli_select_db($link, $db, "foo")))
+		printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+	/* does not make too much sense, unless we have access to at least one more database
than $db */
+	if (!mysqli_select_db($link, $db))
+		printf("[005] Cannot select DB %s, [%d] %s\n", $db, mysqli_errno($link),
mysqli_error($link));
+
+	if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
+		printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if (!$row = mysqli_fetch_assoc($res))
+		printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if ($row['dbname'] !== (string)$db)
+		printf("[008] Expecting database '%s', found '%s'\n", $db, $row['dbname']);
+	mysqli_free_result($res);
+
+	if (mysqli_select_db($link, 'mysql')) {
+		// Yippie, a second database to play with - that's great because mysqli_select_db
+		// ($db) was done by mysqli__connect() already and the previous test
+		// was quite useless
+		if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
+			printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+		if (!$row = mysqli_fetch_assoc($res))
+			printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+		if (strtolower($row['dbname']) !== 'mysql')
+			printf("[011] Expecting database 'mysql', found '%s'\n", $row['dbname']);
+		mysqli_free_result($res);
+	}
+
+	mysqli_report(MYSQLI_REPORT_OFF);
+	mysqli_select_db($link, 'I can not imagine that this database exists');
+	mysqli_report(MYSQLI_REPORT_ERROR);
+	mysqli_select_db($link, 'I can not imagine that this database exists');
+
+	mysqli_close($link);
+
+	if (NULL !== ($tmp = mysqli_select_db($link, $db)))
+		printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+	print "done!\n";
 ?>
 --EXPECTF--
 Warning: mysqli_select_db(): (%d/%d): Unknown database '%s' in %s on line %d
 
 Warning: mysqli_select_db(): Couldn't fetch mysqli in %s on line %d
-done! 
\ No newline at end of file
+done!
\ No newline at end of file

Modified: trunk/tests/ext/mysqli/mysqli_set_charset.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_set_charset.phpt	2007-07-19 15:31:56 UTC (rev 803)
+++ trunk/tests/ext/mysqli/mysqli_set_charset.phpt	2007-07-19 15:52:37 UTC (rev 804)
@@ -2,101 +2,101 @@
 mysqli_set_charset()
 --SKIPIF--
 <?php require_once('skipif.inc'); ?>
-<?php 
-require_once('skipifemb.inc'); 
+<?php
+require_once('skipifemb.inc');
 if (!function_exists('mysqli_set_charset'))
-    die("skip: function not available");
+ 	die("skip Function not available");
 if (ini_get("unicode.semantics"))
-	die("skip: mysqli_set_charset disabled in unicode");
+	die("skip: mysqli_set_charset() is disabled in unicode");
 ?>
 --FILE--
 <?php
-    include "connect.inc";
-    
-    $tmp    = NULL;   
-    $link   = NULL;    
-    
-    if (!is_null($tmp = @mysqli_set_charset()))
-        printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-        
-    if (!is_null($tmp = @mysqli_set_charset($link)))
-        printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-        
-    if (!is_null($tmp = @mysqli_set_charset($link, $link)))
-        printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-    
-    require('table.inc');
-    
-    if (!$res = mysqli_query($link, 'SELECT version() AS server_version'))
-        printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-    $tmp = mysqli_fetch_assoc($res);
-    mysqli_free_result($res);    
-    $version = explode('.', $tmp['server_version']);
-    if (empty($version))
-        printf("[005] Cannot determine server version, need MySQL Server 4.1+ for the
test!\n");
+	include "connect.inc";
 
-    if ($version[0] <= 4 && $version[1] < 1)
-        printf("[006] Need MySQL Server 4.1+ for the test!\n");
-        
-    if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset,
@@collation_connection AS collation'))
-        printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-    $tmp = mysqli_fetch_assoc($res);
-    mysqli_free_result($res);
-    if (!$character_set_connection = $tmp['charset'])
-        printf("[008] Cannot determine current character set and collation\n");
+	$tmp    = NULL;
+	$link   = NULL;
 
-    $new_charset = ('latin1' == $character_set_connection) ? 'latin2' : 'latin1';
-    if (!$res = mysqli_query($link, sprintf('SHOW CHARACTER SET LIKE "%s"',
$new_charset), MYSQLI_STORE_RESULT))
-        printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-    
-    if (mysqli_num_rows($res) == 0)
-        printf("[010] Test will fail, because alternative test character set '%s' seems
not supported\n", $new_charset);
-    
-    if (false !== ($ret = mysqli_set_charset($link, "this is not a valid character
set")))
-        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))
-        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);        
-        
-    if (true !== ($ret = mysqli_set_charset($link, $new_charset)))
-        printf("[013] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret);
-        
-    if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset,
@@collation_connection AS collation'))
-        printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-    $tmp = mysqli_fetch_assoc($res);
-    mysqli_free_result($res);
-    if ($new_charset !== $tmp['charset'])
-        printf("[015] Character set not changed? Expecting %s, got %s\n", $new_charset,
$tmp['charset']);
-        
-    if (!$res = mysqli_query($link, "SHOW CHARACTER SET"))
-        printf("[016] Cannot get list of character sets\n");
-        
-    while ($tmp = mysqli_fetch_assoc($res)) {  
-        if ('ucs2' == $tmp['Charset'])
-            continue;    
-            
-        /* Uncomment to see where it hangs - var_dump($tmp); flush(); */
-        if (!@mysqli_set_charset($link, $tmp['Charset'])) {
-            printf("[017] Cannot set character set to '%s', [%d] %s\n", $tmp['Charset'],
-                mysqli_errno($link), mysqli_error($link));
-            continue;                
-        }
-        
-        /* Uncomment to see where it hangs - var_dump($tmp); flush(); */
-        if (!mysqli_query($link, sprintf("SET NAMES %s", mysqli_real_escape_string($link,
$tmp['Charset']))))
-            printf("[018] Cannot run SET NAMES %s, [%d] %s\n", $tmp['Charset'],
mysqli_errno($link), mysqli_error($link));
-    }            
-    mysqli_free_result($res);
-            
-    mysqli_close($link);
-    
-    if (NULL !== ($tmp = mysqli_set_charset($link, $new_charset)))
-        printf("[016] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-   
-    print "done!\n";  
+	if (!is_null($tmp = @mysqli_set_charset()))
+		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (!is_null($tmp = @mysqli_set_charset($link)))
+		printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+	if (!is_null($tmp = @mysqli_set_charset($link, $link)))
+		printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+	require('table.inc');
+
+	if (!$res = mysqli_query($link, 'SELECT version() AS server_version'))
+		printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	$tmp = mysqli_fetch_assoc($res);
+	mysqli_free_result($res);
+	$version = explode('.', $tmp['server_version']);
+	if (empty($version))
+		printf("[005] Cannot determine server version, need MySQL Server 4.1+ for the
test!\n");
+
+	if ($version[0] <= 4 && $version[1] < 1)
+		printf("[006] Need MySQL Server 4.1+ for the test!\n");
+
+	if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset,
@@collation_connection AS collation'))
+		printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	$tmp = mysqli_fetch_assoc($res);
+	mysqli_free_result($res);
+	if (!$character_set_connection = $tmp['charset'])
+		printf("[008] Cannot determine current character set and collation\n");
+
+	$new_charset = ('latin1' == $character_set_connection) ? 'latin2' : 'latin1';
+	if (!$res = mysqli_query($link, sprintf('SHOW CHARACTER SET LIKE "%s"', $new_charset),
MYSQLI_STORE_RESULT))
+		printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+	if (mysqli_num_rows($res) == 0)
+		printf("[010] Test will fail, because alternative test character set '%s' seems not
supported\n", $new_charset);
+
+	if (false !== ($ret = mysqli_set_charset($link, "this is not a valid character set")))
+		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))
+		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);
+
+	if (true !== ($ret = mysqli_set_charset($link, $new_charset)))
+		printf("[013] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret);
+
+	if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset,
@@collation_connection AS collation'))
+		printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	$tmp = mysqli_fetch_assoc($res);
+	mysqli_free_result($res);
+	if ($new_charset !== $tmp['charset'])
+		printf("[015] Character set not changed? Expecting %s, got %s\n", $new_charset,
$tmp['charset']);
+
+	if (!$res = mysqli_query($link, "SHOW CHARACTER SET"))
+		printf("[016] Cannot get list of character sets\n");
+
+	while ($tmp = mysqli_fetch_assoc($res)) {
+		if ('ucs2' == $tmp['Charset'])
+			continue;
+
+		/* Uncomment to see where it hangs - var_dump($tmp); flush(); */
+		if (!@mysqli_set_charset($link, $tmp['Charset'])) {
+			printf("[017] Cannot set character set to '%s', [%d] %s\n", $tmp['Charset'],
+				mysqli_errno($link), mysqli_error($link));
+			continue;
+		}
+
+		/* Uncomment to see where it hangs - var_dump($tmp); flush(); */
+		if (!mysqli_query($link, sprintf("SET NAMES %s", mysqli_real_escape_string($link,
$tmp['Charset']))))
+			printf("[018] Cannot run SET NAMES %s, [%d] %s\n", $tmp['Charset'],
mysqli_errno($link), mysqli_error($link));
+	}
+	mysqli_free_result($res);
+
+	mysqli_close($link);
+
+	if (NULL !== ($tmp = mysqli_set_charset($link, $new_charset)))
+		printf("[016] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+	print "done!";
 ?>
 --EXPECTF--
 Warning: mysqli_set_charset(): Couldn't fetch mysqli in %s on line %d
-done! 
+done!
\ No newline at end of file

Modified: trunk/tests/ext/mysqli/mysqli_set_local_infile_default.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_set_local_infile_default.phpt	2007-07-19 15:31:56 UTC
(rev 803)
+++ trunk/tests/ext/mysqli/mysqli_set_local_infile_default.phpt	2007-07-19 15:52:37 UTC
(rev 804)
@@ -1,191 +1,191 @@
 --TEST--
 mysqli_set_local_infile_default()
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
-require_once('connect.inc');
+require_once('skipifemb.inc');
 
 if (!function_exists('mysqli_set_local_infile_handler'))
-    die("skip - function not available.");
-    
+	die("skip - function not available.");
+
+require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
-    die("skip - experimental (= unsupported) feature");    
+	die("skip - experimental (= unsupported) feature");
 ?>
 --FILE--
 <?php
-    include "connect.inc";
-    
-    $link = $tmp = null;
-    if (!is_null($tmp = @mysqli_set_local_infile_default()))
-        printf("[001] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
-        
-    if (!is_null($tmp = @mysqli_set_local_infile_default($link)))
-        printf("[002] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);   
-    
-    include("table.inc");
-    
-    if (!is_null($tmp = @mysqli_set_local_infile_default($link, 'foo')))
-        printf("[003] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
-     
-    
-    function callback_simple($fp, &$buffer, $buflen, &$error) {
-        static $invocation = 0;
-        
-        printf("Callback: %d\n", $invocation);
-        
-        $invocation++;
-        if (!is_resource($fp))
-            printf("[012] First argument passed to callback is not a resource but
%s/%s\n",
-                $fp, gettype($fp));
-                
-        if (!$buffer = fread($fp, $buflen)) {
-            if ($invocation == 1) {
-                printf("[013] Cannot read from stream\n");
-                $error = 'Cannot read from stream';
-            } else {
-                return strlen($buffer);
-            }
-        }        
-        
-        $lines = explode("\n", $buffer);        
-        if (count($lines) != 4 && strlen($buffer) > 0) {
-            printf("[014] Test is too simple to handle a buffer of size %d that cannot
hold all lines\n", $buflen);
-            $error = 'Parser too simple';
-        }            
-        
-        $buffer = '';
-        foreach ($lines as $k => $line) {
-            if ('' === trim($line))
-                continue;
-                
-            $columns = explode(';', $line);
-            if (empty($columns)) {
-                printf("[015] Cannot parse columns\n");
-                $error = 'Cannot parse columns';
-            }
-            
-            // increase id column value
-            $columns[0] += 1;
-            $buffer .= implode(';', $columns);
-            $buffer .= "\n";
-        }
-        
-        return strlen($buffer);
-    }    
-    
-    // create a CVS file
-    $file = tempnam(sys_get_temp_dir(), 'mysqli_test');
-    if (!$fp = fopen($file, 'w'))
-        printf("[004] Cannot create CVS file '%s'\n", $file);
+	include "connect.inc";
 
-    if (!fwrite($fp, "97;'x';\n") ||
-        !fwrite($fp, "98;'y';\n") ||
-        !fwrite($fp, "99;'z';\n"))
-        printf("[005] Cannot write CVS file '%s'\n", $file);
-        
-    fclose($fp);    
-    
-    if (!chmod($file, 0644))
-        printf("[006] Cannot change the file perms of '%s' from 0600 to 0644, MySQL might
not be able to read it\n",
-            $file);
+	$link = $tmp = null;
+	if (!is_null($tmp = @mysqli_set_local_infile_default()))
+		printf("[001] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
 
-    function try_handler($offset, $link, $file, $handler, $expected) {
-        
-        if ('default' == $handler) {
-            mysqli_set_local_infile_default($link);
-            printf("Callback set to default\n");
-        } else {
-            if (!mysqli_set_local_infile_handler($link, $handler)) {
-                printf("[%03d] Cannot set infile handler to '%s'\n", $offset, $handler);
-                return false;
-            }
-            printf("Callback set to '%s'\n", $handler);
-        }
-        
-        if (!mysqli_query($link, sprintf("DELETE FROM test"))) {
-            printf("[%03d] Cannot remove records, [%d] %s\n", $offset + 1,
mysqli_errno($link), mysqli_error($link));
-            return false;
-        }
-        
-        
-        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("[%03d] LOAD DATA failed, [%d] %s\n", 
-                    $offset + 2,
-                    mysqli_errno($link), mysqli_error($link));
-        }
-        if (0 !== mysqli_warning_count($link)) {
-            printf("[%03d] There are warnings!\n", $offset + 3);
-        }
-        
-        if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) {
-            printf("[%03d] [%d] %s\n", $offset + 4, mysqli_errno($link),
mysqli_error($link));
-            return false;
-        }
+	if (!is_null($tmp = @mysqli_set_local_infile_default($link)))
+		printf("[002] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
 
-        foreach ($expected as $k => $values) {
-            if (!$tmp = mysqli_fetch_assoc($res)) {
-                printf("[%03d/%d] [%d] %s\n", $offset + 5, $k, mysqli_errno($link),
mysqli_error($link));
-                return false;
-            }
-            if ($values['id'] != $tmp['id']) {
-                printf("[%03d/%d] Expecting %s got %s\n", 
-                    $offset + 6, $k, 
-                    $values['id'], $tmp['id']);
-                return false;
-            }
-            if ($values['label'] != $tmp['label']) {
-                printf("[%03d/%d] Expecting %s got %s\n", 
-                    $offset + 7, $k,
-                    $values['label'], $tmp['label']);
-                return false;
-            }
-        }
-        
-        if ($res && $tmp = mysqli_fetch_assoc($res)) {
-            printf("[%03d] More results than expected! Dumping data \n", $offset + 7);
-            do {
-                var_dump($tmp);
-            } while ($tmp = mysqli_fetch_assoc($res));
-        }
-        
-        if ($res)
-            mysqli_free_result($res);
-        
-        return true;
-    }
-    
-    $expected = array(
-                    array('id' => 98,   'label' => 'x'),
-                    array('id' => 99,   'label' => 'y'),
-                    array('id' => 100,  'label' => 'z'),
-                );
-    try_handler(10, $link, $file, 'callback_simple', $expected);
-    
-    $expected = array(
-                    array('id' => 97,   'label' => 'x'),
-                    array('id' => 98,   'label' => 'y'),
-                    array('id' => 99,   'label' => 'z'),
-                );
-    try_handler(20, $link, $file, 'default', $expected);        
-    
-    $expected = array(
-                    array('id' => 98,   'label' => 'x'),
-                    array('id' => 99,   'label' => 'y'),
-                    array('id' => 100,  'label' => 'z'),
-                );
-    try_handler(30, $link, $file, 'callback_simple', $expected);
-       
-    mysqli_close($link);
-    
-    if (!is_null($tmp = @mysqli_set_local_infile_default($link)))
-        printf("[300] Expecting NULL/NULL got %s/%s\n", $tmp, gettype($tmp));
-        
-    print "done!";
+	include("table.inc");
+
+	if (!is_null($tmp = @mysqli_set_local_infile_default($link, 'foo')))
+		printf("[003] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
+
+
+	function callback_simple($fp, &$buffer, $buflen, &$error) {
+		static $invocation = 0;
+
+		printf("Callback: %d\n", $invocation);
+
+		$invocation++;
+		if (!is_resource($fp))
+			printf("[012] First argument passed to callback is not a resource but %s/%s\n",
+				$fp, gettype($fp));
+
+		if (!$buffer = fread($fp, $buflen)) {
+			if ($invocation == 1) {
+				printf("[013] Cannot read from stream\n");
+				$error = 'Cannot read from stream';
+			} else {
+				return strlen($buffer);
+			}
+		}
+
+		$lines = explode("\n", $buffer);
+		if (count($lines) != 4 && strlen($buffer) > 0) {
+			printf("[014] Test is too simple to handle a buffer of size %d that cannot hold all
lines\n", $buflen);
+			$error = 'Parser too simple';
+		}
+
+		$buffer = '';
+		foreach ($lines as $k => $line) {
+			if ('' === trim($line))
+				continue;
+
+			$columns = explode(';', $line);
+			if (empty($columns)) {
+				printf("[015] Cannot parse columns\n");
+				$error = 'Cannot parse columns';
+			}
+
+			// increase id column value
+			$columns[0] += 1;
+			$buffer .= implode(';', $columns);
+			$buffer .= "\n";
+		}
+
+		return strlen($buffer);
+	}
+
+	// create a CVS file
+	$file = tempnam(sys_get_temp_dir(), 'mysqli_test');
+	if (!$fp = fopen($file, 'w'))
+		printf("[004] Cannot create CVS file '%s'\n", $file);
+
+	if (!fwrite($fp, "97;'x';\n") ||
+		!fwrite($fp, "98;'y';\n") ||
+		!fwrite($fp, "99;'z';\n"))
+		printf("[005] Cannot write CVS file '%s'\n", $file);
+
+	fclose($fp);
+
+	if (!chmod($file, 0644))
+		printf("[006] Cannot change the file perms of '%s' from 0600 to 0644, MySQL might not
be able to read it\n",
+			$file);
+
+	function try_handler($offset, $link, $file, $handler, $expected) {
+
+		if ('default' == $handler) {
+			mysqli_set_local_infile_default($link);
+			printf("Callback set to default\n");
+		} else {
+			if (!mysqli_set_local_infile_handler($link, $handler)) {
+				printf("[%03d] Cannot set infile handler to '%s'\n", $offset, $handler);
+				return false;
+			}
+			printf("Callback set to '%s'\n", $handler);
+		}
+
+		if (!mysqli_query($link, sprintf("DELETE FROM test"))) {
+			printf("[%03d] Cannot remove records, [%d] %s\n", $offset + 1, mysqli_errno($link),
mysqli_error($link));
+			return false;
+		}
+
+
+		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("[%03d] LOAD DATA failed, [%d] %s\n",
+				$offset + 2,
+				mysqli_errno($link), mysqli_error($link));
+		}
+		if (0 !== mysqli_warning_count($link)) {
+			printf("[%03d] There are warnings!\n", $offset + 3);
+		}
+
+		if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) {
+			printf("[%03d] [%d] %s\n", $offset + 4, mysqli_errno($link), mysqli_error($link));
+			return false;
+		}
+
+		foreach ($expected as $k => $values) {
+			if (!$tmp = mysqli_fetch_assoc($res)) {
+				printf("[%03d/%d] [%d] %s\n", $offset + 5, $k, mysqli_errno($link),
mysqli_error($link));
+				return false;
+			}
+			if ($values['id'] != $tmp['id']) {
+				printf("[%03d/%d] Expecting %s got %s\n",
+					$offset + 6, $k,
+					$values['id'], $tmp['id']);
+				return false;
+			}
+			if ($values['label'] != $tmp['label']) {
+				printf("[%03d/%d] Expecting %s got %s\n",
+					$offset + 7, $k,
+					$values['label'], $tmp['label']);
+				return false;
+			}
+		}
+
+		if ($res && $tmp = mysqli_fetch_assoc($res)) {
+			printf("[%03d] More results than expected! Dumping data \n", $offset + 7);
+			do {
+				var_dump($tmp);
+			} while ($tmp = mysqli_fetch_assoc($res));
+		}
+
+		if ($res)
+			mysqli_free_result($res);
+
+		return true;
+	}
+
+	$expected = array(
+		array('id' => 98,   'label' => 'x'),
+		array('id' => 99,   'label' => 'y'),
+		array('id' => 100,  'label' => 'z'),
+	);
+	try_handler(10, $link, $file, 'callback_simple', $expected);
+
+	$expected = array(
+		array('id' => 97,   'label' => 'x'),
+		array('id' => 98,   'label' => 'y'),
+		array('id' => 99,   'label' => 'z'),
+	);
+	try_handler(20, $link, $file, 'default', $expected);
+
+	$expected = array(
+		array('id' => 98,   'label' => 'x'),
+		array('id' => 99,   'label' => 'y'),
+		array('id' => 100,  'label' => 'z'),
+	);
+	try_handler(30, $link, $file, 'callback_simple', $expected);
+
+	mysqli_close($link);
+
+	if (!is_null($tmp = @mysqli_set_local_infile_default($link)))
+		printf("[300] Expecting NULL/NULL got %s/%s\n", $tmp, gettype($tmp));
+
+	print "done!";
 ?>
 --EXPECTF--
 Callback set to 'callback_simple'

Modified: trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_unregister.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_unregister.phpt	2007-07-19
15:31:56 UTC (rev 803)
+++ trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_unregister.phpt	2007-07-19
15:52:37 UTC (rev 804)
@@ -1,125 +1,138 @@
 --TEST--
 mysqli_set_local_infile_handler() - do not use the file pointer
 --SKIPIF--
-<?php 
+<?php
 require_once('skipif.inc');
-require_once('skipifemb.inc'); 
-require_once('connect.inc');
+require_once('skipifemb.inc');
 
 if (!function_exists('mysqli_set_local_infile_handler'))
-    die("skip - function not available.");
-    
+	die("skip - function not available.");
+
+require_once('connect.inc');
 if (!$TEST_EXPERIMENTAL)
-    die("skip - experimental (= unsupported) feature");
+	die("skip - experimental (= unsupported) feature");
 ?>
 --FILE--
 <?php
-    include "connect.inc";
-    include("table.inc");   
+	include "connect.inc";
+	include("table.inc");
 
-    function shutdown_clean($file) {
-	    if ($file) {
-	        unlink($file);
-	    }
+	function shutdown_clean($file) {
+		if ($file) {
+			unlink($file);
+		}
 	}
-    
-    function callback_unregister($fp, &$buffer, $buflen, &$error) {
-        global $link;
-        static $invocation = 0;
-        
-        printf("Callback: %d\n", $invocation++);
-        flush();        
-        if (is_resource($fp))
-            fclose($fp);
-        $buffer = "1;'a';\n";
-        if ($invocation > 10)
-            return 0;
-        
-        mysqli_set_local_infile_default($link);
-        return strlen($buffer);
-    }
 
-    function try_handler($offset, $link, $file, $handler, $expected) {
-        
-        if (!mysqli_set_local_infile_handler($link, $handler)) {
-            printf("[%03d] Cannot set infile handler to '%s'\n", $offset, $handler);
-            return false;
-        }
-        printf("Callback set to '%s'\n", $handler);
-        
-        if (!mysqli_query($link, sprintf("DELETE FROM test"))) {
-            printf("[%03d] Cannot remove records, [%d] %s\n", $offset + 1,
mysqli_errno($link), mysqli_error($link));
-            return false;
-        }
-        
-        
-        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("[%03d] LOAD DATA failed, [%d] %s\n", 
-                    $offset + 2,
-                    mysqli_errno($link), mysqli_error($link));
-        }
-        
-        if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) {
-            printf("[%03d] [%d] %s\n", $offset + 3, mysqli_errno($link),
mysqli_error($link));
-            return false;
-        }
+	function callback_unregister($fp, &$buffer, $buflen, &$error) {
+		global $link;
+		static $invocation = 0;
 
-        foreach ($expected as $k => $values) {
-            if (!$tmp = mysqli_fetch_assoc($res)) {
-                printf("[%03d/%d] [%d] %s\n", $offset + 4, $k, mysqli_errno($link),
mysqli_error($link));
-                return false;
-            }            
-            if ($values['id'] != $tmp['id']) {
-                printf("[%03d/%d] Expecting %s got %s\n", 
-                    $offset + 5, $k, 
-                    $values['id'], $tmp['id']);
-                return false;
-            }
-            if ($values['label'] != $tmp['label']) {
-                printf("[%03d/%d] Expecting %s got %s\n", 
-                    $offset + 6, $k,
-                    $values['label'], $tmp['label']);
-                return false;
-            }
-        }
-        
-        if ($res && $tmp = mysqli_fetch_assoc($res))
-            printf("[%03d] More results than expected!\n");
-        
-        if ($res)
-            mysqli_free_result($res);
-        
-        return true;
-    }    
-    
-    // create a CVS file
-    $file = tempnam(sys_get_temp_dir(), 'mysqli_test');
-    if (!$fp = fopen($file, 'wb'))
-        printf("[005] Cannot create CVS file '%s'\n", $file);
+		printf("Callback: %d\n", $invocation++);
+		flush();
+		if (is_resource($fp))
+				fclose($fp);
+		$buffer = "1;'a';\n";
+		if ($invocation > 10)
+			return 0;
+
+		mysqli_set_local_infile_default($link);
+		return strlen($buffer);
+	}
+
+	function try_handler($offset, $link, $file, $handler, $expected) {
+
+		if ('default' == $handler) {
+			mysqli_set_local_infile_default($link);
+			printf("Callback set to default\n");
+		} else {
+			if (!mysqli_set_local_infile_handler($link, $handler)) {
+				printf("[%03d] Cannot set infile handler to '%s'\n", $offset, $handler);
+				return false;
+			}
+			printf("Callback set to '%s'\n", $handler);
+		}
+
+		if (!mysqli_query($link, sprintf("DELETE FROM test"))) {
+			printf("[%03d] Cannot remove records, [%d] %s\n", $offset + 1, mysqli_errno($link),
mysqli_error($link));
+			return false;
+		}
+
+
+		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("[%03d] LOAD DATA failed, [%d] %s\n",
+				$offset + 2,
+				mysqli_errno($link), mysqli_error($link));
+		}
+		if (0 !== mysqli_warning_count($link)) {
+			printf("[%03d] There are warnings!\n", $offset + 3);
+		}
+
+		if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) {
+			printf("[%03d] [%d] %s\n", $offset + 4, mysqli_errno($link), mysqli_error($link));
+			return false;
+		}
+
+		foreach ($expected as $k => $values) {
+			if (!$tmp = mysqli_fetch_assoc($res)) {
+				printf("[%03d/%d] [%d] %s\n", $offset + 5, $k, mysqli_errno($link),
mysqli_error($link));
+				return false;
+			}
+			if ($values['id'] != $tmp['id']) {
+				printf("[%03d/%d] Expecting %s got %s\n",
+					$offset + 6, $k,
+					$values['id'], $tmp['id']);
+				return false;
+			}
+			if ($values['label'] != $tmp['label']) {
+				printf("[%03d/%d] Expecting %s got %s\n",
+					$offset + 7, $k,
+					$values['label'], $tmp['label']);
+				return false;
+			}
+		}
+
+		if ($res && $tmp = mysqli_fetch_assoc($res)) {
+			printf("[%03d] More results than expected! Dumping data \n", $offset + 7);
+			do {
+				var_dump($tmp);
+			} while ($tmp = mysqli_fetch_assoc($res));
+		}
+
+		if ($res)
+			mysqli_free_result($res);
+
+		return true;
+	}
+
+
+	// create a CVS file
+	$file = tempnam(sys_get_temp_dir(), 'mysqli_test');
+	if (!$fp = fopen($file, 'wb'))
+		printf("[005] Cannot create CVS file '%s'\n", $file);
 	else
-        register_shutdown_function("shutdown_clean", $file);
+		register_shutdown_function("shutdown_clean", $file);
 
-    if (!fwrite($fp, (binary)"97;'x';\n") ||
-        !fwrite($fp, (binary)"98;'y';\n") ||
-        !fwrite($fp, (binary)"99;'z';\n"))
-        printf("[006] Cannot write CVS file '%s'\n", $file);
-        
-    fclose($fp);    
-    
-    if (!chmod($file, 0644))
-        printf("[007] Cannot change the file perms of '%s' from 0600 to 0644, MySQL might
not be able to read it\n",
-            $file);
+	if (!fwrite($fp, (binary)"97;'x';\n") ||
+		!fwrite($fp, (binary)"98;'y';\n") ||
+		!fwrite($fp, (binary)"99;'z';\n"))
+		printf("[006] Cannot write CVS file '%s'\n", $file);
 
-    
-    $expected = array(array('id' => 1, 'label' => 'a'));
-    try_handler(20, $link, $file, 'callback_unregister', $expected);    
-    
-    mysqli_close($link);    
-    print "done!";
+	fclose($fp);
+
+	if (!chmod($file, 0644))
+		printf("[007] Cannot change the file perms of '%s' from 0600 to 0644, MySQL might not
be able to read it\n",
+			$file);
+
+
+	$expected = array(array('id' => 1, 'label' => 'a'));
+	try_handler(20, $link, $file, 'callback_unregister', $expected);
+
+	mysqli_close($link);
+	print "done!";
 ?>
 --EXPECTF--
 Callback set to 'callback_unregister'

Thread
PHP mysqlnd svn commit: r804 - trunk/tests/ext/mysqliuwendel19 Jul