1

I have a website that is on Drupal 7 and I am attempting to upgrade the version of Civi from 5.10 to 5.13 but when I attempt to upgrade it, I'm receiving the following error:

Database Error Code: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-b_before_insert' at line 1, 1064

I have tried doing the upgrade through drush and also through the /civicrm/upgrade URL with the same error.

It's a bit of a long shot but I was hoping that someone has seen the error before and knows of a fix or how I can determine exactly what is going on.

Taking a look at the debugging information, I can see it has something to do with triggers:

DROP TRIGGER IF EXISTS civicrm_saved_search-b_before_insert [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-b_before_insert' at line 1]
1

After a lot of digging, I realised what was happening. For some reason, there was a second civicrm_saved_search table in the database named civicrm_saved_search-b .

That hyphen - is an 'illegal' character unless you escape it.

To resolve the issue, all I did was change the - to a _ which cleared everything up and enabled me to upgrade my site within minutes.

Hopefully, this will help someone else one day who has a similar issue!

  • 1
    That does bring up an interesting point though - maybe this function should escape the trigger names? github.com/civicrm/civicrm-core/blob/5.14/CRM/Logging/… – Demerit Jun 7 at 17:09
  • I was thinking that myself, decided against changing the core files. I'm not sure whether this would be an issue or just an isolated incident... – Jade Jun 7 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.