If we get an ERROR output when executing an SQL file, consider it failed even if the exit status is zero

This commit is contained in:
Jamie Cameron
2023-01-03 18:25:50 -08:00
parent 9b2fc2c9f4
commit ca814a4e6f

View File

@@ -1036,7 +1036,19 @@ if ($_[4] && $_[4] ne 'root' && $< == 0) {
$cmd = &command_as_user($_[4], 0, $cmd);
}
local $out = &backquote_logged("$cmd 2>&1");
local @rv = ($?, $? ? $out || "$cmd failed" : $out);
local @rv;
if ($?) {
# Total failure
@rv = ($?, $out || "$cmd failed");
}
elsif ($out =~ /(^|\n)(ERROR\s+\d+.*)/) {
# Some command in the file failed
@rv = (1, $2);
}
else {
# All OK
@rv = (0, $out);
}
&make_authstr(); # Put back old password environment variable
return @rv;
}