From ce86463e48656112f6389c31a2aaa9851fed6153 Mon Sep 17 00:00:00 2001 From: hawk__ Date: Sat, 16 Jan 2010 22:15:14 +0000 Subject: [PATCH] Upgrading from WP 2.8.6 to WP 2.9.1 now works with only 1 possible non-blocking error git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@194612 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- pg4wp/driver_pgsql.php | 20 ++++++++++++++++++++ readme.txt | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pg4wp/driver_pgsql.php b/pg4wp/driver_pgsql.php index 46275bb..65ae3e0 100644 --- a/pg4wp/driver_pgsql.php +++ b/pg4wp/driver_pgsql.php @@ -255,6 +255,13 @@ // LIMIT is not allowed in DELETE queries $sql = str_replace( 'LIMIT 1', '', $sql); $sql = str_replace( ' REGEXP ', ' ~ ', $sql); + + // This handles removal of duplicate entries in table options + if( false !== strpos( $sql, 'DELETE o1 FROM ')) + $sql = "DELETE FROM ${table_prefix}options WHERE option_id IN " . + "(SELECT o1.option_id FROM ${table_prefix}options AS o1, ${table_prefix}options AS o2 " . + "WHERE o1.option_name = o2.option_name " . + "AND o1.option_id < o2.option_id)"; } // Fix tables listing elseif( 0 === strpos($sql, 'SHOW TABLES')) @@ -321,6 +328,19 @@ WHERE bc.oid = i.indrelid $index = $table.'_'.$index; $sql = "CREATE {$unique}INDEX $index ON $table ($columns)"; } + $pattern = '/ALTER TABLE\s+(\w+)\s+DROP INDEX\s+([^\s]+)/'; + if( 1 === preg_match( $pattern, $sql, $matches)) + { + $table = $matches[1]; + $index = $matches[2]; + $sql = "DROP INDEX ${table}_${index}"; + } + $pattern = '/ALTER TABLE\s+(\w+)\s+DROP PRIMARY KEY/'; + if( 1 === preg_match( $pattern, $sql, $matches)) + { + $table = $matches[1]; + $sql = "ALTER TABLE ${table} DROP CONSTRAINT ${table}_pkey"; + } } // Table description elseif( 0 === strpos( $sql, 'DESCRIBE')) diff --git a/readme.txt b/readme.txt index a6f88c6..0c382f6 100644 --- a/readme.txt +++ b/readme.txt @@ -50,7 +50,9 @@ There is no screenshot for this plugin == Changelog == -* Upgrading from WP 2.8.6 to WP 2.9.1 works with errors + +* Upgrading from WP 2.8.6 to WP 2.9.1 works with a minor error + Upgrading should remove an index on table "wp_options" that may not exist, throwing an error * Installing WP 2.9.1 works smoothly * Generic hack to avoid duplicate index names * REGEXP gets replaced with '~'