You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.5 KiB

4 years ago
  1. #if MYSQL_6_9
  2. // Copyright © 2004, 2018 Oracle and/or its affiliates. All rights reserved.
  3. //
  4. // MySQL Connector/NET is licensed under the terms of the GPLv2
  5. // <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
  6. // MySQL Connectors. There are special exceptions to the terms and
  7. // conditions of the GPLv2 as it is applied to this software, see the
  8. // FLOSS License Exception
  9. // <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
  10. //
  11. // This program is free software; you can redistribute it and/or modify
  12. // it under the terms of the GNU General Public License as published
  13. // by the Free Software Foundation; version 2 of the License.
  14. //
  15. // This program is distributed in the hope that it will be useful, but
  16. // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  18. // for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License along
  21. // with this program; if not, write to the Free Software Foundation, Inc.,
  22. // 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  23. using Externals.MySql.Data.MySqlClient.Properties;
  24. using System;
  25. using System.ComponentModel;
  26. using System.Data;
  27. using System.Data.Common;
  28. using System.Drawing;
  29. using System.Security;
  30. using System.Security.Permissions;
  31. namespace Externals.MySql.Data.MySqlClient
  32. {
  33. [ToolboxBitmap(typeof(MySqlConnection), "MySqlClient.resources.connection.bmp")]
  34. [DesignerCategory("Code")]
  35. [ToolboxItem(true)]
  36. internal sealed partial class MySqlConnection : DbConnection, ICloneable
  37. {
  38. private bool disposed = false;
  39. /// <summary>
  40. /// Returns schema information for the data source of this <see cref="DbConnection"/>.
  41. /// </summary>
  42. /// <returns>A <see cref="DataTable"/> that contains schema information. </returns>
  43. public override DataTable GetSchema()
  44. {
  45. return GetSchema(null);
  46. }
  47. /// <summary>
  48. /// Returns schema information for the data source of this
  49. /// <see cref="DbConnection"/> using the specified string for the schema name.
  50. /// </summary>
  51. /// <param name="collectionName">Specifies the name of the schema to return. </param>
  52. /// <returns>A <see cref="DataTable"/> that contains schema information. </returns>
  53. public override DataTable GetSchema(string collectionName)
  54. {
  55. if (collectionName == null)
  56. collectionName = SchemaProvider.MetaCollection;
  57. return GetSchema(collectionName, null);
  58. }
  59. /// <summary>
  60. /// Returns schema information for the data source of this <see cref="DbConnection"/>
  61. /// using the specified string for the schema name and the specified string array
  62. /// for the restriction values.
  63. /// </summary>
  64. /// <param name="collectionName">Specifies the name of the schema to return.</param>
  65. /// <param name="restrictionValues">Specifies a set of restriction values for the requested schema.</param>
  66. /// <returns>A <see cref="DataTable"/> that contains schema information.</returns>
  67. public override DataTable GetSchema(string collectionName, string[] restrictionValues)
  68. {
  69. if (collectionName == null)
  70. collectionName = SchemaProvider.MetaCollection;
  71. string[] restrictions = schemaProvider.CleanRestrictions(restrictionValues);
  72. MySqlSchemaCollection c = schemaProvider.GetSchema(collectionName, restrictions);
  73. return c.AsDataTable();
  74. }
  75. protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
  76. {
  77. if (isolationLevel == IsolationLevel.Unspecified)
  78. return BeginTransaction();
  79. return BeginTransaction(isolationLevel);
  80. }
  81. protected override DbCommand CreateDbCommand()
  82. {
  83. return CreateCommand();
  84. }
  85. partial void AssertPermissions()
  86. {
  87. // Security Asserts can only be done when the assemblies
  88. // are put in the GAC as documented in
  89. // http://msdn.microsoft.com/en-us/library/ff648665.aspx
  90. if (this.Settings.IncludeSecurityAsserts)
  91. {
  92. PermissionSet set = new PermissionSet(PermissionState.None);
  93. set.AddPermission(new MySqlClientPermission(ConnectionString));
  94. set.Demand();
  95. MySqlSecurityPermission.CreatePermissionSet(true).Assert();
  96. }
  97. }
  98. #region IDisposeable
  99. protected override void Dispose(bool disposing)
  100. {
  101. if (disposed)
  102. return;
  103. if (State == ConnectionState.Open)
  104. Close();
  105. disposed = true;
  106. base.Dispose(disposing);
  107. }
  108. #endregion
  109. }
  110. }
  111. #endif