Thomas Bruederli
2015-02-07 2f8b1036da42ec3d15a51c6b17a473f9f4df71d3
program/lib/Roundcube/rcube_db_pgsql.php
@@ -1,6 +1,6 @@
<?php
/**
/*
 +-----------------------------------------------------------------------+
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2005-2012, The Roundcube Dev Team                       |
@@ -36,7 +36,7 @@
     */
    protected function conn_configure($dsn, $dbh)
    {
        $this->query("SET NAMES 'utf8'");
        $dbh->query("SET NAMES 'utf8'");
    }
    /**
@@ -73,10 +73,9 @@
        // Note: we support only one sequence per table
        // Note: The sequence name must be <table_name>_seq
        $sequence = $table . '_seq';
        $rcube    = rcube::get_instance();
        // return sequence name if configured
        if ($prefix = $rcube->config->get('db_prefix')) {
        // modify sequence name if prefix is configured
        if ($prefix = $this->options['table_prefix']) {
            return $prefix . $sequence;
        }
@@ -190,4 +189,24 @@
        return $result;
    }
    /**
     * Parse SQL file and fix table names according to table prefix
     */
    protected function fix_table_names($sql)
    {
        if (!$this->options['table_prefix']) {
            return $sql;
        }
        $sql = parent::fix_table_names($sql);
        // replace sequence names, and other postgres-specific commands
        $sql = preg_replace_callback(
            '/((SEQUENCE |RENAME TO |nextval\()["\']*)([^"\' \r\n]+)/',
            array($this, 'fix_table_names_callback'),
            $sql
        );
        return $sql;
    }
}