1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-07 15:16:44 +02:00

PostgreSQL: Support calling functions returning table (fix #1040)

This commit is contained in:
Jakub Vrana
2025-04-15 23:22:36 +02:00
parent 45799f4605
commit 6d6998c3d3
2 changed files with 7 additions and 2 deletions

View File

@@ -2,6 +2,7 @@
- MySQL: Avoid warning on selecting tables with fulltext indexes (bug #1036) - MySQL: Avoid warning on selecting tables with fulltext indexes (bug #1036)
- PostgreSQL, CockroachDB: Creating partitioned tables (bug #1031) - PostgreSQL, CockroachDB: Creating partitioned tables (bug #1031)
- PostgreSQL: Move partitioned tables from table list to parent table - PostgreSQL: Move partitioned tables from table list to parent table
- PostgreSQL: Support calling functions returning table (bug #1040)
- Designs: adminer.css with 'prefers-color-scheme: dark' don't disable dark mode - Designs: adminer.css with 'prefers-color-scheme: dark' don't disable dark mode
- Plugins: Method bodyClass() to add <body class> - Plugins: Method bodyClass() to add <body class>

View File

@@ -8,7 +8,7 @@ $routine = routine($_GET["call"], (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDU
$in = array(); $in = array();
$out = array(); $out = array();
foreach ($routine["fields"] as $i => $field) { foreach ($routine["fields"] as $i => $field) {
if (substr($field["inout"], -3) == "OUT") { if (substr($field["inout"], -3) == "OUT" && JUSH == 'sql') {
$out[$i] = "@" . idf_escape($field["field"]) . " AS " . idf_escape($field["field"]); $out[$i] = "@" . idf_escape($field["field"]) . " AS " . idf_escape($field["field"]);
} }
if (!$field["inout"] || substr($field["inout"], 0, 2) == "IN") { if (!$field["inout"] || substr($field["inout"], 0, 2) == "IN") {
@@ -29,7 +29,11 @@ if (!$error && $_POST) {
connection()->query("SET @" . idf_escape($field["field"]) . " = $val"); connection()->query("SET @" . idf_escape($field["field"]) . " = $val");
} }
} }
$call[] = (isset($out[$key]) ? "@" . idf_escape($field["field"]) : $val); if (isset($out[$key])) {
$call[] = "@" . idf_escape($field["field"]);
} elseif (in_array($key, $in)) {
$call[] = $val;
}
} }
$query = (isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . table($PROCEDURE) . "(" . implode(", ", $call) . ")"; $query = (isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . table($PROCEDURE) . "(" . implode(", ", $call) . ")";