Added a handle for DROP TABLE to remove sequences that are linked with the dropped table

git-svn-id: https://plugins.svn.wordpress.org/postgresql-for-wordpress/trunk@546567 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
hawk__
2012-05-20 12:57:04 +00:00
parent 21754d862d
commit bb14143c77
2 changed files with 10 additions and 1 deletions

View File

@ -372,7 +372,7 @@
}
// Load up upgrade and install functions as required
$begin = substr( $sql, 0, 3);
$search = array( 'SHO', 'ALT', 'DES', 'CRE');
$search = array( 'SHO', 'ALT', 'DES', 'CRE', 'DRO');
if( in_array($begin, $search))
{
require_once( PG4WP_ROOT.'/driver_pgsql_install.php');

View File

@ -207,6 +207,15 @@ WHERE pg_class.relname='$table_name' AND pg_attribute.attnum>=1 AND NOT pg_attri
// Now remove handled indexes
$sql = preg_replace( $pattern, '', $sql);
}// CREATE TABLE
elseif( 0 === strpos($sql, 'DROP TABLE'))
{
$logto = 'DROPTABLE';
$pattern = '/DROP TABLE.+ [`]?(\w+)[`]?$/';
preg_match($pattern, $sql, $matches);
$table = $matches[1];
$seq = $table . '_seq';
$sql .= ";\nDROP SEQUENCE IF EXISTS $seq;";
}// DROP TABLE
return $sql;
}