]> git.joonet.de Git - adminer.git/commitdiff
Add basic support for MySQL replication
authorMatthew Gamble <git@matthewgamble.net>
Fri, 4 Dec 2015 23:43:28 +0000 (10:43 +1100)
committerJakub Vrana <jakub@vrana.cz>
Mon, 20 Feb 2017 11:54:40 +0000 (12:54 +0100)
adminer/drivers/mysql.inc.php
adminer/include/connect.inc.php
adminer/index.php
adminer/lang/xx.inc.php
adminer/replication.inc.php [new file with mode: 0644]
changes.txt
compile.php

index 9e49330ed413a8dd423fe4f1bf463e12ff6b41c3..806ca949a709132b2285eb90c18a9a2c12605db7 100644 (file)
@@ -972,6 +972,14 @@ if (!defined("DRIVER")) {
                return get_key_vals("SHOW STATUS");
        }
 
+       /** Get replication status of master or slave
+       * @param string
+       * @return array ($name => $value)
+       */
+       function replication_status($type) {
+               return get_rows("SHOW $type STATUS");
+       }
+
        /** Convert field in select and edit
        * @param array one element from fields()
        * @return string
index b008faf71c18257a568f3c3d81104402c7b215ed..70cb6d3c1f95989f12967b032ad824c928b7debd 100644 (file)
@@ -17,6 +17,7 @@ function connect_error() {
                        'processlist' => lang('Process list'),
                        'variables' => lang('Variables'),
                        'status' => lang('Status'),
+                       'replication' => lang('Replication'),
                ) as $key => $val) {
                        if (support($key)) {
                                echo "<a href='" . h(ME) . "$key='>$val</a>\n";
@@ -77,7 +78,7 @@ if (isset($_GET["import"])) {
        $_GET["sql"] = $_GET["import"];
 }
 
-if (!(DB != "" ? $connection->select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["variables"]) || $_GET["script"] == "connect" || $_GET["script"] == "kill")) {
+if (!(DB != "" ? $connection->select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["replication"]) || isset($_GET["variables"]) || $_GET["script"] == "connect" || $_GET["script"] == "kill")) {
        if (DB != "" || $_GET["refresh"]) {
                restart_session();
                set_session("dbs", null);
index 88cbcec21b312031d070daf897d8bb6189aa847e..5620c952e4075ae491650d91b8fd226ac5ac6537 100644 (file)
@@ -65,6 +65,8 @@ if (isset($_GET["download"])) {
        include "./user.inc.php";
 } elseif (isset($_GET["processlist"])) {
        include "./processlist.inc.php";
+} elseif (isset($_GET["replication"])) {
+       include "./replication.inc.php";
 } elseif (isset($_GET["select"])) {
        include "./select.inc.php";
 } elseif (isset($_GET["variables"])) {
index 79db0b08ad92d98e459d35895f554408dbf23618..fe24b81af946a91586f748c750a768751faf83f7 100644 (file)
@@ -45,6 +45,10 @@ $translations = array(
        'Variables' => 'Xx',
        'Status' => 'Xx',
        
+       'Replication' => 'Xx',
+       'Master status' => 'Xx',
+       'Slave status' => 'Xx',
+       
        'SQL command' => 'Xx',
        '%d query(s) executed OK.' => array('Xx.', 'Xx.'),
        'Query executed OK, %d row(s) affected.' => array('Xx.', 'Xx.'),
diff --git a/adminer/replication.inc.php b/adminer/replication.inc.php
new file mode 100644 (file)
index 0000000..bd25841
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+page_header(lang('Replication'));
+
+echo "<p><b>" . lang('Master status') . "</b>" . doc_link(array("sql" => "show-master-status.html")) . "\n";
+$master_replication_status = replication_status("MASTER");
+echo "<table cellspacing='0'>\n";
+foreach ($master_replication_status[0] as $key => $val) {
+       echo "<tr>";
+       echo "<th>" . h($key);
+       echo "<td>" . nbsp($val);
+}
+echo "</table>\n";
+
+$slave_replication_status = replication_status("SLAVE");
+if (!empty($slave_replication_status)) {
+       echo "<p><b>" . lang('Slave status') . "</b>" . doc_link(array("sql" => "show-slave-status.html")) . "\n";
+       foreach ($slave_replication_status as $slave) {
+               echo "<table cellspacing='0'>\n";
+               foreach ($slave as $key => $val) {
+                       echo "<tr>";
+                       echo "<th>" . h($key);
+                       echo "<td>" . nbsp($val);
+               }
+               echo "</table>\n";
+       }
+}
index af858fa7350dd0f8ae68ab9b3eb536e8a95a9493..5320d390c74f6565985796fc5978d409c80c1bb6 100644 (file)
@@ -2,6 +2,7 @@ Adminer 4.2.6-dev:
 Add accessibility labels
 Make maxlength in edit fields a soft limit
 Add Cache-Control: immutable to static files
+MySQL: Add dedicated view for replication status
 PostgreSQL: Export
 PostgreSQL: Don't treat partial indexes as unique
 MS SQL: Support pdo_dblib
index fef45fb0259a9f6c82e0765a2e540cc1e02fc552..354b1cf6e2aa55cc4331df36dbf351bbeca83d06 100755 (executable)
@@ -343,7 +343,7 @@ foreach (glob(dirname(__FILE__) . "/adminer/drivers/" . ($driver ? $driver : "*"
 
 include dirname(__FILE__) . "/adminer/include/pdo.inc.php";
 include dirname(__FILE__) . "/adminer/include/driver.inc.php";
-$features = array("call" => "routine", "dump", "event", "privileges", "procedure" => "routine", "processlist", "routine", "scheme", "sequence", "status", "trigger", "type", "user" => "privileges", "variables", "view");
+$features = array("call" => "routine", "dump", "event", "privileges", "procedure" => "routine", "processlist", "routine", "scheme", "sequence", "status", "trigger", "type", "user" => "privileges", "replication", "variables", "view");
 $lang_ids = array(); // global variable simplifies usage in a callback function
 $file = file_get_contents(dirname(__FILE__) . "/$project/index.php");
 if ($driver) {