Skip to content

Commit

Permalink
Eliminate unnecessary DELETE statements in removeBuilds() (#2576)
Browse files Browse the repository at this point in the history
Remove DELETE statements for tables that are now handled by cascading
deletions.

* build2uploadfile was fixed in #1657
* label2buildfailure was fixed in #2452
* dynamicanalysisdefect and label2dynamicanalysis were fixed in #2455
  • Loading branch information
zackgalbreath authored Nov 20, 2024
1 parent 89eb9a2 commit 5d8caad
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions app/Utils/DatabaseCleanupUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public static function removeBuild($buildid) : void
if (count($buildfailureids) > 0) {
$buildfailure_prepare_array = $db->createPreparedArray(count($buildfailureids));
DB::delete("DELETE FROM buildfailure2argument WHERE buildfailureid IN $buildfailure_prepare_array", $buildfailureids);
DB::delete("DELETE FROM label2buildfailure WHERE buildfailureid IN $buildfailure_prepare_array", $buildfailureids);
}

// Delete buildfailuredetails that are only used by builds that are being
Expand Down Expand Up @@ -197,24 +196,6 @@ public static function removeBuild($buildid) : void
)
", array_merge($buildids, $buildids));

// dynamicanalysisdefect
$dynamicanalysis = DB::select("
SELECT id
FROM dynamicanalysis
WHERE buildid IN $buildid_prepare_array
", $buildids);

$dynids = [];
foreach ($dynamicanalysis as $dynamicanalysis_array) {
$dynids[] = intval($dynamicanalysis_array->id);
}

if (count($dynids) > 0) {
$dynids_prepare_array = $db->createPreparedArray(count($dynids));
DB::delete("DELETE FROM dynamicanalysisdefect WHERE dynamicanalysisid IN $dynids_prepare_array", $dynids);
DB::delete("DELETE FROM label2dynamicanalysis WHERE dynamicanalysisid IN $dynids_prepare_array", $dynids);
}

// Delete the note if not shared
DB::delete("
DELETE FROM note WHERE id IN (
Expand Down Expand Up @@ -349,7 +330,6 @@ public static function removeBuild($buildid) : void
if (count($fileids) > 0) {
$fileids_prepare_array = $db->createPreparedArray(count($fileids));
DB::delete("DELETE FROM uploadfile WHERE id IN $fileids_prepare_array", $fileids);
DB::delete("DELETE FROM build2uploadfile WHERE fileid IN $fileids_prepare_array", $fileids);
}

// Remove any children of these builds.
Expand Down

0 comments on commit 5d8caad

Please sign in to comment.