1--TEST--
2Bug #80107 mysqli_query() fails for ~16 MB long query when compression is enabled
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once("connect.inc");
8$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
9if (!$link) {
10    die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
11}
12$result = $link->query("SHOW VARIABLES LIKE 'max_allowed_packet'");
13if ($result->fetch_assoc()['Value'] < 0xffffff) {
14    die('skip max_allowed_packet is less than 0xffffff');
15}
16?>
17--FILE--
18<?php
19
20require_once("connect.inc");
21
22$data_size = 16777174;
23
24// Insert with compression disabled:
25
26$mysqli = mysqli_init();
27$result = my_mysqli_real_connect($mysqli, $host, $user, $passwd, $db, $port, $socket);
28$mysqli->query("DROP TABLE IF EXISTS test");
29$mysqli->query("CREATE TABLE test (`blob` LONGBLOB NOT NULL) ENGINE=MyISAM");
30
31$data = str_repeat("x", $data_size);
32$mysqli->query("INSERT INTO $db.test(`blob`) VALUE ('$data')");
33
34var_dump(mysqli_error_list($mysqli));
35$mysqli->close();
36
37// Insert with compression enabled:
38
39$mysqli = mysqli_init();
40$result = my_mysqli_real_connect($mysqli, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS);
41
42$data = str_repeat("x", $data_size);
43$mysqli->query("INSERT INTO $db.test(`blob`) VALUE ('$data')");
44
45var_dump(mysqli_error_list($mysqli));
46$mysqli->close();
47
48?>
49--CLEAN--
50<?php
51require_once("clean_table.inc");
52?>
53--EXPECT--
54array(0) {
55}
56array(0) {
57}
58