// would result in a wrong index name.
preg_match('/^' .
preg_quote($table_name) . '__(.*)__' .
preg_quote($index_type) . '/',
$index->indexname,
$matches);
$index_name =
$matches[1
];
} $this->connection->
query('ALTER INDEX "' .
$this->defaultSchema . '"."' .
$index->indexname . '" RENAME TO ' .
$this->
ensureIdentifiersLength($new_name,
$index_name,
$index_type));
} // Ensure the new table name does not include schema syntax.
$prefixInfo =
$this->
getPrefixInfo($new_name);
// Rename sequences if the table contains serial fields.
$info =
$this->
queryTableInformation($table);
if (!
empty($info->serial_fields
)) { foreach ($info->serial_fields
as $field) { // The initial name of the sequence is generated automatically by
// PostgreSQL when the table is created, so we need to use
// pg_get_serial_sequence() to retrieve it.
$old_sequence =
$this->connection->
query("SELECT pg_get_serial_sequence('" .
$this->defaultSchema . '.' .
$table_name . "', '" .
$field . "')"
)->
fetchField();
// If the new sequence name exceeds the maximum identifier length limit,
// it will not match the pattern that is automatically applied by
// PostgreSQL on table creation, but that's ok because
// pg_get_serial_sequence() will return our non-standard name on