Commiting changes into HEAD = synching with 5_3

This commit is contained in:
Ulf Wendel 2007-10-10 10:49:00 +00:00
parent 2df3cea685
commit 2dd1b35a85
12 changed files with 173 additions and 131 deletions

View File

@ -1,14 +1,14 @@
--TEST--
constructor test
--SKIPIF--
<?php
require_once('skipif.inc');
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
/* class 1 calls parent constructor */
class mysql1 extends mysqli {
function __construct() {
@ -19,7 +19,7 @@ require_once('skipifconnectfailure.inc');
/* class 2 has an own constructor */
class mysql2 extends mysqli {
function __construct() {
global $host, $user, $passwd, $db, $port, $socket;
$this->connect($host, $user, $passwd, $db, $port, $socket);
@ -28,24 +28,24 @@ require_once('skipifconnectfailure.inc');
/* class 3 has no constructor */
class mysql3 extends mysqli {
}
$foo[0] = new mysql1();
$foo[1] = new mysql2();
$foo[0] = new mysql1();
$foo[1] = new mysql2();
$foo[2] = new mysql3($host, $user, $passwd, $db, $port, $socket);
for ($i=0; $i < 3; $i++) {
if (($result = $foo[$i]->query("SELECT DATABASE()"))) {
$row = $result->fetch_row();
printf("%d: %s\n", $i, $row[0]);
if ($row[0] != $db)
printf("%d: %s\n", $i, $row[0]);
$result->close();
}
$foo[$i]->close();
}
print "done!";
?>
--EXPECTF--
0: test
1: test
2: test
done!

View File

@ -1,8 +1,8 @@
--TEST--
Bug #33263 (mysqli_real_connect in __construct)
Bug #33263 (mysqli_real_connect in __construct)
--SKIPIF--
<?php
require_once('skipif.inc');
<?php
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
@ -23,13 +23,16 @@ require_once('skipifconnectfailure.inc');
$stmt = $mysql->prepare("SELECT DATABASE()");
$stmt->execute();
$stmt->bind_result($db);
$stmt->bind_result($database);
$stmt->fetch();
$stmt->close();
var_dump($db);
if ($database != $db)
printf("[001] Expecting '%s' got %s/'%s'.\n",
gettype($database), $database);
$mysql->close();
print "done!";
?>
--EXPECTF--
%s(4) "test"
done!

View File

@ -1,7 +1,7 @@
--TEST--
mysqli->affected_rows
--SKIPIF--
<?php
<?php
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
@ -10,13 +10,17 @@ mysqli->affected_rows
<?php
include "connect.inc";
$mysqli = new mysqli();
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)) {
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 (0 !== ($tmp = $mysqli->affected_rows))
printf("[002] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
printf("[002] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
if (!$mysqli->query('DROP TABLE IF EXISTS test'))
printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error);

View File

@ -2,28 +2,26 @@
mysqli_autocommit()
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('connect.inc');
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!$link = mysqli_connect($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);
die(sprintf("skip Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket));
}
if (!$res = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) {
printf("skip Cannot fetch have_innodb variable\n");
exit(1);
if (!$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'")) {
die("skip Cannot check for required InnoDB suppot");
}
if (!$row = mysqli_fetch_row($result))
die("skip Cannot check for required InnoDB suppot");
$row = mysqli_fetch_row($res);
mysqli_free_result($res);
mysqli_free_result($result);
mysqli_close($link);
if ($row[1] == "DISABLED" || $row[1] == "NO") {
printf ("skip Innodb support is not installed or enabled.");
exit(1);
die(sprintf ("skip innodb support is not installed or enabled."));
}
?>
--FILE--

View File

@ -2,9 +2,10 @@
mysqli->autocommit()
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
require_once('connect.inc');
if (!$mysqli = new 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",

View File

@ -48,8 +48,6 @@ require_once('skipifconnectfailure.inc');
'rollback' => true,
'select_db' => true,
'set_charset' => true,
'set_local_infile_default' => true,
'set_local_infile_handler' => true,
'set_opt' => true,
'stat' => true,
'stmt_init' => true,
@ -93,6 +91,8 @@ require_once('skipifconnectfailure.inc');
if (function_exists('mysqli_ssl_set'))
$expected_methods['ssl_set'] = true;
$expected_methods['set_local_infile_default'] = true;
$expected_methods['set_local_infile_handler'] = true;
}
/* we should add ruled when to expect them */
@ -305,4 +305,4 @@ setting mysqli->unknown, mysqli_unknown = 'friday'
Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
mysqli->connect_error = ''/unicode (''/unicode)
mysqli->connect_errno = '0'/integer ('0'/integer)
done!
done!

View File

@ -551,38 +551,6 @@ Modifiers: 256
Number of Parameters: 0
Number of Required Parameters: 0
Inspecting method 'set_local_infile_default'
isFinal: no
isAbstract: no
isPublic: yes
isPrivate: no
isProtected: no
isStatic: no
isConstructor: no
isDestructor: no
isInternal: yes
isUserDefined: no
returnsReference: no
Modifiers: 256
Number of Parameters: 0
Number of Required Parameters: 0
Inspecting method 'set_local_infile_handler'
isFinal: no
isAbstract: no
isPublic: yes
isPrivate: no
isProtected: no
isStatic: no
isConstructor: no
isDestructor: no
isInternal: yes
isUserDefined: no
returnsReference: no
Modifiers: 256
Number of Parameters: 0
Number of Required Parameters: 0
Inspecting method 'set_opt'
isFinal: no
isAbstract: no
@ -678,4 +646,4 @@ returnsReference: no
Modifiers: 256
Number of Parameters: 0
Number of Required Parameters: 0
done!
done!

View File

@ -135,6 +135,12 @@ mysqli_connect()
mysqli_free_result($res);
mysqli_close($link);
}
ini_set('mysqli.default_host', 'p:');
if (is_object($link = @mysqli_connect())) {
printf("[024] Usage of mysqli.default_host=p: did not fail\n") ;
mysqli_close($link);
}
}
print "done!";

View File

@ -93,67 +93,67 @@ if (!function_exists('mysqli_fetch_all'))
function func_mysqli_fetch_all($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) {
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, "DROP TABLE IF EXISTS test")) {
printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
return false;
}
if (!mysqli_query($link, $sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
print $sql;
// don't bail, engine might not support the datatype
return false;
}
if (!mysqli_query($link, $sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
print $sql;
// don't bail, engine might not support the datatype
return false;
}
if (is_null($php_value) && !mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
return false;
}
if (is_null($php_value) && !mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
return false;
}
if (!is_null($php_value)) {
if (is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
return false;
} else if (!is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $sql_value))) {
printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
return false;
}
}
if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
printf("[%04d] [%d] %s\n", $offset + 2, mysqli_errno($link), mysqli_error($link));
return false;
}
if (!$tmp = mysqli_fetch_all($res, MYSQLI_BOTH)) {
printf("[%04d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link));
return false;
}
$row = $tmp[0];
$fields = mysqli_fetch_fields($res);
if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) {
if ($regexp_comparison && !$skip) {
if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) {
printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
gettype($php_value), $php_value, $regexp_comparison,
gettype($row[1]), $row[1],
gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
return false;
}
} else {
if (($row['label'] !== $php_value) || ($row[1] != $php_value)) {
printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
gettype($php_value), $php_value,
gettype($row[1]), $row[1],
gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
return false;
}
if (!is_null($php_value)) {
if (is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
return false;
} else if (!is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $sql_value))) {
printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
return false;
}
}
}
return true;
if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
printf("[%04d] [%d] %s\n", $offset + 2, mysqli_errno($link), mysqli_error($link));
return false;
}
if (!$tmp = mysqli_fetch_all($res, MYSQLI_BOTH)) {
printf("[%04d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link));
return false;
}
$row = $tmp[0];
$fields = mysqli_fetch_fields($res);
if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) {
if ($regexp_comparison) {
if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) {
printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
gettype($php_value), $php_value, $regexp_comparison,
gettype($row[1]), $row[1],
gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
return false;
}
} else {
if (($row['label'] !== $php_value) || ($row[1] != $php_value)) {
printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
gettype($php_value), $php_value,
gettype($row[1]), $row[1],
gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
return false;
}
}
}
return true;
}
function func_mysqli_fetch_array_make_string($len) {
@ -558,4 +558,4 @@ array(1) {
Warning: mysqli_fetch_all(): Mode can be only MYSQLI_FETCH_NUM, MYSQLI_FETCH_ASSOC or MYSQLI_FETCH_BOTH in %s on line %d
Warning: mysqli_fetch_array(): Couldn't fetch mysqli_result in %s on line %d
done!
done!

View File

@ -214,12 +214,12 @@ if (!function_exists('mysqli_fetch_all'))
func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400);
// don't care about date() strict TZ warnings...
$date = date('Y-m-d');
$date = @date('Y-m-d');
func_mysqli_fetch_all_oo($link, $engine, "DATE", $date, $date, 410);
func_mysqli_fetch_all_oo($link, $engine, "DATE NOT NULL", $date, $date, 420);
func_mysqli_fetch_all_oo($link, $engine, "DATE", NULL, NULL, 430);
$datetime = date('Y-m-d H:i:s');
$datetime = @date('Y-m-d H:i:s');
func_mysqli_fetch_all_oo($link, $engine, "DATETIME", $datetime, $datetime, 440);
func_mysqli_fetch_all_oo($link, $engine, "DATETIME NOT NULL", $datetime, $datetime, 450);
func_mysqli_fetch_all_oo($link, $engine, "DATETIME", NULL, NULL, 460);

View File

@ -34,7 +34,25 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
if (!$res = mysqli_query($link, "SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) {
if (!$res = mysqli_query($link, "SELECT
1 AS a,
2 AS a,
3 AS c,
4 AS C,
NULL AS d,
true AS e,
5 AS '-1',
6 AS '-10',
7 AS '-100',
8 AS '-1000',
9 AS '10000',
'a' AS '100000',
'b' AS '1000000',
'c' AS '9',
'd' AS '9',
'e' AS '01',
'f' AS '-02'
")) {
printf("[007] Cannot run query, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
print "[008]\n";
@ -60,7 +78,7 @@ array(2) {
[006]
NULL
[008]
array(5) {
array(15) {
["a"]=>
string(1) "2"
["c"]=>
@ -71,6 +89,26 @@ array(5) {
NULL
["e"]=>
string(1) "1"
[-1]=>
string(1) "5"
[-10]=>
string(1) "6"
[-100]=>
string(1) "7"
[-1000]=>
string(1) "8"
[10000]=>
string(1) "9"
[100000]=>
string(1) "a"
[1000000]=>
string(1) "b"
[9]=>
string(1) "d"
["01"]=>
string(1) "e"
["-02"]=>
string(1) "f"
}
Warning: mysqli_fetch_assoc(): Couldn't fetch mysqli_result in %s on line %d
@ -86,7 +124,7 @@ array(2) {
[006]
NULL
[008]
array(5) {
array(15) {
[u"a"]=>
unicode(1) "2"
[u"c"]=>
@ -97,6 +135,26 @@ array(5) {
NULL
[u"e"]=>
unicode(1) "1"
[-1]=>
unicode(1) "5"
[-10]=>
unicode(1) "6"
[-100]=>
unicode(1) "7"
[-1000]=>
unicode(1) "8"
[10000]=>
unicode(1) "9"
[100000]=>
unicode(1) "a"
[1000000]=>
unicode(1) "b"
[9]=>
unicode(1) "d"
[u"01"]=>
unicode(1) "e"
[u"-02"]=>
unicode(1) "f"
}
Warning: mysqli_fetch_assoc(): Couldn't fetch mysqli_result in %s on line %d

View File

@ -96,9 +96,12 @@ require_once('skipifconnectfailure.inc');
I'm using the procedural interface, this should not throw an exception.
Also, I did not ask to get exceptions using the mysqli_options()
*/
if ($TEST_EXPERIMENTAL)
try {
if (false !== ($obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', 'a')))
printf("[011] Should have failed\n");
} catch (Exception $e) {
printf("%s\n", $e->getMessage());
}
mysqli_free_result($res);
@ -145,5 +148,6 @@ NULL
Warning: mysqli_fetch_object(): Couldn't fetch mysqli_result in %s on line %d
NULL
Parameter ctor_params must be an array
Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d