mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +02:00
PostgreSQL: fixed search path resolution in table and column reflection.
This commit is contained in:
@@ -450,7 +450,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
FROM
|
FROM
|
||||||
information_schema.tables
|
information_schema.tables
|
||||||
WHERE
|
WHERE
|
||||||
table_schema = current_schema()";
|
table_schema = ANY (current_schemas(false))";
|
||||||
|
|
||||||
if ($version >= 9.3) {
|
if ($version >= 9.3) {
|
||||||
$query .= "
|
$query .= "
|
||||||
@@ -460,7 +460,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
FROM
|
FROM
|
||||||
pg_matviews
|
pg_matviews
|
||||||
WHERE
|
WHERE
|
||||||
schemaname = current_schema()";
|
schemaname = ANY (current_schemas(false))";
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $this->query($query);
|
$res = $this->query($query);
|
||||||
@@ -481,15 +481,17 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
SELECT indkey
|
SELECT indkey
|
||||||
FROM pg_class
|
FROM pg_class
|
||||||
LEFT JOIN pg_index on pg_class.oid = pg_index.indrelid AND pg_index.indisprimary
|
LEFT JOIN pg_index on pg_class.oid = pg_index.indrelid AND pg_index.indisprimary
|
||||||
WHERE pg_class.relname = $_table
|
WHERE pg_class.oid = $_table::regclass
|
||||||
");
|
");
|
||||||
$primary = (int) pg_fetch_object($res->resultSet)->indkey;
|
$primary = (int) pg_fetch_object($res->resultSet)->indkey;
|
||||||
|
|
||||||
$res = $this->query("
|
$res = $this->query("
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM information_schema.columns
|
FROM information_schema.columns c
|
||||||
WHERE table_name = $_table AND table_schema = current_schema()
|
JOIN pg_class ON pg_class.relname = c.table_name
|
||||||
ORDER BY ordinal_position
|
JOIN pg_namespace nsp ON nsp.oid = pg_class.relnamespace AND nsp.nspname = c.table_schema
|
||||||
|
WHERE pg_class.oid = $_table::regclass
|
||||||
|
ORDER BY c.ordinal_position
|
||||||
");
|
");
|
||||||
|
|
||||||
if (!$res->getRowCount()) {
|
if (!$res->getRowCount()) {
|
||||||
@@ -543,9 +545,16 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
{
|
{
|
||||||
$_table = $this->escape($table, dibi::TEXT);
|
$_table = $this->escape($table, dibi::TEXT);
|
||||||
$res = $this->query("
|
$res = $this->query("
|
||||||
SELECT ordinal_position, column_name
|
SELECT
|
||||||
FROM information_schema.columns
|
a.attnum AS ordinal_position,
|
||||||
WHERE table_name = $_table AND table_schema = current_schema()
|
a.attname AS column_name
|
||||||
|
FROM
|
||||||
|
pg_attribute a
|
||||||
|
JOIN pg_class cls ON a.attrelid = cls.oid
|
||||||
|
WHERE
|
||||||
|
a.attrelid = $_table::regclass
|
||||||
|
AND a.attnum > 0
|
||||||
|
AND NOT a.attisdropped
|
||||||
ORDER BY ordinal_position
|
ORDER BY ordinal_position
|
||||||
");
|
");
|
||||||
|
|
||||||
@@ -559,7 +568,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
FROM pg_class
|
FROM pg_class
|
||||||
LEFT JOIN pg_index on pg_class.oid = pg_index.indrelid
|
LEFT JOIN pg_index on pg_class.oid = pg_index.indrelid
|
||||||
INNER JOIN pg_class as pg_class2 on pg_class2.oid = pg_index.indexrelid
|
INNER JOIN pg_class as pg_class2 on pg_class2.oid = pg_index.indexrelid
|
||||||
WHERE pg_class.relname = $_table
|
WHERE pg_class.oid = $_table::regclass
|
||||||
");
|
");
|
||||||
|
|
||||||
$indexes = array();
|
$indexes = array();
|
||||||
|
Reference in New Issue
Block a user