Skip to content

Commit 6865e45

Browse files
committed
Remove outdated error checking
Also reformat some querries and add comment for the SET sql_mode='' query
1 parent 310e2c9 commit 6865e45

23 files changed

+240
-216
lines changed

ext/mysqli/tests/bind_fetch/bigint_types.phpt

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,30 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1717

1818
$link = default_mysqli_connect();
1919

20-
if (!mysqli_query($link, "SET sql_mode=''"))
21-
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
20+
// To get consistent result without depending on the DB version/setup
21+
mysqli_query($link, "SET sql_mode=''");
2222

23-
$rc = mysqli_query($link,"CREATE TABLE test_bind_fetch_integers_big(c1 bigint default 5,
24-
c2 bigint,
25-
c3 bigint not NULL,
26-
c4 bigint unsigned,
27-
c5 bigint unsigned,
28-
c6 bigint unsigned,
29-
c7 bigint unsigned,
30-
c8 bigint unsigned) ENGINE=" . get_default_db_engine());
31-
if (!$rc)
32-
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
23+
mysqli_query(
24+
$link,
25+
"CREATE TABLE test_bind_fetch_integers_big(
26+
c1 bigint default 5,
27+
c2 bigint,
28+
c3 bigint not NULL,
29+
c4 bigint unsigned,
30+
c5 bigint unsigned,
31+
c6 bigint unsigned,
32+
c7 bigint unsigned,
33+
c8 bigint unsigned
34+
) ENGINE=" . get_default_db_engine()
35+
);
3336

34-
$rc = mysqli_query($link, "INSERT INTO test_bind_fetch_integers_big (c2,c3,c4,c5,c6,c7,c8) ".
35-
"VALUES (-23,4.0,33333333333333,0,-333333333333,99.9,1234)");
36-
if (!$rc)
37-
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
37+
mysqli_query($link, "INSERT INTO test_bind_fetch_integers_big (c2,c3,c4,c5,c6,c7,c8)
38+
VALUES (-23,4.0,33333333333333,0,-333333333333,99.9,1234)");
3839

3940
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_integers_big");
4041
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
4142
mysqli_stmt_execute($stmt);
42-
$rc = mysqli_stmt_fetch($stmt);
43+
mysqli_stmt_fetch($stmt);
4344

4445
if (mysqli_get_server_version($link) < 50000) {
4546
// 4.1 is faulty and will return big number for $c6

ext/mysqli/tests/bind_fetch/char_text_big_types.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1313

1414
$link = default_mysqli_connect();
1515

16-
if (!mysqli_query($link, "CREATE TABLE test_bind_fetch_char_long(c1 char(10), c2 text) ENGINE=" . get_default_db_engine()))
17-
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16+
mysqli_query($link, "CREATE TABLE test_bind_fetch_char_long(c1 char(10), c2 text) ENGINE=" . get_default_db_engine());
1817

1918
$a = str_repeat("A1", 32000);
2019

ext/mysqli/tests/bind_fetch/char_text_types.phpt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,19 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1313

1414
$link = default_mysqli_connect();
1515

16-
if (!mysqli_query($link,"CREATE TABLE test_bind_fetch_char(c1 char(10), c2 text) ENGINE=" . get_default_db_engine()))
17-
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16+
mysqli_query($link,"CREATE TABLE test_bind_fetch_char(c1 char(10), c2 text) ENGINE=" . get_default_db_engine());
1817

19-
if (!mysqli_query($link, "INSERT INTO test_bind_fetch_char VALUES ('1234567890', 'this is a test0')"))
20-
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
18+
/* Insert test data */
19+
mysqli_query(
20+
$link,
21+
"INSERT INTO test_bind_fetch_char VALUES
22+
('1234567890', 'this is a test0'),
23+
('1234567891', 'this is a test1'),
24+
('1234567892', 'this is a test2'),
25+
('1234567893', 'this is a test3')"
26+
);
2127

22-
if (!mysqli_query($link, "INSERT INTO test_bind_fetch_char VALUES ('1234567891', 'this is a test1')"))
23-
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
24-
25-
if (!mysqli_query($link, "INSERT INTO test_bind_fetch_char VALUES ('1234567892', 'this is a test2')"))
26-
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
27-
28-
if (!mysqli_query($link, "INSERT INTO test_bind_fetch_char VALUES ('1234567893', 'this is a test3')"))
29-
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
30-
31-
if (!$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_char ORDER BY c1"))
32-
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
28+
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_char ORDER BY c1");
3329

3430
$c1 = $c2 = NULL;
3531
mysqli_stmt_bind_result($stmt, $c1, $c2);

ext/mysqli/tests/bind_fetch/datetime_types.phpt

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1313

1414
$link = default_mysqli_connect();
1515

16+
// To get consistent result without depending on the DB version/setup
1617
mysqli_query($link, "SET sql_mode=''");
1718

1819
try {
19-
$rc = mysqli_query($link,
20+
mysqli_query(
21+
$link,
2022
"CREATE TABLE test_bind_result_datetime(
21-
c1 date,
22-
c2 time,
23-
c3 timestamp(14),
24-
c4 year,
25-
c5 datetime,
26-
c6 timestamp(4),
27-
c7 timestamp(6)) ENGINE=" . get_default_db_engine()
23+
c1 date,
24+
c2 time,
25+
c3 timestamp(14),
26+
c4 year,
27+
c5 datetime,
28+
c6 timestamp(4),
29+
c7 timestamp(6)
30+
) ENGINE=" . get_default_db_engine()
2831
);
2932
} catch (\mysqli_sql_exception) {
3033
/* 14 Too big precision for timestamp */
@@ -38,27 +41,27 @@ try {
3841
the display width is ignored.
3942
[...]
4043
*/
41-
$rc = mysqli_query($link,
44+
mysqli_query(
45+
$link,
4246
"CREATE TABLE test_bind_result_datetime(
43-
c1 date,
44-
c2 time,
45-
c3 timestamp,
46-
c4 year,
47-
c5 datetime,
48-
c6 timestamp(4),
49-
c7 timestamp(6)) ENGINE=" . get_default_db_engine()
47+
c1 date,
48+
c2 time,
49+
c3 timestamp,
50+
c4 year,
51+
c5 datetime,
52+
c6 timestamp(4),
53+
c7 timestamp(6)
54+
) ENGINE=" . get_default_db_engine()
5055
);
5156
}
5257

53-
$rc = mysqli_query($link, "INSERT INTO test_bind_result_datetime VALUES(
58+
mysqli_query($link, "INSERT INTO test_bind_result_datetime VALUES(
5459
'2002-01-02',
5560
'12:49:00',
5661
'2002-01-02 17:46:59',
5762
2010,
5863
'2010-07-10',
5964
'2020','1999-12-29')");
60-
if (!$rc)
61-
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
6265

6366
$stmt = mysqli_prepare($link, "SELECT c1, c2, c3, c4, c5, c6, c7 FROM test_bind_result_datetime");
6467
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);

ext/mysqli/tests/bind_fetch/float_types.phpt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,25 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1515

1616
$link = default_mysqli_connect();
1717

18-
if (!mysqli_query($link, "SET sql_mode=''"))
19-
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
18+
// To get consistent result without depending on the DB version/setup
19+
mysqli_query($link, "SET sql_mode=''");
2020

21-
$rc = mysqli_query($link, "CREATE TABLE test_bind_fetch_float(c1 float(3),
22-
c2 float,
23-
c3 float unsigned,
24-
c4 float,
25-
c5 float,
26-
c6 float,
27-
c7 float(10) unsigned) ENGINE=" . get_default_db_engine());
28-
if (!$rc)
29-
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
21+
mysqli_query(
22+
$link,
23+
"CREATE TABLE test_bind_fetch_float(
24+
c1 float(3),
25+
c2 float,
26+
c3 float unsigned,
27+
c4 float,
28+
c5 float,
29+
c6 float,
30+
c7 float(10) unsigned
31+
) ENGINE=" . get_default_db_engine()
32+
);
3033

3134

32-
mysqli_query($link, "INSERT INTO test_bind_fetch_float (c1,c2,c3,c4,c5,c6,c7) VALUES (3.1415926535,-0.000001, -5, 999999999999,
33-
sin(0.6), 1.00000000000001, 888888888888888)");
35+
mysqli_query($link, "INSERT INTO test_bind_fetch_float (c1,c2,c3,c4,c5,c6,c7)
36+
VALUES (3.1415926535,-0.000001, -5, 999999999999, sin(0.6), 1.00000000000001, 888888888888888)");
3437

3538
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_float");
3639
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);

ext/mysqli/tests/bind_fetch/identical_fetch_row.phpt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,24 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1313

1414
$link = default_mysqli_connect();
1515

16-
$rc = mysqli_query($link, "CREATE TABLE test_bind_fetch_and_row_fetch(c1 tinyint, c2 smallint,
17-
c3 int, c4 bigint,
18-
c5 decimal(4,2), c6 double,
19-
c7 varbinary(10),
20-
c8 varchar(10)) ENGINE=" . get_default_db_engine());
21-
if (!$rc)
22-
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
23-
24-
if (!mysqli_query($link, "INSERT INTO test_bind_fetch_and_row_fetch VALUES(120,2999,3999,54,
25-
2.6,58.89,
26-
'206','6.7')"))
27-
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16+
mysqli_query(
17+
$link,
18+
"CREATE TABLE test_bind_fetch_and_row_fetch(
19+
c1 tinyint, c2 smallint,
20+
c3 int, c4 bigint,
21+
c5 decimal(4,2), c6 double,
22+
c7 varbinary(10),
23+
c8 varchar(10)
24+
) ENGINE=" . get_default_db_engine()
25+
);
26+
27+
mysqli_query($link, "INSERT INTO test_bind_fetch_and_row_fetch
28+
VALUES(120,2999,3999,54, 2.6,58.89, '206','6.7')");
2829

2930
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_and_row_fetch");
3031

3132
$c = array(0,0,0,0,0,0,0,0);
32-
$b_res= mysqli_stmt_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
33+
mysqli_stmt_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
3334
mysqli_stmt_execute($stmt);
3435
mysqli_stmt_fetch($stmt);
3536
mysqli_stmt_close($stmt);

ext/mysqli/tests/bind_fetch/integer_types.phpt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1313

1414
$link = default_mysqli_connect();
1515

16-
if (!mysqli_query($link, "SET sql_mode=''"))
17-
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16+
// To get consistent result without depending on the DB version/setup
17+
mysqli_query($link, "SET sql_mode=''");
1818

19-
$rc = mysqli_query($link,"CREATE TABLE test_bind_fetch_integers(c1 int unsigned,
20-
c2 int unsigned,
21-
c3 int,
22-
c4 int,
23-
c5 int,
24-
c6 int unsigned,
25-
c7 int) ENGINE=" . get_default_db_engine());
26-
if (!$rc)
27-
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
19+
mysqli_query(
20+
$link,
21+
"CREATE TABLE test_bind_fetch_integers(
22+
c1 int unsigned,
23+
c2 int unsigned,
24+
c3 int,
25+
c4 int,
26+
c5 int,
27+
c6 int unsigned,
28+
c7 int
29+
) ENGINE=" . get_default_db_engine()
30+
);
2831

29-
if (!mysqli_query($link, "INSERT INTO test_bind_fetch_integers VALUES (-23,35999,NULL,-500,-9999999,-0,0)"))
30-
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
32+
mysqli_query($link, "INSERT INTO test_bind_fetch_integers VALUES (-23,35999,NULL,-500,-9999999,-0,0)");
3133

3234
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_integers");
3335
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);

ext/mysqli/tests/bind_fetch/mysql_functions.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1313

1414
$link = default_mysqli_connect();
1515

16-
if (!$stmt = mysqli_prepare($link, "SELECT md5('bar'), database(), 'foo'"))
17-
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16+
$stmt = mysqli_prepare($link, "SELECT md5('bar'), database(), 'foo'");
1817

1918
mysqli_stmt_bind_result($stmt, $c0, $c1, $c2);
2019
mysqli_stmt_execute($stmt);

ext/mysqli/tests/bind_fetch/smallint_types.phpt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1313

1414
$link = default_mysqli_connect();
1515

16-
if (!mysqli_query($link, "SET sql_mode=''"))
17-
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16+
// To get consistent result without depending on the DB version/setup
17+
mysqli_query($link, "SET sql_mode=''");
1818

19-
$rc = mysqli_query($link, "CREATE TABLE test_bind_fetch_integers_small(c1 smallint unsigned,
20-
c2 smallint unsigned,
21-
c3 smallint,
22-
c4 smallint,
23-
c5 smallint,
24-
c6 smallint unsigned,
25-
c7 smallint) ENGINE=" . get_default_db_engine());
26-
if (!$rc)
27-
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
19+
mysqli_query(
20+
$link,
21+
"CREATE TABLE test_bind_fetch_integers_small(
22+
c1 smallint unsigned,
23+
c2 smallint unsigned,
24+
c3 smallint,
25+
c4 smallint,
26+
c5 smallint,
27+
c6 smallint unsigned,
28+
c7 smallint
29+
) ENGINE=" . get_default_db_engine()
30+
);
2831

29-
if (!mysqli_query($link, "INSERT INTO test_bind_fetch_integers_small VALUES (-23,35999,NULL,-500,-9999999,+30,0)"))
30-
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
32+
mysqli_query($link, "INSERT INTO test_bind_fetch_integers_small VALUES (-23,35999,NULL,-500,-9999999,+30,0)");
3133

3234
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_integers_small");
3335
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);

ext/mysqli/tests/bind_fetch/system_variable.phpt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1313

1414
$link = default_mysqli_connect();
1515

16-
if (!mysqli_query($link, "SET AUTOCOMMIT=0"))
17-
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16+
mysqli_query($link, "SET AUTOCOMMIT=0");
1817

19-
if (!$stmt = mysqli_prepare($link, "SELECT @@autocommit"))
20-
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
18+
$stmt = mysqli_prepare($link, "SELECT @@autocommit");
2119

2220
mysqli_stmt_bind_result($stmt, $c0);
2321
mysqli_stmt_execute($stmt);

ext/mysqli/tests/bind_fetch/tinyint_types.phpt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1313

1414
$link = default_mysqli_connect();
1515

16-
if (!mysqli_query($link, "SET sql_mode=''"))
17-
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16+
// To get consistent result without depending on the DB version/setup
17+
mysqli_query($link, "SET sql_mode=''");
1818

19-
$rc = mysqli_query($link, "CREATE TABLE test_bind_fetch_integers_tiny(c1 tinyint,
20-
c2 tinyint unsigned,
21-
c3 tinyint not NULL,
22-
c4 tinyint,
23-
c5 tinyint,
24-
c6 tinyint unsigned,
25-
c7 tinyint) ENGINE=" . get_default_db_engine());
26-
if (!$rc)
27-
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
19+
mysqli_query(
20+
$link,
21+
"CREATE TABLE test_bind_fetch_integers_tiny(
22+
c1 tinyint,
23+
c2 tinyint unsigned,
24+
c3 tinyint not NULL,
25+
c4 tinyint,
26+
c5 tinyint,
27+
c6 tinyint unsigned,
28+
c7 tinyint
29+
) ENGINE=" . get_default_db_engine()
30+
);
2831

29-
if (!mysqli_query($link, "INSERT INTO test_bind_fetch_integers_tiny VALUES (-23,300,0,-100,-127,+30,0)"))
30-
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
32+
mysqli_query($link, "INSERT INTO test_bind_fetch_integers_tiny VALUES (-23,300,0,-100,-127,+30,0)");
3133

3234
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_integers_tiny");
3335
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);

ext/mysqli/tests/bind_fetch/unsigned_integer_types.phpt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,17 @@ require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
1313

1414
$link = default_mysqli_connect();
1515

16-
if (!mysqli_query($link, "SET sql_mode=''"))
17-
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16+
// To get consistent result without depending on the DB version/setup
17+
mysqli_query($link, "SET sql_mode=''");
1818

19-
$rc = mysqli_query($link, "CREATE TABLE test_bind_fetch_uint(c1 integer unsigned, c2 integer unsigned) ENGINE=" . get_default_db_engine());
20-
if (!$rc)
21-
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
19+
mysqli_query($link, "CREATE TABLE test_bind_fetch_uint(c1 integer unsigned, c2 integer unsigned) ENGINE=" . get_default_db_engine());
2220

23-
if (!mysqli_query($link, "INSERT INTO test_bind_fetch_uint (c1,c2) VALUES (20123456, 3123456789)"))
24-
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
21+
mysqli_query($link, "INSERT INTO test_bind_fetch_uint (c1,c2) VALUES (20123456, 3123456789)");
2522

2623
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_uint");
2724
mysqli_stmt_bind_result($stmt, $c1, $c2);
2825
mysqli_stmt_execute($stmt);
29-
$rc = mysqli_stmt_fetch($stmt);
26+
mysqli_stmt_fetch($stmt);
3027

3128
echo $c1, "\n", $c2, "\n";
3229

0 commit comments

Comments
 (0)