Issue 1965: Delete legacy CUBRID indexes (on recreate cache).

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10646 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2012-04-30 19:12:26 +00:00
parent ab0d78ffde
commit 018b29f09f
2 changed files with 50 additions and 0 deletions

View file

@ -464,6 +464,48 @@
return true;
}
function deleteDuplicateIndexes()
{
$query = sprintf("
select \"class_name\"
, case
when substr(\"index_name\", 0, %d) = '%s'
then substr(\"index_name\", %d)
else \"index_name\" end as unprefixed_index_name
, \"is_unique\"
from \"db_index\"
where \"class_name\" like %s
group by \"class_name\"
, case
when substr(\"index_name\", 0, %d) = '%s'
then substr(\"index_name\", %d)
else \"index_name\"
end
having count(*) > 1
", strlen($this->prefix)
, $this->prefix
, strlen($this->prefix) + 1
, "'" . $this->prefix . '%' . "'"
, strlen($this->prefix)
, $this->prefix
, strlen($this->prefix) + 1
);
$result = $this->_query ($query);
if ($this->isError ()) return false;
$output = $this->_fetch ($result);
if (!$output) return false;
$indexes_to_be_deleted = $output->data;
foreach($indexes_to_be_deleted as $index)
{
$this->dropIndex($index->class_name, $index->unprefixed_index_name, $index->is_unique == 'YES' ? true : false);
}
return true;
}
/**
* @brief creates a table by using xml file
**/