Close a MySQL connection */
PHP_FUNCTION(mysql_close)
{
+ int resource_id;
zval *mysql_link=NULL;
php_mysql_conn *mysql;
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, NULL, MySG(default_link), "MySQL-Link", le_link, le_plink);
}
+ resource_id = mysql_link ? Z_RESVAL_P(mysql_link) : MySG(default_link);
+ PHPMY_UNBUFFERED_QUERY_CHECK();
#ifdef MYSQL_USE_MYSQLND
{
int tmp;
- if ((mysql = zend_list_find(Z_RESVAL_P(mysql_link), &tmp)) && tmp == le_plink) {
+ if ((mysql = zend_list_find(resource_id, &tmp)) && tmp == le_plink) {
mysqlnd_end_psession(mysql->conn);
}
}
#endif
- if (mysql_link) { /* explicit resource number */
- PHPMY_UNBUFFERED_QUERY_CHECK();
- zend_list_delete(Z_RESVAL_P(mysql_link));
- }
+ zend_list_delete(resource_id);
if (!mysql_link
|| (mysql_link && Z_RESVAL_P(mysql_link)==MySG(default_link))) {
- PHPMY_UNBUFFERED_QUERY_CHECK();
- zend_list_delete(MySG(default_link));
MySG(default_link) = -1;
+ if (mysql_link) {
+ /* on an explicit close of the default connection it had a refcount of 2 so we need one more call */
+ zend_list_delete(resource_id);
+ }
}
RETURN_TRUE;
}
}
- if ((result_type & MYSQL_BOTH) == 0) {
+ if (result_type & ~MYSQL_BOTH) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH");
result_type = MYSQL_BOTH;
}
}
ZEND_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, -1, "MySQL result", le_result);
+ if (mode & ~MYSQL_BOTH) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH");
+ mode = MYSQL_BOTH;
+ }
+
mysqlnd_fetch_into(result, mode, return_value, MYSQLND_MYSQL);
#endif
}
--- /dev/null
+--TEST--
+Bug #48754 (mysql_close() crash php when no handle specified)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+require_once('connect.inc');
+
+function my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket) {
+ if ($socket)
+ $host = sprintf("%s:%s", $host, $socket);
+ else if ($port)
+ $host = sprintf("%s:%s", $host, $port);
+
+ if (!$link = mysql_pconnect($host, $user, $passwd, true)) {
+ printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n",
+ $host, $user, $passwd,
+ mysql_errno(), mysql_error());
+ return false;
+ }
+ return $link;
+}
+
+echo "Explicit connection on close\n";
+$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket);
+$link1_thread_id = mysql_thread_id($link);
+$default1_thread_id = mysql_thread_id();
+echo 'Expect same thread id for $link and default conn: ';
+var_dump($link1_thread_id == $default1_thread_id);
+var_dump($link);
+mysql_close($link);
+var_dump($link);
+
+// we sohuld have no default link anymore
+mysql_close();
+
+echo "\nClosing default link\n";
+$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket);
+$link2_thread_id = mysql_thread_id($link);
+$default2_thread_id = mysql_thread_id();
+echo 'Expect same thread id for $link and default conn but not the previous: ';
+var_dump($link1_thread_id == $default1_thread_id && $link1_thread_id != $link2_thread_id);
+var_dump($link);
+mysql_close();
+var_dump($link);
+mysql_close($link);
+var_dump($link);
+
+echo "\nExplicit resource and pconnect\n";
+$link = my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket);
+var_dump($link);
+mysql_close($link);
+var_dump($link);
+
+// we sohuld have no default link
+mysql_close();
+
+echo "\nDefault link and pconnect\n";
+$link = my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket);
+var_dump($link);
+mysql_close();
+var_dump($link);
+mysql_close($link);
+var_dump($link);
+?>
+--EXPECTF--
+Explicit connection on close
+Expect same thread id for $link and default conn: bool(true)
+resource(%d) of type (mysql link)
+resource(%d) of type (Unknown)
+
+Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d
+
+Closing default link
+Expect same thread id for $link and default conn but not the previous: bool(true)
+resource(%d) of type (mysql link)
+resource(%d) of type (mysql link)
+resource(%d) of type (Unknown)
+
+Explicit resource and pconnect
+resource(%d) of type (mysql link persistent)
+resource(%d) of type (Unknown)
+
+Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d
+
+Default link and pconnect
+resource(%d) of type (mysql link persistent)
+resource(%d) of type (mysql link persistent)
+resource(%d) of type (Unknown)
}
/* wrapper to simplify test porting */
-function my_mysql_connect($host, $user, $passwd, $db, $port, $socket) {
+function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL) {
+ global $connect_flags;
+
+ $flags = ($flags === NULL) ? $connect_flags : $flags;
if ($socket)
$host = sprintf("%s:%s", $host, $socket);
else if ($port)
$host = sprintf("%s:%s", $host, $port);
- if (!$link = mysql_connect($host, $user, $passwd, true)) {
+ if (!$link = mysql_connect($host, $user, $passwd, true, $flags)) {
printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n",
$host, $user, $passwd,
mysql_errno(), mysql_error());
$engine = getenv("MYSQL_TEST_ENGINE") ? getenv("MYSQL_TEST_ENGINE") : "MyISAM";
$socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null;
$skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true;
+$connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0;
/* Development setting: test experimal features and/or feature requests that never worked before? */
$TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
mysql_close($link);
+if (!$link = mysql_connect($myhost, $user, $passwd, true))
+ printf("[003] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $myhost, $user, $db, $port, $socket);
+
+mysql_close();
+
if ($link = mysql_connect($myhost, $user . 'unknown_really', $passwd . 'non_empty', true))
- printf("[003] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
+ printf("[004] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
$host, $myhost, $user . 'unknown_really', $db, $port, $socket);
if (false !== $link)
-printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
+printf("[005] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
// Run the following tests without an anoynmous MySQL user and use a password for the test user!
ini_set('mysql.default_socket', $socket);
if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
- printf("[005] Usage of mysql.default_socket failed\n");
+ printf("[006] Usage of mysql.default_socket failed\n");
} else {
mysql_close($link);
}
ini_set('mysql.default_port', $port);
if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
- printf("[006] Usage of mysql.default_port failed\n");
+ printf("[007] Usage of mysql.default_port failed\n");
} else {
mysql_close($link);
}
ini_set('mysql.default_password', $passwd);
if (!is_resource($link = mysql_connect($myhost, $user))) {
- printf("[007] Usage of mysql.default_password failed\n");
+ printf("[008] Usage of mysql.default_password failed\n");
} else {
mysql_close($link);
}
ini_set('mysql.default_user', $user);
if (!is_resource($link = mysql_connect($myhost))) {
- printf("[008] Usage of mysql.default_user failed\n");
+ printf("[009] Usage of mysql.default_user failed\n");
} else {
mysql_close($link);
}
ini_set('mysql.default_host', $myhost);
if (!is_resource($link = mysql_connect())) {
- printf("[009] Usage of mysql.default_host failed\n") ;
+ printf("[010] Usage of mysql.default_host failed\n") ;
} else {
mysql_close($link);
}
+ if (!is_resource($link = mysql_connect()) || !is_resource($link2 = mysql_connect())) {
+ printf("[011] Usage of mysql.default_host failed\n") ;
+ } else {
+ mysql_close();
+ mysql_close($link2);
+ }
+
if (!stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'netware')) {
ini_set('mysql.default_port', -1);
if (putenv(sprintf('MYSQL_TCP_PORT=%d', $port))) {
if (!is_resource($link = mysql_connect())) {
- printf("[010] Usage of env MYSQL_TCP_PORT failed\n") ;
+ printf("[012] Usage of env MYSQL_TCP_PORT failed\n") ;
} else {
mysql_close($link);
}
} else if (putenv(sprintf('MYSQL_TCP_PORT=%d', $port + 1))) {
if (!is_resource($link = mysql_connect())) {
- printf("[011] Usage of env MYSQL_TCP_PORT=%d should have failed\n", $port + 1) ;
+ printf("[013] Usage of env MYSQL_TCP_PORT=%d should have failed\n", $port + 1) ;
mysql_close($link);
}
}
do {
$illegal_mode = mt_rand(0, 10000);
} while (in_array($illegal_mode, array(MYSQL_ASSOC, MYSQL_NUM, MYSQL_BOTH)));
-$tmp = @mysql_fetch_array($res, $illegal_mode);
+$tmp = mysql_fetch_array($res, $illegal_mode);
if (!is_array($tmp))
printf("[013] Expecting array, got %s/%s. [%d] %s\n",
gettype($tmp), $tmp, mysql_errno($link), mysql_error($link));
%unicode|string%(1) "1"
}
+Warning: mysql_fetch_array(): The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH in %s on line %d
+
Warning: mysql_fetch_array(): %d is not a valid MySQL result resource in %s on line %d
done!
printf("[017] [%d] %s\n", mysql_errno($link), mysql_error($link));
}
$res = mysql_list_fields($db, 'test');
- while ($tmp = mysql_fetch_field($res))
- if ($tmp->name == 'id')
+ $found = false;
+ while ($tmp = mysql_fetch_field($res)) {
+ if ($tmp->name == 'id') {
+ printf("Fetch field from mysql_list_fields result set.\n");
+ $found = true;
var_dump($tmp);
+ }
+ }
+ if (!$found)
+ printf("[018] mysqli_list_fields result set processing has failed.\n");
mysql_free_result($res);
[%u|b%"zerofill"]=>
int(0)
}
+Fetch field from mysql_list_fields result set.
object(stdClass)#%d (13) {
[%u|b%"name"]=>
%unicode|string%(2) "id"
$tmp = NULL;
$link = NULL;
-// This will implicitly try to connect, and we don't want it
-//if (false !== ($tmp = mysql_list_fields($link, $link)))
-// printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
-
require 'table.inc';
if (!$res = mysql_list_fields($db, 'test', $link))
printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (2 !== ($num = mysql_num_fields($res)))
- printf("[004] Expecting two fields, got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link));
+ printf("[004] Expecting two fields from 'test', got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link));
mysql_free_result($res);
-if (!mysql_query("DROP TABLE IF EXISTS test2", $link) ||
- !mysql_query("CREATE TABLE test2(id INT)", $link))
+if (!mysql_query("DROP TABLE IF EXISTS test2", $link))
printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
-if (!$res = mysql_list_fields($db, 'test', $link))
+if (!$res = @mysql_list_fields($db, 'test2', $link))
printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
+if (!$res = mysql_list_fields($db, 'test', $link))
+ printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
if (2 !== ($num = mysql_num_fields($res)))
- printf("[007] Expecting 3 fields from test and test2, got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link));
+ printf("[008] Expecting 2 fields from 'test', got %d. [%d] %s\n", $num, mysql_errno($link), mysql_error($link));
+
+var_dump(mysql_fetch_assoc($res));
+for ($field_offset = 0; $field_offset < mysql_num_fields($res); $field_offset++) {
+ printf("Field Offset %d\n", $field_offset);
+ printf("mysql_field_flags(): %s\n", mysql_field_flags($res, $field_offset));
+ printf("mysql_field_len(): %s\n", mysql_field_len($res, $field_offset));
+ printf("mysql_field_name(): %s\n", mysql_field_name($res, $field_offset));
+ printf("mysql_field_type(): %s\n", mysql_field_type($res, $field_offset));
+}
mysql_free_result($res);
mysql_close($link);
mysql_close($link);
?>
--EXPECTF--
+[006] [%d] %s
+bool(false)
+Field Offset 0
+mysql_field_flags()%s
+mysql_field_len(): 11
+mysql_field_name(): id
+mysql_field_type(): int
+Field Offset 1
+mysql_field_flags()%s
+mysql_field_len(): 1
+mysql_field_name(): label
+mysql_field_type(): string
done!
--- /dev/null
+--TEST--
+mysqlnd.net_read_timeout > default_socket_timeout
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+require_once('connect.inc');
+?>
+--INI--
+default_socket_timeout=1
+mysqlnd.net_read_timeout=12
+max_execution_time=12
+--FILE--
+<?php
+ set_time_limit(12);
+ include ("connect.inc");
+
+ if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysql_errno(), mysqlerror());
+ }
+
+ if (!$res = mysql_query("SELECT SLEEP(6)", $link))
+ printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+ var_dump(mysql_fetch_assoc($res));
+
+ mysql_free_result($res);
+ mysql_close($link);
+
+ print "done!";
+?>
+--EXPECTF--
+array(1) {
+ [%u|b%"SLEEP(6)"]=>
+ %unicode|string%(1) "0"
+}
+done!
\ No newline at end of file
if (!mysql_select_db($db, $link))
die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link)));
+ if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link))
+ die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link)));
+
+ $row = mysql_fetch_assoc($res);
+ mysql_free_result($res);
+ $host = substr($row['_user'], strrpos($row['_user'], "@") + 1, strlen($row['_user']));
+
mysql_query('DROP USER pcontest', $link);
- if (!mysql_query('CREATE USER pcontest IDENTIFIED BY "pcontest"', $link)) {
+ mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
+ if (!mysql_query(sprintf('CREATE USER pcontest@"%s" IDENTIFIED BY "pcontest"', mysql_real_escape_string($host, $link)), $link)) {
printf("skip Cannot create second DB user [%d] %s", mysql_errno($link), mysql_error($link));
mysql_close($link);
die();
}
// we might be able to specify the host using CURRENT_USER(), but...
- if (!mysql_query(sprintf("GRANT SELECT ON TABLE %s.test TO pcontest@'%%'", $db), $link)) {
+ if (!mysql_query(sprintf('GRANT SELECT ON TABLE %s.test TO pcontest@"%s"', $db, mysql_real_escape_string($host, $link)), $link)) {
printf("skip Cannot GRANT SELECT to second DB user [%d] %s", mysql_errno($link), mysql_error($link));
- mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link);
- mysql_query('DROP USER pcontest', $link);
+ mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
+ mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
mysql_close($link);
die();
}
+
mysql_close($link);
?>
--INI--
-mysql.max_links=2
-mysql.max_persistent=1
+mysql.max_links=3
+mysql.max_persistent=2
mysql.allow_persistent=1
--FILE--
<?php
var_dump($row);
// change the password for the second DB user and kill the persistent connection
- if (!mysql_query('SET PASSWORD FOR pcontest = PASSWORD("newpass")', $link))
- printf("[006] Cannot change PW of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link));
+ if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link))
+ printf("[006] [%d] %s", mysql_errno($link), mysql_error($link));
+
+ $row = mysql_fetch_assoc($res);
+ mysql_free_result($res);
+ $host = substr($row['_user'], strrpos($row['_user'], "@") + 1, strlen($row['_user']));
+
+ $sql = sprintf('SET PASSWORD FOR pcontest@"%s" = PASSWORD("newpass")', mysql_real_escape_string($host, $link));
+ if (!mysql_query($sql, $link))
+ printf("[007] Cannot change PW of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link));
// persistent connections cannot be closed but only be killed
$pthread_id = mysql_thread_id($plink);
if (!mysql_query(sprintf('KILL %d', $pthread_id), $link))
- printf("[007] Cannot KILL persistent connection of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link));
+ printf("[008] Cannot KILL persistent connection of second DB user, [%d] %s\n", mysql_errno($link), mysql_error($link));
// give the server a second to really kill the thread
sleep(1);
if (!$res = mysql_query("SHOW FULL PROCESSLIST", $link))
- printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link));
+ printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link));
$running_threads = array();
while ($row = mysql_fetch_assoc($res))
mysql_free_result($res);
if (isset($running_threads[$pthread_id]))
- printf("[009] Persistent connection has not been killed");
+ printf("[010] Persistent connection has not been killed\n");
// we might get the old handle
if ($plink = @mysql_pconnect($host, 'pcontest', 'pcontest'))
- printf("[010] Can connect using the old password, [%d] %s\n",
+ printf("[011] Can connect using the old password, [%d] %s\n",
mysql_errno(), mysql_error());
ob_start();
ob_end_clean();
$phpinfo = substr($phpinfo, strpos($phpinfo, 'MySQL Support => enabled'), 500);
if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches))
- printf("[011] Cannot get # active persistent links from phpinfo()");
+ printf("[012] Cannot get # active persistent links from phpinfo()\n");
$num_plinks_kill = $matches[1];
- if ($num_plinks_kill >= $num_plinks)
- printf("[012] Statistics seems to be wrong, got %d active persistent links, expecting < %d links",
+ if ($num_plinks_kill > $num_plinks)
+ printf("[013] Statistics seems to be wrong, got %d active persistent links, expecting < %d links\n",
$num_plinks_kill, $num_plinks);
// The first connection has been closed, the last pconnect() was unable to connect -> no connection open
// We must be able to connect because max_persistent limit has not been reached
if (!$plink = mysql_pconnect($host, 'pcontest', 'newpass'))
- printf("[013] Cannot connect using the second DB, [%d] %s\n",
- mysql_errno(), mysql_error());
+ die(sprintf("[014] Cannot connect using the second DB, [%d] %s\n",
+ mysql_errno(), mysql_error()));
if (!mysql_select_db($db, $plink))
- printf("[014] [%d] %s\n", mysql_errno($plink), mysql_error($plink));
+ printf("[015] [%d] %s\n", mysql_errno($plink), mysql_error($plink));
if (!$res = mysql_query('SELECT id, label FROM test WHERE id = 1', $plink))
- printf("[015] Cannot run query on persistent connection of second DB user, [%d] %s\n",
+ printf("[016] Cannot run query on persistent connection of second DB user, [%d] %s\n",
mysql_errno($plink), mysql_error($plink));
if (!$row = mysql_fetch_assoc($res))
- printf("[016] Cannot run fetch result, [%d] %s\n",
+ printf("[017] Cannot run fetch result, [%d] %s\n",
mysql_errno($plink), mysql_error($plink));
mysql_free_result($res);
var_dump($row);
- mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link);
- mysql_query('DROP USER pcontest', $link);
+ mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
+ mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
mysql_close($link);
print "done!";
?>
$host, $myhost, $user, $db, $port, $socket);
}
-@mysql_query('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest', $link);
-@mysql_query('DROP USER pcontest', $link);
+if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link))
+ printf("[c002] [%d] %s", mysql_errno($link), mysql_error($link));
+
+$row = mysql_fetch_assoc($res);
+mysql_free_result($res);
+$host = substr($row['_user'], strrpos($row['_user'], "@") + 1, strlen($row['_user']));
+
+@mysql_query(sprintf('REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
+@mysql_query(sprintf('DROP USER pcontest@"%s"', mysql_real_escape_string($host, $link)), $link);
mysql_close($link);
?>
else if ($port)
$myhost = sprintf("%s:%s", $host, $port);
- if (!$link = @mysql_connect($myhost, $user, $passwd, true))
+ if (!$link = @mysql_connect($myhost, $user, $passwd, true, $connect_flags))
die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysql_errno(), mysql_error()));
if (!@mysql_select_db($db, $link))
#include "ext/standard/php_string.h"
#include "php_mysqli_structs.h"
#include "zend_exceptions.h"
+#include "ext/mysqlnd/mysqlnd_portability.h"
ZEND_DECLARE_MODULE_GLOBALS(mysqli)
static PHP_GINIT_FUNCTION(mysqli);
zval tmp_member;
mysqli_object *obj;
mysqli_prop_handler *hnd;
- zend_object_handlers *std_hnd;
int ret;
if (member->type != IS_STRING) {
MAKE_STD_ZVAL(res);
- /* check if we need magic quotes */
- if (PG(magic_quotes_runtime)) {
- Z_TYPE_P(res) = IS_STRING;
- Z_STRVAL_P(res) = php_addslashes(row[i], field_len[i], &Z_STRLEN_P(res), 0 TSRMLS_CC);
- } else {
- ZVAL_STRINGL(res, row[i], field_len[i], 1);
+#if MYSQL_VERSION_ID > 50002
+ if (mysql_fetch_field_direct(result, i)->type == MYSQL_TYPE_BIT) {
+ my_ulonglong llval;
+ char tmp[22];
+ switch (field_len[i]) {
+ case 8:llval = (my_ulonglong) bit_uint8korr(row[i]);break;
+ case 7:llval = (my_ulonglong) bit_uint7korr(row[i]);break;
+ case 6:llval = (my_ulonglong) bit_uint6korr(row[i]);break;
+ case 5:llval = (my_ulonglong) bit_uint5korr(row[i]);break;
+ case 4:llval = (my_ulonglong) bit_uint4korr(row[i]);break;
+ case 3:llval = (my_ulonglong) bit_uint3korr(row[i]);break;
+ case 2:llval = (my_ulonglong) bit_uint2korr(row[i]);break;
+ case 1:llval = (my_ulonglong) uint1korr(row[i]);break;
+ }
+ /* even though lval is declared as unsigned, the value
+ * may be negative. Therefor we cannot use MYSQLI_LLU_SPEC and must
+ * use MYSQLI_LL_SPEC.
+ */
+ snprintf(tmp, sizeof(tmp), (mysql_fetch_field_direct(result, i)->flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval);
+ ZVAL_STRING(res, tmp, 1);
+ } else
+#endif
+ {
+
+ /* check if we need magic quotes */
+ if (PG(magic_quotes_runtime)) {
+ Z_TYPE_P(res) = IS_STRING;
+ Z_STRVAL_P(res) = php_addslashes(row[i], field_len[i], &Z_STRLEN_P(res), 0 TSRMLS_CC);
+ } else {
+ ZVAL_STRINGL(res, row[i], field_len[i], 1);
+ }
}
if (fetchtype & MYSQLI_NUM) {
#include "php_globals.h"
#include "ext/standard/info.h"
#include "php_mysqli_structs.h"
+#include "ext/mysqlnd/mysqlnd_portability.h"
/* {{{ proto mixed mysqli_affected_rows(object link)
Get number of affected rows in previous MySQL operation */
bind[ofs].is_null = &stmt->result.is_null[ofs];
bind[ofs].buffer_length = stmt->result.buf[ofs].buflen;
bind[ofs].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0;
+ bind[ofs].length = &stmt->result.buf[ofs].output_len;
break;
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DECIMAL:
+ case MYSQL_TYPE_GEOMETRY:
#ifdef FIELD_TYPE_NEWDECIMAL
case MYSQL_TYPE_NEWDECIMAL:
#endif
different lengths and you will see that we get different lengths in stmt->stmt->fields[ofs].length
The just take 256 and saves us from realloc-ing.
*/
- stmt->result.buf[ofs].buflen = 256;
+ stmt->result.buf[ofs].buflen =
+ (stmt->stmt->fields) ? (stmt->stmt->fields[ofs].length) ? stmt->stmt->fields[ofs].length + 1: 256: 256;
+
} else {
/*
the user has called store_result(). if he does not there is no way to determine the
bind[ofs].buffer = stmt->result.buf[ofs].val;
bind[ofs].is_null = &stmt->result.is_null[ofs];
bind[ofs].buffer_length = stmt->result.buf[ofs].buflen;
- bind[ofs].length = &stmt->result.buf[ofs].buflen;
+ bind[ofs].length = &stmt->result.buf[ofs].output_len;
break;
}
default:
for (i = 0; i < stmt->param.var_cnt; i++) {
for (j = i + 1; j < stmt->param.var_cnt; j++) {
/* Oops, someone binding the same variable - clone */
- if (stmt->param.vars[j] == stmt->param.vars[i]) {
+ if (stmt->param.vars[j] == stmt->param.vars[i] && stmt->param.vars[i]) {
php_mysqli_stmt_copy_it(&copies, stmt->param.vars[i], stmt->param.var_cnt, i);
break;
}
ZVAL_DOUBLE(stmt->result.vars[i], *(double *)stmt->result.buf[i].val);
break;
case IS_STRING:
- if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG) {
+ if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG
+#if MYSQL_VERSION_ID > 50002
+ || stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT
+#endif
+ ) {
my_bool uns= (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? 1:0;
- llval= *(my_ulonglong *) stmt->result.buf[i].val;
+#if MYSQL_VERSION_ID > 50002
+ if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT) {
+ switch (stmt->result.buf[i].output_len) {
+ case 8:llval = (my_ulonglong) bit_uint8korr(stmt->result.buf[i].val);break;
+ case 7:llval = (my_ulonglong) bit_uint7korr(stmt->result.buf[i].val);break;
+ case 6:llval = (my_ulonglong) bit_uint6korr(stmt->result.buf[i].val);break;
+ case 5:llval = (my_ulonglong) bit_uint5korr(stmt->result.buf[i].val);break;
+ case 4:llval = (my_ulonglong) bit_uint4korr(stmt->result.buf[i].val);break;
+ case 3:llval = (my_ulonglong) bit_uint3korr(stmt->result.buf[i].val);break;
+ case 2:llval = (my_ulonglong) bit_uint2korr(stmt->result.buf[i].val);break;
+ case 1:llval = (my_ulonglong) uint1korr(stmt->result.buf[i].val);break;
+ }
+ } else
+#endif
+ {
+ llval= *(my_ulonglong *) stmt->result.buf[i].val;
+ }
#if SIZEOF_LONG==8
if (uns && llval > 9223372036854775807L) {
#elif SIZEOF_LONG==4
} else {
ZVAL_LONG(stmt->result.vars[i], llval);
}
- }
-#if MYSQL_VERSION_ID > 50002
- else if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT) {
- llval = *(my_ulonglong *)stmt->result.buf[i].val;
- ZVAL_LONG(stmt->result.vars[i], llval);
- }
-#endif
- else {
+ } else {
#if defined(MYSQL_DATA_TRUNCATED) && MYSQL_VERSION_ID > 50002
if (ret == MYSQL_DATA_TRUNCATED && *(stmt->stmt->bind[i].error) != 0) {
/* result was truncated */
{
#endif
ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
- stmt->result.buf[i].buflen, 1);
+ stmt->result.buf[i].output_len, 1);
}
}
break;
long mode_in;
ulong mode;
ulong attr;
- int rc;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll", &mysql_stmt, mysqli_stmt_class_entry, &attr, &mode_in) == FAILURE) {
return;
}
mode = mode_in;
- if ((rc = mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode))) {
+#if !defined(MYSQLI_USE_MYSQLND)
+ if (FALSE == mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode)) {
+#else
+ if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode)) {
+#endif
RETURN_FALSE;
}
RETURN_TRUE;
for (i = mysql_stmt_field_count(stmt->stmt) - 1; i >=0; --i) {
if (stmt->stmt->fields && (stmt->stmt->fields[i].type == MYSQL_TYPE_BLOB ||
stmt->stmt->fields[i].type == MYSQL_TYPE_MEDIUM_BLOB ||
- stmt->stmt->fields[i].type == MYSQL_TYPE_LONG_BLOB))
+ stmt->stmt->fields[i].type == MYSQL_TYPE_LONG_BLOB ||
+ stmt->stmt->fields[i].type == MYSQL_TYPE_GEOMETRY))
{
my_bool tmp=1;
mysql_stmt_attr_set(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp);
MyG(num_active_persistent) + MyG(num_inactive_persistent));
goto err;
}
- if (!is_real_connect && !mysql->mysql) {
+ if (!mysql->mysql) {
#if !defined(MYSQLI_USE_MYSQLND)
if (!(mysql->mysql = mysql_init(NULL))) {
#else
};
typedef struct {
- ulong buflen;
char *val;
+ ulong buflen;
+ ulong output_len;
ulong type;
} VAR_BUFFER;
--TEST--
mysqli connect
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
$test = "";
/*** test mysqli_connect localhost:port ***/
- $link = mysqli_connect($host, $user, $passwd, "", $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, "", $port, $socket);
$test .= ($link) ? "1" : "0";
mysqli_close($link);
/*** test mysqli_real_connect ***/
$link = mysqli_init();
- $test.= (mysqli_real_connect($link, $host, $user, $passwd, "", $port, $socket) )
+ $test.= (my_mysqli_real_connect($link, $host, $user, $passwd, "", $port, $socket) )
? "1" : "0";
mysqli_close($link);
/*** test mysqli_real_connect with db ***/
$link = mysqli_init();
- $test .= (mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+ $test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
? "1" : "0";
mysqli_close($link);
/*** test mysqli_real_connect with port ***/
$link = mysqli_init();
- $test .= (mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+ $test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
? "1":"0";
mysqli_close($link);
if (!$link = mysqli_init())
printf("[001 + %d] mysqli_init() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
- if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
printf("[002 + %d] mysqli_real_connect() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
mysqli_close($link);
/*** test mysqli_real_connect compressed ***/
/*
$link = mysqli_init();
- $test .= (mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS))
+ $test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS))
? "1" : "0";
mysqli_close($link);
*/
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
<?php
include "connect.inc";
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_query($link, "SET sql_mode=''");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
include ("connect.inc");
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
var_dump($test);
+ /* this will crash with libmysql from PHP 5.0.6 (or earlier) to 5.3.0 */
+ mysqli_fetch($stmt);
+
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET sql_mode=''"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET sql_mode=''"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET sql_mode=''"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET sql_mode=''"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET sql_mode=''"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
include "connect.inc";
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) {
die("skip Cannot check for required InnoDB suppot");
}
--FILE--
<?php
include "connect.inc";
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_autocommit($link, TRUE))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
include "connect.inc";
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
<?php
include "connect.inc";
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!$link)
printf("[001] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET @dummy='foobar'"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!$stmt = mysqli_prepare($link, "SELECT md5('bar'), database(), 'foo'"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
--TEST--
mysqli fetch system variables
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET AUTOCOMMIT=0"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "DROP TABLE IF EXISTS insert_read"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS insert_read"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
--TEST--
function test: mysqli_stat
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$status = mysqli_stat($link);
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$cset = substr(mysqli_character_set_name($link),0,6);
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS general_test"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$errno = mysqli_errno($link);
var_dump($errno);
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$error = mysqli_error($link);
var_dump($error);
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS general_test"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$hinfo = mysqli_get_host_info($link);
--TEST--
function test: mysqli_get_proto_info
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$pinfo = mysqli_get_proto_info($link);
--TEST--
function test: mysqli_get_server_info
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$sinfo = substr(mysqli_get_server_info($link),0,1);
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS t036"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_real_query($link, "SHOW VARIABLES");
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "DROP TABLE IF EXISTS test_warnings");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_update"))
--TEST--
mysqli_get_server_version
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$i = mysqli_get_server_version($link);
require_once('skipifconnectfailure.inc');
include "connect.inc";
- $link = mysqli_connect($host, $user, $passwd);
+ $link = my_mysqli_connect($host, $user, $passwd);
$stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'");
mysqli_execute($stmt);
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'");
mysqli_execute($stmt);
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_affected"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_affected"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $mysql = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$mysql->select_db($db);
$mysql->query("DROP TABLE IF EXISTS test_fetch_null");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $mysql = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$mysql->select_db($db);
$result = $mysql->query("SELECT DATABASE()");
$result->close();
var_dump($row);
+ if ($row[0] != $db)
+ printf("[001] Expecting '%s' got '%s'\n", $db, $row[0]);
$mysql->close();
print "done!";
--TEST--
non freed statement test
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
/************************
* non freed stamement
************************/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$stmt = mysqli_prepare($link, "SELECT CURRENT_USER()");
mysqli_execute($stmt);
--TEST--
free statement after close
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
/************************
* free statement after close
************************/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$stmt1 = mysqli_prepare($link, "SELECT CURRENT_USER()");
mysqli_execute($stmt1);
--TEST--
call statement after close
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
-
+
/************************
- * statement call after close
+ * statement call after close
************************/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
--TEST--
-not freed resultset
+not freed resultset
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
-
+
/************************
- * non freed resultset
+ * non freed resultset
************************/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$result = mysqli_query($link, "SELECT CURRENT_USER()");
mysqli_close($link);
--TEST--
-free resultset after close
+free resultset after close
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
-
+
/************************
- * free resultset after close
+ * free resultset after close
************************/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$result1 = mysqli_query($link, "SELECT CURRENT_USER()");
mysqli_close($link);
--TEST--
-free nothing
+free nothing
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
-
+
/************************
- * don't free anything
+ * don't free anything
************************/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$result2 = mysqli_query($link, "SELECT CURRENT_USER()");
$stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_store_result"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS mbind"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS mbind"))
}
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch"))
}
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
/* create temporary file */
$filename = dirname(__FILE__) . "061.csv";
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS t_061"))
<?php
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->real_query("SELECT 'foo' FROM DUAL");
<?php
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$stmt = new mysqli_stmt($mysql, "SELECT 'foo' FROM DUAL");
$stmt->execute();
--TEST--
-NULL binding
+NULL binding
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$stmt = new mysqli_stmt($mysql, "SELECT NULL FROM DUAL");
$stmt->execute();
<?php
include "connect.inc";
- if (!$mysql = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($mysql, "SET sql_mode=''"))
include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->query("DROP TABLE IF EXISTS test_warnings");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"))
require_once('skipifconnectfailure.inc');
include "connect.inc";
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to check required version");
/* skip cursor test for versions < 50004 */
}
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
if ((!$IS_MYSQLND && mysqli_get_client_version() < 50009) ||
(mysqli_get_server_version($mysql) < 50009)) {
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
for ($i =0; $i < 3; $i++) {
<?php
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->multi_query('SELECT 1;SELECT 2');
do {
$res = $mysql->store_result();
--TEST--
mysqli ping
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
var_dump($mysql->ping());
$mysql->close();
print "done!";
--TEST--
mysqli thread_id & kill
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
<?php
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
var_dump($mysql->ping());
$mysql->close();
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
var_dump(mysqli_ping($mysql));
<?php
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->query("DROP TABLE IF EXISTS not_exists");
include "connect.inc";
- $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
var_dump($mysqli->autocommit(false));
$result = $mysqli->query("SELECT @@autocommit");
<?php
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->multi_query('SELECT 1;SELECT 2');
do {
$res = $mysql->store_result();
var_dump($mysql->error, __LINE__);
$mysql->close();
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->multi_query('SELECT 1;SELECT 2');
do {
$res = $mysql->store_result();
include ("connect.inc");
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, "test");
mysqli_query($link, "SET sql_mode=''");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_users"))
--TEST--
Bug #33090 (mysql_prepare doesn't return an error)
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
include ("connect.inc");
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, null, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, null, $port, $socket);
mysqli_select_db($link, $db);
if (!($link->prepare("this makes no sense"))) {
printf("%d\n", $link->errno);
printf("%s\n", $link->sqlstate);
- }
+ }
$link->close();
?>
--EXPECT--
--TEST--
Bug #34785 (Can not properly subclass mysqli_stmt)
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
}
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_query($link, "SET sql_mode=''");
$stmt = new my_stmt($link, "SELECT 'foo' FROM DUAL");
public function connect() {
include "connect.inc";
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
var_dump($link);
$link = mysqli_init();
/* @ is to supress 'Property access is not allowed yet' */
@var_dump($link);
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->query("DROP TABLE IF EXISTS test_warnings");
$mysql->query("CREATE TABLE test_warnings (a int not null)");
$mysql->query("SET sql_mode=''");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"))
EOSQL;
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->query("DROP TABLE IF EXISTS test_bint");
$mysql->query("CREATE TABLE test_bint (a bigint(20) default NULL) ENGINE=MYISAM");
$mysql->query("INSERT INTO test_bint VALUES (9223372036854775807),(-9223372036854775808),(-2147483648),(-2147483649),(-2147483647),(2147483647),(2147483648),(2147483649)");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bint") || !mysqli_query($link, "DROP TABLE IF EXISTS test_buint"))
<?php
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)");
$mysql->query("INSERT INTO temp (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS temp"))
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS blobby"))
--TEST--
Bug #36420 (segfault when access result->num_rows after calling result->close())
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
-$mysqli = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$result = $mysqli->query('select 1');
echo "Done\n";
?>
---EXPECTF--
+--EXPECTF--
Warning: main(): Couldn't fetch mysqli_result in %s on line %d
Warning: main(): Couldn't fetch mysqli_result in %s on line %d
include ("connect.inc");
/*** test mysqli_connect 127.0.0.1 ***/
- $mysql = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$mysql->query("DROP TABLE IF EXISTS litest");
$mysql->query("CREATE TABLE litest (a VARCHAR(20))");
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS litest"))
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
-
- class my_mysqli extends mysqli {
- function __construct()
+ class really_my_mysqli extends mysqli {
+ function __construct()
{
}
}
include "connect.inc";
-
-
$mysql = mysqli_init();
/* following operations should not work */
}
$x[1] = @$mysql->query("SELECT 'foo' FROM DUAL");
- /* following operations should work */
+ /* following operations should work */
$x[2] = ($mysql->client_version > 0);
$x[3] = $mysql->errno;
$mysql->close();
-
-
var_dump($x);
?>
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS my_time"))
<?php
include "connect.inc";
- $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$cs = array();
$cs[] = $mysql->set_charset("latin1");
--TEST--
Bug #38710 (data leakage because of nonexisting boundary checking in statements)
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
-$db = new mysqli($host, $user, $passwd, $db, $port, $socket);
+$db = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$qry=$db->stmt_init();
$qry->prepare("SELECT REPEAT('a',100000)");
$qry->execute();
}
echo "Done";
?>
---EXPECTF--
+--EXPECTF--
Done
\ No newline at end of file
return true;
}
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect - [%d] %s\n",
mysqli_connect_errno(),
mysqli_connect_error());
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) <= 50000) {
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
mysqli_query($link, "DROP PROCEDURE IF EXISTS p1");
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) <= 50000) {
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
$index = 0;
while ($stmt->fetch()) {
+ /* NOTE: libmysql - http://bugs.mysql.com/bug.php?id=47483 */
if ($data[$index] != $column1) {
- printf("[004] Row %d, expecting %s/%s got %s/%s\n",
- $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+ if ($IS_MYSQLND || $index != 1) {
+ printf("[004] Row %d, expecting %s/%s got %s/%s\n",
+ $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+ } else {
+ if ($column1 != "thre")
+ printf("[005] Got '%s'. Please check if http://bugs.mysql.com/bug.php?id=47483 has been fixed and adapt tests bug45019.phpt/mysqli_ps_select_union.phpt", $column1);
+ }
}
$index++;
}
$stmt->close();
- // Regular (non-prepared) queries
- print "Mixing CAST('somestring'AS CHAR), integer and CAST(integer AS CHAR)...\n";
- if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)")))
- printf("[005] [%d] %s\n", $link->errno, $link->error);
-
- $data = array();
- while ($row = $res->fetch_assoc()) {
- $data[] = $row['column1'];
- }
- $res->free();
-
- // Prepared Statements
- if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)")))
- printf("[006] [%d] %s\n", $link->errno, $link->error);
-
- $column1 = null;
- if (!$stmt->execute() || !$stmt->bind_result($column1))
- printf("[007] [%d] %s\n", $stmt->errno, $stmt->error);
-
- $index = 0;
- while ($stmt->fetch()) {
- if ($data[$index] != $column1) {
- printf("[008] Row %d, expecting %s/%s got %s/%s\n",
- $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
- }
- var_dump($column1);
- $index++;
- }
- $stmt->close();
-
- print "Using integer only...\n";
- if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2")))
- printf("[009] [%d] %s\n", $link->errno, $link->error);
-
- $data = array();
- while ($row = $res->fetch_assoc()) {
- $data[] = $row['column1'];
- }
- $res->free();
-
- // Prepared Statements
- if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2")))
- printf("[010] [%d] %s\n", $link->errno, $link->error);
-
- $column1 = null;
- if (!$stmt->bind_result($column1) || !$stmt->execute())
- printf("[011] [%d] %s\n", $stmt->errno, $stmt->error);
-
- $index = 0;
- while ($stmt->fetch()) {
- if ($data[$index] != $column1) {
- printf("[012] Row %d, expecting %s/%s got %s/%s\n",
- $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
- }
- var_dump($column1);
- $index++;
- }
- $stmt->close();
-
- print "Testing bind_param(), strings only...\n";
- $two = 'two';
- $three = 'three';
- if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?")))
- printf("[013] [%d] %s\n", $stmt->errno, $stmt->error);
-
- $column1 = null;
- if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute())
- printf("[014] [%d] %s\n", $stmt->errno, $stmt->error);
-
- while ($stmt->fetch()) {
- var_dump($column1);
- }
- $stmt->close();
-
- print "Testing bind_param(), strings only, with CAST AS CHAR...\n";
- $two = 'two';
- $three = 'three beers are more than enough';
- if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)")))
- printf("[013] [%d] %s\n", $stmt->errno, $stmt->error);
-
- $column1 = null;
- if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute())
- printf("[014] [%d] %s\n", $stmt->errno, $stmt->error);
-
- while ($stmt->fetch()) {
- var_dump($column1);
- }
- $stmt->close();
-
$link->close();
print "done!";
%unicode|string%(3) "one"
%unicode|string%(5) "three"
%unicode|string%(3) "two"
-Mixing CAST('somestring'AS CHAR), integer and CAST(integer AS CHAR)...
-%unicode|string%(1) "1"
-%unicode|string%(5) "three"
-%unicode|string%(1) "2"
-Using integer only...
-int(1)
-int(303)
-int(2)
-Testing bind_param(), strings only...
-%unicode|string%(3) "one"
-%unicode|string%(5) "three"
-%unicode|string%(3) "two"
-Testing bind_param(), strings only, with CAST AS CHAR...
-%unicode|string%(3) "one"
-%unicode|string%(32) "three beers are more than enough"
-%unicode|string%(3) "two"
done!
?>
--FILE--
<?php
- include("connect.inc");
require('table.inc');
+ $link->close();
+
+ $link = mysqli_init();
+ if (!($link->real_connect($host, $user, $passwd, $db, $port, $socket)))
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
$id = 1;
if (!($stmt = $link->prepare('SELECT id, label FROM test WHERE id=? LIMIT 1')))
- printf("[001] [%d] %s\n", $link->errno, $link->error);
+ printf("[002] [%d] %s\n", $link->errno, $link->error);
if (!$stmt->bind_param('i', $id) || !$stmt->execute())
- printf("[002] [%d] %s\n", $stmt->errno, $stmt->error);
+ printf("[003] [%d] %s\n", $stmt->errno, $stmt->error);
if ($res = $link->store_result()) {
- printf("[003] Can store result!\n");
+ if ($IS_MYSQLND)
+ printf("[004] Can store result!\n");
+ else
+ printf("[004] [007] http://bugs.mysql.com/bug.php?id=47485\n");
} else {
- printf("[003] [%d] %s\n", $link->errno, $link->error);
+ printf("[004] [%d] %s\n", $link->errno, $link->error);
}
-
- var_dump($res->fetch_assoc());
?>
--CLEAN--
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
-[003] [0%s
-
-Fatal error: Call to a member function fetch_assoc() on a non-object in %s on line %d
+[004] [0%s
<?php
class MySQL_Ext extends mysqli{
protected $fooData = array();
-
+
public function isEmpty()
{
$this->extData[] = 'Bar';
}
}
+include ("connect.inc");
+$MySQL_Ext = new MySQL_Ext($host, $user, $passwd, $db, $port, $socket);
-
- include ("connect.inc");
- $MySQL_Ext = new MySQL_Ext($host, $user, $passwd, $db);
-
- $isEmpty = $MySQL_Ext->isEmpty();
- var_dump($isEmpty);
+$isEmpty = $MySQL_Ext->isEmpty();
+var_dump($isEmpty);
?>
--EXPECT--
bool(false)
<?php
include ("connect.inc");
- $link1 = mysqli_connect($host, $user, $passwd, null, $port, $socket);
+ $link1 = my_mysqli_connect($host, $user, $passwd, null, $port, $socket);
mysqli_select_db($link1, $db);
$link1->query("SELECT 'test'", MYSQLI_ASYNC);
--- /dev/null
+--TEST--
+Bug #48909 (Segmentation fault in mysqli_stmt_execute)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+ include "connect.inc";
+
+ if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
+ if (!$link->query("DROP TABLE IF EXISTS test") ||
+ !$link->query(sprintf("CREATE TABLE test(id INT, label varchar(255)) ENGINE = %s", $engine)))
+ printf("[002] [%d] %s\n", $link->errno, $link->error);
+
+ if (!$stmt = $link->prepare("INSERT INTO test(id, label) VALUES (?, ?)"))
+ printf("[003] [%d] %s\n", $link->errno, $link->error);
+
+ if (!$stmt->bind_param("bb",$bvar, $bvar))
+ printf("[004] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ if (!$stmt->execute())
+ printf("[005] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $stmt->close();
+ $link->close();
+
+ echo "done";
+?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
+--EXPECTF--
+done
\ No newline at end of file
<?php
include ("connect.inc");
- $link=mysqli_init();
- if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "SELECT 1")){
- echo "Broken 2!\n";
- }
- if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "SELECT 13")){
- echo "Broken 2!\n";
+ $link = mysqli_init();
+ if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "SELECT 1")) {
+ printf("[001] Cannot set INIT_COMMAND\n");
}
- require('table_real_connect.inc');
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
var_dump($link->query("SELECT 42")->fetch_row());
+
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
+ !mysqli_query($link, sprintf("CREATE TABLE test(id INT) ENGINE=%s", $engine))) {
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+
+ mysqli_close($link);
+
+ $link = mysqli_init();
+ if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(id) VALUES(1)")) {
+ printf("[004] Cannot set INIT_COMMAND\n");
+ }
+
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[005] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+
+ if (!$res = mysqli_query($link, "SELECT id FROM test"))
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ var_dump(mysqli_fetch_assoc($res));
+
+ mysqli_free_result($res);
+ mysqli_close($link);
+
+ print "done!";
+?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
?>
--EXPECTF--
array(1) {
[0]=>
%unicode|string%(2) "42"
}
+array(1) {
+ [%u|b%"id"]=>
+ %unicode|string%(1) "1"
+}
+done!
--- /dev/null
+--TEST--
+Bug #49422 (mysqlnd: mysqli_real_connect() and LOAD DATA INFILE crash)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--INI--
+mysqli.allow_local_infile=1
+mysqli.allow_persistent=1
+mysqli.max_persistent=1
+--FILE--
+<?php
+ include ("connect.inc");
+
+ $link = mysqli_init();
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+
+ if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
+ printf("[002] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+
+ if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine)) {
+ printf("[003] Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+
+ include("local_infile_tools.inc");
+ $file = create_standard_csv(4);
+
+ if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s'
+ INTO TABLE test
+ FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\''
+ LINES TERMINATED BY '\n'",
+ mysqli_real_escape_string($link, $file)))) {
+ printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+
+ if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id"))
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $rows = array();
+ while ($row = mysqli_fetch_assoc($res)) {
+ var_dump($row);
+ $rows[] = $row;
+ }
+
+ mysqli_free_result($res);
+
+ mysqli_query($link, "DELETE FROM test");
+ mysqli_close($link);
+
+ if ($IS_MYSQLND) {
+ /*
+ mysqlnd makes a connection created through mysql_init()/mysqli_real_connect() always a 'persistent' one.
+ At this point 'persistent' is not to be confused with what a user calls a 'persistent' - in this case
+ 'persistent' means that mysqlnd uses malloc() instead of emalloc(). nothing else. ext/mysqli will
+ not consider it as a 'persistent' connection in a user sense, ext/mysqli will not appy max_persistent etc.
+ Its only about malloc() vs. emalloc().
+
+ However, the bug is about malloc() and efree(). You can make make mysqlnd use malloc() by either using
+ pconnect or mysql_init() - so we should test pconnect as well..
+ */
+ $host = 'p:' . $host;
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[007] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+
+ /* bug happened during query processing */
+ if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s'
+ INTO TABLE test
+ FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\''
+ LINES TERMINATED BY '\n'",
+ mysqli_real_escape_string($link, $file)))) {
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ }
+
+ /* we survived? that's good enough... */
+
+ if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id"))
+ printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $i = 0;
+ while ($row = mysqli_fetch_assoc($res)) {
+ if (($row['id'] != $rows[$i]['id']) || ($row['label'] != $rows[$i]['label'])) {
+ printf("[010] Wrong values, check manually!\n");
+ }
+ $i++;
+ }
+ mysqli_close($link);
+ }
+
+ print "done!";
+?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
+--EXPECTF--
+array(2) {
+ [%u|b%"id"]=>
+ %unicode|string%(2) "97"
+ [%u|b%"label"]=>
+ %unicode|string%(1) "x"
+}
+array(2) {
+ [%u|b%"id"]=>
+ %unicode|string%(2) "98"
+ [%u|b%"label"]=>
+ %unicode|string%(1) "y"
+}
+array(2) {
+ [%u|b%"id"]=>
+ %unicode|string%(2) "99"
+ [%u|b%"label"]=>
+ %unicode|string%(1) "z"
+}
+done!
\ No newline at end of file
<?PHP
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
$engine = getenv("MYSQL_TEST_ENGINE") ? getenv("MYSQL_TEST_ENGINE") : "MyISAM";
$socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null;
$skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true;
+ $connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0;
/* Development setting: test experimal features and/or feature requests that never worked before? */
$TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
/* unknown */
$MYSQLND_VERSION = -1;
}
+
}
if (!function_exists('sys_get_temp_dir')) {
return FALSE;
}
}
+
+ /**
+ * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
+ *
+ * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)?
+ */
+ function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+ global $connect_flags;
+
+ $flags = ($enable_env_flags) ? $connect_flags : false;
+
+ if ($flags !== false) {
+ $link = mysqli_init();
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags))
+ $link = false;
+ } else {
+ $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ }
+
+ return $link;
+ }
+
+ /**
+ * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
+ *
+ * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)
+ */
+ function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) {
+ global $connect_flags;
+
+ if ($enable_env_flags)
+ $flags & $connect_flags;
+
+ return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags);
+ }
+
+ class my_mysqli extends mysqli {
+ public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+ global $connect_flags;
+
+ $flags = ($enable_env_flags) ? $connect_flags : false;
+
+ if ($flags !== false) {
+ parent::init();
+ $this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags);
+ } else {
+ parent::__construct($host, $user, $passwd, $db, $port, $socket);
+ }
+ }
+ }
?>
\ No newline at end of file
if (!is_null($tmp = @mysqli_affected_rows($link, $link)))
printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
if (NULL !== ($tmp = @$mysqli->affected_rows))
printf("[000a] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
require_once('connect.inc');
require_once('skipifconnectfailure.inc');
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket));
}
if (!is_null($tmp = @mysqli_autocommit($link, $link, $link)))
printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
printf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
exit(1);
<?php
include "connect.inc";
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
mysqli_change_user()
--SKIPIF--
<?php
-require_once('skipif.inc');
+require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
if (!is_null($tmp = @mysqli_change_user($link, $link, $link, $link, $link)))
printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
/* Ok, let's try a NEW connection and a NEW lock! */
mysqli_close($link);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[010] Cannot open new connection, [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$IS_MYSQLND) {
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Can't test server version, might hit known bugs http://bugs.mysql.com/bug.php?id=30472, http://bugs.mysql.com/bug.php?id=45184");
if (mysqli_get_client_version($link) <= 50135)
/* TODO - check wich version got the patch */
<?php
require_once('connect.inc');
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, 'DROP TABLE IF EXISTS test'))
require_once('connect.inc');
require_once('table.inc');
- if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot create second connection handle, [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
$link = NULL;
$tmp = NULL;
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
<?php
require_once('connect.inc');
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!$stmt = mysqli_prepare($link, "SELECT 'prepared statements should be released'"))
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
-$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die(sprintf("skip [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!$res = mysqli_query($link, 'SELECT version() AS server_version'))
<?php
require_once('connect.inc');
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!$res = mysqli_query($link, "SHOW CHARACTER SET LIKE 'latin%'"))
$tmp = NULL;
$link = NULL;
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
--TEST--
mysqli_chararcter_set_name(), mysql_client_encoding() [alias]
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
if (!is_null($tmp = @mysqli_character_set_name($link, $link, $link)))
printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
--TEST--
mysqli_chararcter_set_name(), mysql_client_encoding() [alias]
--SKIPIF--
-<?php
+<?php
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
$tmp = NULL;
$link = NULL;
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
*/
if (!$IS_MYSQLND)
die("skip Test has been written for the latest version of mysqlnd only");
-if ($MYSQLND_VERSION < 50005)
- die("skip Test requires mysqlnd Revision 5.0.4 or newer");
?>
--FILE--
<?php
require('connect.inc');
$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
printf("Parent class:\n");
var_dump(get_parent_class($mysqli));
@$mysqli->unknown = $unknown;
printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown);
- $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n");
assert(mysqli_connect_error() === $mysqli->connect_error);
printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n",
require('connect.inc');
require('table.inc');
- $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysqli_result = $mysqli->query('SELECT * FROM test');
$row = $mysqli_result->fetch_row();
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$res = mysqli_query($link, 'SELECT * FROM test');
assert(mysqli_fetch_row($res) === $row);
require('connect.inc');
require('table.inc');
- $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$stmt = new mysqli_stmt($link);
printf("Parent class:\n");
$mysqli = new mysqli();
$warning = new mysqli_warning($mysqli);
- $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$stmt = new mysqli_stmt($mysqli);
$warning = new mysqli_warning($stmt);
$warning = new mysqli_warning($obj);
include("table.inc");
- $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$res = $mysqli->query('INSERT INTO test(id, label) VALUES (1, "zz")');
$warning = mysqli_get_warnings($mysqli);
--TEST--
mysqli_close()
--SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('skipifemb.inc');
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
if (!is_null($tmp = @mysqli_close($link, $link)))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
--TEST--
mysqli_close()
--SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('skipifemb.inc');
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
$tmp = NULL;
$link = NULL;
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket));
}
if (!is_null($tmp = @mysqli_commit($link, $link)))
printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
-if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) {
+if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket));
}
if (!is_null($tmp = @$mysqli->commit()))
printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
--TEST--
mysqli_connect_errno()
--SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('skipifemb.inc');
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
if (0 !== ($tmp = @mysqli_connect_errno($link)))
printf("[001] Expecting integer/0, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
mysqli_close($link);
- $link = @mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket);
+ $link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket);
if (false !== $link)
printf("[004] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s, expecting boolean/false, got %s/%s\n",
- $host, $user . 'unknown_really', $db, $port, $socket, gettype($link), $link);
+ $host, $user . 'unknown_really', $db, $port, $socket, gettype($link), var_export($link, true));
if (0 === ($tmp = mysqli_connect_errno()))
printf("[005] Expecting integer/any non-zero, got %s/%s\n", gettype($tmp), $tmp);
--TEST--
mysqli_connect_error()
--SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('skipifemb.inc');
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
if (!is_null($tmp = @mysqli_connect_error($link)))
printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
mysqli_close($link);
- if ($link = @mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+ if ($link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
printf("[003] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
$host, $user . 'unknown_really', $db, $port, $socket);
<?php
include "connect.inc";
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
if (!$thread_id = mysqli_thread_id($link))
printf("[002] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- if (true !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
+ if (true !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0))
mysqli_close($link);
- if (!$link = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
if (NULL !== ($tmp = @mysqli_disable_reads_from_master($link)))
printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
$ok = false;
try {
- if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+ if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
printf("[007] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
$host, $user . 'unknown_really', $db, $port, $socket);
mysqli_close($link);
$driver->report_mode = MYSQLI_REPORT_OFF;
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[016] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
mysqli_query($link, "NO_SQL");
mysqli_close($link);
$driver->report_mode = MYSQLI_REPORT_ERROR;
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
mysqli_query($link, "NO_SQL");
mysqli_close($link);
if (NULL !== ($tmp = @mysqli_dump_debug_info($link)))
printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
exit(1);
--TEST--
mysqli_enable_reads_from_master()
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (NULL !== ($tmp = @mysqli_enable_reads_from_master($link)))
printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
if (!is_null($tmp = @mysqli_errno($link)))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
--TEST--
mysqli_error()
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
if (!is_null($tmp = @mysqli_error($link)))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
$mysqli = new mysqli();
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
--- /dev/null
+--TEST--
+mysqli_fetch_array() - large packages (to test compression)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+ include "connect.inc";
+
+ function mysqli_fetch_array_large($offset, $link, $package_size) {
+
+ /* we are aiming for maximum compression to test MYSQLI_CLIENT_COMPRESS */
+ $random_char = str_repeat('a', 255);
+ $sql = "INSERT INTO test(label) VALUES ";
+
+ while (strlen($sql) < ($package_size - 259))
+ $sql .= sprintf("('%s'), ", $random_char);
+
+ $sql = substr($sql, 0, -2);
+ assert(strlen($sql) < $package_size);
+
+ if (!@mysqli_query($link, $sql)) {
+ if (1153 == mysqli_errno($link) || stristr(mysqli_error($link), 'max_allowed_packet'))
+ /* [1153] Got a packet bigger than 'max_allowed_packet' bytes */
+ return false;
+
+ printf("[%03d + 1] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ /* buffered result set - let's hope we do not run into PHP memory limit... */
+ if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
+ printf("[%03d + 2] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ while ($row = mysqli_fetch_assoc($res)) {
+ if ($row['label'] != $random_char) {
+ printf("[%03d + 3] Wrong results - expecting '%s' got '%s', [%d] %s\n",
+ $offset, $random_char, $row['label'], mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+ }
+ mysqli_free_result($res);
+
+ if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test")) {
+ printf("[%03d + 4] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ /* unbuffered result set */
+ if (!mysqli_stmt_execute($stmt)) {
+ printf("[%03d + 5] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ $id = $label = NULL;
+ if (!mysqli_stmt_bind_result($stmt, $id, $label)) {
+ printf("[%03d + 6] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ while (mysqli_stmt_fetch($stmt)) {
+ if ($label != $random_char) {
+ printf("[%03d + 7] Wrong results - expecting '%s' got '%s', [%d] %s\n",
+ $offset, $random_char, $label, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+ }
+
+ mysqli_stmt_free_result($stmt);
+ mysqli_stmt_close($stmt);
+
+ return true;
+ }
+
+ function parse_memory_limit($limit) {
+
+ $val = trim($limit);
+ $last = strtolower($val[strlen($val)-1]);
+
+ switch($last) {
+ // The 'G' modifier is available since PHP 5.1.0
+ case 'g':
+ $val *= 1024;
+ case 'm':
+ $val *= 1024;
+ case 'k':
+ $val *= 1024;
+ default:
+ break;
+ }
+ return $val;
+ }
+
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+ }
+
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
+ !mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255)) ENGINE = %s", $engine)))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $package_size = 524288;
+ $offset = 3;
+ $limit = (ini_get('memory_limit') > 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32);
+
+ /* try to respect php.ini but make run time a soft limit */
+ $max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30;
+ set_time_limit(0);
+
+ do {
+ if ($package_size > $limit) {
+ printf("stop: memory limit - %s vs. %s\n", $package_size, $limit);
+ break;
+ }
+
+ $start = microtime(true);
+ if (!mysqli_fetch_array_large($offset++, $link, $package_size)) {
+ printf("stop: packet size - %d\n", $package_size);
+ break;
+ }
+
+ $duration = microtime(true) - $start;
+ $max_runtime -= $duration;
+ if ($max_runtime < ($duration * 3)) {
+ /* likely the next iteration will not be within max_execution_time */
+ printf("stop: time limit - %2.2fs\n", $max_runtime);
+ break;
+ }
+
+ $package_size += $package_size;
+
+ } while (true);
+
+
+ mysqli_close($link);
+ print "done!";
+?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
+--EXPECTF--
+stop: %s
+done!
\ No newline at end of file
$link = NULL;
require('table.inc');
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
return $bin;
}
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
require('table.inc');
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
require('table.inc');
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die(printf("skip: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
if (mysqli_get_server_version($link) < 50041)
return array($expected_flags, $unexpected_flags, $found_flags);
}
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
foreach ($columns as $column_def => $expected_flags) {
<?php
include "connect.inc";
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect\n");
require('table.inc');
printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
require('table.inc');
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
die("skip POSIX functions not available");
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket));
}
gettype($errno), $errno, gettype($error), $error);
mysqli_close($link);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
case 0:
/* child */
- if (!($plink = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) || !mysqli_autocommit($plink, true))
+ if (!($plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) || !mysqli_autocommit($plink, true))
exit(mysqli_errno($plink));
$sql = sprintf("INSERT INTO messages(pid, sender, msg) VALUES (%d, 'child', '%%s')", posix_getpid());
default:
/* parent */
- if (!$plink = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[010] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
mysqli_free_result($res);
mysqli_close($link);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[018] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
;
$after = mysqli_get_cache_stats();
- if ($before !== $after) {
- printf("[004] Statistics have changed\n");
- var_dump($before);
- var_dump($after);
+ /* references has to be maintained - it is used for memory management */
+ $ignore = array('references' => true);
+ foreach ($before as $k => $v) {
+ if (isset($ignore[$k]))
+ continue;
+
+ if ($before[$k] != $after[$k])
+ printf("[004] Statistics have changed - %s: %s => %s\n", $
+ $k, $before[$k], $after[$k]);
}
$ignore = array("size" => true, "free_items" => true, "references" => true);
var_dump($info);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
exit(1);
mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, (string)($info['buffered_sets'] + 1), $test_counter, 'mysqli_use_result()');
$info = $new_info;
+ mysqli_close($link);
+
/*
no_index_used
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
mysqli_close($link);
?>
--EXPECTF--
-array(119) {
+array(121) {
[%u|b%"bytes_sent"]=>
%unicode|string%(1) "0"
[%u|b%"bytes_received"]=>
[%u|b%"mem_malloc_ammount"]=>
%unicode|string%(1) "0"
[%u|b%"mem_calloc_count"]=>
- %unicode|string%(1) "0"
+ %unicode|string%(%d) "%d"
[%u|b%"mem_calloc_ammount"]=>
- %unicode|string%(1) "0"
+ %unicode|string%(%d) "%d"
[%u|b%"mem_realloc_count"]=>
%unicode|string%(1) "0"
[%u|b%"mem_realloc_ammount"]=>
%unicode|string%(1) "0"
[%u|b%"proto_binary_fetched_other"]=>
%unicode|string%(1) "0"
+ [%u|b%"init_command_executed_count"]=>
+ %unicode|string%(1) "0"
+ [%u|b%"init_command_failed_count"]=>
+ %unicode|string%(1) "0"
}
Testing buffered normal...
Testing buffered normal... - SELECT id, label FROM test
var_dump($info2);
}
+ if (!is_array($info = $link->get_connection_stats()) || empty($info))
+ printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
+
+ foreach ($info as $k => &$v) {
+ if (strpos($k, "mem_") === 0) {
+ $v = 0;
+ }
+ }
+
+ if ($info !== $info2) {
+ printf("[007] The hashes should be identical except of the memory related fields\n");
+ var_dump($info);
+ var_dump($info2);
+ }
+
mysqli_close($link);
include "table.inc";
if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info))
- printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
+ printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2))
- printf("[007] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2);
+ printf("[009] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2);
// assuming the test is run in a plain-vanilla CLI environment
if ($info === $info2) {
- printf("[008] The hashes should not be identical\n");
+ printf("[010] The hashes should not be identical\n");
var_dump($info);
var_dump($info2);
}
// connect and table inc connect to mysql and create tables
require_once('connect.inc');
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
}
mysqli_close($link);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
if (!is_null($tmp = @mysqli_get_warnings('')))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
}
mysqli_close($link);
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[021] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!$mysqli->query("DROP TABLE IF EXISTS t1"))
printf("[026] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
/* Yes, I really want to check if the object property is empty */
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[027] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
$warning = new mysqli_warning($mysqli);
if ('' != ($tmp = $warning->message))
printf("[029] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp);
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[030] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!$mysqli->query("DROP TABLE IF EXISTS t1"))
?>
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
}
if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
- printf("[015] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
+ printf("[016] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
unlink($file);
} while (false);
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_insert_id_var"))
mysqli_close($link);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[009] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
mysqli_kill($link, -1);
mysqli_free_result($res);
mysqli_close($link);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[011] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1);
$links = array();
for ($i = 1; $i <= 5; $i++)
- if ($links[$i] = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if ($links[$i] = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[%03d] One link is already open, it should not be possible to open more, [%d] %s, [%d] %s\n",
$i, mysqli_connect_errno(), mysqli_connect_error(),
mysqli_errno($links[$i]), mysqli_error($links[$i]));
bool(true)
int(1)
-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d
--- /dev/null
+--TEST--
+mysqlnd.net_read_timeout limit check
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+require_once('connect.inc');
+if (!$IS_MYSQLND)
+ /* The libmysql read_timeout limit default is 365 * 24 * 3600 seconds. It cannot be altered through PHP API calls */
+ die("skip mysqlnd only test");
+?>
+--INI--
+default_socket_timeout=60
+max_execution_time=60
+mysqlnd.net_read_timeout=1
+--FILE--
+<?php
+ include ("connect.inc");
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+
+ if (!$res = mysqli_query($link, "SELECT SLEEP(5)"))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ mysqli_close($link);
+
+ print "done!";
+?>
+--EXPECTF--
+Warning: mysqli_query(): MySQL server has gone away in %s on line %d
+
+Warning: mysqli_query(): Error reading result set's header in %s on line %d
+[002] [%d] %s
+done!
\ No newline at end of file
--- /dev/null
+--TEST--
+mysqlnd.net_read_timeout > default_socket_timeout
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+require_once('connect.inc');
+?>
+--INI--
+default_socket_timeout=1
+mysqlnd.net_read_timeout=12
+max_execution_time=12
+--FILE--
+<?php
+ set_time_limit(12);
+ include ("connect.inc");
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+
+ if (!$res = mysqli_query($link, "SELECT SLEEP(6)"))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ var_dump($res->fetch_assoc());
+
+ mysqli_free_result($res);
+ mysqli_close($link);
+
+ print "done!";
+?>
+--EXPECTF--
+array(1) {
+ [%u|b%"SLEEP(6)"]=>
+ %unicode|string%(1) "0"
+}
+done!
\ No newline at end of file
--- /dev/null
+--TEST--
+mysqlnd.net_read_timeout = 0
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+require_once('connect.inc');
+?>
+--INI--
+default_socket_timeout=10
+max_execution_time=10
+mysqlnd.net_read_timeout=0
+--FILE--
+<?php
+ include ("connect.inc");
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ }
+
+ if (!$res = mysqli_query($link, "SELECT SLEEP(2)"))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ var_dump($res->fetch_assoc());
+
+ mysqli_free_result($res);
+ mysqli_close($link);
+
+ print "done!";
+?>
+--EXPECTF--
+array(1) {
+ [%u|b%"SLEEP(2)"]=>
+ %unicode|string%(1) "0"
+}
+done!
\ No newline at end of file
require_once("connect.inc");
require_once("table.inc");
- if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot create second database connection, [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
printf("[011] Executing a query should not be possible, connection should be closed, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
- if (!$link = @mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[012] Cannot create database connection, [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
$valid_options[] = constant('MYSQLI_OPT_INT_AND_FLOAT_NATIVE');
if (defined('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE'))
$valid_options[] = constant('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE');
-
+
$tmp = NULL;
$link = NULL;
!($tmp = mysqli_options($link, constant('MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE'), true)))
printf("[006] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
- for ($flag = -10000; $flag < 10000; $flag++) {
- if (in_array($flag, $valid_options))
- continue;
- if (FALSE !== ($tmp = mysqli_options($link, $flag, 'definetely not an mysqli_option'))) {
- var_dump("SOME_FLAG", $flag, $tmp);
+ if ($IS_MYSQLND) {
+ /* Don't do this with libmysql. You may hit options not exported to PHP and cause false positives */
+ for ($flag = -10000; $flag < 10000; $flag++) {
+ if (in_array($flag, $valid_options))
+ continue;
+ if (FALSE !== ($tmp = mysqli_options($link, $flag, 'definetely not an mysqli_option'))) {
+ var_dump(array("SOME_FLAG" => $flag, "ret" => $tmp));
+ }
}
}
echo "Link closed";
var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=1'));
- var_dump("SOME_RANDOM_FLAG", mysqli_options($link, $flag, 'definetly not an mysqli_option'));
print "done!";
?>
--EXPECTF--
Warning: mysqli_options(): Couldn't fetch mysqli in %s line %d
%s(19) "MYSQLI_INIT_COMMAND"
NULL
-
-Warning: mysqli_options(): Couldn't fetch mysqli in %s line %d
-%s(16) "SOME_RANDOM_FLAG"
-NULL
done!
--TEST--
mysqli_options()
--SKIPIF--
-<?php
+<?php
require_once('skipif.inc');
-require_once('skipifemb.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
-
-die("skip - STUB - TODO - this is a stub to remind me that we should also actually test the options");
?>
<?php require_once('skipifemb.inc'); ?>
--FILE--
<?php
/* see mysqli.c for details */
include "connect.inc";
+
+ if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
+ /* TODO: test more options */
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
+ !mysqli_query($link, sprintf("CREATE TABLE test(id INT) ENGINE = %s\n", $engine)) ||
+ !mysqli_query($link, "INSERT INTO test(id) VALUES (1)"))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!$res = mysqli_query($link, "SELECT COUNT(id) AS _num_rows FROM test"))
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+
+ if ($row['_num_rows'] != 1)
+ printf("[003] Expecting 1 got %s\n", $row['_num_rows']);
+
+ mysqli_close($link);
+
+ $link = mysqli_init();
+ if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(id) VALUES (2)"))
+ printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+ printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
+ if (!$res = mysqli_query($link, "SELECT COUNT(id) AS _num_rows FROM test"))
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+
+ if ($row['_num_rows'] != 2)
+ printf("[007] Expecting 1 got %s\n", $row['_num_rows']);
+
+ mysqli_close($link);
+
+ $link = mysqli_init();
+ if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(i_do_no_exist) VALUES (2)"))
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ mysqli_close($link);
+
+ $link = mysqli_init();
+ if (true !== mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(i_do_no_exist) VALUES (2)"))
+ printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+ printf("[010] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
print "done!";
?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
--EXPECTF--
-done!
+Warning: mysqli_real_connect(): (%s/%d): %s in %s on line %d
+[010] Cannot connect to the server using %s
+done!
\ No newline at end of file
--FILE--
<?php
require_once('connect.inc');
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (false !== mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1))
include "connect.inc";
$host = 'p:' . $host;
- if (!$link1 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
// automatic downgrade to normal connections has failed
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
$host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
mysqli_errno($link1), mysqli_error($link1));
- if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
// automatic downgrade to normal connections has failed
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
$host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
print "done!";
?>
--EXPECTF--
-Warning: mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
+Warning: my_mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
-Warning: mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
+Warning: my_mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d
Connecction 1 - SELECT @pcondisabled -> 'Connection 1'
Connecction 2 - SELECT @pcondisabled -> ''
done!
\ No newline at end of file
require_once("table.inc");
$host = 'p:' . $host;
- if (!$plink = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
// On PHP side this should do nothing. PHP should not try to close the connection or something.
@mysqli_close($plink);
- if (!$plink = @mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$plink = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[011] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
if (!$res3 = @mysqli_query($plink, 'SELECT id FROM test ORDER BY id LIMIT 1')) {
// remove the "p:<host>" from the host variable
$host = substr($host, 2);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[013] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
if (!$res4 = mysqli_query($link, 'SELECT id FROM test ORDER BY id LIMIT 1'))
mysqli_free_result($res);
printf("Regular connection 1 - '%s'\n", $row['_desc']);
- if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot open second regular connection, [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
printf("Regular connection 2 - '%s'\n", $row['_desc']);
$host = 'p:' . $host;
- if (!$plink = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[004] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
$host, $user, $db, $port, $socket,
mysqli_connect_errno(), mysqli_connect_error());
mysqli_free_result($res);
printf("Persistent connection 1 - '%s'\n", $row['_desc']);
- if (!$plink2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$plink2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[006] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
$host, $user, $db, $port, $socket,
mysqli_connect_errno(), mysqli_connect_error());
printf("Persistent connection 2 - '%s'\n", $row['_desc']);
$plink3 = mysqli_init();
- if (!mysqli_real_connect($plink3, $host, $user, $passwd, $db, $port, $socket))
+ if (!my_mysqli_real_connect($plink3, $host, $user, $passwd, $db, $port, $socket))
printf("[008] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
$host, $user, $db, $port, $socket,
mysqli_connect_errno(), mysqli_connect_error());
die("skip mysqlnd only test");
// we need a second DB user to test for a possible flaw in the ext/mysql[i] code
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die(sprintf("skip Cannot connect [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
mysqli_query($link, 'DROP USER pcontest');
die("skip GRANT failed");
}
- if (!($link_pcontest = @mysqli_connect($host, 'pcontest', 'pcontest', $db, $port, $socket))) {
+ if (!($link_pcontest = @my_mysqli_connect($host, 'pcontest', 'pcontest', $db, $port, $socket))) {
mysqli_query($link, 'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest');
mysqli_query($link, 'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest@localhost');
mysqli_query($link, 'DROP USER pcontest@localhost');
require_once("connect.inc");
require_once('table.inc');
- if (!$plink = mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
+ if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
printf("[001] Cannot connect using the second DB user created during SKIPIF, [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
printf("[009] Persistent connection has not been killed\n");
// this fails and we have 0 (<= $num_plinks) connections
- if ($plink = @mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
+ if ($plink = @my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
printf("[010] Can connect using the old password, [%d] %s\n",
mysqli_connect_errno($link), mysqli_connect_error($link));
if ($num_plinks_kill > $num_plinks)
printf("[011] Expecting Active Persistent Links < %d, got %d\n", $num_plinks, $num_plinks_kill);
- if (!$plink = mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket))
+ if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket))
printf("[012] Cannot connect using the new password, [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
mysqli_free_result($res);
var_dump($row);
- if ($plink2 = mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket))
+ if ($plink2 = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket))
printf("[015] Can open more persistent connections than allowed, [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
%unicode|string%(1) "a"
}
-Warning: mysqli_connect(): Too many open persistent links (%d) in %s on line %d
+Warning: my_mysqli_connect(): Too many open persistent links (%d) in %s on line %d
done!
\ No newline at end of file
include "connect.inc";
$host = 'p:' . $host;
- if (!$link1 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
$host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
}
printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n",
mysqli_errno($link1), mysqli_error($link1));
- if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
$host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
}
mysqli_close($link2);
/* reuse of existing persistent connection expected! */
- if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[008] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
$host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error());
}
include "connect.inc";
$host = 'p:' . $host;
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
$num = 20;
$connections = array();
for ($i = 0; $i < $num; $i++) {
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[003] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
$connections[] = $link;
}
$connections = array();
$num = 20;
for ($i = 0; $i < $num; $i++) {
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
$connections[] = $link;
}
unset($connections[$index]);
} else {
$left--;
- if (!$connections[$index] = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$connections[$index] = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
}
flush();
--TEST--
mysqli_ping()
--SKIPIF--
-<?php
+<?php
require_once('skipif.inc');
-require_once('skipifemb.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
function get_connection() {
global $host, $user, $passwd, $db, $port, $socket;
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
return $link;
}
printf("[009] Expecting int/0 got %s/%s\n", gettype($tmp), var_export($tmp, true));
- function poll_async($offset, $links, $errors, $reject, $exp_ready) {
+ function poll_async($offset, $link, $links, $errors, $reject, $exp_ready, $use_oo_syntax) {
- if ($exp_ready !== ($tmp = mysqli_poll($links, $errors, $reject, 0, 1000)))
- printf("[%03d + 1] There should be %d links ready to read from, %d ready\n",
- $exp_ready, $tmp);
+ if ($use_oo_syntax) {
+ if ($exp_ready !== ($tmp = $link->poll($links, $errors, $reject, 0, 1000)))
+ printf("[%03d + 1] There should be %d links ready to read from, %d ready\n",
+ $exp_ready, $tmp);
+ } else {
+ if ($exp_ready !== ($tmp = mysqli_poll($links, $errors, $reject, 0, 1000)))
+ printf("[%03d + 1] There should be %d links ready to read from, %d ready\n",
+ $exp_ready, $tmp);
+ }
foreach ($links as $mysqli) {
- if (is_object($res = mysqli_reap_async_query($mysqli))) {
+ if ($use_oo_syntax) {
+ $res = $mysqli->reap_async_query();
+ } else {
+ $res = mysqli_reap_async_query($mysqli);
+ }
+ if (is_object($res)) {
printf("[%03d + 2] Can fetch resultset although no query has been run!\n", $offset);
} else if (mysqli_errno($mysqli) > 0) {
printf("[%03d + 3] Error indicated through links array: %d/%s",
$links = array($link);
$errors = array($link);
$reject = array($link);
- poll_async(10, $links, $errors, $reject, 0);
+ poll_async(10, $link, $links, $errors, $reject, 0, false);
+ mysqli_close($link);
+
+ $link = get_connection();
+ $links = array($link);
+ $errors = array($link);
+ $reject = array($link);
+ poll_async(11, $link, $links, $errors, $reject, 0, true);
mysqli_close($link);
// Connections on which no query has been send - 2
$links = array($link, $link);
$errors = array($link, $link);
$reject = array();
- poll_async(11, $links, $errors, $reject, 0);
+ poll_async(12, $link, $links, $errors, $reject, 0, false);
// Connections on which no query has been send - 3
// Difference: pass two connections
$links = array($link, get_connection());
$errors = array($link, $link);
$reject = array();
- poll_async(12, $links, $errors, $reject, 0);
+ poll_async(13, $link, $links, $errors, $reject, 0, false);
// Reference mess...
$link = get_connection();
$errors = array($link);
$ref_errors =& $errors;
$reject = array();
- poll_async(13, $links, $ref_errors, $reject, 0);
+ poll_async(14, $link, $links, $ref_errors, $reject, 0, false);
print "done!";
?>
--EXPECTF--
[010 + 6] Rejecting thread %d: 0/
[011 + 6] Rejecting thread %d: 0/
-[011 + 6] Rejecting thread %d: 0/
[012 + 6] Rejecting thread %d: 0/
[012 + 6] Rejecting thread %d: 0/
[013 + 6] Rejecting thread %d: 0/
+[013 + 6] Rejecting thread %d: 0/
+[014 + 6] Rejecting thread %d: 0/
done!
function get_connection() {
global $host, $user, $passwd, $db, $port, $socket;
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
return $link;
}
function get_connection() {
global $host, $user, $passwd, $db, $port, $socket;
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
return $link;
}
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
if (!$IS_MYSQLND)
die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip cannot connect");
-if (mysqli_server_version($link) < 50012))
+if (mysqli_server_version($link) < 50012)
die("skip Test needs SQL function SLEEP() available as of MySQL 5.0.12");
-mysqli_close($link);
?>
--FILE--
<?php
function get_connection() {
global $host, $user, $passwd, $db, $port, $socket;
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
return $link;
}
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
mysqli_close($link);
- if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
+ if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
--- /dev/null
+--TEST--
+Prepared Statements and SELECT UNION
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+ require_once("connect.inc");
+ require_once("table.inc");
+
+ // Regular (non-prepared) queries
+ print "Using CAST('somestring' AS CHAR)...\n";
+ if (!($res = $link->query("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)")))
+ printf("[001] [%d] %s\n", $link->errno, $link->error);
+
+ $data = array();
+ while ($row = $res->fetch_assoc()) {
+ $data[] = $row['column1'];
+ var_dump($row['column1']);
+ }
+ $res->free();
+
+ // Prepared Statements
+ if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)")))
+ printf("[002] [%d] %s\n", $link->errno, $link->error);
+
+ $column1 = null;
+ if (!$stmt->execute() || !$stmt->bind_result($column1))
+ printf("[003] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $index = 0;
+ while ($stmt->fetch()) {
+ if ($data[$index] != $column1) {
+ printf("[004] Row %d, expecting %s/%s got %s/%s\n",
+ $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+ }
+ $index++;
+ }
+ $stmt->close();
+
+ if ($IS_MYSQLND) {
+ /*
+ Advantage mysqlnd -
+ The metadata mysqlnd has availabe after prepare is better than
+ the one made availabe by the MySQL Client Library (libmysql).
+ "libmysql" will give wrong results and that is OK -
+ http://bugs.mysql.com/bug.php?id=47483
+ */
+ if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)")))
+ printf("[005] [%d] %s\n", $link->errno, $link->error);
+
+ $column1 = null;
+ /* Note: bind_result before execute */
+ if (!$stmt->bind_result($column1) || !$stmt->execute())
+ printf("[006] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $index = 0;
+ while ($stmt->fetch()) {
+ if ($data[$index] != $column1) {
+ printf("[007] Row %d, expecting %s/%s got %s/%s\n",
+ $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+ }
+ $index++;
+ }
+ $stmt->close();
+ }
+
+ // Regular (non-prepared) queries
+ print "Mixing CAST('somestring'AS CHAR), integer and CAST(integer AS CHAR)...\n";
+ if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)")))
+ printf("[008] [%d] %s\n", $link->errno, $link->error);
+
+ $data = array();
+ while ($row = $res->fetch_assoc()) {
+ $data[] = $row['column1'];
+ }
+ $res->free();
+
+ // Prepared Statements
+ if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)")))
+ printf("[009] [%d] %s\n", $link->errno, $link->error);
+
+ $column1 = null;
+ if (!$stmt->execute() || !$stmt->bind_result($column1))
+ printf("[010] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $index = 0;
+ while ($stmt->fetch()) {
+ if ($data[$index] != $column1) {
+ printf("[011] Row %d, expecting %s/%s got %s/%s\n",
+ $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+ }
+ var_dump($column1);
+ $index++;
+ }
+ $stmt->close();
+
+ if ($IS_MYSQLND) {
+ /* Advantage mysqlnd - see above... */
+ if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)")))
+ printf("[012] [%d] %s\n", $link->errno, $link->error);
+
+ $column1 = null;
+ if (!$stmt->bind_result($column1) || !$stmt->execute())
+ printf("[013] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $index = 0;
+ while ($stmt->fetch()) {
+ if ($data[$index] != $column1) {
+ printf("[014] Row %d, expecting %s/%s got %s/%s\n",
+ $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+ }
+ $index++;
+ }
+ $stmt->close();
+ }
+
+ print "Using integer only...\n";
+ if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2")))
+ printf("[015] [%d] %s\n", $link->errno, $link->error);
+
+ $data = array();
+ while ($row = $res->fetch_assoc()) {
+ $data[] = $row['column1'];
+ }
+ $res->free();
+
+ // Prepared Statements
+ if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2")))
+ printf("[016] [%d] %s\n", $link->errno, $link->error);
+
+ $column1 = null;
+ if (!$stmt->execute() || !$stmt->bind_result($column1))
+ printf("[017] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $index = 0;
+ while ($stmt->fetch()) {
+ if ($data[$index] != $column1) {
+ printf("[018] Row %d, expecting %s/%s got %s/%s\n",
+ $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+ }
+ var_dump($column1);
+ $index++;
+ }
+ $stmt->close();
+
+ if ($IS_MYSQLND) {
+ /* Advantage mysqlnd - see above */
+ if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2")))
+ printf("[019] [%d] %s\n", $link->errno, $link->error);
+
+ $column1 = null;
+ if (!$stmt->bind_result($column1) || !$stmt->execute())
+ printf("[020] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $index = 0;
+ while ($stmt->fetch()) {
+ if ($data[$index] != $column1) {
+ printf("[021] Row %d, expecting %s/%s got %s/%s\n",
+ $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+ }
+ $index++;
+ }
+ $stmt->close();
+ }
+
+ print "Testing bind_param(), strings only...\n";
+ $two = 'two';
+ $three = 'three';
+ if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?")))
+ printf("[022] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $column1 = null;
+ if (!$stmt->bind_param('ss', $three, $two) || !$stmt->execute() || !$stmt->bind_result($column1))
+ printf("[023] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $index = 0;
+ $data = array();
+ while ($stmt->fetch()) {
+ $data[$index++] = $column1;
+ var_dump($column1);
+ }
+ $stmt->close();
+
+ if ($IS_MYSQLND) {
+ /* Advantage mysqlnd - see above */
+ $two = 'two';
+ $three = 'three';
+ if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?")))
+ printf("[024] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $column1 = null;
+ if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute())
+ printf("[025] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $index = 0;
+ while ($stmt->fetch()) {
+ if ($data[$index] != $column1) {
+ printf("[26] Row %d, expecting %s/%s, got %s/%s\n",
+ $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+ }
+ $index++;
+ }
+ $stmt->close();
+ }
+
+ print "Testing bind_param(), strings only, with CAST AS CHAR...\n";
+ $two = 'two';
+ $three = 'three beers are more than enough';
+ if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)")))
+ printf("[027] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $column1 = null;
+ if (!$stmt->bind_param('ss', $three, $two) || !$stmt->execute() || !$stmt->bind_result($column1))
+ printf("[028] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $index = 0;
+ $data = array();
+ while ($stmt->fetch()) {
+ $data[$index++] = $column1;
+ var_dump($column1);
+ }
+ $stmt->close();
+
+ if ($IS_MYSQLND) {
+ /* Advantage mysqlnd - see above */
+ $two = 'two';
+ $three = 'three beers are more than enough';
+ if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)")))
+ printf("[029] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $column1 = null;
+ if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute())
+ printf("[030] [%d] %s\n", $stmt->errno, $stmt->error);
+
+ $index = 0;
+ while ($stmt->fetch()) {
+ if ($data[$index] != $column1) {
+ printf("[31] Row %d, expecting %s/%s, got %s/%s\n",
+ $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
+ }
+ $index++;
+ }
+ $stmt->close();
+ }
+
+ $link->close();
+
+ print "done!";
+?>
+--EXPECTF--
+Using CAST('somestring' AS CHAR)...
+%unicode|string%(3) "one"
+%unicode|string%(5) "three"
+%unicode|string%(3) "two"
+Mixing CAST('somestring'AS CHAR), integer and CAST(integer AS CHAR)...
+%unicode|string%(1) "1"
+%unicode|string%(5) "three"
+%unicode|string%(1) "2"
+Using integer only...
+int(1)
+int(303)
+int(2)
+Testing bind_param(), strings only...
+%unicode|string%(3) "one"
+%unicode|string%(5) "three"
+%unicode|string%(3) "two"
+Testing bind_param(), strings only, with CAST AS CHAR...
+%unicode|string%(3) "one"
+%unicode|string%(32) "three beers are more than enough"
+%unicode|string%(3) "two"
+done!
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
+--INI--
+mysqli.allow_local_infile=1
--FILE--
<?php
// Create a large CVS file
printf("Filesize in bytes: %d\nRows: %d\n", $bytes, $rowno);
include "connect.inc";
- if (!($link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
+ if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
printf("[002] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
if (!mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';'", mysqli_real_escape_string($link, $file))))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ if ((!is_string(mysqli_info($link))) || ('' == mysqli_info($link))) {
+ printf("[005] [%d] %s, mysqli_info not set \n", mysqli_errno($link), mysqli_error($link));
+ }
+
if (!($res = mysqli_query($link, "SELECT COUNT(*) AS _num FROM test")))
- printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$row = mysqli_fetch_assoc($res);
if (($row["_num"] != $rowno))
- printf("[006] Expecting %d rows, found %d\n", $rowno, $row["_num"]);
+ printf("[007] Expecting %d rows, found %d\n", $rowno, $row["_num"]);
mysqli_free_result($res);
$random = mt_rand(1, $rowno);
if (!$res = mysqli_query($link, "SELECT id, col1, col2 FROM test WHERE id = " . $random))
- printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$row = mysqli_fetch_assoc($res);
var_dump($row);
unlink($file);
include "connect.inc";
-if (!($link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
+if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) <= 50000) {
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
printf("[025] Usage of mysqli.default_host=p: did not fail\n") ;
mysqli_close($link);
}
+ @mysqli_close($link);
}
@var_dump($link);
- if (NULL === ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
- printf("[026] Expecting not NULL, got %s/%s\n", gettype($tmp), $tmp);
+ if (NULL !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
+ printf("[026] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
print "done!";
?>
[%u|b%"affected_rows"]=>
NULL
[%u|b%"client_info"]=>
- %unicode|string%(%d) "%s"
+ %s
[%u|b%"client_version"]=>
int(%d)
[%u|b%"connect_errno"]=>
int(%d)
[%u|b%"connect_error"]=>
- %unicode|string%(%d) "%s"
+ %unicode|string%(%d) "%s
[%u|b%"errno"]=>
- int(%d)
+ %s
[%u|b%"error"]=>
- %unicode|string%(%d) "%s"
+ %s
[%u|b%"field_count"]=>
NULL
[%u|b%"host_info"]=>
[%u|b%"warning_count"]=>
NULL
}
-done!
+
+Warning: mysqli_real_connect(): Couldn't fetch mysqli in %s on line %d
+done!
\ No newline at end of file
require_once("connect.inc");
require_once("table.inc");
- if (!$link2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot create second database connection, [%d] %s\n",
mysqli_connect_errno(), mysqli_connect_error());
mysqli_close($link);
/* mysqli_stmt_execute() = mysql_stmt_execute cannot be tested from PHP */
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[008] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
$stmt = mysqli_stmt_init($link);
mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
// Check
mysqli_report(MYSQLI_REPORT_OFF);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[010] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
$stmt = mysqli_stmt_init($link);
mysqli_stmt_prepare($stmt, "FOO");
mysqli_stmt_close($stmt);
mysqli_close($link);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[011] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
$stmt = mysqli_stmt_init($link);
mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
already tested
php_mysqli_throw_sql_exception() ->
- mysqli_real_connect()
- mysqli_connect()
+ my_mysqli_real_connect()
+ my_mysqli_connect()
can't be tested: mysqli_query() via mysql_use_result()/mysql_store_result()
*/
try {
- if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+ if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
printf("[012] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
$host, $user . 'unknown_really', $db, $port, $socket);
mysqli_close($link);
if (!$link = mysqli_init())
printf("[014] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- if ($link = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+ if ($link = my_mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
printf("[015] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
$host, $user . 'unknown_really', $db, $port, $socket);
mysqli_close($link);
mysqli_report(MYSQLI_REPORT_OFF);
mysqli_report(MYSQLI_REPORT_INDEX);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
// this might cause a warning - no index used
// mysqli_use_result(), mysqli_thread_safe(), mysqli_thread_id()
mysqli_report(MYSQLI_REPORT_OFF);
mysqli_close($link);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[024] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!$stmt = mysqli_stmt_init($link))
try {
- if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+ if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
printf("[010] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
$host, $user . 'unknown_really', $db, $port, $socket);
mysqli_close($link);
if (!$link = mysqli_init())
printf("[012] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
- if ($link = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
+ if ($link = my_mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
printf("[013] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
$host, $user . 'unknown_really', $db, $port, $socket);
mysqli_close($link);
mysqli_free_result($res);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
require_once('connect.inc');
if (!$IS_MYSQLND)
die("skip Test for mysqlnd only");
+
+if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1))
+ die("skip (TODO) PHP 6.0 has a difference debug_zval_dump output format");
?>
<?php require_once('skipifemb.inc'); ?>
--FILE--
$references[$idx]['id_ref'] = &$row['id'];
$references[$idx++]['id_copy'] = $row['id'];
}
+
+ debug_zval_dump($references);
mysqli_free_result($res);
if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) ||
print "done!";
?>
--EXPECTF--
-array(2) refcount(2){
+array(1) refcount(2){
[0]=>
array(4) refcount(1){
[%u|b%"row_ref"]=>
[%u|b%"id_copy"]=>
%unicode|string%(1) "1" refcount(1)
}
+}
+array(2) refcount(2){
+ [0]=>
+ array(4) refcount(1){
+ [%u|b%"row_ref"]=>
+ &NULL refcount(2)
+ [%u|b%"row_copy"]=>
+ array(2) refcount(1){
+ [%u|b%"id"]=>
+ %unicode|string%(1) "1" refcount(1)
+ [%u|b%"label"]=>
+ %unicode|string%(1) "a" refcount(1)
+ }
+ [%u|b%"id_ref"]=>
+ %unicode|string%(1) "1" refcount(1)
+ [%u|b%"id_copy"]=>
+ %unicode|string%(1) "1" refcount(1)
+ }
[1]=>
array(5) refcount(1){
[%u|b%"row_ref"]=>
[%u|b%"id"]=>
&%unicode|string%(1) "2" refcount(2)
[%u|b%"label"]=>
- %unicode|string%(1) "b" refcount(3)
+ %unicode|string%(1) "b" refcount(2)
}
[%u|b%"row_copy"]=>
array(2) refcount(1){
[%u|b%"id"]=>
- %unicode|string%(1) "2" refcount(2)
+ %unicode|string%(1) "2" refcount(1)
[%u|b%"label"]=>
- %unicode|string%(1) "b" refcount(3)
+ %unicode|string%(1) "b" refcount(2)
}
[%u|b%"id_ref"]=>
&%unicode|string%(1) "2" refcount(2)
--TEST--
Trying to clone mysqli_result object
--SKIPIF--
-<?php
+<?php
require_once('skipif.inc');
-require_once('skipifemb.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
require_once('connect.inc');
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket));
}
if (!is_null($tmp = @mysqli_rollback($link)))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
--TEST--
mysqli_select_db()
--SKIPIF--
-<?php
+<?php
require_once('skipif.inc');
-require_once('skipifemb.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
if (!is_null($tmp = @mysqli_select_db($link)))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
if (NULL !== ($tmp = @mysqli_send_query($link)))
printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
die("skip Function not available");
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!($res = mysqli_query($link, 'SELECT version() AS server_version')) ||
printf("[011] Expecting boolean/false because of invalid character set, got %s/%s\n", gettype($ret), $ret);
mysqli_close($link);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[012] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
die("skip - function not available.");
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
die("skip - function not available.");
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
die("skip - function not available.");
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
if (!$TEST_EXPERIMENTAL)
die("skip - experimental (= unsupported) feature");
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
die("skip - function not available.");
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwb, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwb, $db, $port, $socket))
die("skip Cannot connect to MySQL");
if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
--TEST--
mysqli_set_opt()
--SKIPIF--
-<?php
+<?php
require_once('skipif.inc');
-require_once('skipifemb.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
var_dump(mysqli_set_opt($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10));
var_dump(mysqli_set_opt($link, MYSQLI_OPT_LOCAL_INFILE, 1));
var_dump(mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0'));
- var_dump(mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket));
+ var_dump(my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket));
var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf'));
var_dump(mysqli_set_opt($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf'));
var_dump(mysqli_set_opt($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10));
--TEST--
mysqli_ssl_set() - test is a stub!
--SKIPIF--
-<?php
+<?php
require_once('skipif.inc');
-require_once('skipifemb.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_ssl_set'))
die("skip function not available");
printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
- If SSL setup is incorrect mysqli_real_connect()
+ If SSL setup is incorrect my_mysqli_real_connect()
will return an error when you attempt to connect.
... and the above SSL setup should be always incorrect.
- if (false !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
+ if (false !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
*/
print "done!\n";
if (!is_null($tmp = @mysqli_stmt_affected_rows($link)))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
--TEST--
-mysqli_stmt_attr_set() - KNOWN ISSUE: mysqlnd does not check for invalid codes
+mysqli_stmt_attr_set() - mysqlnd does not check for invalid codes
--SKIPIF--
<?php
require_once('skipif.inc');
if (in_array($i, $valid_attr))
continue;
$invalid_attr = $i;
- if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0)))
+ if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) {
printf("[006a] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp);
+ }
}
for ($i = 0; $i < 10; $i++) {
do {
- $invalid_attr = mt_rand(-1 * PHP_INT_MAX + 1, PHP_INT_MAX);
+ $invalid_attr = mt_rand(-1 * (min(4294967296, PHP_INT_MAX) + 1), min(4294967296, PHP_INT_MAX));
} while (in_array($invalid_attr, $valid_attr));
- if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0)))
- printf("[006b] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp);
+ if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) {
+ /* Although it may be desired to get false neither the MySQL Client Library nor mysqlnd are supposed to detect invalid codes */
+ printf("[006b] Expecting boolean/true for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp);
+ }
}
$stmt->close();
require_once("clean_table.inc");
?>
--EXPECTF--
-done!
\ No newline at end of file
+done!
printf("[025] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
findRow(26, $link, $id_ref_ref, $label_ref_ref);
+ unset($id);
+ unset($label);
$id = 102;
$label = new stdClass();
$label->label = 'y';
$id_ref = &$GLOBALS['id'];
$label_ref = &$label->label;
-
if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref, $label_ref)))
printf("[027] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
if (true !== @mysqli_stmt_execute($stmt))
func_mysqli_stmt_bind_result($link, $engine, "b", "MEDIUMTEXT", "", 1640, $hint_str_or_unicode);
/* Is this one related? http://bugs.php.net/bug.php?id=35759 */
- func_mysqli_stmt_bind_result($link, $engine, "b", "LONGBLOB", "", 1660);
- func_mysqli_stmt_bind_result($link, $engine, "b", "LONGTEXT", "", 1680, $hint_str_or_unicode);
+ if (($IS_MYSQLND) || (!$IS_MYSQLND && (ini_get('memory_limit') > 4294967296))) {
+ /* NOTE: the MySQL Client Library - not mysqlnd - will allocate
+ a hugge max_length(type) = 4GB bind buffer */
+ func_mysqli_stmt_bind_result($link, $engine, "b", "LONGBLOB", "", 1660);
+ func_mysqli_stmt_bind_result($link, $engine, "b", "LONGTEXT", "", 1680, $hint_str_or_unicode);
+ }
func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", "a", 1700, $hint_str_or_unicode);
func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", NULL, 1720, $hint_str_or_unicode);
return $bin;
}
- if (!$link_ins = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link_ins = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
- if (!$link_sel = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link_sel = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
return true;
}
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect - [%d] %s\n",
mysqli_connect_errno(),
mysqli_connect_error());
--FILE--
<?php
include "connect.inc";
- if (!$c1 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$c1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
exit(1);
}
- if (!$c2 = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if (!$c2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
exit(1);
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS type_change"))
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
}
if (mysqli_get_server_version($link) <= 50000) {
--CLEAN--
<?php
include "connect.inc";
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
<?php
require('connect.inc');
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
- for ($bits = 1; $bits < 64; $bits++) {
+ /* NOTE: works only for up to 31 bits! This limitation should be documented. */
+ for ($bits = 1; $bits < 32; $bits++) {
$max_value = pow(2, $bits) - 1;
$tests = 0;
if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
--- /dev/null
+--TEST--
+mysqli_stmt_fetch - geometry / spatial types
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
+
+ if (!defined("MYSQLI_TYPE_GEOMETRY"))
+ die("skip MYSQLI_TYPE_GEOMETRY not defined");
+?>
+--FILE--
+<?php
+ require('connect.inc');
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+
+ function func_mysqli_stmt_fetch_geom($link, $engine, $sql_type, $bind_value, $offset) {
+
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+ printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
+ // don't bail - column type might not be supported by the server, ignore this
+ return false;
+ }
+
+ for ($id = 1; $id < 4; $id++) {
+ $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, %s)", $id, $bind_value);
+ if (!mysqli_query($link, $sql)) {
+ printf("[%04d] [%d] %s\n", $offset + 2 + $id, mysqli_errno($link), mysqli_error($link));
+ }
+ }
+
+ if (!$stmt = mysqli_stmt_init($link)) {
+ printf("[%04d] [%d] %s\n", $offset + 6, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) {
+ printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ mysqli_stmt_close($stmt);
+ return false;
+ }
+
+ if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_store_result($stmt)) {
+ printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ mysqli_stmt_close($stmt);
+ return false;
+ }
+
+ if (!mysqli_stmt_bind_result($stmt, $id, $bind_res)) {
+ printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ mysqli_stmt_close($stmt);
+ return false;
+ }
+
+ $result = mysqli_stmt_result_metadata($stmt);
+ $fields = mysqli_fetch_fields($result);
+ if ($fields[1]->type != MYSQLI_TYPE_GEOMETRY) {
+ printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type);
+ }
+
+ $num = 0;
+ $rows = array();
+ while (true === @mysqli_stmt_fetch($stmt)) {
+ $rows[] = array('id' => $id, 'label' => $bind_res);
+ $num++;
+ }
+
+ if ($num != 3) {
+ printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n",
+ $offset + 17, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num);
+ return false;
+ }
+ mysqli_stmt_close($stmt);
+
+ foreach ($rows as $row) {
+ if (!$stmt = mysqli_stmt_init($link)) {
+ printf("[%04d] [%d] %s\n", $offset + 10, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) {
+ printf("[%04d] [%d] %s\n", $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ $new_id = $row['id'] + 10;
+ if (!mysqli_stmt_bind_param($stmt, "is", $new_id, $row['label'])) {
+ printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+
+ if (!mysqli_stmt_execute($stmt)) {
+ printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ return false;
+ }
+ mysqli_stmt_close($stmt);
+
+ if (!$res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test WHERE id = %d",
+ $new_id))) {
+ printf("[%04d] [%d] %s\n", $offset + 14, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!$row_normal = mysqli_fetch_assoc($res_normal)) {
+ printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if ($row_normal['label'] != $row['label']) {
+ printf("[%04d] PS and non-PS return different data.\n", $offset + 16);
+ return false;
+ }
+ mysqli_free_result($res_normal);
+ }
+
+ return true;
+ }
+
+ func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRY", "GeomFromText('POINT(2 2)')", 20);
+ func_mysqli_stmt_fetch_geom($link, $engine, "POINT", "GeomFromText('POINT(1 1)')", 40);
+ func_mysqli_stmt_fetch_geom($link, $engine, "LINESTRING", "GeomFromText('LINESTRING(0 0,1 1,2 2)')", 60);
+ func_mysqli_stmt_fetch_geom($link, $engine, "POLYGON", "GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80);
+ func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOINT", "GeomFromText('MULTIPOINT(1 1, 2 2)')", 100);
+ func_mysqli_stmt_fetch_geom($link, $engine, "MULTILINESTRING", "GeomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120);
+ func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOLYGON", "GeomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140);
+ func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRYCOLLECTION", "GeomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160);
+
+ mysqli_close($link);
+ print "done!";
+?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
+--EXPECTF--
+done!
\ No newline at end of file
return $bin;
}
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
--- /dev/null
+--TEST--
+mysqli_stmt_get_result - geometry / spatial types
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
+
+ if (!function_exists('mysqli_stmt_get_result'))
+ die("skip mysqli_stmt_get_result() not available");
+
+ if (!defined("MYSQLI_TYPE_GEOMETRY"))
+ die("skip MYSQLI_TYPE_GEOMETRY not defined");
+?>
+--FILE--
+<?php
+ require('connect.inc');
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+
+ function func_mysqli_stmt_get_result_geom($link, $engine, $sql_type, $bind_value, $offset) {
+
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+ printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
+ // don't bail - column type might not be supported by the server, ignore this
+ return false;
+ }
+
+ for ($id = 1; $id < 4; $id++) {
+ $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, %s)", $id, $bind_value);
+ if (!mysqli_query($link, $sql)) {
+ printf("[%04d] [%d] %s\n", $offset + 2 + $id, mysqli_errno($link), mysqli_error($link));
+ }
+ }
+
+ if (!$stmt = mysqli_stmt_init($link)) {
+ printf("[%04d] [%d] %s\n", $offset + 6, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) {
+ printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ mysqli_stmt_close($stmt);
+ return false;
+ }
+
+ if (!mysqli_stmt_execute($stmt)) {
+ printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ mysqli_stmt_close($stmt);
+ return false;
+ }
+ if (!$res = mysqli_stmt_get_result($stmt)) {
+ printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+ mysqli_stmt_close($stmt);
+ return false;
+ }
+
+ $result = mysqli_stmt_result_metadata($stmt);
+ $fields = mysqli_fetch_fields($result);
+ if ($fields[1]->type != MYSQLI_TYPE_GEOMETRY) {
+ printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type);
+ }
+
+ $num = 0;
+ while ($row = mysqli_fetch_assoc($res)) {
+ $bind_res = &$row['label'];
+
+ if (!$stmt2 = mysqli_stmt_init($link)) {
+ printf("[%04d] [%d] %s\n", $offset + 11, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!mysqli_stmt_prepare($stmt2, "INSERT INTO test(id, label) VALUES (?, ?)")) {
+ printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
+ return false;
+ }
+
+ $id = $row['id'] + 10;
+ if (!mysqli_stmt_bind_param($stmt2, "is", $id, $bind_res)) {
+ printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
+ return false;
+ }
+
+ if (!mysqli_stmt_execute($stmt2)) {
+ printf("[%04d] [%d] %s\n", $offset + 14, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2));
+ return false;
+ }
+ mysqli_stmt_close($stmt2);
+
+ if (!$res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test WHERE id = %d",
+ $row['id'] + 10))) {
+ printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if (!$row_normal = mysqli_fetch_assoc($res_normal)) {
+ printf("[%04d] [%d] %s\n", $offset + 16, mysqli_errno($link), mysqli_error($link));
+ return false;
+ }
+
+ if ($row_normal['label'] != $bind_res) {
+ printf("[%04d] PS and non-PS return different data.\n", $offset + 17);
+ return false;
+ }
+ mysqli_free_result($res_normal);
+ $num++;
+ }
+
+ if ($num != 3) {
+ printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n",
+ $offset + 18, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num);
+ mysqli_free_result($res);
+ mysqli_stmt_close($stmt);
+ return false;
+ }
+ mysqli_free_result($res);
+ mysqli_stmt_close($stmt);
+
+ return true;
+ }
+
+ func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRY", "GeomFromText('POINT(2 2)')", 20);
+ func_mysqli_stmt_get_result_geom($link, $engine, "POINT", "GeomFromText('POINT(1 1)')", 40);
+ func_mysqli_stmt_get_result_geom($link, $engine, "LINESTRING", "GeomFromText('LINESTRING(0 0,1 1,2 2)')", 60);
+ func_mysqli_stmt_get_result_geom($link, $engine, "POLYGON", "GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80);
+ func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOINT", "GeomFromText('MULTIPOINT(1 1, 2 2)')", 100);
+ func_mysqli_stmt_get_result_geom($link, $engine, "MULTILINESTRING", "GeomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120);
+ func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOLYGON", "GeomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140);
+ func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRYCOLLECTION", "GeomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160);
+
+ mysqli_close($link);
+ print "done!";
+?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
+--EXPECTF--
+done!
\ No newline at end of file
--FILE--
<?php
require('connect.inc');
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
$hint_str_or_unicode = (version_compare(PHP_VERSION, '5.9.9', '>') == 1) ? 'unicode' : 'string';
!mysqli_stmt_execute($stmt))
printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
- if (!$link_buf = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link_buf = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!$stmt_buf = mysqli_stmt_init($link_buf))
<?php
include "connect.inc";
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
<?php
include "connect.inc";
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
<?php
include "connect.inc";
- if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
require_once('connect.inc');
if ($skip_on_connect_failure) {
include_once('connect.inc');
- $link = @mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+ $link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!is_object($link))
die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
mysqli_close($link);
<?PHP
require_once('connect.inc');
-if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
exit(1);
dnl $Id$
dnl config.m4 for mysqlnd driver
-
PHP_ARG_ENABLE(mysqlnd_threading, whether to enable threaded fetch in mysqlnd,
[ --enable-mysqlnd-threading
EXPERIMENTAL: Enable mysqlnd threaded fetch.
PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, no)
PHP_ADD_BUILD_DIR([ext/mysqlnd], 1)
- PHP_INSTALL_HEADERS([ext/mysqlnd])
- PHP_INSTALL_HEADERS([$ext_builddir/php_mysqlnd_config.h])
dnl Windows uses config.w32 thus this code is safe for now
if test "$PHP_MYSQLND_THREADING" = "yes"; then
PHP_BUILD_THREAD_SAFE
AC_DEFINE([MYSQLND_THREADED], 1, [Use mysqlnd internal threading])
fi
+fi
+
+if test "$PHP_MYSQLND_ENABLED" = "yes" || test "$PHP_MYSQLI" != "no"; then
+ PHP_ADD_BUILD_DIR([ext/mysqlnd], 1)
dnl This creates a file so it has to be after above macros
PHP_CHECK_TYPES([int8 uint8 int16 uint16 int32 uint32 uchar ulong int8_t uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_t], [
- $ext_builddir/php_mysqlnd_config.h
+ ext/mysqlnd/php_mysqlnd_config.h
],[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
unsigned int i;
for (i = 0; i < conn->options.num_commands; i++) {
/* allocated with pestrdup */
- pefree(conn->options.init_commands[i], pers);
+ mnd_pefree(conn->options.init_commands[i], pers);
}
mnd_pefree(conn->options.init_commands, pers);
conn->options.init_commands = NULL;
host?host:"", user?user:"", db?db:"", port, mysql_flags,
conn? conn->persistent:0, conn? CONN_GET_STATE(conn):-1);
- DBG_INF_FMT("state=%d", CONN_GET_STATE(conn));
if (conn && CONN_GET_STATE(conn) > CONN_ALLOCED && CONN_GET_STATE(conn) ) {
+ DBG_INF_FMT("state=%d", CONN_GET_STATE(conn));
DBG_INF("Connecting on a connected handle.");
if (CONN_GET_STATE(conn) < CONN_QUIT_SENT) {
mnd_efree(hashed_details);
}
+ if (!conn->options.timeout_read) {
+ /* should always happen because read_timeout cannot be set via API */
+ conn->options.timeout_read = (unsigned int) MYSQLND_G(net_read_timeout);
+ }
if (conn->options.timeout_read)
{
tv.tv_sec = conn->options.timeout_read;
conn->greet_charset = mysqlnd_find_charset_nr(greet_packet.charset_no);
/* we allow load data local infile by default */
- mysql_flags |= CLIENT_LOCAL_FILES;
+ mysql_flags |= CLIENT_LOCAL_FILES | CLIENT_PS_MULTI_RESULTS;
+#ifndef MYSQLND_COMPRESSION_ENABLED
+ if (mysql_flags & CLIENT_COMPRESS) {
+ mysql_flags &= ~CLIENT_COMPRESS;
+ }
+#endif
auth_packet->user = user;
auth_packet->password = passwd;
SET_EMPTY_ERROR(conn->error_info);
conn->zval_cache = mysqlnd_palloc_get_thd_cache_reference(zval_cache);
- conn->net.cmd_buffer.length = 128L*1024L;
- conn->net.cmd_buffer.buffer = mnd_pemalloc(conn->net.cmd_buffer.length, conn->persistent);
mysqlnd_local_infile_default(conn);
{
(char *)&buf_size TSRMLS_CC);
}
- MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_CONNECT_SUCCESS);
+ MYSQLND_INC_CONN_STATISTIC_W_VALUE2(&conn->stats, STAT_CONNECT_SUCCESS, 1, STAT_OPENED_CONNECTIONS, 1);
if (reconnect) {
MYSQLND_INC_GLOBAL_STATISTIC(STAT_RECONNECT);
}
- MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_OPENED_CONNECTIONS);
if (conn->persistent) {
- MYSQLND_INC_CONN_STATISTIC(&conn->stats, STAT_OPENED_PERSISTENT_CONNECTIONS);
+ MYSQLND_INC_CONN_STATISTIC_W_VALUE2(&conn->stats, STAT_PCONNECT_SUCCESS, 1, STAT_OPENED_PERSISTENT_CONNECTIONS, 1);
}
DBG_INF_FMT("connection_id=%llu", conn->thread_id);
break;
#endif
case MYSQLND_OPT_NET_CMD_BUFFER_SIZE:
+ if (*(unsigned int*) value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) {
+ DBG_RETURN(FAIL);
+ }
conn->net.cmd_buffer.length = *(unsigned int*) value;
if (!conn->net.cmd_buffer.buffer) {
conn->net.cmd_buffer.buffer = mnd_pemalloc(conn->net.cmd_buffer.length, conn->persistent);
#define MYSQLND_VERSION_ID 50005
/* This forces inlining of some accessor functions */
-#define MYSQLND_USE_OPTIMISATIONS 1
+#define MYSQLND_USE_OPTIMISATIONS 0
#define MYSQLND_STRING_TO_INT_CONVERSION
/*
/*****************************************************************************************************/
-PHPAPI void mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind);
-PHPAPI void mysqlnd_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind);
+PHPAPI void mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind TSRMLS_DC);
+PHPAPI void mysqlnd_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind TSRMLS_DC);
PHPAPI const char * mysqlnd_field_type_name(enum mysqlnd_field_types field_type);
#define mysqlnd_select_db(conn, db, db_len) (conn)->m->select_db((conn), (db), (db_len) TSRMLS_CC)
#define mysqlnd_ping(conn) (conn)->m->ping((conn) TSRMLS_CC)
#define mysqlnd_kill(conn, pid) (conn)->m->kill_connection((conn), (pid) TSRMLS_CC)
-#define mysqlnd_refresh(conn, options) (conn)->m->refresh_server((conn), (options) TSRMLS_CC)
+#define mysqlnd_refresh(conn, options) (conn)->m->refresh_server((conn), (options) TSRMLS_CC)
#define mysqlnd_shutdown(conn, level) (conn)->m->shutdown_server((conn), (level) TSRMLS_CC)
#define mysqlnd_get_server_version(conn) (conn)->m->get_server_version((conn))
#define mysqlnd_set_character_set(conn, cs) (conn)->m->set_charset((conn), (cs) TSRMLS_CC)
#ifdef MYSQLND_THREADED
THREAD_T thread_id;
#endif
+ long net_read_timeout;
ZEND_END_MODULE_GLOBALS(mysqlnd)
ZEND_EXTERN_MODULE_GLOBALS(mysqlnd);
#define MYSQLND_SQLSTATE_LENGTH 5
#define MYSQLND_SQLSTATE_NULL "00000"
+
+#define MYSQLND_NET_CMD_BUFFER_MIN_SIZE 4096
+#define MYSQLND_NET_CMD_BUFFER_MIN_SIZE_STR "4096"
+
#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
#define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */
#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
#define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */
+#define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */
typedef enum mysqlnd_extension
{
/* {{{ _mysqlnd_palloc_init_cache */
PHPAPI MYSQLND_ZVAL_PCACHE* _mysqlnd_palloc_init_cache(unsigned int cache_size TSRMLS_DC)
{
- MYSQLND_ZVAL_PCACHE *ret = calloc(1, sizeof(MYSQLND_ZVAL_PCACHE));
+ MYSQLND_ZVAL_PCACHE *ret = mnd_calloc(1, sizeof(MYSQLND_ZVAL_PCACHE));
unsigned int i;
DBG_ENTER("_mysqlnd_palloc_init_cache");
/* 1. First initialize the free list part of the structure */
/* One more for empty position of last_added - always 0x0, bounds checking */
- ret->free_list.ptr_line = calloc(ret->max_items + 1, sizeof(mysqlnd_zval *));
+ ret->free_list.ptr_line = mnd_calloc(ret->max_items + 1, sizeof(mysqlnd_zval *));
ret->free_list.last_added = ret->free_list.ptr_line + ret->max_items;
ret->free_list.canary1 = (void*)0xBEEF;
ret->free_list.canary2 = (void*)0xAFFE;
/* 3. Allocate and initialize our zvals and initialize the free list */
- ret->block = calloc(ret->max_items, sizeof(mysqlnd_zval));
+ ret->block = mnd_calloc(ret->max_items, sizeof(mysqlnd_zval));
ret->last_in_block = &(ret->block[ret->max_items]);
for (i = 0; i < ret->max_items; i++) {
/* 1. Initialize */
/* {{{ _mysqlnd_palloc_init_thd_cache */
PHPAPI MYSQLND_THD_ZVAL_PCACHE* _mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * const cache TSRMLS_DC)
{
- MYSQLND_THD_ZVAL_PCACHE *ret = calloc(1, sizeof(MYSQLND_THD_ZVAL_PCACHE));
+ MYSQLND_THD_ZVAL_PCACHE *ret = mnd_calloc(1, sizeof(MYSQLND_THD_ZVAL_PCACHE));
DBG_ENTER("_mysqlnd_palloc_init_thd_cache");
DBG_INF_FMT("ret = %p", ret);
ret->references = 1;
/* 1. Initialize the GC list */
- ret->gc_list.ptr_line = calloc(cache->max_items, sizeof(mysqlnd_zval *));
+ ret->gc_list.ptr_line = mnd_calloc(cache->max_items, sizeof(mysqlnd_zval *));
/* Backward and forward looping is possible */
ret->gc_list.last_added = ret->gc_list.ptr_line;
ret->gc_list.canary1 = (void*)0xCAFE;
were added to improve the header file, to get it more consistent.
*/
+#ifndef MYSQLND_PORTABILITY_H
+#define MYSQLND_PORTABILITY_H
+
/* Comes from global.h as OFFSET, renamed to STRUCT_OFFSET */
#define STRUCT_OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
#endif /* __CYGWIN__ */
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
-# include <ext/mysqlnd/config-win.h>
+# include "ext/mysqlnd/config-win.h"
#else
-# include "ext/mysqlnd/php_mysqlnd_config.h"
+# include <ext/mysqlnd/php_mysqlnd_config.h>
#endif /* _WIN32... */
#ifdef HAVE_SYS_TYPES_H
#endif /* WORDS_BIGENDIAN */
+#endif /* MYSQLND_PORTABILITY_H */
/*
if ((buf)) { \
pefree((buf), (persistent)); \
} \
- (buf) = (message); \
+ if ((message)) { \
+ (buf) = pestrndup((message), (len), (persistent)); \
+ } else { \
+ buf = NULL; \
+ } \
(buf_len) = (len); \
- /* Transfer ownership*/ \
- (message) = NULL; \
}
#define SET_EMPTY_MESSAGE(buf, buf_len, persistent) \
SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
DBG_ERR("not prepared");
if (param_bind && stmt->param_bind_dtor) {
- stmt->param_bind_dtor(param_bind);
+ stmt->param_bind_dtor(param_bind TSRMLS_CC);
}
DBG_RETURN(FAIL);
}
}
}
if (stmt->param_bind != param_bind && stmt->param_bind_dtor) {
- stmt->param_bind_dtor(stmt->param_bind);
+ stmt->param_bind_dtor(stmt->param_bind TSRMLS_CC);
}
}
if (stmt->param_count) {
if (!stmt->param_bind) {
- stmt->param_bind = ecalloc(stmt->param_count, sizeof(MYSQLND_PARAM_BIND));
+ stmt->param_bind = mnd_ecalloc(stmt->param_count, sizeof(MYSQLND_PARAM_BIND));
}
/* Prevent from freeing */
/* {{{ mysqlnd_stmt::set_bind_param_dtor */
static void
MYSQLND_METHOD(mysqlnd_stmt, set_param_bind_dtor)(MYSQLND_STMT * const stmt,
- void (*param_bind_dtor)(MYSQLND_PARAM_BIND *dtor) TSRMLS_DC)
+ void (*param_bind_dtor)(MYSQLND_PARAM_BIND * dtor TSRMLS_DC) TSRMLS_DC)
{
DBG_ENTER("mysqlnd_stmt::set_bind_param_dtor");
DBG_INF_FMT("stmt=%p", param_bind_dtor);
if (stmt->state < MYSQLND_STMT_PREPARED) {
SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
if (result_bind && stmt->result_bind_dtor) {
- stmt->result_bind_dtor(result_bind);
+ stmt->result_bind_dtor(result_bind TSRMLS_CC);
}
DBG_ERR("not prepared");
DBG_RETURN(FAIL);
stmt->result_bind[i].bound = TRUE;
}
} else if (result_bind && stmt->result_bind_dtor) {
- stmt->result_bind_dtor(result_bind);
+ stmt->result_bind_dtor(result_bind TSRMLS_CC);
}
DBG_INF("PASS");
DBG_RETURN(PASS);
mysqlnd_stmt_separate_one_result_bind(stmt, param_no TSRMLS_CC);
/* Guaranteed is that stmt->result_bind is NULL */
if (!stmt->result_bind) {
- stmt->result_bind = ecalloc(stmt->field_count, sizeof(MYSQLND_RESULT_BIND));
+ stmt->result_bind = mnd_ecalloc(stmt->field_count, sizeof(MYSQLND_RESULT_BIND));
} else {
- stmt->result_bind = erealloc(stmt->result_bind, stmt->field_count * sizeof(MYSQLND_RESULT_BIND));
+ stmt->result_bind = mnd_erealloc(stmt->result_bind, stmt->field_count * sizeof(MYSQLND_RESULT_BIND));
}
ALLOC_INIT_ZVAL(stmt->result_bind[param_no].zv);
/*
/* {{{ mysqlnd_stmt::set_bind_result_dtor */
static void
MYSQLND_METHOD(mysqlnd_stmt, set_result_bind_dtor)(MYSQLND_STMT * const stmt,
- void (*result_bind_dtor)(MYSQLND_RESULT_BIND *dtor) TSRMLS_DC)
+ void (*result_bind_dtor)(MYSQLND_RESULT_BIND * dtor TSRMLS_DC) TSRMLS_DC)
{
DBG_ENTER("mysqlnd_stmt::set_bind_param_dtor");
DBG_INF_FMT("stmt=%p", result_bind_dtor);
}
}
if (stmt->result_bind_dtor) {
- stmt->result_bind_dtor(stmt->result_bind);
+ stmt->result_bind_dtor(stmt->result_bind TSRMLS_CC);
}
stmt->result_bind = NULL;
}
}
if (stmt->param_bind_dtor) {
- stmt->param_bind_dtor(stmt->param_bind);
+ stmt->param_bind_dtor(stmt->param_bind TSRMLS_CC);
}
stmt->param_bind = NULL;
}
/* {{{ mysqlnd_efree_param_bind_dtor */
PHPAPI void
-mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind)
+mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind TSRMLS_DC)
{
- efree(param_bind);
+ mnd_efree(param_bind);
}
/* }}} */
/* {{{ mysqlnd_efree_result_bind_dtor */
PHPAPI void
-mysqlnd_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind)
+mysqlnd_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind TSRMLS_DC)
{
- efree(result_bind);
+ mnd_efree(result_bind);
}
/* }}} */
/* {{{ mysqlnd_stmt_copy_it */
static void
-mysqlnd_stmt_copy_it(zval *** copies, zval *original, unsigned int param_count, unsigned int current)
+mysqlnd_stmt_copy_it(zval *** copies, zval *original, unsigned int param_count, unsigned int current TSRMLS_DC)
{
if (!*copies) {
- *copies = ecalloc(param_count, sizeof(zval *));
+ *copies = mnd_ecalloc(param_count, sizeof(zval *));
}
MAKE_STD_ZVAL((*copies)[current]);
*(*copies)[current] = *original;
for (j = i + 1; j < stmt->param_count; j++) {
if (stmt->param_bind[j].zv == the_var) {
/* Double binding of the same zval, make a copy */
- mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i);
+ mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC);
break;
}
}
data_size += 8;
if (Z_TYPE_P(the_var) != IS_DOUBLE) {
if (!copies || !copies[i]) {
- mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i);
+ mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC);
}
}
break;
#endif
if (Z_TYPE_P(the_var) != IS_LONG) {
if (!copies || !copies[i]) {
- mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i);
+ mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC);
}
}
break;
#endif
{
if (!copies || !copies[i]) {
- mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i);
+ mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC);
}
the_var = copies[i];
#if PHP_MAJOR_VERSION >= 6
zval_ptr_dtor(&copies[i]);
}
}
- efree(copies);
+ mnd_efree(copies);
}
}
/* }}} */
STAT_COPY_ON_WRITE_PERFORMED, 0);
/* Free last row's zvals */
- efree(unbuf->last_row_data);
+ mnd_efree(unbuf->last_row_data);
unbuf->last_row_data = NULL;
}
if (unbuf->last_row_buffer) {
}
DBG_INF("Freeing data & row_buffer");
if (set->data) {
- pefree(set->data, set->persistent);
+ mnd_pefree(set->data, set->persistent);
set->data = NULL;
}
if (set->row_buffers) {
- pefree(set->row_buffers, set->persistent);
+ mnd_pefree(set->row_buffers, set->persistent);
set->row_buffers = NULL;
}
set->data_cursor = NULL;
}
DBG_INF("Freeing set");
- pefree(set, set->persistent);
+ mnd_pefree(set, set->persistent);
DBG_INF_FMT("after: real_usage=%lu usage=%lu", zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC));
DBG_VOID_RETURN;
#if MYSQLND_DEBUG_MEMORY
DBG_INF("Freeing current_row & current_buffer");
#endif
- pefree(current_row, set->persistent);
+ mnd_pefree(current_row, set->persistent);
}
current_buffer->free_chunk(current_buffer, TRUE TSRMLS_CC);
}
DBG_INF("Freeing data & row_buffer");
- pefree(set->data, set->persistent);
- pefree(set->row_buffers, set->persistent);
+ mnd_pefree(set->data, set->persistent);
+ mnd_pefree(set->row_buffers, set->persistent);
set->data = NULL;
set->row_buffers = NULL;
set->data_cursor = NULL;
}
DBG_INF("Freeing set");
- pefree(set, set->persistent);
+ mnd_pefree(set, set->persistent);
DBG_INF_FMT("after: real_usage=%lu usage=%lu", zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC));
DBG_VOID_RETURN;
if (result->unbuf) {
mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
- efree(result->unbuf);
+ mnd_efree(result->unbuf);
result->unbuf = NULL;
} else if (result->stored_data) {
mysqlnd_free_buffered_data(result TSRMLS_CC);
#endif
if (result->lengths) {
- efree(result->lengths);
+ mnd_efree(result->lengths);
result->lengths = NULL;
}
result->conn = NULL;
}
- efree(result);
+ mnd_efree(result);
DBG_VOID_RETURN;
}
if (FAIL == (ret = result->m.read_result_metadata(result, conn TSRMLS_CC))) {
/* For PS, we leave them in Prepared state */
if (!stmt) {
- efree(conn->current_result);
+ mnd_efree(conn->current_result);
conn->current_result = NULL;
}
DBG_ERR("Error ocurred while reading metadata");
if (FAIL == (ret = PACKET_READ_ALLOCA(fields_eof, conn))) {
DBG_ERR("Error ocurred while reading the EOF packet");
result->m.free_result_contents(result TSRMLS_CC);
- efree(result);
+ mnd_efree(result);
if (!stmt) {
conn->current_result = NULL;
} else {
lengths[i] = len;
}
- /* Forbid ZE to free it, we will clean it */
- Z_ADDREF_P(data);
-
- if ((flags & MYSQLND_FETCH_BOTH) == MYSQLND_FETCH_BOTH) {
- Z_ADDREF_P(data);
- }
if (flags & MYSQLND_FETCH_NUM) {
+ Z_ADDREF_P(data);
zend_hash_next_index_insert(row_ht, &data, sizeof(zval *), NULL);
}
if (flags & MYSQLND_FETCH_ASSOC) {
the index is a numeric and convert it to it. This however means constant
hashing of the column name, which is not needed as it can be precomputed.
*/
+ Z_ADDREF_P(data);
if (zend_hash_key->is_numeric == FALSE) {
#if PHP_MAJOR_VERSION >= 6
zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE,
for (i = 0; i < result->field_count; i++, field++, zend_hash_key++) {
zval *data = current_row[i];
- /*
- Let us later know what to do with this zval. If ref_count > 1, we will just
- decrease it, otherwise free it. zval_ptr_dtor() make this very easy job.
- */
- Z_ADDREF_P(data);
-
- if ((flags & MYSQLND_FETCH_BOTH) == MYSQLND_FETCH_BOTH) {
- Z_ADDREF_P(data);
- }
if (flags & MYSQLND_FETCH_NUM) {
+ Z_ADDREF_P(data);
zend_hash_next_index_insert(Z_ARRVAL_P(row), &data, sizeof(zval *), NULL);
}
if (flags & MYSQLND_FETCH_ASSOC) {
the index is a numeric and convert it to it. This however means constant
hashing of the column name, which is not needed as it can be precomputed.
*/
+ Z_ADDREF_P(data);
if (zend_hash_key->is_numeric == FALSE) {
#if PHP_MAJOR_VERSION >= 6
zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE,
if (result->m.fetch_row) {
if (result->m.fetch_row == result->m.fetch_row_normal_buffered) {
- return mysqlnd_fetch_row_buffered_c(result TSRMLS_CC);
+ DBG_RETURN(mysqlnd_fetch_row_buffered_c(result TSRMLS_CC));
} else if (result->m.fetch_row == result->m.fetch_row_normal_unbuffered) {
- return mysqlnd_fetch_row_unbuffered_c(result TSRMLS_CC);
+ DBG_RETURN(mysqlnd_fetch_row_unbuffered_c(result TSRMLS_CC));
} else {
*((int*)NULL) = 1;
}
PACKET_FREE_ALLOCA(field_packet);
DBG_RETURN(FAIL);
}
+ if (field_packet.error_info.error_no) {
+ conn->error_info = field_packet.error_info;
+ /* Return back from CONN_QUERY_SENT */
+ PACKET_FREE_ALLOCA(field_packet);
+ DBG_RETURN(FAIL);
+ }
+
if (field_packet.stupid_list_fields_eof == TRUE) {
- meta->field_count = i + 1;
+ meta->field_count = i;
break;
}
enum_func_status (*bind_parameters)(MYSQLND_STMT * const stmt, MYSQLND_PARAM_BIND * const param_bind TSRMLS_DC);
enum_func_status (*bind_one_parameter)(MYSQLND_STMT * const stmt, unsigned int param_no, zval * const zv, zend_uchar type TSRMLS_DC);
enum_func_status (*refresh_bind_param)(MYSQLND_STMT * const stmt TSRMLS_DC);
- void (*set_param_bind_dtor)(MYSQLND_STMT * const stmt, void (*param_bind_dtor)(MYSQLND_PARAM_BIND *) TSRMLS_DC);
+ void (*set_param_bind_dtor)(MYSQLND_STMT * const stmt, void (*param_bind_dtor)(MYSQLND_PARAM_BIND * TSRMLS_DC) TSRMLS_DC);
enum_func_status (*bind_result)(MYSQLND_STMT * const stmt, MYSQLND_RESULT_BIND * const result_bind TSRMLS_DC);
enum_func_status (*bind_one_result)(MYSQLND_STMT * const stmt, unsigned int param_no TSRMLS_DC);
- void (*set_result_bind_dtor)(MYSQLND_STMT * const stmt, void (*result_bind_dtor)(MYSQLND_RESULT_BIND *) TSRMLS_DC);
+ void (*set_result_bind_dtor)(MYSQLND_STMT * const stmt, void (*result_bind_dtor)(MYSQLND_RESULT_BIND * TSRMLS_DC) TSRMLS_DC);
enum_func_status (*send_long_data)(MYSQLND_STMT * const stmt, unsigned int param_num,
const char * const data, unsigned long length TSRMLS_DC);
MYSQLND_RES * (*get_parameter_metadata)(MYSQLND_STMT * const stmt);
MYSQLND_CMD_BUFFER execute_cmd_buffer;
unsigned int execute_count;/* count how many times the stmt was executed */
- void (*param_bind_dtor)(MYSQLND_PARAM_BIND *);
- void (*result_bind_dtor)(MYSQLND_RESULT_BIND *);
+ void (*param_bind_dtor)(MYSQLND_PARAM_BIND * TSRMLS_DC);
+ void (*result_bind_dtor)(MYSQLND_RESULT_BIND * TSRMLS_DC);
struct st_mysqlnd_stmt_methods *m;
};
/* There is a message */
if (packet->header.size > p - buf && (i = php_mysqlnd_net_field_length(&p))) {
- packet->message = pestrndup((char *)p, MIN(i, sizeof(buf) - (p - buf)), conn->persistent);
+ packet->message = estrndup((char *)p, MIN(i, sizeof(buf) - (p - buf)));
packet->message_len = i;
} else {
packet->message = NULL;
Thus, the name is size - 1. And we add 1 for a trailing \0.
*/
len = packet->header.size - 1;
- packet->info_or_local_file = mnd_pemalloc(len + 1, conn->persistent);
+ packet->info_or_local_file = mnd_emalloc(len + 1);
memcpy(packet->info_or_local_file, p, len);
packet->info_or_local_file[len] = '\0';
packet->info_or_local_file_len = len;
p+=2;
/* Check for additional textual data */
if (packet->header.size > (p - buf) && (len = php_mysqlnd_net_field_length(&p))) {
- packet->info_or_local_file = mnd_pemalloc(len + 1, conn->persistent);
+ packet->info_or_local_file = mnd_emalloc(len + 1);
memcpy(packet->info_or_local_file, p, len);
packet->info_or_local_file[len] = '\0';
packet->info_or_local_file_len = len;
if (packet->skip_parsing) {
DBG_RETURN(PASS);
}
- if (*p == 0xFE && packet->header.size < 8) {
+ if (*p == 0xFF) {
+ /* Error */
+ p++;
+ php_mysqlnd_read_error_from_line(p, packet->header.size - 1,
+ packet->error_info.error, sizeof(packet->error_info.error),
+ &packet->error_info.error_no, packet->error_info.sqlstate
+ TSRMLS_CC);
+ DBG_ERR_FMT("Server error : (%d) %s", packet->error_info.error_no, packet->error_info.error);
+ DBG_RETURN(PASS);
+ } else if (*p == 0xFE && packet->header.size < 8) {
/* Premature EOF. That should be COM_FIELD_LIST */
DBG_INF("Premature EOF. That should be COM_FIELD_LIST");
packet->stupid_list_fields_eof = TRUE;
zend_uchar *null_ptr, bit;
zval **current_field, **end_field, **start_field;
zend_bool as_unicode = conn->options.numeric_and_datetime_as_unicode;
+#ifdef USE_ZVAL_CACHE
zend_bool allocated;
void *obj;
+#endif
DBG_ENTER("php_mysqlnd_rowp_read_binary_protocol");
PACKET_READ_HEADER_AND_BODY(packet, conn, buf, sizeof(buf), "statistics", PROT_STATS_PACKET);
- packet->message = mnd_pemalloc(packet->header.size + 1, conn->persistent);
+ packet->message = mnd_emalloc(packet->header.size + 1);
memcpy(packet->message, buf, packet->header.size);
packet->message[packet->header.size] = '\0';
packet->message_len = packet->header.size;
/* For table definitions, empty for result sets */
zend_bool skip_parsing;
zend_bool stupid_list_fields_eof;
+
+ mysqlnd_error_info error_info;
} php_mysql_packet_res_field;
#include "mysqlnd_debug.h"
#include "ext/standard/info.h"
-
/* {{{ mysqlnd_functions[]
*
* Every user visible function must have an entry in mysqlnd_functions[].
php_info_print_table_row(2, "Command buffer size", buf);
snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_buffer_size));
php_info_print_table_row(2, "Read buffer size", buf);
+ snprintf(buf, sizeof(buf), "%ld", MYSQLND_G(net_read_timeout));
+ php_info_print_table_row(2, "Read timeout", buf);
php_info_print_table_row(2, "Collecting statistics", MYSQLND_G(collect_statistics)? "Yes":"No");
php_info_print_table_row(2, "Collecting memory statistics", MYSQLND_G(collect_memory_statistics)? "Yes":"No");
php_info_print_table_end();
mysqlnd_globals->collect_memory_statistics = FALSE;
mysqlnd_globals->debug = NULL; /* The actual string */
mysqlnd_globals->dbg = NULL; /* The DBG object*/
- mysqlnd_globals->net_cmd_buffer_size = 2048;
+ mysqlnd_globals->net_cmd_buffer_size = MYSQLND_NET_CMD_BUFFER_MIN_SIZE;
mysqlnd_globals->net_read_buffer_size = 32768;
+ mysqlnd_globals->net_read_timeout = 31536000;
mysqlnd_globals->log_mask = 0;
}
/* }}} */
+static PHP_INI_MH(OnUpdateNetCmdBufferSize)
+{
+ long long_value = atol(new_value);
+ if (long_value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) {
+ return FAILURE;
+ }
+ MYSQLND_G(net_cmd_buffer_size) = long_value;
+
+ return SUCCESS;
+}
+
/* {{{ PHP_INI_BEGIN
*/
PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("mysqlnd.collect_statistics", "1", PHP_INI_ALL, OnUpdateBool, collect_statistics, zend_mysqlnd_globals, mysqlnd_globals)
STD_PHP_INI_BOOLEAN("mysqlnd.collect_memory_statistics", "0", PHP_INI_SYSTEM, OnUpdateBool, collect_memory_statistics, zend_mysqlnd_globals, mysqlnd_globals)
STD_PHP_INI_ENTRY("mysqlnd.debug", NULL, PHP_INI_SYSTEM, OnUpdateString, debug, zend_mysqlnd_globals, mysqlnd_globals)
- STD_PHP_INI_ENTRY("mysqlnd.net_cmd_buffer_size", "2048", PHP_INI_ALL, OnUpdateLong, net_cmd_buffer_size, zend_mysqlnd_globals, mysqlnd_globals)
+ STD_PHP_INI_ENTRY("mysqlnd.net_cmd_buffer_size", MYSQLND_NET_CMD_BUFFER_MIN_SIZE_STR, PHP_INI_ALL, OnUpdateNetCmdBufferSize, net_cmd_buffer_size, zend_mysqlnd_globals, mysqlnd_globals)
STD_PHP_INI_ENTRY("mysqlnd.net_read_buffer_size", "32768",PHP_INI_ALL, OnUpdateLong, net_read_buffer_size, zend_mysqlnd_globals, mysqlnd_globals)
+ STD_PHP_INI_ENTRY("mysqlnd.net_read_timeout", "31536000", PHP_INI_SYSTEM, OnUpdateLong, net_read_timeout, zend_mysqlnd_globals, mysqlnd_globals)
STD_PHP_INI_ENTRY("mysqlnd.log_mask", "0", PHP_INI_ALL, OnUpdateLong, log_mask, zend_mysqlnd_globals, mysqlnd_globals)
PHP_INI_END()
/* }}} */
if (driver_options) {
long connect_timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
long local_infile = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0 TSRMLS_CC);
+ char *init_cmd = NULL;
#ifndef PDO_USE_MYSQLND
- char *init_cmd = NULL, *default_file = NULL, *default_group = NULL;
+ char *default_file = NULL, *default_group = NULL;
long compress = 0;
#endif
H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);
mysql_options(H->server, MYSQL_OPT_RECONNECT, (const char*)&reconnect);
}
#endif
-#ifndef PDO_USE_MYSQLND
init_cmd = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_INIT_COMMAND, NULL TSRMLS_CC);
if (init_cmd) {
if (mysql_options(H->server, MYSQL_INIT_COMMAND, (const char *)init_cmd)) {
}
efree(init_cmd);
}
-
+#ifndef PDO_USE_MYSQLND
default_file = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_READ_DEFAULT_FILE, NULL TSRMLS_CC);
if (default_file) {
if (mysql_options(H->server, MYSQL_READ_DEFAULT_FILE, (const char *)default_file)) {
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY);
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE", (long)PDO_MYSQL_ATTR_LOCAL_INFILE);
+ REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND);
#ifndef PDO_USE_MYSQLND
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_MAX_BUFFER_SIZE", (long)PDO_MYSQL_ATTR_MAX_BUFFER_SIZE);
- REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND);
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_FILE", (long)PDO_MYSQL_ATTR_READ_DEFAULT_FILE);
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_GROUP", (long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP);
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_COMPRESS", (long)PDO_MYSQL_ATTR_COMPRESS);
enum {
PDO_MYSQL_ATTR_USE_BUFFERED_QUERY = PDO_ATTR_DRIVER_SPECIFIC,
PDO_MYSQL_ATTR_LOCAL_INFILE,
-#ifndef PDO_USE_MYSQLND
PDO_MYSQL_ATTR_INIT_COMMAND,
+#ifndef PDO_USE_MYSQLND
PDO_MYSQL_ATTR_READ_DEFAULT_FILE,
PDO_MYSQL_ATTR_READ_DEFAULT_GROUP,
PDO_MYSQL_ATTR_MAX_BUFFER_SIZE,
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
MySQLPDOTest::skip();
$db = MySQLPDOTest::factory();
-if (MySQLPDOTest::isPDOMySQLnd())
- die("skip PDO::MYSQL_ATTR_MAX_INIT_COMMAND not supported with mysqlnd");
?>
--INI--
error_reporting=E_ALL
var_dump($create);
$db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => $create));
- var_dump($db->errorInfo());
+ $info = $db->errorInfo();
+ var_dump($info[0]);
$db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table));
$stmt = $db->query(sprintf('SELECT id FROM %s', $table));
$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
print "done!\n";
-?>
--EXPECTF--
-string(58) "CREATE TABLE test_%s(id INT)"
-array(3) {
- [0]=>
- string(5) "00000"
- [1]=>
- NULL
- [2]=>
- NULL
-}
+%unicode|string%(58) "CREATE TABLE test_%s(id INT)"
+%unicode|string%(5) "00000"
array(1) {
[0]=>
array(1) {
- ["id"]=>
- string(1) "1"
+ [%u|b%"id"]=>
+ %unicode|string%(1) "1"
}
}
done!