max_allowed_packet doesn't work
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@570 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
6e566c7f26
commit
e160ad27cb
|
@ -12,11 +12,10 @@ function tar_file($filename, $contents) {
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
$ext = dump_headers((strlen($_GET["dump"]) ? $_GET["dump"] : $_GET["db"]), (!strlen($_GET["db"]) || count(array_filter((array) $_POST["tables"]) + array_filter((array) $_POST["data"])) > 1));
|
$ext = dump_headers((strlen($_GET["dump"]) ? $_GET["dump"] : $_GET["db"]), (!strlen($_GET["db"]) || count(array_filter((array) $_POST["tables"]) + array_filter((array) $_POST["data"])) > 1));
|
||||||
if ($_POST["format"] != "csv") {
|
if ($_POST["format"] != "csv") {
|
||||||
$max_packet = 16777216;
|
$max_packet = 1048576; // default, minimum is 1024
|
||||||
echo "SET NAMES utf8;\n";
|
echo "SET NAMES utf8;\n";
|
||||||
echo "SET foreign_key_checks = 0;\n";
|
echo "SET foreign_key_checks = 0;\n";
|
||||||
echo "SET time_zone = '" . $mysql->escape_string($mysql->result($mysql->query("SELECT @@time_zone"))) . "';\n";
|
echo "SET time_zone = '" . $mysql->escape_string($mysql->result($mysql->query("SELECT @@time_zone"))) . "';\n";
|
||||||
echo "SET max_allowed_packet = $max_packet;\n"; // ignored because of MySQL bug #22891
|
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ function dump_csv($row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function dump_table($table, $style, $is_view = false) {
|
function dump_table($table, $style, $is_view = false) {
|
||||||
global $mysql, $max_packet, $types;
|
global $mysql, $types;
|
||||||
if ($_POST["format"] == "csv") {
|
if ($_POST["format"] == "csv") {
|
||||||
echo "\xef\xbb\xbf";
|
echo "\xef\xbb\xbf";
|
||||||
if ($style) {
|
if ($style) {
|
||||||
|
@ -24,17 +24,6 @@ function dump_table($table, $style, $is_view = false) {
|
||||||
$create = $mysql->result($result, 1);
|
$create = $mysql->result($result, 1);
|
||||||
$result->free();
|
$result->free();
|
||||||
echo ($style != "CREATE, ALTER" ? $create : ($is_view ? substr_replace($create, " OR REPLACE", 6, 0) : substr_replace($create, " IF NOT EXISTS", 12, 0))) . ";\n\n";
|
echo ($style != "CREATE, ALTER" ? $create : ($is_view ? substr_replace($create, " OR REPLACE", 6, 0) : substr_replace($create, " IF NOT EXISTS", 12, 0))) . ";\n\n";
|
||||||
if ($max_packet < 1073741824) { // protocol limit
|
|
||||||
$row_size = 21 + strlen(idf_escape($table));
|
|
||||||
foreach (fields($table) as $field) {
|
|
||||||
$type = $types[$field["type"]];
|
|
||||||
$row_size += 5 + ($field["length"] ? (preg_match('~enum|set~', $field["type"]) ? strlen($field["length"]) : $field["length"]) : $type) * (preg_match('~char|text|enum|set~', $field["type"]) ? 3 : 1); // UTF-8 in MySQL uses up to 3 bytes
|
|
||||||
}
|
|
||||||
if ($row_size > $max_packet) {
|
|
||||||
$max_packet = min(1073741824, 1024 * ceil($row_size / 1024));
|
|
||||||
echo "SET max_allowed_packet = $max_packet;\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($mysql->server_info >= 5) {
|
if ($mysql->server_info >= 5) {
|
||||||
if ($style == "CREATE, ALTER" && !$is_view) {
|
if ($style == "CREATE, ALTER" && !$is_view) {
|
||||||
|
|
Loading…
Reference in a new issue