function apdqc_convert_cache_index in Asynchronous Prefetch Database Query Cache 7
Converts a database index from one form to another.
Parameters
array $before: List of keys that need to be removed.
array $after: List of keys that will be used in the new index.
3 calls to apdqc_convert_cache_index()
- apdqc_admin_convert_tables_indexes in ./
apdqc.admin.inc - Convert table indexes to expire, created.
- apdqc_disable in ./
apdqc.install - Implements hook_disable().
- apdqc_modules_installed in ./
apdqc.module - Implements hook_modules_installed().
File
- ./
apdqc.admin.inc, line 1244 - Admin page callbacks for the apdqc module.
Code
function apdqc_convert_cache_index(array $before, array $after, array $cache_tables = array()) {
$table_indexes = apdqc_get_cache_table_indexes($cache_tables);
$before_name = implode('_', $before);
$after_name = implode('_', $after);
foreach ($table_indexes as $table_name => $indexes) {
if (isset($indexes[$before_name])) {
if (function_exists('apdqc_query')) {
$query = "ALTER TABLE {$table_name} DROP INDEX `{$before_name}`";
$mysqli = apdqc_query(array(
$table_name,
), array(
'*',
), $query, array(
'async' => TRUE,
'log' => FALSE,
'get_mysqli' => TRUE,
));
if (isset($mysqli->thread_id)) {
apdqc_kill_metadata_lock($mysqli->thread_id);
}
}
else {
db_drop_index($table_name, $before_name);
}
}
if (!isset($indexes[$after_name])) {
if (function_exists('apdqc_query')) {
$columns = apdqc_create_key_sql($after);
$query = "ALTER TABLE {$table_name} ADD INDEX `{$after_name}` ({$columns})";
$mysqli = apdqc_query(array(
$table_name,
), array(
'*',
), $query, array(
'async' => TRUE,
'log' => FALSE,
'get_mysqli' => TRUE,
));
if (isset($mysqli->thread_id)) {
apdqc_kill_metadata_lock($mysqli->thread_id);
}
}
else {
db_add_index($table_name, $after_name, $after);
}
}
}
if (function_exists('apdqc_get_db_object')) {
apdqc_get_db_object(array(), array(), array(
'async' => FALSE,
'reap' => TRUE,
));
}
}