diff mbox

[OSSTEST,7/9] Executive DB retry: Avoid an undefined warning

Message ID 1450371968-27997-7-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson Dec. 17, 2015, 5:06 p.m. UTC
If something other than the DB statements inside need_retry throws an
exception, ->err will normally be undef (because
$dbh_tests->begin_work will clear it, if nothing else).

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/JobDB/Executive.pm |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ian Campbell Dec. 17, 2015, 5:31 p.m. UTC | #1
On Thu, 2015-12-17 at 17:06 +0000, Ian Jackson wrote:
> If something other than the DB statements inside need_retry throws an
> exception, ->err will normally be undef (because
> $dbh_tests->begin_work will clear it, if nothing else).
> 
> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

> ---
>  Osstest/JobDB/Executive.pm |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
> index 6fb77a4..c0af21c 100644
> --- a/Osstest/JobDB/Executive.pm
> +++ b/Osstest/JobDB/Executive.pm
> @@ -50,7 +50,7 @@ sub begin_work ($$$) { #method
>  sub need_retry ($$$) {
>      my ($jd, $dbh,$committing) = @_;
>      return
> -	$dbh_tests->err()==7 &&
> +	($dbh_tests->err() // 0)==7 &&
>  	($dbh_tests->state =~ m/^40P01/); # DEADLOCK DETECTED
>  }
>
diff mbox

Patch

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index 6fb77a4..c0af21c 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -50,7 +50,7 @@  sub begin_work ($$$) { #method
 sub need_retry ($$$) {
     my ($jd, $dbh,$committing) = @_;
     return
-	$dbh_tests->err()==7 &&
+	($dbh_tests->err() // 0)==7 &&
 	($dbh_tests->state =~ m/^40P01/); # DEADLOCK DETECTED
 }