PHP  
 PHP_5_6
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/mysqli/tests/mysqli_begin_transaction.phpt ('mysqli_begin_transaction()')

Script

1: <?php
2:     
require_once("connect.inc");
3:     
/* {{{ proto bool mysqli_begin_transaction(object link, [int flags [, string name]]) */
4:     
$tmp    NULL;
5:     
$link   NULL;
6:
7:     if (!
is_null($tmp = @mysqli_begin_transaction()))
8:         
printf("[001] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
9:
10:     if (!
is_null($tmp = @mysqli_begin_transaction($link)))
11:         
printf("[002] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
12:
13:     if (!
is_null($tmp = @mysqli_begin_transaction($link$link)))
14:         
printf("[003] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
15:
16:     if (!
$link my_mysqli_connect($host$user$passwd$db$port$socket))
17:         
printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
18:             
$host$user$db$port$socket);
19:
20:     if (!
is_null($tmp = @mysqli_begin_transaction($link$link)))
21:         
printf("[005] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
22:
23:     if (!
is_null($tmp = @mysqli_begin_transaction($link0$link)))
24:         
printf("[006] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
25:
26:     if (!
is_null($tmp = @mysqli_begin_transaction($link0"mytrx"$link)))
27:         
printf("[007] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
28:
29:     if (!
mysqli_query($link'DROP TABLE IF EXISTS test'))
30:         
printf("[008] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
31:
32:     if (!
mysqli_query($link'CREATE TABLE test(id INT) ENGINE = InnoDB'))
33:         
printf("[009] Cannot create test table, [%d] %s\n"mysqli_errno($link), mysqli_error($link));
34:
35:     if (
true !== ($tmp mysqli_autocommit($linktrue)))
36:         
printf("[010] Cannot turn on autocommit, expecting true, got %s/%s\n"gettype($tmp), $tmp);
37:
38:     
/* overrule autocommit */
39:     
if (true !== ($tmp mysqli_begin_transaction($link)))
40:         
printf("[011] Got %s - [%d] %s\n"var_dump($tmptrue), mysqli_errno($link), mysqli_error($link));
41:
42:     if (!
mysqli_query($link'INSERT INTO test(id) VALUES (1)'))
43:         
printf("[012] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
44:
45:     
$tmp mysqli_rollback($link);
46:     if (
$tmp !== true)
47:         
printf("[013] Expecting boolean/true, got %s/%s\n"gettype($tmp), $tmp);
48:
49:     
/* empty */
50:     
$res mysqli_query($link"SELECT * FROM test");
51:     
var_dump($res->fetch_assoc());
52:
53:     
/* valid flags */
54:     
$flags = array(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT);
55:
56:     if (
mysqli_get_server_version($link) >= 50605) {
57:         
$flags[] = MYSQLI_TRANS_START_READ_WRITE;
58:         
$flags[] = MYSQLI_TRANS_START_READ_ONLY;
59:     }
60:
61:     
/* just coverage */
62:     
foreach ($flags as $flag) {
63:         if (!
mysqli_begin_transaction($link$flagsprintf("flag %d"$flag))) {
64:             
printf("[014] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
65:         }
66:         if (!
mysqli_query($link'SELECT * FROM test') || !mysqli_rollback($link)) {
67:             
printf("[015] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
68:         }
69:     }
70:
71:     
/* does it really set a flag? */
72:     
if (mysqli_get_server_version($link) >= 50605) {
73:         if (!
mysqli_begin_transaction($linkMYSQLI_TRANS_START_READ_ONLYsprintf("flag %d"$flag))) {
74:             
printf("[016] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
75:         }
76:         if (
mysqli_query($link"INSERT INTO test(id) VALUES (2)")) {
77:             
printf("[017] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
78:         } else if (!
mysqli_commit($link)) {
79:             
printf("[018] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
80:         } else {
81:             
$res mysqli_query($link"SELECT id FROM test WHERE id = 2");
82:         }
83:     }
84:     
85:     if (!
mysqli_begin_transaction($link, -1)) {
86:             
printf("[019] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
87:     }
88:
89:     if (
mysqli_get_server_version($link) >= 50605) {
90:         
/* does it like stupid names? */
91:         
if (@!$link->begin_transaction(MYSQLI_TRANS_START_READ_WRITE"*/trick me?\n\0"))
92:                 
printf("[020] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
93:
94:         
/* does it like stupid names? */
95:         
if (@!$link->begin_transaction(MYSQLI_TRANS_START_READ_WRITE"az09"))
96:             
printf("[021] [%d] %s\n"mysqli_errno($link), mysqli_error($link));
97:     }
98:
99:     print 
"done!";
100:
?>
101:

Expected

NULL

Warning: mysqli_begin_transaction(): Invalid value for parameter flags (-1) in %s on line %d
[019] [%d]%A
done!

Output

Out of memory

Diff

001+ Out of memory
001- NULL
002- 
003- Warning: mysqli_begin_transaction(): Invalid value for parameter flags (-1) in %s on line %d
004- [019] [%d]%A
005- done!

 

Generated at Mon, 27 Nov 2017 05:04:32 +0000 (16 days ago)

Copyright © 2005-2017 The PHP Group
All rights reserved.