List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:August 12 2010 3:00pm
Subject:bzr commit into connector-net-6.0 branch (vvaintroub:833) Bug#44715
View as plain text  
#At file:///H:/connector_net/6.0/ based on revid:vvaintroub@stripped

  833 Vladislav Vaintroub	2010-08-12
      Bug#44715 :  Double authorization when altering SP in server explorer .
      
      The problem was that editing stored procedure (or trigger) caused the whole Date Explorer
      to be refreshed, including  database nodes different from active one.
      
      Refresh on DataExplorer window would  attempt to reopen connections that were broken,
      hence triggering authorization dialogs.
      
      The fix is to refresh only the current database node.
      
      This patch also fixes broken editing triggers in VS2008. Trying to get parent node of trigger
      in the hierarchy fails with COM error.  The patch implements more robust way to get table 
      name of the trigger (extracts it from trigger text)

    modified:
      CHANGES
      MySql.VisualStudio/Nodes/BaseNode.cs
      MySql.VisualStudio/Nodes/DocumentNode.cs
      MySql.VisualStudio/Nodes/TriggerNode.cs
=== modified file 'CHANGES'
--- a/CHANGES	2010-08-06 10:26:14 +0000
+++ b/CHANGES	2010-08-12 15:00:17 +0000
@@ -1,3 +1,4 @@
+- Fix authorization popup after modifying stored procedure in VS (Bug #44715)
 - Dispose EventLog after use in MySql.Web.dll provider classes, to avoid wasting resources
   (Bug #55793)
 - Handle cases where server returns unparsable (out-of-range) double values

=== modified file 'MySql.VisualStudio/Nodes/BaseNode.cs'
--- a/MySql.VisualStudio/Nodes/BaseNode.cs	2010-02-12 18:11:12 +0000
+++ b/MySql.VisualStudio/Nodes/BaseNode.cs	2010-08-12 15:00:17 +0000
@@ -395,51 +395,18 @@ namespace MySql.Data.VisualStudio
             manager.SelectConnection(connection);
         }
 
-        public void RefreshServerExplorer()
+        #endregion
+
+        /// <summary>
+        /// Refresh database node in server explorer
+        /// </summary>
+        public void Refresh()
         {
-            // Select connection node to have all content refreshed. 
             SelectConnectionNode();
-
-            // Predefined IDs (constans are available only in H files)             
-            Guid seToolWindow = new Guid("{74946827-37A0-11D2-A273-00C04F8EF4FF}");
-            Guid cmdGroup = new Guid("{74D21311-2AEE-11d1-8BFB-00A0C90F26F7}");
-
-            // Get server explorer window
-            IVsUIShell uiShell = Package.GetGlobalService(typeof(IVsUIShell)) as IVsUIShell;
-
-            IVsWindowFrame frame;
-            uiShell.FindToolWindow(0, ref seToolWindow, out frame);
-            if (frame == null)
-                return;
-
-            // Determine if server explorer window is currently visible
-            bool isVisible = frame.IsVisible() == 0;
-
-            // Display server explorer window, if not visible
-            if (!isVisible)
-                frame.ShowNoActivate();
-
-            // Get OLE command target
-            IOleCommandTarget target = frame as IOleCommandTarget;
-            if (target == null)
-                return;
-
-            // Executes command for selected node (connection node should be selected - only 
-            // in this case all content will be refreshed)
-            int result = target.Exec(
-                ref cmdGroup,
-                0x03004,
-                0,
-                IntPtr.Zero,
-                IntPtr.Zero);
-
-            // Hide server explorer if should be hidden
-            if (!isVisible)
-                frame.Hide();
-
-            Debug.Assert(ErrorHandler.Succeeded(result), "Error while executing refresh command for server explorer!");
+            IVsUIHierarchy hier = HierarchyAccessor.Hierarchy as IVsUIHierarchy;
+            Guid g = VSConstants.GUID_VSStandardCommandSet97;
+            hier.ExecCommand(VSConstants.VSITEMID_ROOT, ref g, (uint)VSConstants.VSStd97CmdID.Refresh, 
+                (uint)OleCommandExecutionOption.DoDefault, IntPtr.Zero, IntPtr.Zero);
         }
-
-        #endregion
 	}
 }

=== modified file 'MySql.VisualStudio/Nodes/DocumentNode.cs'
--- a/MySql.VisualStudio/Nodes/DocumentNode.cs	2010-02-12 18:11:12 +0000
+++ b/MySql.VisualStudio/Nodes/DocumentNode.cs	2010-08-12 15:00:17 +0000
@@ -101,6 +101,7 @@ namespace MySql.Data.VisualStudio
             return VSConstants.S_OK;
         }
 
+
         public int SaveDocData(VSSAVEFLAGS dwSave, out string pbstrMkDocumentNew, out int pfSaveCanceled)
         {
             string oldMoniker = Moniker;
@@ -131,9 +132,10 @@ namespace MySql.Data.VisualStudio
                 Name = GetCurrentName();
                 pbstrMkDocumentNew = String.Format("/Connection/{0}s/{1}", NodeId, Name);
                 VsShellUtilities.RenameDocument(MySqlDataProviderPackage.Instance, oldMoniker, Moniker);
-
+                 
                 // update server explorer
-                RefreshServerExplorer();
+                Refresh();
+
                 Load();
             }
             return VSConstants.S_OK;

=== modified file 'MySql.VisualStudio/Nodes/TriggerNode.cs'
--- a/MySql.VisualStudio/Nodes/TriggerNode.cs	2009-05-29 21:30:21 +0000
+++ b/MySql.VisualStudio/Nodes/TriggerNode.cs	2010-08-12 15:00:17 +0000
@@ -39,6 +39,7 @@ namespace MySql.Data.VisualStudio
 	{
 		private string sql_mode;
         private TextBufferEditor editor;
+        string table;
 
 		public TriggerNode(DataViewHierarchyAccessor hierarchyAccessor, int id) : 
 			base(hierarchyAccessor, id)
@@ -128,6 +129,7 @@ namespace MySql.Data.VisualStudio
                     MessageBox.Show("Unable to load object with error: " + ex.Message);
                 }
             }
+            table = GetTargetedTable(editor.Text);
 		}
 
         /// <summary>
@@ -142,7 +144,7 @@ namespace MySql.Data.VisualStudio
                 string sql = editor.Text.Trim();
                 if (!IsNew)
                 {
-                    MakeSureWeAreNotChangingTables();
+                    MakeSureWeAreNotChangingTables(sql);
 
                     // first we need to check the syntax of our changes.  THis will throw
                     // an exception if the syntax is bad
@@ -167,19 +169,18 @@ namespace MySql.Data.VisualStudio
         ///  this because we don't want the user using an 'ALTER' script to move a trigger to a 
         ///  different table
         /// </summary>
-        private void MakeSureWeAreNotChangingTables()
+        private void MakeSureWeAreNotChangingTables(string sql)
         {
-            string tableName = GetTargetedTable();
-            object parentItemId = HierarchyAccessor.GetProperty(ItemId, (int)__VSHPROPID.VSHPROPID_Parent);
-            string parentName = HierarchyAccessor.GetNodeName((int)parentItemId);
-            if (tableName.ToLowerInvariant() != parentName.ToLowerInvariant())
+            string newTable = GetTargetedTable(sql);
+            if (table != null && newTable != null && 
+                newTable.ToLowerInvariant() != table.ToLowerInvariant())
                 throw new InvalidOperationException(
-                    String.Format(Resources.AlterTriggerOnWrongTable, Name, tableName));
+                    String.Format(Resources.AlterTriggerOnWrongTable, Name, newTable));
         }
 
-        private string GetTargetedTable()
+        private string GetTargetedTable(string sql)
         {
-            MySqlTokenizer tokenizer = new MySqlTokenizer(editor.Text.Trim());
+            MySqlTokenizer tokenizer = new MySqlTokenizer(sql);
             tokenizer.ReturnComments = false;
             tokenizer.AnsiQuotes = sql_mode.ToLowerInvariant().Contains("ansi_quotes");
             tokenizer.BackslashEscapes = !sql_mode.ToLowerInvariant().Contains("no_backslash_escapes");


Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20100812150017-b074qvztbyaj72p7.bundle
Thread
bzr commit into connector-net-6.0 branch (vvaintroub:833) Bug#44715Vladislav Vaintroub12 Aug