Commit 5149b31a authored by Hugh Davenport's avatar Hugh Davenport Committed by Gerrit Code Review
Browse files

Merge "Insert fewer rows per query in MySQL textbox upgrade (bug #1018590)"

parents da2e96d9 4218ab66
......@@ -40,7 +40,15 @@ function xmldb_blocktype_textbox_upgrade($oldversion=0) {
ORDER BY b.id';
$done = 0;
$lastid = 0;
$limit = 5000;
if (is_mysql()) {
$mp = mysql_get_variable('max_allowed_packet');
$limit = ($mp && is_numeric($mp) && $mp > 1048576) ? ($mp / 8192) : 100;
}
else {
$limit = 5000;
}
while ($records = get_records_sql_array($sql, array($lastid, 'textbox'), 0, $limit)) {
// Create the new artefacts
$values = array();
......
......@@ -1800,3 +1800,15 @@ function db_drop_trigger($name, $table) {
throw new SQLException("db_drop_trigger() is not implemented for your database engine");
}
}
function mysql_get_variable($name) {
global $db;
if (!is_mysql()) {
throw new SQLException('mysql_get_variable() expects a mysql database');
}
if (empty($name) || preg_match('/[^a-z_]/', $name)) {
throw new SQLException('mysql_get_variable: invalid variable name');
}
$result = $db->Execute("SHOW VARIABLES LIKE ?", array($name));
return $result->fields['Value'];
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment