You are here

function apdqc_semaphore_conversion in Asynchronous Prefetch Database Query Cache 7

Returns an int depending on the state of the semaphore table.

Return value

int 0 - No changes needed. 1 - Convert to MEMORY. 2 - Convert to InnoDB.

4 calls to apdqc_semaphore_conversion()
apdqc_admin_convert_semaphore_table_to_innodb in ./apdqc.admin.inc
Convert semaphore table to InnoDB.
apdqc_admin_convert_table_to_memory in ./apdqc.admin.inc
Convert semaphore table to MEMORY.
apdqc_admin_operations_form in ./apdqc.admin.inc
Form builder; perform apdqc operations.
drush_apdqc in ./apdqc.drush.inc
Drush command to all all the apdqc functions.

File

./apdqc.module, line 1728
Asynchronous Prefetch Database Query Cache module.

Code

function apdqc_semaphore_conversion() {
  $conversion = 0;
  $results = db_query("SELECT VERSION()")
    ->fetchAssoc();
  $version = reset($results);
  $real_table_name_semaphore = str_replace("`", "'", Database::getConnection()
    ->prefixTables("{" . db_escape_table('semaphore') . "}"));
  $results = db_query("SHOW TABLE STATUS WHERE Name = {$real_table_name_semaphore}")
    ->fetchAssoc();
  if (version_compare($version, '5.6.0', '<=')) {
    if (strcasecmp($results['Engine'], 'MEMORY') != 0) {
      $conversion = 1;
    }
  }
  elseif (strcasecmp($results['Engine'], 'InnoDB') != 0) {
    $conversion = 2;
  }
  return $conversion;
}