summaryrefslogtreecommitdiff
path: root/program/lib/Roundcube/rcube_db_mssql.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2014-04-29 11:34:43 +0200
committerAleksander Machniak <alec@alec.pl>2014-04-29 11:34:43 +0200
commit90f7aa9e39e744e708a597ff6d1ac83f7c4fcef5 (patch)
treee1f87bcbf54f21efd6eccbfda2a7c012e3f9ec56 /program/lib/Roundcube/rcube_db_mssql.php
parentd5038ee5d910ffe200e5cad60ca407f615b2691d (diff)
Fix varius db_prefix issues (#1489839)
- Move DDL script execution code to rcube_db class(es). - Improve prefix replacement code, so index names are also modified
Diffstat (limited to 'program/lib/Roundcube/rcube_db_mssql.php')
-rw-r--r--program/lib/Roundcube/rcube_db_mssql.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/program/lib/Roundcube/rcube_db_mssql.php b/program/lib/Roundcube/rcube_db_mssql.php
index 726e4b421..4138b1489 100644
--- a/program/lib/Roundcube/rcube_db_mssql.php
+++ b/program/lib/Roundcube/rcube_db_mssql.php
@@ -167,4 +167,24 @@ class rcube_db_mssql extends rcube_db
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;
+ }
+
+ // replace sequence names, and other postgres-specific commands
+ $sql = preg_replace_callback(
+ '/((TABLE|(?<!ON )UPDATE|INSERT INTO|FROM(?! deleted)| ON(?! (DELETE|UPDATE|\[PRIMARY\]))'
+ . '|REFERENCES|CONSTRAINT|TRIGGER|INDEX)\s+(\[dbo\]\.)?[\[\]]*)([^\[\]\( \r\n]+)/',
+ array($this, 'fix_table_names_callback'),
+ $sql
+ );
+
+ return $sql;
+ }
}