mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-29 09:17:14 +02:00
Improved INDEX creation support
git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@429262 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
@ -163,13 +163,14 @@ WHERE pg_class.relname='$table_name' AND pg_attribute.attnum>=1 AND NOT pg_attri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Support for INDEX creation
|
// Support for INDEX creation
|
||||||
$pattern = '/,\s+(UNIQUE |)KEY\s+([^\s]+)\s+\(([^\)]+)\)/';
|
$pattern = '/,\s+(UNIQUE |)KEY\s+([^\s]+)\s+\(((?:[\w]+(?:\([\d]+\))?[,]?)*)\)/';
|
||||||
if( preg_match_all( $pattern, $sql, $matches, PREG_SET_ORDER))
|
if( preg_match_all( $pattern, $sql, $matches, PREG_SET_ORDER))
|
||||||
foreach( $matches as $match)
|
foreach( $matches as $match)
|
||||||
{
|
{
|
||||||
$unique = $match[1];
|
$unique = $match[1];
|
||||||
$index = $match[2];
|
$index = $match[2];
|
||||||
$columns = $match[3];
|
$columns = $match[3];
|
||||||
|
$columns = preg_replace( '/\(\d+\)/', '', $columns);
|
||||||
// Workaround for index name duplicate
|
// Workaround for index name duplicate
|
||||||
$index = $table.'_'.$index;
|
$index = $table.'_'.$index;
|
||||||
$sql .= "\nCREATE {$unique}INDEX $index ON $table ($columns);";
|
$sql .= "\nCREATE {$unique}INDEX $index ON $table ($columns);";
|
||||||
|
Reference in New Issue
Block a user