mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-29 17:27:13 +02:00
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:
@ -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');
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user