Execution of DDL scripts on replication sets.
authorchriskl <chriskl>
Wed, 15 Jun 2005 14:32:58 +0000 (14:32 +0000)
committerchriskl <chriskl>
Wed, 15 Jun 2005 14:32:58 +0000 (14:32 +0000)
classes/plugins/Slony.php
lang/english.php
lang/recoded/english.php
plugin_slony.php

index 800782f163fb64d37a15e2c3741d641c7d81cc75..182b67b77654f626537cb22c04df8064b1814935 100755 (executable)
@@ -3,7 +3,7 @@
 /**
  * A class that implements the Slony 1.0.x support plugin
  *
- * $Id: Slony.php,v 1.1.2.22 2005/06/12 14:36:25 chriskl Exp $
+ * $Id: Slony.php,v 1.1.2.23 2005/06/15 14:32:58 chriskl Exp $
  */
 
 include_once('./classes/plugins/Plugin.php');
@@ -408,6 +408,22 @@ class Slony extends Plugin {
                return $data->execute($sql);
        }
 
+       /**
+        * Executes schema changing DDL set on nodes
+        */
+       function executeReplicationSet($set_id, $script) {
+               global $data;
+
+               $schema = $this->slony_schema;
+               $data->fieldClean($schema);
+               $data->clean($set_id);
+               $data->clean($script);
+
+               $sql = "SELECT \"{$schema}\".ddlscript('{$set_id}', '{$script}')";
+
+               return $data->execute($sql);
+       }       
+       
        // TABLES
        
        /**
index 92ebda04fc880c7bd71262363855d5f7ced4f28b..aa74ee492d93b89509ffa4b1636aeee3101770ec 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.176.2.4 2005/06/11 08:20:08 chriskl Exp $
+        * $Id: english.php,v 1.176.2.5 2005/06/15 14:32:58 chriskl Exp $
         */
 
        // Language and character set
        $lang['strtablespacealtered'] = 'Tablespace altered.';
        $lang['strtablespacealteredbad'] = 'Tablespace alteration failed.';
 
-       // Slony clusters
+               // Slony clusters
        $lang['strnoclusters'] = 'No clusters found.';
-       $lang['strconfdropcluster'] = 'Are you sure you want to drop cluster "%s"?';
+       $lang['strconfdropcluster'] = 'Are you sure you want to drop cluster &quot;%s&quot;?';
        $lang['strclusterdropped'] = 'Cluster dropped.';
        $lang['strclusterdroppedbad'] = 'Cluster drop failed.';
-
+       $lang['strinitcluster'] = 'Initialize Cluster';
+       $lang['strclustercreated'] = 'Cluster initialized.';
+       $lang['strclustercreatedbad'] = 'Cluster initialization failed.';
+       $lang['strclusterneedsname'] = 'You must give a name for the cluster.';
+       $lang['strclusterneedsnodeid'] = 'You must give an ID for the local node.';
+       
        // Slony nodes
        $lang['strnodes'] = 'Nodes';
        $lang['strnonodes'] = 'No nodes found.';
        $lang['stractive'] = 'Active';
        $lang['strnodecreated'] = 'Node created.';
        $lang['strnodecreatedbad'] = 'Node creation failed.';
-       $lang['strconfdropnode'] = 'Are you sure you want to drop node "%s"?';
+       $lang['strconfdropnode'] = 'Are you sure you want to drop node &quot;%s&quot;?';
        $lang['strnodedropped'] = 'Node dropped.';
        $lang['strnodedroppedbad'] = 'Node drop failed';
-
+       $lang['strfailover'] = 'Failover';
+       $lang['strnodefailedover'] = 'Node failed over.';
+       $lang['strnodefailedoverbad'] = 'Node fail over fail.';
+       
        // Slony paths  
        $lang['strpaths'] = 'Paths';
        $lang['strnopaths'] = 'No paths found.';
        $lang['strpathneedsconnretry'] = 'You must give the number of seconds to wait before retry to connect.';
        $lang['strpathcreated'] = 'Path created.';
        $lang['strpathcreatedbad'] = 'Path creation failed.';
-       $lang['strconfdroppath'] = 'Are you sure you want to drop path "%s"?';
+       $lang['strconfdroppath'] = 'Are you sure you want to drop path &quot;%s&quot;?';
        $lang['strpathdropped'] = 'Path dropped.';
        $lang['strpathdroppedbad'] = 'Path drop failed.';
 
        $lang['strnolistens'] = 'No listens found.';
        $lang['strcreatelisten'] = 'Create listen';
        $lang['strlistencreated'] = 'Listen created.';
-       $lang['strlistencreatedbad'] = 'Listen creation failed.';
-       $lang['strconfdroplisten'] = 'Are you sure you want to drop listen "%s"?';
+       $lang['strlistencreated'] = 'Listen creation failed.';
+       $lang['strconfdroplisten'] = 'Are you sure you want to drop listen &quot;%s&quot;?';
        $lang['strlistendropped'] = 'Listen dropped.';
        $lang['strlistendroppedbad'] = 'Listen drop failed.';
 
        $lang['strrepsetdropped'] = 'Replication set dropped.';
        $lang['strrepsetdroppedbad'] = 'Replication set drop failed.';
        $lang['strmerge'] = 'Merge';
-       $lang['strmergeinto'] = 'Merge into';
+       $lang['strmergeinto'] = 'Merge Into';
        $lang['strrepsetmerged'] = 'Replication sets merged.';
        $lang['strrepsetmergedbad'] = 'Replication sets merge failed.';
        $lang['strmove'] = 'Move';
-       $lang['strneworigin'] = 'New origin';
+       $lang['strneworigin'] = 'New Origin';
        $lang['strrepsetmoved'] = 'Replication set moved.';
        $lang['strrepsetmovedbad'] = 'Replication set move failed.';
        $lang['strnewrepset'] = 'New replication set';
+       $lang['strlock'] = 'Lock';
+       $lang['strlocked'] = 'Locked';
+       $lang['strunlock'] = 'Unlock';
+       $lang['strconflockrepset'] = 'Are you sure you want to lock replication set &quot;%s&quot;?';
+       $lang['strrepsetlocked'] = 'Replication set locked.';
+       $lang['strrepsetlockedbad'] = 'Replication set lock failed.';
+       $lang['strconfunlockrepset'] = 'Are you sure you want to unlock replication set &quot;%s&quot;?';
+       $lang['strrepsetunlocked'] = 'Replication set unlocked.';
+       $lang['strrepsetunlockedbad'] = 'Replication set unlock failed.';
+       $lang['strexecute'] = 'Execute';
+       $lang['stronlyonnode'] = 'Only on node';
+       $lang['strddlscript'] = 'DDL Script';
+       $lang['strscriptneedsbody'] = 'You must supply a script to be executed on all nodes.';
+       $lang['strscriptexecuted'] = 'Replication set DDL script executed.';
+       $lang['strscriptexecutedbad'] = 'Failed executing replication set DDL script.';
 
        // Slony subscriptions
        $lang['strsubscriptions'] = 'Subscriptions';
        $lang['strnosubscriptions'] = 'No subscriptions found.';
 
        // Miscellaneous
-       $lang['strtopbar'] = '%s running on %s:%s -- You are logged in as user "%s", %s';
+       $lang['strtopbar'] = '%s running on %s:%s -- You are logged in as user &quot;%s&quot;, %s';
        $lang['strtimefmt'] = 'jS M, Y g:iA';
        $lang['strhelp'] = 'Help';
        $lang['strhelpicon'] = '?';
index b7ff010a34f6ad6b63f120dbbee5ff631a5c76dd..1f76fd6f73735f0e32bf62014cd84b62f18235b3 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.128.2.5 2005/06/12 14:36:26 chriskl Exp $
+        * $Id: english.php,v 1.128.2.6 2005/06/15 14:32:58 chriskl Exp $
         */
 
        // Language and character set
        $lang['strconfunlockrepset'] = 'Are you sure you want to unlock replication set &quot;%s&quot;?';
        $lang['strrepsetunlocked'] = 'Replication set unlocked.';
        $lang['strrepsetunlockedbad'] = 'Replication set unlock failed.';
+       $lang['strexecute'] = 'Execute';
+       $lang['stronlyonnode'] = 'Only on node';
+       $lang['strddlscript'] = 'DDL Script';
+       $lang['strscriptneedsbody'] = 'You must supply a script to be executed on all nodes.';
+       $lang['strscriptexecuted'] = 'Replication set DDL script executed.';
+       $lang['strscriptexecutedbad'] = 'Failed executing replication set DDL script.';
 
        // Slony subscriptions
        $lang['strsubscriptions'] = 'Subscriptions';
index e87471bec84918d98a7846ae31c760f05976b27d..1c139efcaaebe162c37cf74ea5db7dcc894b3d46 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Slony database tab plugin
         *
-        * $Id: plugin_slony.php,v 1.1.2.22 2005/06/12 14:36:25 chriskl Exp $
+        * $Id: plugin_slony.php,v 1.1.2.23 2005/06/15 14:32:58 chriskl Exp $
         */
 
        // Include application functions
                        echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n";
                        echo "\t\t<td class=\"data1\"><textarea name=\"no_comment\" rows=\"3\" cols=\"32\" wrap=\"virtual\">", 
                                htmlspecialchars($_POST['no_comment']), "</textarea></td>\n\t</tr>\n";
-                               
-                       echo "\t</tr>\n";
                        echo "</table>\n";
                        echo "<p>\n";
                        echo "<input type=\"hidden\" name=\"action\" value=\"save_create_cluster\" />\n";
                                'title' => $lang['strmove'],
                                'url'   => "plugin_slony.php?{$misc->href}&amp;action=move_set&amp;",
                                'vars'  => array('set_id' => 'set_id')
+                       ),
+                       'execute' => array(
+                               'title' => $lang['strexecute'],
+                               'url'   => "plugin_slony.php?{$misc->href}&amp;action=execute_set&amp;",
+                               'vars'  => array('set_id' => 'set_id')
                        )
                );
                
                echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=confirm_lock_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strlock']}</a> |\n";
                echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=confirm_unlock_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strunlock']}</a> |\n";
                echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=merge_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strmerge']}</a> |\n";
-               echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=move_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strmove']}</a></p>\n";
+               echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=move_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strmove']}</a> |\n";
+               echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=execute_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strexecute']}</a></p>\n";
        }
 
        /**
                                doMoveReplicationSet(true, $lang['strrepsetmovedbad']);
                }
        }
+
+       /**
+        * Displays a screen where they can enter a DDL script to
+        * be executed on all or a particular node, for this set.
+        */
+       function doExecuteReplicationSet($confirm, $msg = '') {
+               global $slony, $misc;
+               global $PHP_SELF, $lang;
                
+               if ($confirm) {
+                       if (!isset($_POST['script'])) $_POST['script'] = '';
+       
+                       $nodes = $slony->getNodes();
+       
+                       $misc->printTrail('slony_sets');
+                       $misc->printTitle($lang['strexecute']);
+                       $misc->printMsg($msg);
+       
+                       echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+                       echo $misc->form;
+                       echo "<table>\n";
+                       /* Slony 1.1 only
+                       echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['stronlyonnode']}</th>\n";
+                       echo "<td class=\"data1\" colspan=\"3\"><select name=\"only_on_node\">";
+                       echo "<option value=\"0\"></option>\n";
+                       while (!$nodes->EOF) {
+                               echo "<option value=\"{$nodes->f['no_id']}\"", ($_POST['only_on_node'] == $nodes->f['no_id'] ? ' selected="selected"' : ''), ">";
+                               echo htmlspecialchars($nodes->f['no_comment']), "</option>\n";
+                               $nodes->moveNext();     
+                       }
+                       echo "</select></td></tr>\n";
+                       */
+                       echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strddlscript']}</th>\n";
+                       echo "\t\t<td class=\"data1\"><textarea name=\"script\" rows=\"20\" cols=\"40\" wrap=\"virtual\">", 
+                               htmlspecialchars($_POST['script']), "</textarea></td>\n\t</tr>\n";
+                       echo "</table>\n";
+                       echo "<p>\n";
+                       echo "<input type=\"hidden\" name=\"action\" value=\"save_execute_set\" />\n";
+                       echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
+                       echo "<input type=\"submit\" value=\"{$lang['strexecute']}\" />\n";
+                       echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+                       echo "</p>\n";
+                       echo "</form>\n";
+               }
+               else {
+                       if (trim($_POST['script']) == '') {
+                               doExecuteReplicationSet(true, $lang['strscriptneedsbody']);
+                               return;
+                       }
+                       
+                       $status = $slony->executeReplicationSet($_POST['set_id'], $_POST['script']);
+                       if ($status == 0)
+                               doReplicationSet($lang['strscriptexecuted']);
+                       else
+                               doExecuteReplicationSet(true, $lang['strscriptexecutedbad']);
+               }
+       }
+                       
        // TABLES
        
        /**
                case 'move_set':
                        doMoveReplicationSet(true);
                        break;
+               case 'save_execute_set':
+                       if (isset($_POST['cancel'])) doReplicationSet();
+                       else doExecuteReplicationSet(false);
+                       break;
+               case 'execute_set':
+                       doExecuteReplicationSet(true);
+                       break;
                case 'tables_properties':
                        doTables();
                        break;