]> git.joonet.de Git - adminer.git/commitdiff
PostgreSQL: Allow escaped table name in foreign key (bug #333)
authorJakub Vrana <jakub@vrana.cz>
Sat, 21 Dec 2013 02:43:14 +0000 (18:43 -0800)
committerJakub Vrana <jakub@vrana.cz>
Sat, 21 Dec 2013 02:43:14 +0000 (18:43 -0800)
adminer/drivers/pgsql.inc.php

index e6c4ba2300aa4673d859cad8e8943324efb95173..732d6524a5f9e352a369d66331b9a21a91b79013 100644 (file)
@@ -321,10 +321,9 @@ AND contype = 'f'::char
 ORDER BY conkey, conname") as $row) {
                        if (preg_match('~FOREIGN KEY\s*\((.+)\)\s*REFERENCES (.+)\((.+)\)(.*)$~iA', $row['definition'], $match)) {
                                $row['source'] = array_map('trim', explode(',', $match[1]));
-                               $row['table'] = $match[2];
-                               if (preg_match('~(.+)\.(.+)~', $match[2], $match2)) {
-                                       $row['ns'] = $match2[1];
-                                       $row['table'] = $match2[2];
+                               if (preg_match('~^(("([^"]|"")+"|[^"]+)\.)?"?("([^"]|"")+"|[^"]+)$~', $match[2], $match2)) {
+                                       $row['ns'] = str_replace('""', '"', preg_replace('~^"(.+)"$~', '\1', $match2[2]));
+                                       $row['table'] = str_replace('""', '"', preg_replace('~^"(.+)"$~', '\1', $match2[4]));
                                }
                                $row['target'] = array_map('trim', explode(',', $match[3]));
                                $row['on_delete'] = (preg_match("~ON DELETE ($on_actions)~", $match[4], $match2) ? $match2[1] : 'NO ACTION');