]> git.joonet.de Git - adminer.git/commitdiff
Sequences
authorJakub Vrana <jakub@vrana.cz>
Wed, 5 May 2010 21:01:57 +0000 (23:01 +0200)
committerJakub Vrana <jakub@vrana.cz>
Wed, 5 May 2010 21:17:40 +0000 (23:17 +0200)
adminer/db.inc.php
adminer/drivers/mysql.inc.php
adminer/drivers/pgsql.inc.php
adminer/index.php
adminer/lang/cs.inc.php
adminer/sequence.inc.php [new file with mode: 0644]
todo.txt

index f95c3b81065d8aff555158d8b9a5ba53aa9b5e44..d7076e565d860770e68e280a5d1692e15dafb32c 100644 (file)
@@ -89,6 +89,7 @@ if ($_GET["ns"] !== "") {
        if (support("view")) {
                echo '<a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n";
        }
+
        if (support("routine")) {
                echo "<h3>" . lang('Routines') . "</h3>\n";
                $routines = routines();
@@ -108,6 +109,21 @@ if ($_GET["ns"] !== "") {
                echo '<p><a href="' . h(ME) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n";
        }
        
+       if (support("sequence")) {
+               echo "<h3>" . lang('Sequences') . "</h3>\n";
+               $sequences = get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema()");
+               if ($sequences) {
+                       echo "<table cellspacing='0'>\n";
+                       echo "<thead><tr><th>" . lang('Name') . "</thead>\n";
+                       odd('');
+                       foreach ($sequences as $val) {
+                               echo "<tr" . odd() . "><th><a href='" . h(ME) . "sequence=" . urlencode($val) . "'>" . h($val) . "</a>\n";
+                       }
+                       echo "</table>\n";
+               }
+               echo "<p><a href='" . h(ME) . "sequence='>" . lang('Create sequence') . "</a>\n";
+       }
+       
        if (support("event")) {
                echo "<h3>" . lang('Events') . "</h3>\n";
                $result = $connection->query("SHOW EVENTS");
index f8099e9b4e1f5f179cd6cd868078c81138645ab5..928332b50ac9443a18d053c8df2496c83e65ff2c 100644 (file)
@@ -846,7 +846,7 @@ if (!defined("DRIVER")) {
        */
        function support($feature) {
                global $connection;
-               return !ereg("scheme" . ($connection->server_info < 5.1 ? "|event|partitioning" . ($connection->server_info < 5 ? "|view|routine|trigger" : "") : ""), $feature);
+               return !ereg("scheme|sequence" . ($connection->server_info < 5.1 ? "|event|partitioning" . ($connection->server_info < 5 ? "|view|routine|trigger" : "") : ""), $feature);
        }
 
        $driver = "sql"; ///< @var string JUSH identifier
index c3436a5f91fd33797715c187e484ffd05d71051a..63c6994772f9adf84899b86b5497edeb10e6df09 100644 (file)
@@ -489,7 +489,7 @@ WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = " . $connection->qu
        }
        
        function support($feature) {
-               return ereg('^(comment|view|scheme|trigger|variables|drop_col)$', $feature); //! routine|sequence|
+               return ereg('^(comment|view|scheme|sequence|trigger|variables|drop_col)$', $feature); //! routine|
        }
        
        $driver = "pgsql";
index cac42a40324c4983ada1872e0ee1f900562aa437..16f3086a886a5f563069c84472d703e813ec7903 100644 (file)
@@ -52,6 +52,8 @@ if (isset($_GET["download"])) {
        include "./event.inc.php";
 } elseif (isset($_GET["procedure"])) {
        include "./procedure.inc.php";
+} elseif (isset($_GET["sequence"])) {
+       include "./sequence.inc.php";
 } elseif (isset($_GET["trigger"])) {
        include "./trigger.inc.php";
 } elseif (isset($_GET["user"])) {
index e37ed6447342398879556594bbc74193af240c89..caf57cf3023650980e7f41a82c5a17dda738d605 100644 (file)
@@ -244,4 +244,10 @@ $translations = array(
        'Schema has been altered.' => 'Schéma bylo změněno.',
        'schema' => 'schéma',
        'Schema' => 'Schéma',
+       'Sequences' => 'Sekvence',
+       'Create sequence' => 'Vytvořit sekvenci',
+       'Sequence has been dropped.' => 'Sekvence byla odstraněna.',
+       'Sequence has been created.' => 'Sekvence byla vytvořena.',
+       'Sequence has been altered.' => 'Sekvence byla změněna.',
+       'Alter sequence' => 'Pozměnit sekvenci',
 );
diff --git a/adminer/sequence.inc.php b/adminer/sequence.inc.php
new file mode 100644 (file)
index 0000000..97b6f22
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+$SEQUENCE = $_GET["sequence"];
+
+if ($_POST && !$error) {
+       $link = substr(ME, 0, -1);
+       if ($_POST["drop"]) {
+               query_redirect("DROP SEQUENCE " . idf_escape($SEQUENCE), $link, lang('Sequence has been dropped.'));
+       } elseif ($SEQUENCE == "") {
+               query_redirect("CREATE SEQUENCE " . idf_escape($_POST["name"]), $link, lang('Sequence has been created.'));
+       } elseif ($SEQUENCE != $_POST["name"]) {
+               query_redirect("ALTER SEQUENCE " . idf_escape($SEQUENCE) . " RENAME TO " . idf_escape($_POST["name"]), $link, lang('Sequence has been altered.'));
+       } else {
+               redirect($link);
+       }
+}
+
+page_header($SEQUENCE != "" ? lang('Alter sequence') . ": " . h($SEQUENCE) : lang('Create sequence'), $error);
+
+$row = array("name" => $SEQUENCE);
+if ($_POST) {
+       $row = $_POST;
+}
+?>
+
+<form action="" method="post">
+<p><input name="name" value="<?php echo h($row["name"]); ?>">
+<input type="hidden" name="token" value="<?php echo $token; ?>">
+<input type="submit" value="<?php echo lang('Save'); ?>">
+<?php
+if ($SEQUENCE != "") {
+       echo "<input type='submit' name='drop' value='" . lang('Drop') . "'$confirm>\n";
+}
+?>
+</form>
index 215736f6283b82539b49a51c3f55b24a6c28d186..64e64fae47c6d7488af1c54d01b9df4430bf13e2 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -38,7 +38,6 @@ ORDER BY COUNT(*)
 Export - http://www.postgresql.org/docs/8.4/static/functions-info.html
 Column rights - http://www.postgresql.org/docs/8.4/static/functions-info.html
 Dollar terminated string in SQL command
-Sequences
 bool in Editor
 Check PDO driver