From e0f44275b825fa6dec95acb750507d632d3ebf48 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 3e1675bb13..ffd74394b3 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.39.5