]> git.joonet.de Git - adminer.git/commitdiff
PostgreSQL: Export functions
authorJakub Vrana <jakub@vrana.cz>
Sun, 23 Feb 2025 17:28:33 +0000 (18:28 +0100)
committerJakub Vrana <jakub@vrana.cz>
Sun, 23 Feb 2025 17:28:33 +0000 (18:28 +0100)
adminer/dump.inc.php
adminer/include/editing.inc.php
changes.txt

index 9e1ca291677d61812a9be5df1f030cd4a264bd44..d79793b5cc54251d4e9f0faef0b7e17ab1cd10e6 100644 (file)
@@ -53,12 +53,12 @@ SET foreign_key_checks = 0;
                                $out = "";
 
                                if ($_POST["routines"]) {
-                                       foreach (array("FUNCTION", "PROCEDURE") as $routine) {
-                                               foreach (get_rows("SHOW $routine STATUS WHERE Db = " . q($db), null, "-- ") as $row) {
-                                                       $create = remove_definer($connection->result("SHOW CREATE $routine " . idf_escape($row["Name"]), 2));
-                                                       set_utf8mb4($create);
-                                                       $out .= ($style != 'DROP+CREATE' ? "DROP $routine IF EXISTS " . idf_escape($row["Name"]) . ";;\n" : "") . "$create;;\n\n";
-                                               }
+                                       foreach (routines() as $row) {
+                                               $name = $row["ROUTINE_NAME"];
+                                               $routine = $row["ROUTINE_TYPE"];
+                                               $create = create_routine($routine, array("name" => $name) + routine($row["SPECIFIC_NAME"], $routine));
+                                               set_utf8mb4($create);
+                                               $out .= ($style != 'DROP+CREATE' ? "DROP $routine IF EXISTS " . idf_escape($name) . ";;\n" : "") . "$create;\n\n";
                                        }
                                }
 
@@ -70,9 +70,7 @@ SET foreign_key_checks = 0;
                                        }
                                }
 
-                               if ($out) {
-                                       echo "DELIMITER ;;\n\n$out" . "DELIMITER ;\n\n";
-                               }
+                               echo ($out && $jush == 'sql' ? "DELIMITER ;;\n\n$out" . "DELIMITER ;\n\n" : $out);
                        }
 
                        if ($_POST["table_style"] || $_POST["data_style"]) {
index c53539fafbe2abd33a152270acd2a60e883c2efb..cb93d3ff79a740098922e0e53a4a9eddaa75c83a 100644 (file)
@@ -521,13 +521,13 @@ function create_routine($routine, $row) {
                        $set[] = (preg_match("~^($inout)\$~", $field["inout"]) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET");
                }
        }
-       $definition = rtrim("\n$row[definition]", ";");
+       $definition = rtrim($row["definition"], ";");
        return "CREATE $routine "
                . idf_escape(trim($row["name"]))
                . " (" . implode(", ", $set) . ")"
-               . (isset($_GET["function"]) ? " RETURNS" . process_type($row["returns"], "CHARACTER SET") : "")
+               . ($routine == "FUNCTION" ? " RETURNS" . process_type($row["returns"], "CHARACTER SET") : "")
                . ($row["language"] ? " LANGUAGE $row[language]" : "")
-               . ($jush == "pgsql" ? " AS " . q($definition) : "$definition;")
+               . ($jush == "pgsql" ? " AS " . q($definition) : "\n$definition;")
        ;
 }
 
index 663eb9b91a3dba27e888bb13890b7593cef7c1ca..874a59ab35f65f12d485732db3b8e6329f0aa4a6 100644 (file)
@@ -7,6 +7,7 @@ MySQL: Show comments at routine call (bug #874)
 MySQL: Don't offer empty enum value in edit
 PostgreSQL: Link user defined types
 PostgreSQL: Constraint enum values in editing (bug #270)
+PostgreSQL: Export functions
 SQLite: Show all supported pragmas in Variables
 MS SQL: Allow altering table in non-default schema (bug #405)
 MS SQL: Fix default values (bug #732, bug #733)