Commit 242b84a2 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1483084: Upgrade problem with assigning artefact path



Postgres works slightly differently to mysql with the
update .. limit command

behatnotneeded: as this is an upgrde problem

Change-Id: I6ae18e545d9e3ba56ca3a258b02038b3759ea178
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent f1dbbaa7
......@@ -3282,7 +3282,13 @@ function xmldb_core_upgrade($oldversion=0) {
$limitsmall = 200;
$total = count_records_select('artefact', 'path IS NULL AND parent IS NULL');
for ($i = 0; $i <= $total; $i += $limitsmall) {
execute_sql("UPDATE {artefact} SET path = CONCAT('/', id) WHERE path IS NULL AND parent IS NULL LIMIT " . $limitsmall);
if (is_mysql()) {
execute_sql("UPDATE {artefact} SET path = CONCAT('/', id) WHERE path IS NULL AND parent IS NULL LIMIT " . $limitsmall);
}
else {
// Postgres can only handle limit in subquery
execute_sql("UPDATE {artefact} SET path = CONCAT('/', id) WHERE id IN (SELECT id FROM {artefact} WHERE path IS NULL AND parent IS NULL LIMIT " . $limitsmall . ")");
}
$count += $limitsmall;
if (($count % $limit) == 0 || $count == $total) {
log_debug("$count/$total");
......
Markdown is supported
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