From: rburnett Date: April 14 2009 9:25pm Subject: Connector/NET commit: r1559 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Provider/Source/docs MySql.Data/Tests/Source List-Archive: http://lists.mysql.com/commits/72072 X-Bug: 44194 Message-Id: <200904142125.n3ELPCUG030573@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/5.2/CHANGES branches/5.2/MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs branches/5.2/MySql.Data/Provider/Source/NativeDriver.cs branches/5.2/MySql.Data/Provider/Source/docs/MySqlConnection.xml branches/5.2/MySql.Data/Tests/Source/CommandTests.cs Log: - added connection string option 'use affected rows'. (bug #44194) Modified: branches/5.2/CHANGES =================================================================== --- branches/5.2/CHANGES 2009-04-08 20:36:25 UTC (rev 1558) +++ branches/5.2/CHANGES 2009-04-14 21:25:11 UTC (rev 1559) @@ -30,6 +30,7 @@ - fixed index and index column schema collections that would fail if you specified the any restrictions more specific than table name (bug #43991) - removed a couple of unnecessary lines from NativeDriver.Open() (bug #44028) +- added connection string option 'use affected rows'. (bug #44194) Version 5.2.5 - 11/14/2008 - fixed problem with package registration that kept the DDEX provider from working (bug #40726) Modified: branches/5.2/MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs =================================================================== --- branches/5.2/MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs 2009-04-08 20:36:25 UTC (rev 1558) +++ branches/5.2/MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs 2009-04-14 21:25:11 UTC (rev 1559) @@ -56,6 +56,7 @@ bool clearing; bool interactiveSession; bool functionsReturnString; + bool useAffectedRows; static MySqlConnectionStringBuilder() { @@ -98,6 +99,7 @@ defaultValues.Add(Keyword.AllowUserVariables, false); defaultValues.Add(Keyword.InteractiveSession, false); defaultValues.Add(Keyword.FunctionsReturnString, false); + defaultValues.Add(Keyword.UseAffectedRows, false); } /// @@ -723,6 +725,22 @@ } } +#if !CF && !MONO + [Category("Advanced")] + [DisplayName("Use Affected Rows")] + [Description("Should the returned affected row count reflect affected rows instead of found rows?")] + [DefaultValue(false)] +#endif + public bool UseAffectedRows + { + get { return useAffectedRows; } + set + { + SetValue("Use Affected Rows", value); + useAffectedRows = value; + } + } + #endregion #region Pooling Properties @@ -1154,6 +1172,8 @@ return Keyword.InteractiveSession; case "functions return string": return Keyword.FunctionsReturnString; + case "use affected rows": + return Keyword.UseAffectedRows; } throw new ArgumentException(Resources.KeywordNotSupported, key); } @@ -1240,6 +1260,8 @@ return interactiveSession; case Keyword.FunctionsReturnString: return functionsReturnString; + case Keyword.UseAffectedRows: + return useAffectedRows; default: return null; /* this will never happen */ } @@ -1348,6 +1370,8 @@ interactiveSession = ConvertToBool(value); break; case Keyword.FunctionsReturnString: functionsReturnString = ConvertToBool(value); break; + case Keyword.UseAffectedRows: + useAffectedRows = ConvertToBool(value); break; } } @@ -1529,6 +1553,7 @@ TreatTinyAsBoolean, AllowUserVariables, InteractiveSession, - FunctionsReturnString + FunctionsReturnString, + UseAffectedRows } } Modified: branches/5.2/MySql.Data/Provider/Source/NativeDriver.cs =================================================================== --- branches/5.2/MySql.Data/Provider/Source/NativeDriver.cs 2009-04-08 20:36:25 UTC (rev 1558) +++ branches/5.2/MySql.Data/Provider/Source/NativeDriver.cs 2009-04-14 21:25:11 UTC (rev 1559) @@ -332,8 +332,12 @@ /// private void SetConnectionFlags() { - ClientFlags flags = ClientFlags.FOUND_ROWS; + // allow load data local infile + ClientFlags flags = ClientFlags.LOCAL_FILES; + if (!Settings.UseAffectedRows) + flags |= ClientFlags.FOUND_ROWS; + if (version.isAtLeast(4, 1, 1)) { flags |= ClientFlags.PROTOCOL_41; @@ -363,9 +367,6 @@ else flags &= ~ClientFlags.LONG_PASSWORD; - // allow load data local infile - flags |= ClientFlags.LOCAL_FILES; - // did the user request an interactive session? if (Settings.InteractiveSession) flags |= ClientFlags.INTERACTIVE; Modified: branches/5.2/MySql.Data/Provider/Source/docs/MySqlConnection.xml =================================================================== --- branches/5.2/MySql.Data/Provider/Source/docs/MySqlConnection.xml 2009-04-08 20:36:25 UTC (rev 1558) +++ branches/5.2/MySql.Data/Provider/Source/docs/MySqlConnection.xml 2009-04-14 21:25:11 UTC (rev 1559) @@ -1086,6 +1086,15 @@ Set this option to true to force the return value of SQL functions to be string. + + Use Affected Rows + false + + Set this option to true to cause the affected rows reported to reflect only the + rows that are actually changed. By default, the number of rows that are matched + is returned. + + Modified: branches/5.2/MySql.Data/Tests/Source/CommandTests.cs =================================================================== --- branches/5.2/MySql.Data/Tests/Source/CommandTests.cs 2009-04-08 20:36:25 UTC (rev 1558) +++ branches/5.2/MySql.Data/Tests/Source/CommandTests.cs 2009-04-14 21:25:11 UTC (rev 1559) @@ -444,6 +444,28 @@ { } } + + /// + /// Bug #44194 ExecuteNonQuery for update commands does not match actual rows updated + /// + [Test] + public void UseAffectedRows() + { + execSQL("INSERT INTO Test VALUES (1, 'A')"); + execSQL("INSERT INTO Test VALUES (2, 'B')"); + execSQL("INSERT INTO Test VALUES (3, 'C')"); + + MySqlCommand cmd = new MySqlCommand("UPDATE Test SET name='C' WHERE id=3", conn); + Assert.AreEqual(1, cmd.ExecuteNonQuery()); + + string conn_str = GetConnectionString(true) + ";use affected rows=true"; + using (MySqlConnection c = new MySqlConnection(conn_str)) + { + c.Open(); + cmd.Connection = c; + Assert.AreEqual(0, cmd.ExecuteNonQuery()); + } + } }