From: Ulf Wendel Date: Wed, 10 Oct 2007 10:46:06 +0000 (+0000) Subject: More updates to the ext/mysqli tests in HEAD = synching with 5_3 X-Git-Tag: RELEASE_2_0_0a1~1617 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2df3cea685814bc906f893db4b351de3397cca15;p=php More updates to the ext/mysqli tests in HEAD = synching with 5_3 --- diff --git a/ext/mysqli/tests/mysqli_get_client_stats.phpt b/ext/mysqli/tests/mysqli_get_client_stats.phpt index e7d91b3e5a..042f14bd99 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats.phpt @@ -9,6 +9,9 @@ if (!function_exists('mysqli_get_client_stats')) { die("skip only available with mysqlnd"); } ?> +--INI-- +mysqlnd.collect_statistics=1 +mysqlnd.collect_memory_statistics=1 --FILE-- $v) + if ($info[$k] != $expected[$k]) + printf("$k - $v != %s\n", $expected[$k]); + */ + print "... done with fetch statistics\n"; + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", ++$test_counter, gettype($info), $info); @@ -142,6 +493,10 @@ if (!function_exists('mysqli_get_client_stats')) { // result_set_queries statistics // + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); + if (!$res = mysqli_query($link, "SELECT id, label FROM test")) printf("[%03d] SELECT failed, [%d] %s\n", ++$test_counter, mysqli_errno($link), mysqli_error($link)); @@ -504,7 +859,7 @@ if (!function_exists('mysqli_get_client_stats')) { print "done!"; ?> --EXPECTF-- -array(33) { +array(61) { ["bytes_sent"]=> string(1) "0" ["bytes_received"]=> @@ -537,11 +892,31 @@ array(33) { string(1) "0" ["flushed_ps_sets"]=> string(1) "0" - ["rows_fetched_from_server"]=> + ["ps_prepared_never_executed"]=> + string(1) "0" + ["ps_prepared_once_executed"]=> + string(1) "0" + ["rows_fetched_from_server_normal"]=> + string(1) "0" + ["rows_fetched_from_server_ps"]=> + string(1) "0" + ["rows_buffered_from_client_normal"]=> + string(1) "0" + ["rows_buffered_from_client_ps"]=> + string(1) "0" + ["rows_fetched_from_client_normal_buffered"]=> + string(1) "0" + ["rows_fetched_from_client_normal_unbuffered"]=> string(1) "0" - ["rows_fetched_from_client"]=> + ["rows_fetched_from_client_ps_buffered"]=> string(1) "0" - ["rows_skipped"]=> + ["rows_fetched_from_client_ps_unbuffered"]=> + string(1) "0" + ["rows_fetched_from_client_ps_cursor"]=> + string(1) "0" + ["rows_skipped_normal"]=> + string(1) "0" + ["rows_skipped_ps"]=> string(1) "0" ["copy_on_write_saved"]=> string(1) "0" @@ -555,6 +930,14 @@ array(33) { string(1) "0" ["connection_reused"]=> string(1) "0" + ["reconnect"]=> + string(1) "0" + ["pconnect_success"]=> + string(1) "0" + ["active_connections"]=> + string(1) "0" + ["active_persistent_connections"]=> + string(1) "0" ["explicit_close"]=> string(1) "0" ["implicit_close"]=> @@ -571,10 +954,49 @@ array(33) { string(1) "0" ["implicit_stmt_close"]=> string(1) "0" + ["mem_emalloc_count"]=> + string(1) "0" + ["mem_emalloc_ammount"]=> + string(1) "0" + ["mem_ecalloc_count"]=> + string(1) "0" + ["mem_ecalloc_ammount"]=> + string(1) "0" + ["mem_erealloc_count"]=> + string(1) "0" + ["mem_erealloc_ammount"]=> + string(1) "0" + ["mem_efree_count"]=> + string(1) "0" + ["mem_malloc_count"]=> + string(1) "0" + ["mem_malloc_ammount"]=> + string(1) "0" + ["mem_calloc_count"]=> + string(1) "0" + ["mem_calloc_ammount"]=> + string(1) "0" + ["mem_realloc_calloc"]=> + string(1) "0" + ["mem_realloc_ammount"]=> + string(1) "0" + ["mem_free_count"]=> + string(1) "0" } +Testing buffered normal... +Testing buffered normal... - SELECT id, label FROM test +Testing unbuffered normal... +Testing unbuffered normal... - SELECT id, label FROM test, not all fetched +Testing if implicit fetching and cleaning happens... +Testing buffered Prepared Statements... +Testing buffered Prepared Statements... - fetching all +Testing buffered Prepared Statements... - fetching all but one +Testing unbuffered Prepared Statements... - fetching all +Testing unbuffered Prepared Statements... - fetching all but one +... done with fetch statistics done! --UEXPECTF-- -array(33) { +array(61) { [u"bytes_sent"]=> unicode(1) "0" [u"bytes_received"]=> @@ -607,11 +1029,31 @@ array(33) { unicode(1) "0" [u"flushed_ps_sets"]=> unicode(1) "0" - [u"rows_fetched_from_server"]=> + [u"ps_prepared_never_executed"]=> + unicode(1) "0" + [u"ps_prepared_once_executed"]=> + unicode(1) "0" + [u"rows_fetched_from_server_normal"]=> + unicode(1) "0" + [u"rows_fetched_from_server_ps"]=> + unicode(1) "0" + [u"rows_buffered_from_client_normal"]=> unicode(1) "0" - [u"rows_fetched_from_client"]=> + [u"rows_buffered_from_client_ps"]=> unicode(1) "0" - [u"rows_skipped"]=> + [u"rows_fetched_from_client_normal_buffered"]=> + unicode(1) "0" + [u"rows_fetched_from_client_normal_unbuffered"]=> + unicode(1) "0" + [u"rows_fetched_from_client_ps_buffered"]=> + unicode(1) "0" + [u"rows_fetched_from_client_ps_unbuffered"]=> + unicode(1) "0" + [u"rows_fetched_from_client_ps_cursor"]=> + unicode(1) "0" + [u"rows_skipped_normal"]=> + unicode(1) "0" + [u"rows_skipped_ps"]=> unicode(1) "0" [u"copy_on_write_saved"]=> unicode(1) "0" @@ -625,6 +1067,14 @@ array(33) { unicode(1) "0" [u"connection_reused"]=> unicode(1) "0" + [u"reconnect"]=> + unicode(1) "0" + [u"pconnect_success"]=> + unicode(1) "0" + [u"active_connections"]=> + unicode(1) "0" + [u"active_persistent_connections"]=> + unicode(1) "0" [u"explicit_close"]=> unicode(1) "0" [u"implicit_close"]=> @@ -641,5 +1091,44 @@ array(33) { unicode(1) "0" [u"implicit_stmt_close"]=> unicode(1) "0" + [u"mem_emalloc_count"]=> + unicode(1) "0" + [u"mem_emalloc_ammount"]=> + unicode(1) "0" + [u"mem_ecalloc_count"]=> + unicode(1) "0" + [u"mem_ecalloc_ammount"]=> + unicode(1) "0" + [u"mem_erealloc_count"]=> + unicode(1) "0" + [u"mem_erealloc_ammount"]=> + unicode(1) "0" + [u"mem_efree_count"]=> + unicode(1) "0" + [u"mem_malloc_count"]=> + unicode(1) "0" + [u"mem_malloc_ammount"]=> + unicode(1) "0" + [u"mem_calloc_count"]=> + unicode(1) "0" + [u"mem_calloc_ammount"]=> + unicode(1) "0" + [u"mem_realloc_calloc"]=> + unicode(1) "0" + [u"mem_realloc_ammount"]=> + unicode(1) "0" + [u"mem_free_count"]=> + unicode(1) "0" } -done! \ No newline at end of file +Testing buffered normal... +Testing buffered normal... - SELECT id, label FROM test +Testing unbuffered normal... +Testing unbuffered normal... - SELECT id, label FROM test, not all fetched +Testing if implicit fetching and cleaning happens... +Testing buffered Prepared Statements... +Testing buffered Prepared Statements... - fetching all +Testing buffered Prepared Statements... - fetching all but one +Testing unbuffered Prepared Statements... - fetching all +Testing unbuffered Prepared Statements... - fetching all but one +... done with fetch statistics +done! diff --git a/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt b/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt new file mode 100644 index 0000000000..6d835abd8b --- /dev/null +++ b/ext/mysqli/tests/mysqli_get_client_stats_implicit_free.phpt @@ -0,0 +1,42 @@ +--TEST-- +mysqli_get_client_stats() - implicit_free_result +--SKIPIF-- + +--INI-- +mysqlnd.collect_statistics=1 +mysqlnd.collect_memory_statistics=1 +--FILE-- + +--EXPECTF-- +BEGINNING: implicit_free_result = %d +END: implicit_free_result = %d +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_get_client_stats_off.phpt b/ext/mysqli/tests/mysqli_get_client_stats_off.phpt new file mode 100644 index 0000000000..8a731ca746 --- /dev/null +++ b/ext/mysqli/tests/mysqli_get_client_stats_off.phpt @@ -0,0 +1,38 @@ +--TEST-- +mysqli_get_client_stats() - php_ini setting +--SKIPIF-- + +--INI-- +mysqlnd.collect_statistics=0 +mysqlnd.collect_memory_statistics=0 +--FILE-- + $v) + if ($v != 0) { + printf("[002] Field %s should not have any other value but 0, got %s.\n", + $k, $v); + } + + mysqli_close($link); + print "done!"; +?> +--EXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt b/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt new file mode 100644 index 0000000000..fea641b816 --- /dev/null +++ b/ext/mysqli/tests/mysqli_get_client_stats_ps.phpt @@ -0,0 +1,102 @@ +--TEST-- +mysqli_get_client_stats() - PS +--SKIPIF-- + +--INI-- +mysqlnd.collect_statistics=1 +mysqlnd.collect_memory_statistics=1 +--FILE-- + +--EXPECTF-- +BEGINNING: rows_fetched_from_client_ps_unbuffered = %d +BEGINNING: rows_fetched_from_client_ps_buffered = %d +BEGINNING: rows_fetched_from_client_ps_cursor = 0 +BUFFERED: rows_fetched_from_client_ps_unbuffered = %d +BUFFERED: rows_fetched_from_client_ps_buffered = %d +BUFFERED: rows_fetched_from_client_ps_cursor = 0 +UNBUFFERED: rows_fetched_from_client_ps_unbuffered = %d +UNBUFFERED: rows_fetched_from_client_ps_buffered = %d +UNBUFFERED: rows_fetched_from_client_ps_cursor = 0 +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt b/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt new file mode 100644 index 0000000000..9dd802db0d --- /dev/null +++ b/ext/mysqli/tests/mysqli_get_client_stats_skipped.phpt @@ -0,0 +1,49 @@ +--TEST-- +mysqli_get_client_stats() - skipped rows +--SKIPIF-- + +--FILE-- + 2); + mysqli_free_result($res); + + $before = mysqli_get_client_stats(); + printf("BEFORE: rows_skipped_normal = %d\n", $before['rows_skipped_normal']); + + if (!$res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_USE_RESULT)) + printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + /* fetch all rows but the last one */ + for ($i = 0; $i < $num_rows - 1; $i++) + $row = mysqli_fetch_assoc($res); + + /* enforce implicit cleaning of the wire and skipping the last row */ + mysqli_free_result($res); + $after = mysqli_get_client_stats(); + printf("AFTER: rows_skipped_normal = %d\n", $after['rows_skipped_normal']); + + if ($after['rows_skipped_normal'] != $before['rows_skipped_normal'] + 1) + printf("Statistics should show an increase of 1 for rows_skipped_normal, ". + "but before=%d after=%d\n", $before['rows_skipped_normal'], $after['rows_skipped_normal']); + + mysqli_close($link); + print "done!"; +?> +--EXPECTF-- +BEFORE: rows_skipped_normal = %d +AFTER: rows_skipped_normal = %d +done! diff --git a/ext/mysqli/tests/mysqli_max_links.phpt b/ext/mysqli/tests/mysqli_max_links.phpt new file mode 100644 index 0000000000..a9a7980229 --- /dev/null +++ b/ext/mysqli/tests/mysqli_max_links.phpt @@ -0,0 +1,72 @@ +--TEST-- +Testing mysqli.max_links +--SKIPIF-- + +--INI-- +mysqli.max_links=1 +--FILE-- + +--EXPECTF-- +bool(true) +int(1) + +Warning: mysqli_connect(): 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_connect(): 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_connect(): 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 + +Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in %s on line %d + +Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d + +Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in %s on line %d + +Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d + +Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in %s on line %d + +Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d + +Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in %s on line %d + +Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d + +Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in %s on line %d +done! diff --git a/ext/mysqli/tests/mysqli_no_reconnect.phpt b/ext/mysqli/tests/mysqli_no_reconnect.phpt new file mode 100644 index 0000000000..d392b5a1cf --- /dev/null +++ b/ext/mysqli/tests/mysqli_no_reconnect.phpt @@ -0,0 +1,111 @@ +--TEST-- +Trying implicit reconnect after wait_timeout and KILL using mysqli_ping() +--SKIPIF-- + +--INI-- +mysqli.reconnect=0 +--FILE-- + +--EXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_options_openbasedir.phpt b/ext/mysqli/tests/mysqli_options_openbasedir.phpt new file mode 100644 index 0000000000..d5a5bf45ca --- /dev/null +++ b/ext/mysqli/tests/mysqli_options_openbasedir.phpt @@ -0,0 +1,24 @@ +--TEST-- +mysqli_options() - MYSQLI_OPT_LOCAL_INFILE and open_basedir +--SKIPIF-- + +--INI-- +open_basedir="." +--FILE-- + +--EXPECTF-- +done! diff --git a/ext/mysqli/tests/mysqli_pconn_disabled.phpt b/ext/mysqli/tests/mysqli_pconn_disabled.phpt new file mode 100644 index 0000000000..746dd3ba90 --- /dev/null +++ b/ext/mysqli/tests/mysqli_pconn_disabled.phpt @@ -0,0 +1,63 @@ +--TEST-- +mysqli_pconnect() - mysqli.allow_persistent = 0 +--SKIPIF-- + +--INI-- +mysqli.allow_persistent=0 +mysqli.max_persistent=2 +mysqli.max_links=2 +--FILE-- + '%s'\n", $row['_test']); + mysqli_free_result($res); + + if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) + printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); + + $row = mysqli_fetch_assoc($res); + printf("Connecction 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']); + mysqli_free_result($res); + + if ($link1 === $link2) + printf("[006] Links should not be identical\n"); + + mysqli_close($link1); + mysqli_close($link2); + print "done!"; +?> +--EXPECTF-- +Warning: 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 +Connecction 1 - SELECT @pcondisabled -> 'Connection 1' +Connecction 2 - SELECT @pcondisabled -> '' +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_pconn_kill.phpt b/ext/mysqli/tests/mysqli_pconn_kill.phpt new file mode 100755 index 0000000000..61d5624515 --- /dev/null +++ b/ext/mysqli/tests/mysqli_pconn_kill.phpt @@ -0,0 +1,95 @@ +--TEST-- +Killing a persistent connection. +--SKIPIF-- + +--INI-- +mysqli.allow_persistent=1 +mysqli.max_persistent=2 +--FILE-- +" from the host variable + $host = substr($host, 2); + if (!$link = 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')) + printf("[014] New regular connection cannot execute queries, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + mysqli_free_result($res4); + mysqli_close($link); + print "done!"; +?> +--EXPECTF-- +done! +--UEXPECTF-- +done! diff --git a/ext/mysqli/tests/mysqli_pconn_limits.phpt b/ext/mysqli/tests/mysqli_pconn_limits.phpt new file mode 100644 index 0000000000..774154deeb --- /dev/null +++ b/ext/mysqli/tests/mysqli_pconn_limits.phpt @@ -0,0 +1,96 @@ +--TEST-- +Persistent connections - limits (-1, unlimited) +--SKIPIF-- + +--INI-- +mysqli.allow_persistent=1 +mysqli.max_persistent=-1 +mysqli.max_links=-1 +--FILE-- + +--EXPECTF-- +Regular connection 1 - 'works..' +Regular connection 2 - 'works...' +Persistent connection 1 - 'works...' +Persistent connection 2 - 'works...' +Persistent connection 3 - 'works...' +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_pconn_max_links.phpt b/ext/mysqli/tests/mysqli_pconn_max_links.phpt new file mode 100644 index 0000000000..8b47728c1e --- /dev/null +++ b/ext/mysqli/tests/mysqli_pconn_max_links.phpt @@ -0,0 +1,172 @@ +--TEST-- +Persistent connections and mysqli.max_links +--SKIPIF-- + +--INI-- +mysqli.allow_persistent=1 +mysqli.max_persistent=2 +--FILE-- + enabled'), 500); + if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches)) + printf("[002] Cannot get # active persistent links from phpinfo()\n"); + $num_plinks = $matches[1]; + + if (!$res = mysqli_query($plink, 'SELECT id, label FROM test WHERE id = 1')) + printf("[003] Cannot run query on persistent connection of second DB user, [%d] %s\n", + mysqli_errno($plink), mysqli_error($plink)); + + if (!$row = mysqli_fetch_assoc($res)) + printf("[004] Cannot run fetch result, [%d] %s\n", + mysqli_errno($plink), mysqli_error($plink)); + mysqli_free_result($res); + var_dump($row); + + // change the password for the second DB user and kill the persistent connection + if (!mysqli_query($link, 'SET PASSWORD FOR pcontest = PASSWORD("newpass")') || + !mysqli_query($link, 'FLUSH PRIVILEGES')) + printf("[005] Cannot change PW of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + // persistent connections cannot be closed but only be killed + $pthread_id = mysqli_thread_id($plink); + if (!mysqli_query($link, sprintf('KILL %d', $pthread_id))) + printf("[006] Cannot KILL persistent connection of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + // give the server a second to really kill the thread + sleep(1); + + if (!$res = mysqli_query($link, "SHOW FULL PROCESSLIST")) + printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $running_threads = array(); + while ($row = mysqli_fetch_assoc($res)) + $running_threads[$row['Id']] = $row; + mysqli_free_result($res); + + if (isset($running_threads[$pthread_id])) + printf("[008] 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)) + printf("[009] Can connect using the old password, [%d] %s\n", + mysqli_connect_errno($link), mysqli_connect_error($link)); + + ob_start(); + phpinfo(); + $phpinfo = strip_tags(ob_get_contents()); + ob_end_clean(); + $phpinfo = substr($phpinfo, stripos($phpinfo, 'MysqlI Support => enabled'), 500); + if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches)) + printf("[010] Cannot get # of active persistent links from phpinfo()\n"); + + $num_plinks_kill = $matches[1]; + 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)) + printf("[012] Cannot connect using the new password, [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + + if (!$res = mysqli_query($plink, 'SELECT id, label FROM test WHERE id = 1')) + printf("[013] Cannot run query on persistent connection of second DB user, [%d] %s\n", + mysqli_errno($plink), mysqli_error($plink)); + + if (!$row = mysqli_fetch_assoc($res)) + printf("[014] Cannot run fetch result, [%d] %s\n", + mysqli_errno($plink), mysqli_error($plink)); + mysqli_free_result($res); + var_dump($row); + + if ($plink2 = 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()); + + ob_start(); + phpinfo(); + $phpinfo = strip_tags(ob_get_contents()); + ob_end_clean(); + $phpinfo = substr($phpinfo, stripos($phpinfo, 'MysqlI Support => enabled'), 500); + if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches)) + printf("[016] Cannot get # of active persistent links from phpinfo()\n"); + + $num_plinks = $matches[1]; + if ($num_plinks > (int)ini_get('mysqli.max_persistent')) + printf("[017] mysqli.max_persistent=%d allows %d open connections!\n", ini_get('mysqli.max_persistent'),$num_plinks); + + mysqli_query($link, 'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest'); + mysqli_query($link, 'DROP USER pcontest'); + mysqli_close($link); + print "done!"; +?> +--EXPECTF-- +array(2) { + ["id"]=> + string(1) "1" + ["label"]=> + string(1) "a" +} +array(2) { + ["id"]=> + string(1) "1" + ["label"]=> + string(1) "a" +} + +Warning: mysqli_connect(): Too many open persistent links (%d) in %s on line %d +done! +--UEXPECTF-- +array(2) { + [u"id"]=> + unicode(1) "1" + [u"label"]=> + unicode(1) "a" +} +array(2) { + [u"id"]=> + unicode(1) "1" + [u"label"]=> + unicode(1) "a" +} + +Warning: mysqli_connect(): Too many open persistent links (%d) in %s on line %d +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_pconn_reuse.phpt b/ext/mysqli/tests/mysqli_pconn_reuse.phpt new file mode 100644 index 0000000000..4a7e75b72f --- /dev/null +++ b/ext/mysqli/tests/mysqli_pconn_reuse.phpt @@ -0,0 +1,92 @@ +--TEST-- +mysqli_pconnect() - reusing/caching persistent connections +--SKIPIF-- + +--INI-- +mysqli.allow_persistent=1 +mysqli.max_persistent=2 +mysqli.max_links=2 +--FILE-- + '%s'\n", $row['_test']); + mysqli_free_result($res); + + if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) + printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); + + $row = mysqli_fetch_assoc($res); + printf("Connection 2 (no reuse) - SELECT @pcondisabled -> '%s'\n", $row['_test']); + $thread_id = mysqli_thread_id($link2); + printf("Connection 2 (no reuse) - Thread ID -> '%s'\n", $thread_id); + mysqli_free_result($res); + + if (!mysqli_query($link2, 'SET @pcondisabled = "Connection 2"')) + printf("[006] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n", + mysqli_errno($link2), mysqli_error($link2)); + + if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) + printf("[007] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); + + $row = mysqli_fetch_assoc($res); + printf("Connection 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']); + mysqli_free_result($res); + + mysqli_close($link2); + + /* reuse of existing persistent connection expected! */ + if (!$link2 = 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()); + } + + if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) + printf("[009] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); + + $row = mysqli_fetch_assoc($res); + printf("Connection 2 (reuse) - SELECT @pcondisabled -> '%s'\n", $row['_test']); + $thread_id_reuse = mysqli_thread_id($link2); + printf("Connection 2 (reuse) - Thread ID -> '%s'\n", $thread_id_reuse); + mysqli_free_result($res); + + if ($thread_id != $thread_id_reuse) + printf("[010] Seems as if we have got a new connection, connections should have been cached and reused!\n"); + + mysqli_close($link1); + mysqli_close($link2); + print "done!"; +?> +--EXPECTF-- +Connection 1 - SELECT @pcondisabled -> 'Connection 1' +Connection 2 (no reuse) - SELECT @pcondisabled -> '' +Connection 2 (no reuse) - Thread ID -> '%d' +Connection 2 - SELECT @pcondisabled -> 'Connection 2' +Connection 2 (reuse) - SELECT @pcondisabled -> 'Connection 2' +Connection 2 (reuse) - Thread ID -> '%d' +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_query_stored_proc.phpt b/ext/mysqli/tests/mysqli_query_stored_proc.phpt new file mode 100644 index 0000000000..051b541fdb --- /dev/null +++ b/ext/mysqli/tests/mysqli_query_stored_proc.phpt @@ -0,0 +1,212 @@ +--TEST-- +mysqli_query() - Stored Procedures +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +array(2) { + ["id"]=> + string(1) "1" + ["label"]=> + string(1) "a" +} +array(2) { + ["id"]=> + string(1) "1" + ["label"]=> + string(1) "a" +} +array(2) { + ["id"]=> + string(1) "1" + ["label"]=> + string(1) "a" +} +array(2) { + ["id"]=> + string(1) "1" + ["label"]=> + string(1) "a" +} +array(1) { + ["id"]=> + string(1) "1" +} +done! +--UEXPECTF-- +array(2) { + [u"id"]=> + unicode(1) "1" + [u"label"]=> + unicode(1) "a" +} +array(2) { + [u"id"]=> + unicode(1) "1" + [u"label"]=> + unicode(1) "a" +} +array(2) { + [u"id"]=> + unicode(1) "1" + [u"label"]=> + unicode(1) "a" +} +array(2) { + [u"id"]=> + unicode(1) "1" + [u"label"]=> + unicode(1) "a" +} +array(1) { + [u"id"]=> + unicode(1) "1" +} +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt b/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt new file mode 100644 index 0000000000..ea49205611 --- /dev/null +++ b/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt @@ -0,0 +1,54 @@ +--TEST-- +mysqli_real_escape_string() - big5 +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) +bool(true) +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt b/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt new file mode 100644 index 0000000000..ef9c3f065e --- /dev/null +++ b/ext/mysqli/tests/mysqli_real_escape_string_eucjpms.phpt @@ -0,0 +1,53 @@ +--TEST-- +mysqli_real_escape_string() - eucjpms +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) +bool(true) +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt b/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt new file mode 100644 index 0000000000..a15a51cd80 --- /dev/null +++ b/ext/mysqli/tests/mysqli_real_escape_string_euckr.phpt @@ -0,0 +1,53 @@ +--TEST-- +mysqli_real_escape_string() - euckr +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) +bool(true) +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt b/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt new file mode 100644 index 0000000000..016115fc68 --- /dev/null +++ b/ext/mysqli/tests/mysqli_real_escape_string_gb2312.phpt @@ -0,0 +1,54 @@ +--TEST-- +mysqli_real_escape_string() - gb2312 +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) +bool(true) +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt b/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt new file mode 100644 index 0000000000..bee717f1d3 --- /dev/null +++ b/ext/mysqli/tests/mysqli_real_escape_string_gbk.phpt @@ -0,0 +1,54 @@ +--TEST-- +mysqli_real_escape_string() - gbk +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) +bool(true) +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_real_escape_string_nobackslash.phpt b/ext/mysqli/tests/mysqli_real_escape_string_nobackslash.phpt new file mode 100644 index 0000000000..bdbcc19c14 --- /dev/null +++ b/ext/mysqli/tests/mysqli_real_escape_string_nobackslash.phpt @@ -0,0 +1,71 @@ +--TEST-- +mysqli_real_escape_string() - SQL Mode NO_BACKSLASH_ESCAPE +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +array(1) { + ["label"]=> + string(1) "\" +} +done! +--UEXPECTF-- +array(1) { + [u"label"]=> + unicode(1) "\" +} +done! diff --git a/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt b/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt new file mode 100644 index 0000000000..7655ecd1e3 --- /dev/null +++ b/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt @@ -0,0 +1,54 @@ +--TEST-- +mysqli_real_escape_string() - sjis +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) +bool(true) +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_reconnect.phpt b/ext/mysqli/tests/mysqli_reconnect.phpt new file mode 100644 index 0000000000..68cffc3b2b --- /dev/null +++ b/ext/mysqli/tests/mysqli_reconnect.phpt @@ -0,0 +1,130 @@ +--TEST-- +Trying implicit reconnect after wait_timeout and KILL using mysqli_ping() +--SKIPIF-- + +--INI-- +mysqli.reconnect=1 +--FILE-- + +--EXPECTF-- +done! diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt new file mode 100644 index 0000000000..a4f20cb75e --- /dev/null +++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt @@ -0,0 +1,110 @@ +--TEST-- +mysqli_set_local_infile_handler() - open basedir restrictions +--SKIPIF-- + +--INI-- +open_basedir="." +--FILE-- + 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); + } + + $file = create_standard_csv(5); + $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); + mysqli_close($link); + print "done!"; +?> +--EXPECTF-- +Warning: tempnam(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s on line %d +[005 + 1] Cannot create CVS file '' +Callback set to 'callback_simple' +[012] LOAD DATA failed, [%d] %s +[014/0] [0] '' +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt new file mode 100644 index 0000000000..ba88686971 --- /dev/null +++ b/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt @@ -0,0 +1,333 @@ +--TEST-- +Playing with SELECT FORMAT(...) AS _format - see also bugs.php.net/42378 +--SKIPIF-- + +--INI-- +memory_limit=83886080 +--FILE-- + $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 100); + + $expected = create_table($link, 'FLOAT UNSIGNED', 0, 10000, $engine, 110); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 120); + + $expected = create_table($link, 'TINYINT', -128, 127, $engine, 130); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 140); + + $expected = create_table($link, 'SMALLINT UNSIGNED', 0, 65535, $engine, 150); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 160); + + $expected = create_table($link, 'MEDIUMINT', 0, 8388607, $engine, 170); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 180); + + $expected = create_table($link, 'INT UNSIGNED', 0, 1000, $engine, 190); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 200); + + $expected = create_table($link, 'BIGINT', -1000, 1000, $engine, 210); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 220); + + $expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 230); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 240); + + // http://bugs.php.net/bug.php?id=42378 + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[300] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (mysqli_query($link, "CREATE TABLE `test` ( + `targetport` int(11) NOT NULL default '0', + `sources` double(17,4) default NULL, + `current_sources` double(17,0) default NULL, + `reports` double(17,4) default NULL, + `current_reports` double(17,0) default NULL, + `targets` double(17,4) default NULL, + `current_targets` double(17,0) default NULL, + `maxsources` int(11) default NULL, + `maxtargets` int(11) default NULL, + `maxreports` int(11) default NULL, + `trend` float default NULL, + PRIMARY KEY (`targetport`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1")) { + + do { + $values = array(); + for ($i = 0; $i < 200; $i++) { + $current_targets = mt_rand(-100000, 100000) / 10; + do { + $trend = (mt_rand(0, 3) > 1) ? (mt_rand(-10000, 10000) / 100) : 'NULL'; + } while (isset($values[$trend])); + + $sql = sprintf('INSERT INTO test(targetport, current_targets, maxreports, trend) VALUES (%d, %f, %s, %s)', + $i, + $current_targets, + (mt_rand(0, 1) > 0) ? mt_rand(0, 1000) : 'NULL', + $trend); + if (!mysqli_query($link, $sql)) { + printf("[301] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break 2; + } + if ($current_targets > 0 && $trend != 'NULL') + $values[$trend] = $i; + } + krsort($values); + + if (!$stmt = mysqli_stmt_init($link)) { + printf("[302] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break; + } + + if (!mysqli_stmt_prepare($stmt, 'SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) { + printf("[303] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + if (!mysqli_stmt_execute($stmt)) { + printf("[304] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + if (!mysqli_stmt_store_result($stmt)) { + printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + $trend = $targetport = $format = null; + if (!mysqli_stmt_bind_result($stmt, $trend, $targetport, $format)) { + + printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + reset($values); + while (mysqli_stmt_fetch($stmt)) { + list($exp_trend, $exp_targetport) = each($values); + if ($targetport != $exp_targetport) { + printf("[306] Values fetched from MySQL seem to be wrong, check manually\n"); + printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format); + } + } + mysqli_stmt_free_result($stmt); + mysqli_stmt_close($stmt); + + // same but OO interface + if (!$stmt = mysqli_stmt_init($link)) { + printf("[307] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break; + } + + if (!$stmt->prepare('SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) { + printf("[308] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + if (!$stmt->execute()) { + printf("[309] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + if (!$stmt->store_result()) { + printf("[310] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + $trend = $targetport = $format = null; + if (!$stmt->bind_result($trend, $targetport, $format)) { + + printf("[311] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + reset($values); + while ($stmt->fetch()) { + list($exp_trend, $exp_targetport) = each($values); + if ($targetport != $exp_targetport) { + printf("[312] Values fetched from MySQL seem to be wrong, check manually\n"); + printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format); + } + } + $stmt->free_result(); + $stmt->close(); + + } while (false); + + } else { + var_dump(mysqli_error($link)); + } + + + mysqli_close($link); + print "done!"; +?> +--EXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt new file mode 100644 index 0000000000..f6b7444cba --- /dev/null +++ b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc.phpt @@ -0,0 +1,185 @@ +--TEST-- +mysqli_stmt_execute() - Stored Procedures +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt index 8f01f28c4d..12489cef5d 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt @@ -102,7 +102,7 @@ object(stdClass)#%d (11) { ["max_length"]=> int(0) ["length"]=> - int(17) + int(%d) ["charsetnr"]=> int(63) ["flags"]=> @@ -200,7 +200,7 @@ object(stdClass)#%d (11) { [u"max_length"]=> int(0) [u"length"]=> - int(17) + int(%d) [u"charsetnr"]=> int(63) [u"flags"]=> diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt new file mode 100644 index 0000000000..12e33f2209 --- /dev/null +++ b/ext/mysqli/tests/mysqli_stmt_get_result_non_select.phpt @@ -0,0 +1,94 @@ +--TEST-- +mysqli_stmt_get_result() - SHOW, DESCRIBE, EXPLAIN +--SKIPIF-- + +--FILE-- +prepare('SHOW ENGINES') || + !$stmt->execute()) + printf("[002] [%d] %s\n", $stmt->errno, $stmt->error); + + if (!$res = $stmt->get_result()) + printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); + + $engines = mysqli_fetch_all($res, MYSQLI_NUM); + if (empty($engines)) { + printf("[004] It is very unlikely that SHOW ENGINES returns no data, check manually\n"); + } else { + $found = false; + foreach ($engines as $k => $engine) + foreach ($engine as $k => $v) + if (stristr('MyISAM', $v)) { + $found = true; + break; + } + if (!$found) + printf("[005] It is very unlikely that SHOW ENGINES does not show MyISAM, check manually\n"); + } + mysqli_free_result($res); + } + + if (mysqli_query($link, 'PREPARE mystmt FROM "DESCRIBE test id"')) { + mysqli_query($link, 'DEALLOCATE PREPARE mystmt'); + + if (!$stmt->prepare('DESCRIBE test id') || + !$stmt->execute()) + printf("[006] [%d] %s\n", $stmt->errno, $stmt->error); + + if (!$res = $stmt->get_result()) + printf("[007] [%d] %s\n", $stmt->errno, $stmt->error); + + $description = mysqli_fetch_assoc($res); + if ($description['Field'] != 'id') { + printf("[008] Returned data seems wrong, [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + var_dump($description); + } + mysqli_free_result($res); + } + + if (mysqli_query($link, 'PREPARE mystmt FROM "EXPLAIN SELECT id FROM test"')) { + mysqli_query($link, 'DEALLOCATE PREPARE mystmt'); + + if (!$stmt->prepare('EXPLAIN SELECT id FROM test') || + !$stmt->execute()) + printf("[009] [%d] %s\n", $stmt->errno, $stmt->error); + + if (!$res = $stmt->get_result()) + printf("[010] [%d] %s\n", $stmt->errno, $stmt->error); + + $tmp = mysqli_fetch_assoc($res); + if (empty($tmp)) + printf("[011] Empty EXPLAIN result set seems wrong, check manually, [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + mysqli_free_result($res); + } + mysqli_close($link); + + print "done!"; +?> +--EXPECTF-- +done! +--UEXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_types.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_types.phpt new file mode 100644 index 0000000000..f70eea7c33 --- /dev/null +++ b/ext/mysqli/tests/mysqli_stmt_get_result_types.phpt @@ -0,0 +1,255 @@ +--TEST-- +mysqli_stmt_get_result - data types +--SKIPIF-- + +--FILE-- + PHP_INT_MAX)) ? "string" : null); + func_mysqli_stmt_get_result($link, $engine, "i", "INTEGER UNSIGNED", NULL, 500); + + /* test is broken too: we bind "integer" but value is a float + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", -9223372036854775808, 520); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", 18446744073709551615, 560); + */ + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", NULL, 540); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", NULL, 580); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", -1, 1780); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", 1, 1800); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", -1 * PHP_INT_MAX + 1, 1820); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", PHP_INT_MAX, 1840); + func_mysqli_stmt_get_result($link, $engine, "s", "BIGINT UNSIGNED", "18446744073709551615", 1860); + func_mysqli_stmt_get_result($link, $engine, "s", "BIGINT", "-9223372036854775808", 1880); + + func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT", -9223372036854775808 - 1.1, 600); + func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT", NULL, 620); + func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT UNSIGNED", 18446744073709551615 + 1.1, 640); + func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT UNSIGNED ", NULL, 660); + + // Yes, we need the temporary variable. The PHP casting will fouls us otherwise. + $tmp = strval('-99999999.99'); + func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2)", $tmp, 680, "string"); + func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2)", NULL, 700); + $tmp = strval('99999999.99'); + func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", $tmp , 720, "string"); + func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", NULL, 740); + $tmp = strval('-99999999.99'); + func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 760, "string"); + func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 780); + $tmp = strval('99999999.99'); + func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 800, "string"); + func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 820); + + // don't care about date() strict TZ warnings... + func_mysqli_stmt_get_result($link, $engine, "s", "DATE", @date('Y-m-d'), 840); + func_mysqli_stmt_get_result($link, $engine, "s", "DATE NOT NULL", @date('Y-m-d'), 860); + func_mysqli_stmt_get_result($link, $engine, "s", "DATE", NULL, 880); + + func_mysqli_stmt_get_result($link, $engine, "s", "DATETIME", @date('Y-m-d H:i:s'), 900); + func_mysqli_stmt_get_result($link, $engine, "s", "DATETIME NOT NULL", @date('Y-m-d H:i:s'), 920); + func_mysqli_stmt_get_result($link, $engine, "s", "DATETIME", NULL, 940); + + func_mysqli_stmt_get_result($link, $engine, "s", "TIMESTAMP", @date('Y-m-d H:i:s'), 960); + + func_mysqli_stmt_get_result($link, $engine, "s", "TIME", @date('H:i:s'), 980); + func_mysqli_stmt_get_result($link, $engine, "s", "TIME NOT NULL", @date('H:i:s'), 1000); + func_mysqli_stmt_get_result($link, $engine, "s", "TIME", NULL, 1020); + + $tmp = intval(@date('Y')); + func_mysqli_stmt_get_result($link, $engine, "s", "YEAR", $tmp, 1040, "integer"); + func_mysqli_stmt_get_result($link, $engine, "s", "YEAR NOT NULL", $tmp, 1060, "integer"); + func_mysqli_stmt_get_result($link, $engine, "s", "YEAR", NULL, 1080); + + $string255 = func_mysqli_stmt_bind_make_string(255); + func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(1)", "a", 1110, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(255)", $string255, 1120, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(1) NOT NULL", "a", 1140, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(1)", NULL, 1160); + + $string65k = func_mysqli_stmt_bind_make_string(65535); + func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(1)", "a", 1180, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(255)", $string255, 1200, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(65635)", $string65k, 1220, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(1) NOT NULL", "a", 1240, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(1)", NULL, 1260); + + func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1)", "a", 1280); + func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1)", chr(0), 1300); + func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1) NOT NULL", "b", 1320); + func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1)", NULL, 1340); + + func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1)", "a", 1360); + func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1)", chr(0), 1380); + func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1) NOT NULL", "b", 1400); + func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1)", NULL, 1420); + + func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB", "a", 1440); + func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB", chr(0), 1460); + func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB NOT NULL", "b", 1480); + func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB", NULL, 1500); + + func_mysqli_stmt_get_result($link, $engine, "s", "TINYTEXT", "a", 1520, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "TINYTEXT NOT NULL", "a", 1540, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "TINYTEXT", NULL, 1560, $hint_str_or_unicode); + + // Note: you cannot insert any blob values this way. But you can check the API at least partly this way + // Extra BLOB tests are in mysqli_stmt_send_long() + func_mysqli_stmt_get_result($link, $engine, "b", "BLOB", b"", 1580); + func_mysqli_stmt_get_result($link, $engine, "b", "TEXT", "", 1600, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "b", "MEDIUMBLOB", b"", 1620); + func_mysqli_stmt_get_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_get_result($link, $engine, "b", "LONGBLOB", "", 1660); + func_mysqli_stmt_get_result($link, $engine, "b", "LONGTEXT", "", 1680, $hint_str_or_unicode); + + func_mysqli_stmt_get_result($link, $engine, "s", "ENUM('a', 'b')", "a", 1700, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "ENUM('a', 'b')", NULL, 1720, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "SET('a', 'b')", "a", 1740, $hint_str_or_unicode); + func_mysqli_stmt_get_result($link, $engine, "s", "SET('a', 'b')", NULL, 1760, $hint_str_or_unicode); + + mysqli_close($link); + print "done!"; +?> +--EXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysqli/tests/skipifunicode.inc b/ext/mysqli/tests/skipifunicode.inc new file mode 100644 index 0000000000..23cd79d460 --- /dev/null +++ b/ext/mysqli/tests/skipifunicode.inc @@ -0,0 +1,5 @@ +