From e116c99c4535fec5c984737af2231591af879686 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 11 Sep 2024 10:50:42 -0400 Subject: [PATCH] Bug 37895: Update skelton.pl to show an example use of coding guideline SQL14 Guideline SQL14 recommends using try/finally blocks to report database modification errors. It would be helpful to update skeleton.pl to use this methodology. Test Plan: 1) Apply this patch 2) Copy skeleton.pl to test.pl 3) Add a bad query to the the $dbh->do({}) line 4) Run updatedatabase.pl 5) Note the error message is displayed 6) Change the bad query to a good query 7) Run updatedatabase.pl 8) Note the success message is displayed! --- installer/data/mysql/atomicupdate/skeleton.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/installer/data/mysql/atomicupdate/skeleton.pl b/installer/data/mysql/atomicupdate/skeleton.pl index 9e5738136b8..62870ef5ecb 100755 --- a/installer/data/mysql/atomicupdate/skeleton.pl +++ b/installer/data/mysql/atomicupdate/skeleton.pl @@ -9,7 +9,15 @@ return { my ( $dbh, $out ) = @$args{qw(dbh out)}; # Do you stuffs here - $dbh->do(q{}); + try { + $dbh->do(q{}); + } finally { + if (@_) { + say_failure( $out, "Database modification failed with errors: @_" ); + } else { + say_success( $out, "Database modification was successful!" ); + } + }; # Print useful stuff here # tables -- 2.39.3 (Apple Git-146)