Plugin Directory

Changeset 546567


Ignore:
Timestamp:
05/20/2012 12:57:04 PM (14 years ago)
Author:
hawk__
Message:

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

Location:
postgresql-for-wordpress/trunk/pg4wp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • postgresql-for-wordpress/trunk/pg4wp/driver_pgsql.php

    r546556 r546567  
    373373        // Load up upgrade and install functions as required
    374374        $begin = substr( $sql, 0, 3);
    375         $search = array( 'SHO', 'ALT', 'DES', 'CRE');
     375        $search = array( 'SHO', 'ALT', 'DES', 'CRE', 'DRO');
    376376        if( in_array($begin, $search))
    377377        {
  • postgresql-for-wordpress/trunk/pg4wp/driver_pgsql_install.php

    r545542 r546567  
    208208            $sql = preg_replace( $pattern, '', $sql);
    209209        }// CREATE TABLE
     210        elseif( 0 === strpos($sql, 'DROP TABLE'))
     211        {
     212            $logto = 'DROPTABLE';
     213            $pattern = '/DROP TABLE.+ [`]?(\w+)[`]?$/';
     214            preg_match($pattern, $sql, $matches);
     215            $table = $matches[1];
     216            $seq = $table . '_seq';
     217            $sql .= ";\nDROP SEQUENCE IF EXISTS $seq;";
     218        }// DROP TABLE
    210219       
    211220        return $sql;
Note: See TracChangeset for help on using the changeset viewer.