Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-19968 SQL tweaks to make it more likely that reverting to single language w… #9783

Merged
merged 2 commits into from
Sep 5, 2017

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Feb 4, 2017

…ill actually work.
Disabling multiple languages is almost certain to fail on an existing reasonably well populated system due to row size constraints. This patch makes a couple of simple tweaks to the SQL queries so that it is much more likely to succeed!

  1. Column is renamed instead of created and copied, as the copy often leads to a row size constraint (eg. in civicrm_event when you have some text in intro_text_lang).
  2. Use DROP VIEW IF EXISTS instead of DROP VIEW (supported in mysql 5.1+). There is more support for IF EXISTS on other SQL functions in new versions of mysql but we can't use them if we're maintaining compatibility.

@civicrm-builder
Copy link

Can one of the admins verify this patch?

@mlutfy mlutfy changed the title SQL tweaks to make it more likely that reverting to single language w… CRM-19968 SQL tweaks to make it more likely that reverting to single language w… Feb 4, 2017
@mlutfy
Copy link
Member

mlutfy commented Feb 4, 2017

jenkins, test this please

foreach ($locales as $loc) {
$dropQueries[] = "ALTER TABLE {$table} DROP {$column}_{$loc}";
if (strcmp($loc,$retain) !== 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a space after the comma

@mlutfy
Copy link
Member

mlutfy commented Feb 4, 2017

jenkins, test this please

@totten totten added the master label Feb 6, 2017
foreach ($locales as $loc) {
$dropQueries[] = "ALTER TABLE {$table} DROP {$column}_{$loc}";
if (strcmp($loc,$retain) !== 0) {
Copy link
Member

@xurizaemon xurizaemon Feb 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you raised the spectre of MySQL 5.1 in JIRA - I'm not fussed, but easy to account for it?

I thought CiviCRM might already have status available to check but it seems we query MySQL for this as we need.

$mysql_version = CRM_CORE_DAO::singleValueQuery('SELECT VERSION()');
foreach ($locales as $loc) {
  if (version_compare($mysql_version, '5.1', '>=')) {
    $queries[] = "DROP VIEW IF EXISTS {$table}_{$loc}";
  }
  else {
    $queries[] = "DROP VIEW {$table}_{$loc}";
  }
}

There might also be a 😱 MySQL comment syntax which <5.1 will ignore? I kinda hate this as it's harder to read, but

foreach ($locales as $loc) {
  $queries[] = "DROP VIEW  /*!50100 IF EXISTS */  {$table}_{$loc}";
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@xurizaemon xurizaemon Feb 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now my initial comment misjudged @mattwire's intent - I believe he's saying we do curerntly support 5.1+ anyway, but we could use IF EXISTS more with later MySQL versions to reduce some of that fragility (which I do think is an issue). I'll open that as a separate ticket in JIRA and copy these notes there.

@eileenmcnaughton
Copy link
Contributor

@xurizaemon I think this can be merged? It looks like you reviewed it & @mattwire responded to your review?

@mattwire
Copy link
Contributor Author

@xurizaemon @eileenmcnaughton I think we agreed that it improved the situation, but highlighted that further improvements could be made to reliability of SQL elsewhere in CiviCRM (and in this particular area of code) for which https://issues.civicrm.org/jira/browse/CRM-20031 was opened. However, as this is an improvement over what was there before it should be merged - @xurizaemon do you agree?

@xurizaemon
Copy link
Member

I'm happy with this.

@eileenmcnaughton
Copy link
Contributor

Merging based on @xurizaemon review & comment above

@eileenmcnaughton eileenmcnaughton merged commit ec89e24 into civicrm:master Sep 5, 2017
@mattwire mattwire deleted the back_to_single_lang branch September 7, 2017 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants