Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Default trigger statement

  • Loading branch information...
commit 1a30f25311a2f971546bbd292c696ff74262bfb6 1 parent 5275ed8
@vrana authored
View
3  adminer/drivers/mssql.inc.php
@@ -521,6 +521,9 @@ function move_tables($tables, $views, $target) {
}
function trigger($name) {
+ if ($name == "") {
+ return array();
+ }
$rows = get_rows("SELECT s.name [Trigger],
CASE WHEN OBJECTPROPERTY(s.id, 'ExecIsInsertTrigger') = 1 THEN 'INSERT' WHEN OBJECTPROPERTY(s.id, 'ExecIsUpdateTrigger') = 1 THEN 'UPDATE' WHEN OBJECTPROPERTY(s.id, 'ExecIsDeleteTrigger') = 1 THEN 'DELETE' END [Event],
CASE WHEN OBJECTPROPERTY(s.id, 'ExecIsInsteadOfTrigger') = 1 THEN 'INSTEAD OF' ELSE 'AFTER' END [Timing],
View
3  adminer/drivers/mysql.inc.php
@@ -697,6 +697,9 @@ function copy_tables($tables, $views, $target) {
* @return array array("Trigger" => , "Timing" => , "Event" => , "Statement" => )
*/
function trigger($name) {
+ if ($name == "") {
+ return array();
+ }
$rows = get_rows("SHOW TRIGGERS WHERE `Trigger` = " . q($name));
return reset($rows);
}
View
3  adminer/drivers/pgsql.inc.php
@@ -440,6 +440,9 @@ function move_tables($tables, $views, $target) {
}
function trigger($name) {
+ if ($name == "") {
+ return array("Statement" => "EXECUTE PROCEDURE ()");
+ }
$rows = get_rows('SELECT trigger_name AS "Trigger", condition_timing AS "Timing", event_manipulation AS "Event", \'FOR EACH \' || action_orientation AS "Type", action_statement AS "Statement" FROM information_schema.triggers WHERE event_object_table = ' . q($_GET["trigger"]) . ' AND trigger_name = ' . q($name));
return reset($rows);
}
View
3  adminer/drivers/sqlite.inc.php
@@ -450,6 +450,9 @@ function move_tables($tables, $views, $target) {
function trigger($name) {
global $connection;
+ if ($name == "") {
+ return array("Statement" => "BEGIN\n\t;\nEND\n");
+ }
preg_match('~^CREATE\\s+TRIGGER\\s*(?:[^`"\\s]+|`[^`]*`|"[^"]*")+\\s*([a-z]+)\\s+([a-z]+)\\s+ON\\s*(?:[^`"\\s]+|`[^`]*`|"[^"]*")+\\s*(?:FOR\\s*EACH\\s*ROW\\s)?(.*)~is', $connection->result("SELECT sql FROM sqlite_master WHERE name = " . q($name)), $match);
return array("Timing" => strtoupper($match[1]), "Event" => strtoupper($match[2]), "Trigger" => $name, "Statement" => $match[3]);
}
View
8 adminer/trigger.inc.php
@@ -20,11 +20,9 @@
page_header(($_GET["name"] != "" ? lang('Alter trigger') . ": " . h($_GET["name"]) : lang('Create trigger')), $error, array("table" => $TABLE));
-$row = array("Trigger" => $TABLE . "_bi");
-if ($_POST) {
- $row = $_POST;
-} elseif ($_GET["name"] != "") {
- $row = trigger($_GET["name"]);
+$row = $_POST;
+if (!$row) {
+ $row = trigger($_GET["name"]) + array("Trigger" => $TABLE . "_bi");
}
?>
View
1  changes.txt
@@ -1,5 +1,6 @@
Adminer 3.3.3-dev:
Fix trigger export (SQLite)
+Default trigger statement (SQLite, PostgreSQL)
Adminer 3.3.2 (released 2011-08-08):
Display error with non-existent row in edit
Please sign in to comment.
Something went wrong with that request. Please try again.