From 3b022ff77cbc234cf4f541904e1e5347ae96191e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 28 Oct 2019 17:13:09 +0000 Subject: [PATCH] Bug 23805: (RM follow-up) updatedatabase.pl mariadb support MySQL and MariaDB have different syntax when it comes to dropping a CHECK constraint. Signed-off-by: Martin Renvoize --- installer/data/mysql/updatedatabase.pl | 35 ++++++++++++++++++++------ 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index a0c00b43fb..18b4d78488 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -20011,14 +20011,33 @@ if ( CheckVersion($DBversion) ) { } # Dropping the check constraint in accountlines - $dbh->do( - qq{ - ALTER TABLE - accountlines - DROP CHECK - `accountlines_check_type` - } - ); + my ($raise_error) = $dbh->{RaiseError}; + $dbh->{AutoCommit} = 0; + $dbh->{RaiseError} = 1; + eval { + # MariaDB Specific Drop + $dbh->do( + qq{ + ALTER TABLE + accountlines + DROP CONSTRAINT + `accountlines_check_type` + } + ); + }; + if ($@) { + # MySQL Specific Drop + $dbh->do( + qq{ + ALTER TABLE + accountlines + DROP CHECK + `accountlines_check_type` + } + ); + } + $dbh->{AutoCommit} = 1; + $dbh->{RaiseError} = $raise_error; # Update accountype 'C' to 'CREDIT' $dbh->do( -- 2.20.1