diff --git a/pg4wp/driver_pgsql.php b/pg4wp/driver_pgsql.php index 2880f5c..aba2dd2 100644 --- a/pg4wp/driver_pgsql.php +++ b/pg4wp/driver_pgsql.php @@ -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'); diff --git a/pg4wp/driver_pgsql_install.php b/pg4wp/driver_pgsql_install.php index 0151b0a..ceb3e18 100644 --- a/pg4wp/driver_pgsql_install.php +++ b/pg4wp/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; }