From: Jakub Vrana Date: Sat, 21 Dec 2013 02:43:14 +0000 (-0800) Subject: PostgreSQL: Allow escaped table name in foreign key (bug #333) X-Git-Tag: v4.0.0~11 X-Git-Url: https://git.joonet.de/?a=commitdiff_plain;h=1de6fed32a36a840864dafb433fc09f24e835c71;p=adminer.git PostgreSQL: Allow escaped table name in foreign key (bug #333) --- diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index e6c4ba23..732d6524 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -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');