#if MYSQL_6_10 // Copyright © 2004, 2018, Oracle and/or its affiliates. All rights reserved. // // MySQL Connector/NET is licensed under the terms of the GPLv2 // , like most // MySQL Connectors. There are special exceptions to the terms and // conditions of the GPLv2 as it is applied to this software, see the // FLOSS License Exception // . // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published // by the Free Software Foundation; version 2 of the License. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA using System; using System.ComponentModel; using System.Data; using System.Data.Common; using System.Security; using System.Drawing; using System.Security.Permissions; using System.Transactions; namespace Externals.MySql.Data.MySqlClient { [DesignerCategory("Code")] [ToolboxItem(true)] internal sealed partial class MySqlConnection : DbConnection, ICloneable { /// /// Returns schema information for the data source of this . /// /// A that contains schema information. public override DataTable GetSchema() { return GetSchema(null); } /// /// Returns schema information for the data source of this /// using the specified string for the schema name. /// /// Specifies the name of the schema to return. /// A that contains schema information. public override DataTable GetSchema(string collectionName) { if (collectionName == null) collectionName = SchemaProvider.MetaCollection; return GetSchema(collectionName, null); } /// /// Returns schema information for the data source of this /// using the specified string for the schema name and the specified string array /// for the restriction values. /// /// Specifies the name of the schema to return. /// Specifies a set of restriction values for the requested schema. /// A that contains schema information. public override DataTable GetSchema(string collectionName, string[] restrictionValues) { if (collectionName == null) collectionName = SchemaProvider.MetaCollection; string[] restrictions = _schemaProvider.CleanRestrictions(restrictionValues); MySqlSchemaCollection c = _schemaProvider.GetSchema(collectionName, restrictions); return c.AsDataTable(); } /// /// Enlists in the specified transaction. /// /// /// A reference to an existing in which to enlist. /// public override void EnlistTransaction(Transaction transaction) { // enlisting in the null transaction is a noop if (transaction == null) return; // guard against trying to enlist in more than one transaction if (driver.currentTransaction != null) { if (driver.currentTransaction.BaseTransaction == transaction) return; Throw(new MySqlException("Already enlisted")); } // now see if we need to swap out drivers. We would need to do this since // we have to make sure all ops for a given transaction are done on the // same physical connection. Driver existingDriver = DriverTransactionManager.GetDriverInTransaction(transaction); if (existingDriver != null) { // we can't allow more than one driver to contribute to the same connection if (existingDriver.IsInActiveUse) Throw(new NotSupportedException(Resources.MultipleConnectionsInTransactionNotSupported)); // there is an existing driver and it's not being currently used. // now we need to see if it is using the same connection string string text1 = existingDriver.Settings.ConnectionString; string text2 = Settings.ConnectionString; if (String.Compare(text1, text2, true) != 0) Throw(new NotSupportedException(Resources.MultipleConnectionsInTransactionNotSupported)); // close existing driver // set this new driver as our existing driver CloseFully(); driver = existingDriver; } if (driver.currentTransaction == null) { MySqlPromotableTransaction t = new MySqlPromotableTransaction(this, transaction); if (!transaction.EnlistPromotableSinglePhase(t)) Throw(new NotSupportedException(Resources.DistributedTxnNotSupported)); driver.currentTransaction = t; DriverTransactionManager.SetDriverInTransaction(driver); driver.IsInActiveUse = true; } } void AssertPermissions() { // Security Asserts can only be done when the assemblies // are put in the GAC as documented in // http://msdn.microsoft.com/en-us/library/ff648665.aspx if (this.Settings.IncludeSecurityAsserts) { PermissionSet set = new PermissionSet(PermissionState.None); set.AddPermission(new MySqlClientPermission(ConnectionString)); set.Demand(); MySqlSecurityPermission.CreatePermissionSet(true).Assert(); } } /// /// Creates a new MySqlConnection object with the exact same ConnectionString value /// /// A cloned MySqlConnection object public object Clone() { MySqlConnection clone = new MySqlConnection(); string connectionString = Settings.ConnectionString; if (connectionString != null) clone.ConnectionString = connectionString; return clone; } } } #endif