From e011414debf0a96d506ffbccce479fc649a64ae2 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Mon, 14 Jun 2010 16:14:15 +0000 Subject: [PATCH] mysql-connector-net-6.2.3 removed from svn; we're using postgres --- FLocal.sln | 10 - MySQLConnector/MySQLConnector.csproj | 4 - ThirdParty/mysql-connector-net-6.2.3/CHANGES | 47 - ThirdParty/mysql-connector-net-6.2.3/COPYING | 343 - .../mysql-connector-net-6.2.3/EXCEPTIONS | 119 - .../mysql-connector-net-6.2.3/License.txt | 3 - .../MySQL-VS2005.sln | 96 - .../MySQLClient-VS2010.sln | 136 - .../MySQLClient-mono.sln | 166 - .../mysql-connector-net-6.2.3/MySQLClient.sln | 305 - .../MySql.Data/Provider/MySql.Data.CF.csproj | 178 - .../MySql.Data/Provider/MySql.Data.csproj | 315 - .../MySql.Data/Provider/MySql.Data.xml | 6971 ----------------- .../Provider/Properties/AssemblyInfo.cs | 75 - .../Provider/Properties/ReservedWords.txt | 76 - .../Provider/Properties/Resources.Designer.cs | 1147 --- .../Provider/Properties/Resources.resx | 460 -- .../Provider/Properties/VersionInfo.cs | 39 - .../Provider/Properties/keywords.txt | 229 - .../MySql.Data/Provider/Source/BulkLoader.cs | 391 - .../MySql.Data/Provider/Source/CharSetMap.cs | 197 - .../Provider/Source/CommandBuilder.cs | 281 - .../Provider/Source/CompressedStream.cs | 308 - .../MySql.Data/Provider/Source/Connection.cs | 867 -- .../MySql.Data/Provider/Source/Crypt.cs | 338 - .../MySql.Data/Provider/Source/Driver.cs | 513 -- .../MySql.Data/Provider/Source/Exception.cs | 94 - .../MySql.Data/Provider/Source/Field.cs | 417 - .../Provider/Source/ISSchemaProvider.cs | 694 -- .../MySql.Data/Provider/Source/Installer.cs | 192 - .../Provider/Source/MySqlClientFactory.cs | 159 - .../Source/MySqlConnectionStringBuilder.cs | 929 --- .../MySql.Data/Provider/Source/MySqlError.cs | 351 - .../MySql.Data/Provider/Source/MySqlHelper.cs | 406 - .../MySql.Data/Provider/Source/MySqlPacket.cs | 356 - .../MySql.Data/Provider/Source/MySqlPool.cs | 330 - .../Provider/Source/MySqlPoolManager.cs | 153 - .../Source/MySqlPromotableTransaction.cs | 125 - .../MySql.Data/Provider/Source/MySqlScript.cs | 433 - .../MySql.Data/Provider/Source/MySqlStream.cs | 241 - .../MySql.Data/Provider/Source/MySqlTrace.cs | 109 - .../MySql.Data/Provider/Source/MysqlDefs.cs | 410 - .../Provider/Source/NativeDriver.cs | 880 --- .../Provider/Source/PerformanceMonitor.cs | 88 - .../Provider/Source/PreparableStatement.cs | 211 - .../Provider/Source/ProcedureCache.cs | 137 - .../MySql.Data/Provider/Source/ResultSet.cs | 282 - .../MySql.Data/Provider/Source/Runtime.cs | 26 - .../Provider/Source/SchemaProvider.cs | 1030 --- .../MySql.Data/Provider/Source/Statement.cs | 215 - .../Provider/Source/StoredProcedure.cs | 289 - .../MySql.Data/Provider/Source/TimedStream.cs | 297 - .../Provider/Source/TracingDriver.cs | 248 - .../Provider/Source/Types/MetaData.cs | 137 - .../Provider/Source/Types/MySqlBinary.cs | 226 - .../Provider/Source/Types/MySqlBit.cs | 137 - .../Provider/Source/Types/MySqlByte.cs | 171 - .../Source/Types/MySqlConversionException.cs | 39 - .../Provider/Source/Types/MySqlDateTime.cs | 646 -- .../Provider/Source/Types/MySqlDecimal.cs | 173 - .../Provider/Source/Types/MySqlDouble.cs | 147 - .../Provider/Source/Types/MySqlGuid.cs | 241 - .../Provider/Source/Types/MySqlInt16.cs | 141 - .../Provider/Source/Types/MySqlInt32.cs | 161 - .../Provider/Source/Types/MySqlInt64.cs | 140 - .../Provider/Source/Types/MySqlSingle.cs | 146 - .../Provider/Source/Types/MySqlString.cs | 165 - .../Provider/Source/Types/MySqlTime.cs | 206 - .../Provider/Source/Types/MySqlUByte.cs | 140 - .../Provider/Source/Types/MySqlUInt16.cs | 140 - .../Provider/Source/Types/MySqlUInt32.cs | 159 - .../Provider/Source/Types/MySqlUInt64.cs | 140 - .../Provider/Source/Types/MySqlValue.cs | 41 - .../Source/base/DbConnectionStringBuilder.cs | 339 - .../Provider/Source/base/DbException.cs | 60 - .../Provider/Source/cf/BufferedStream.cs | 197 - .../Provider/Source/cf/MissingAttributes.cs | 70 - .../MySql.Data/Provider/Source/cf/WinCE.cs | 34 - .../MySql.Data/Provider/Source/command.cs | 917 --- .../Provider/Source/common/Cache.cs | 76 - .../Provider/Source/common/ContextString.cs | 170 - .../Source/common/LowResolutionStopwatch.cs | 91 - .../Provider/Source/common/MyNetworkStream.cs | 180 - .../Provider/Source/common/MySqlTokenizer.cs | 312 - .../Provider/Source/common/NamedPipeStream.cs | 236 - .../Provider/Source/common/NativeMethods.cs | 154 - .../Provider/Source/common/Platform.cs | 64 - .../Provider/Source/common/QueryNormalizer.cs | 392 - .../MySql.Data/Provider/Source/common/SHA1.cs | 275 - .../Source/common/SharedMemoryStream.cs | 353 - .../Provider/Source/common/SocketStream.cs | 142 - .../Provider/Source/common/StreamCreator.cs | 264 - .../Provider/Source/common/Version.cs | 100 - .../MySql.Data/Provider/Source/dataadapter.cs | 309 - .../MySql.Data/Provider/Source/datareader.cs | 924 --- .../Provider/Source/docs/MySqlCommand.xml | 934 --- .../Source/docs/MySqlCommandBuilder.xml | 321 - .../Provider/Source/docs/MySqlConnection.xml | 1239 --- .../docs/MySqlConnectionStringBuilder.xml | 55 - .../Provider/Source/docs/MySqlDataAdapter.xml | 801 -- .../Provider/Source/docs/MySqlDataReader.xml | 452 -- .../Provider/Source/docs/MySqlException.xml | 53 - .../Provider/Source/docs/MySqlHelper.xml | 53 - .../Provider/Source/docs/MySqlParameter.xml | 45 - .../Source/docs/MySqlParameterCollection.xml | 45 - .../Provider/Source/docs/MySqlTransaction.xml | 329 - .../MySql.Data/Provider/Source/parameter.cs | 714 -- .../Provider/Source/parameter_collection.cs | 501 -- .../MySql.Data/Provider/Source/transaction.cs | 111 - .../Provider/Source/zlib/Adler32.cs | 108 - .../Provider/Source/zlib/Deflate.cs | 1799 ----- .../Provider/Source/zlib/InfBlocks.cs | 720 -- .../Provider/Source/zlib/InfCodes.cs | 716 -- .../Provider/Source/zlib/InfTree.cs | 377 - .../Provider/Source/zlib/Inflate.cs | 450 -- .../Provider/Source/zlib/StaticTree.cs | 93 - .../Provider/Source/zlib/SupportClass.cs | 219 - .../MySql.Data/Provider/Source/zlib/Tree.cs | 349 - .../Provider/Source/zlib/ZInputStream.cs | 196 - .../Provider/Source/zlib/ZOutputStream.cs | 282 - .../Provider/Source/zlib/ZStream.cs | 233 - .../Provider/Source/zlib/ZStreamException.cs | 57 - .../MySql.Data/Provider/Source/zlib/Zlib.cs | 83 - .../Tests/MySql.Data.CF.Tests.csproj | 119 - .../MySql.Data/Tests/MySql.Data.Tests.csproj | 148 - .../Tests/Properties/AssemblyInfo.cs | 65 - .../MySql.Data/Tests/Properties/Setup.sql | 17 - .../MySql.Data/Tests/Source/AsyncTests.cs | 111 - .../MySql.Data/Tests/Source/BaseTest.cs | 343 - .../MySql.Data/Tests/Source/BlobTests.cs | 366 - .../MySql.Data/Tests/Source/BulkLoading.cs | 366 - .../Tests/Source/CharacterSetTests.cs | Bin 25290 -> 0 bytes .../Tests/Source/CommandBuilderTests.cs | 389 - .../MySql.Data/Tests/Source/CommandTests.cs | 498 -- .../Tests/Source/ConfigurationManager.cs | 101 - .../Tests/Source/ConnectionStringBuilder.cs | 118 - .../Tests/Source/ConnectionTests.cs | 495 -- .../MySql.Data/Tests/Source/CultureTests.cs | 140 - .../MySql.Data/Tests/Source/CursorTests.cs | 157 - .../Tests/Source/DataAdapterTests.cs | 848 -- .../Tests/Source/DataReaderTests.cs | 801 -- .../MySql.Data/Tests/Source/DataTypeTests.cs | 1062 --- .../MySql.Data/Tests/Source/DateTimeTests.cs | 430 - .../MySql.Data/Tests/Source/EventTests.cs | 75 - .../MySql.Data/Tests/Source/ExceptionTests.cs | 89 - .../MySql.Data/Tests/Source/GetSchemaTests.cs | 554 -- .../MySql.Data/Tests/Source/InterfaceTests.cs | 56 - .../MySql.Data/Tests/Source/LanguageTests.cs | 302 - .../MySql.Data/Tests/Source/Logging.cs | 112 - .../MySql.Data/Tests/Source/ParameterTests.cs | 545 -- .../MySql.Data/Tests/Source/PerfMonTests.cs | 88 - .../MySql.Data/Tests/Source/PoolingTests.cs | 468 -- .../Tests/Source/PreparedStatements.cs | 898 --- .../Tests/Source/ProcedureParameters.cs | 371 - .../Tests/Source/ScriptExecution.cs | 235 - .../Tests/Source/SimpleTransactions.cs | 162 - .../MySql.Data/Tests/Source/SqlTokenizer.cs | 58 - .../Tests/Source/StoredProcedure.cs | 1293 --- .../Tests/Source/StoredProcedureWithAccess.cs | 395 - .../MySql.Data/Tests/Source/StressTests.cs | 184 - .../MySql.Data/Tests/Source/Syntax.cs | 472 -- .../MySql.Data/Tests/Source/Syntax2.cs | 170 - .../Tests/Source/Tester/TestClasses.cs | 151 - .../Tests/Source/Tester/TestRunner.cs | 200 - .../MySql.Data/Tests/Source/Threading.cs | 125 - .../Tests/Source/TimeoutAndCancel.cs | 292 - .../MySql.Data/Tests/Source/Tokenizer.cs | 276 - .../MySql.Data/Tests/Source/Transactions.cs | 506 -- .../MySql.Data/Tests/Source/UsageAdvisor.cs | 202 - .../MySql.Data/Tests/Source/Utils.cs | 40 - .../MySql.Data/Tests/configs/mysql-41.config | 8 - .../MySql.Data/Tests/configs/mysql-50.config | 8 - .../MySql.Data/Tests/configs/mysql-51.config | 8 - ThirdParty/mysql-connector-net-6.2.3/README | 68 - .../Release Notes.txt | 19 - 175 files changed, 58210 deletions(-) delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/CHANGES delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/COPYING delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/EXCEPTIONS delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/License.txt delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySQL-VS2005.sln delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySQLClient-VS2010.sln delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySQLClient-mono.sln delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySQLClient.sln delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/MySql.Data.CF.csproj delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/MySql.Data.csproj delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/MySql.Data.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/AssemblyInfo.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/ReservedWords.txt delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/Resources.Designer.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/Resources.resx delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/VersionInfo.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/keywords.txt delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/BulkLoader.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CharSetMap.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CommandBuilder.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CompressedStream.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Connection.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Crypt.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Driver.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Exception.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Field.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ISSchemaProvider.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Installer.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlClientFactory.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlError.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlHelper.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPacket.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPool.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPoolManager.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPromotableTransaction.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlScript.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlStream.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlTrace.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MysqlDefs.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/NativeDriver.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/PerformanceMonitor.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/PreparableStatement.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ProcedureCache.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ResultSet.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Runtime.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/SchemaProvider.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Statement.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/StoredProcedure.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/TimedStream.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/TracingDriver.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MetaData.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlBinary.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlBit.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlByte.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlConversionException.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDateTime.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDecimal.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDouble.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlGuid.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt16.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt32.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt64.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlSingle.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlString.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlTime.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUByte.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt16.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt32.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt64.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlValue.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/base/DbConnectionStringBuilder.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/base/DbException.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/BufferedStream.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/MissingAttributes.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/WinCE.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/command.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Cache.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/ContextString.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/LowResolutionStopwatch.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/MyNetworkStream.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/MySqlTokenizer.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/NamedPipeStream.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/NativeMethods.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Platform.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/QueryNormalizer.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SHA1.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SharedMemoryStream.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SocketStream.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/StreamCreator.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Version.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/dataadapter.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/datareader.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlCommand.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlCommandBuilder.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlConnection.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlConnectionStringBuilder.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlDataAdapter.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlDataReader.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlException.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlHelper.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlParameter.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlParameterCollection.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlTransaction.xml delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/parameter.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/parameter_collection.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/transaction.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Adler32.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Deflate.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfBlocks.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfCodes.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfTree.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Inflate.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/StaticTree.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/SupportClass.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Tree.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZInputStream.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZOutputStream.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZStream.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZStreamException.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Zlib.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/MySql.Data.CF.Tests.csproj delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/MySql.Data.Tests.csproj delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Properties/AssemblyInfo.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Properties/Setup.sql delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/AsyncTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BaseTest.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BlobTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BulkLoading.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CharacterSetTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CommandBuilderTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CommandTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConfigurationManager.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConnectionStringBuilder.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConnectionTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CultureTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CursorTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataAdapterTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataReaderTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataTypeTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DateTimeTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/EventTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ExceptionTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/GetSchemaTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/InterfaceTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/LanguageTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Logging.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ParameterTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PerfMonTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PoolingTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PreparedStatements.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ProcedureParameters.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ScriptExecution.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/SimpleTransactions.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/SqlTokenizer.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StoredProcedure.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StoredProcedureWithAccess.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StressTests.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Syntax.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Syntax2.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tester/TestClasses.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tester/TestRunner.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Threading.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/TimeoutAndCancel.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tokenizer.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Transactions.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/UsageAdvisor.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Utils.cs delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-41.config delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-50.config delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-51.config delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/README delete mode 100644 ThirdParty/mysql-connector-net-6.2.3/Release Notes.txt diff --git a/FLocal.sln b/FLocal.sln index 7e5a334..5ef4cdb 100644 --- a/FLocal.sln +++ b/FLocal.sln @@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySQLConnector", "MySQLConnector\MySQLConnector.csproj", "{E38DE5B1-F9C2-43BA-A5DF-0743ABD4DFC7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySql.Data", "ThirdParty\mysql-connector-net-6.2.3\MySql.Data\Provider\MySql.Data.csproj", "{E9DF5ED1-4CBD-4226-B931-9A51610AC14D}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Builder\Builder.csproj", "{D8D6EFEC-76D7-4870-BD71-C90FA6D7368A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tmp", "tmp\tmp.csproj", "{BDC42785-41F7-4C32-880E-A6C43A448054}" @@ -47,14 +45,6 @@ Global {E38DE5B1-F9C2-43BA-A5DF-0743ABD4DFC7}.Release|Any CPU.ActiveCfg = Release|Any CPU {E38DE5B1-F9C2-43BA-A5DF-0743ABD4DFC7}.Release|Any CPU.Build.0 = Release|Any CPU {E38DE5B1-F9C2-43BA-A5DF-0743ABD4DFC7}.Release|x86.ActiveCfg = Release|Any CPU - {E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Debug|x86.ActiveCfg = Debug|x86 - {E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Debug|x86.Build.0 = Debug|x86 - {E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Release|Any CPU.Build.0 = Release|Any CPU - {E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Release|x86.ActiveCfg = Release|x86 - {E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Release|x86.Build.0 = Release|x86 {D8D6EFEC-76D7-4870-BD71-C90FA6D7368A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D8D6EFEC-76D7-4870-BD71-C90FA6D7368A}.Debug|Any CPU.Build.0 = Debug|Any CPU {D8D6EFEC-76D7-4870-BD71-C90FA6D7368A}.Debug|x86.ActiveCfg = Debug|Any CPU diff --git a/MySQLConnector/MySQLConnector.csproj b/MySQLConnector/MySQLConnector.csproj index dc22f9d..e9e78ce 100644 --- a/MySQLConnector/MySQLConnector.csproj +++ b/MySQLConnector/MySQLConnector.csproj @@ -64,10 +64,6 @@ {6F532626-E9F8-498E-9683-1538E7CD62CB} Core - - {E9DF5ED1-4CBD-4226-B931-9A51610AC14D} - MySql.Data - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/MySql.Data.csproj b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/MySql.Data.csproj deleted file mode 100644 index 79abda9..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/MySql.Data.csproj +++ /dev/null @@ -1,315 +0,0 @@ - - - - Local - 9.0.30729 - 2.0 - {E9DF5ED1-4CBD-4226-B931-9A51610AC14D} - Debug - AnyCPU - - - - - MySql.Data - - - JScript - Grid - IE50 - false - Library - MySql.Data.MySqlClient - OnBuildSuccess - - - - - - - false - 3.5 - v2.0 - false - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - - - bin\Debug\ - true - full - false - TRACE;DEBUG;WINDOWS - prompt - 4 - false - 285212672 - false - - - MySql.Data.xml - 4096 - false - 1591 - false - false - false - false - 4 - false - - - AllRules.ruleset - - - bin\Release\ - true - full - false - TRACE;DEBUG;WINDOWS - false - 285212672 - false - - - MySql.Data.xml - 4096 - false - 1591 - false - false - false - 4 - AllRules.ruleset - - - true - bin\x86\Debug\ - TRACE;DEBUG;WINDOWS NET20 - 285212672 - doc.xml - x86 - true - GlobalSuppressions.cs - AllRules.ruleset - - - true - full - false - TRACE;DEBUG;WINDOWS NET20 - bin\x86\Release\ - 285212672 - doc.xml - x86 - true - GlobalSuppressions.cs - AllRules.ruleset - - - - System - - - - System.Data - - - System.Design - - - System.Drawing - - - - System.XML - - - - - - - - - - - - - - - - - - - - Component - - - - - - - - - - Component - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Designer - PublicResXFileCodeGenerator - Resources.Designer.cs - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - Code - - - - - - - - CHANGES - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 2.0 %28x86%29 - false - - - False - .NET Framework 3.0 %28x86%29 - false - - - False - .NET Framework 3.5 - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Microsoft Visual Basic PowerPacks 10.0 - true - - - False - Windows Installer 3.1 - true - - - - - - - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/MySql.Data.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/MySql.Data.xml deleted file mode 100644 index a76ff91..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/MySql.Data.xml +++ /dev/null @@ -1,6971 +0,0 @@ - - - - MySql.Data - - - - - Wrapper around NetworkStream. - - MyNetworkStream is equivalent to NetworkStream, except - 1. It throws TimeoutException if read or write timeout occurs, instead - of IOException, to match behavior of other streams (named pipe and - shared memory). This property comes handy in TimedStream. - - 2. It implements workarounds for WSAEWOULDBLOCK errors, that can start - occuring after stream has times out. For a discussion about the CLR bug, - refer to http://tinyurl.com/lhgpyf. This error should never occur, as - we're not using asynchronous operations, but apparerntly it does occur - directly after timeout has expired. - The workaround is hinted in the URL above and implemented like this: - For each IO operation, if it throws WSAEWOULDBLOCK, we explicitely set - the socket to Blocking and retry the operation once again. - - - - Returns the total number of bytes input so far. - - - Returns the total number of bytes output so far. - - - - By creating a private ctor, we keep the compiler from creating a default ctor - - - - - The exception that is thrown when MySQL returns an error. This class cannot be inherited. - - - - This class is created whenever the MySql Data Provider encounters an error generated from the server. - - - Any open connections are not automatically closed when an exception is thrown. If - the client application determines that the exception is fatal, it should close any open - objects or objects. - - - The following example generates a MySqlException due to a missing server, - and then displays the exception. - - - Public Sub ShowException() - Dim mySelectQuery As String = "SELECT column1 FROM table1" - Dim myConnection As New MySqlConnection ("Data Source=localhost;Database=Sample;") - Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) - - Try - myCommand.Connection.Open() - Catch e As MySqlException - MessageBox.Show( e.Message ) - End Try - End Sub - - - public void ShowException() - { - string mySelectQuery = "SELECT column1 FROM table1"; - MySqlConnection myConnection = - new MySqlConnection("Data Source=localhost;Database=Sample;"); - MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection); - - try - { - myCommand.Connection.Open(); - } - catch (MySqlException e) - { - MessageBox.Show( e.Message ); - } - } - - - - - - Gets a number that identifies the type of error. - - - - - True if this exception was fatal and cause the closing of the connection, false otherwise. - - - - - Summary description for Version. - - - - - Read a single quoted identifier from the stream - - - - - - - DBProviderFactory implementation for MysqlClient. - - - - - Gets an instance of the . - This can be used to retrieve strongly typed data objects. - - - - - Returns a strongly typed instance. - - A new strongly typed instance of DbCommandBuilder. - - - - Returns a strongly typed instance. - - A new strongly typed instance of DbCommand. - - - - Returns a strongly typed instance. - - A new strongly typed instance of DbConnection. - - - - Returns a strongly typed instance. - - A new strongly typed instance of DbDataAdapter. - - - - Returns a strongly typed instance. - - A new strongly typed instance of DbParameter. - - - - Returns a strongly typed instance. - - A new strongly typed instance of DbConnectionStringBuilder. - - - - Returns true if a MySqlDataSourceEnumerator can be created; - otherwise false. - - - - - Provide a simple caching layer - - - - - Provides a means of reading a forward-only stream of rows from a MySQL database. This class cannot be inherited. - - - To create a MySQLDataReader, you must call the - method of the object, rather than directly using a constructor. - - - While the MySqlDataReader is in use, the associated - is busy serving the MySqlDataReader, and no other operations can be performed - on the MySqlConnection other than closing it. This is the case until the - method of the MySqlDataReader is called. - - - and - are the only properties that you can call after the MySqlDataReader is - closed. Though the RecordsAffected property may be accessed at any time - while the MySqlDataReader exists, always call Close before returning - the value of RecordsAffected to ensure an accurate return value. - - - For optimal performance, MySqlDataReader avoids creating - unnecessary objects or making unnecessary copies of data. As a result, multiple calls - to methods such as return a reference to the - same object. Use caution if you are modifying the underlying value of the objects - returned by methods such as GetValue. - - - The following example creates a , - a , and a MySqlDataReader. The example reads through - the data, writing it out to the console. Finally, the example closes the MySqlDataReader, then the - MySqlConnection. - - Public Sub ReadMyData(myConnString As String) - Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders" - Dim myConnection As New MySqlConnection(myConnString) - Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) - myConnection.Open() - Dim myReader As MySqlDataReader - myReader = myCommand.ExecuteReader() - ' Always call Read before accessing data. - While myReader.Read() - Console.WriteLine((myReader.GetInt32(0) & ", " & myReader.GetString(1))) - End While - ' always call Close when done reading. - myReader.Close() - ' Close the connection when done with it. - myConnection.Close() - End Sub 'ReadMyData - - - public void ReadMyData(string myConnString) { - string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders"; - MySqlConnection myConnection = new MySqlConnection(myConnString); - MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection); - myConnection.Open(); - MySqlDataReader myReader; - myReader = myCommand.ExecuteReader(); - // Always call Read before accessing data. - while (myReader.Read()) { - Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1)); - } - // always call Close when done reading. - myReader.Close(); - // Close the connection when done with it. - myConnection.Close(); - } - - - - - - Closes the MySqlDataReader object. - - - - - Gets the value of the specified column as a Boolean. - - - - - - - Gets the value of the specified column as a Boolean. - - - - - - - Gets the value of the specified column as a byte. - - - - - - - Gets the value of the specified column as a byte. - - - - - - - Gets the value of the specified column as a sbyte. - - - - - - - Gets the value of the specified column as a sbyte. - - - - - - - Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset. - - The zero-based column ordinal. - The index within the field from which to begin the read operation. - The buffer into which to read the stream of bytes. - The index for buffer to begin the read operation. - The maximum length to copy into the buffer. - The actual number of bytes read. - - - - - Gets the value of the specified column as a single character. - - - - - - - Gets the value of the specified column as a single character. - - - - - - - Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset. - - - - - - - - - - - Gets the name of the source data type. - - - - - - - Gets the value of the specified column as a object. - - - No conversions are performed; therefore, the data retrieved must already be a DateTime object. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal or column name.The value of the specified column. - - - - Gets the value of the specified column as a object. - - - No conversions are performed; therefore, the data retrieved must already be a DateTime object. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal or column name.The value of the specified column. - - - - Gets the value of the specified column as a object. - - - No conversions are performed; therefore, the data retrieved must already be a DateTime object. - - - Call IsDBNull to check for null values before calling this method. - - - - MySql allows date columns to contain the value '0000-00-00' and datetime - columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain - or represent these values. To read a datetime value from a column that might - contain zero values, use . - - - The behavior of reading a zero datetime column using this method is defined by the - ZeroDateTimeBehavior connection string option. For more information on this option, - please refer to . - - - The column name.The value of the specified column. - - - - Gets the value of the specified column as a object. - - - No conversions are performed; therefore, the data retrieved must already be a DateTime object. - - - Call IsDBNull to check for null values before calling this method. - - - - MySql allows date columns to contain the value '0000-00-00' and datetime - columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain - or represent these values. To read a datetime value from a column that might - contain zero values, use . - - - The behavior of reading a zero datetime column using this method is defined by the - ZeroDateTimeBehavior connection string option. For more information on this option, - please refer to . - - - The zero-based column ordinal.The value of the specified column. - - - - Gets the value of the specified column as a object. - - - No conversions are performed; therefore, the data retrieved must already be a Decimal object. - - - Call IsDBNull to check for null values before calling this method. - - The column nameThe value of the specified column. - - - - Gets the value of the specified column as a object. - - - No conversions are performed; therefore, the data retrieved must already be a Decimal object. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinalThe value of the specified column. - - - Gets the value of the specified column as a double-precision floating point number. - - No conversions are performed; therefore, the data retrieved must already be a Double object. - - - Call IsDBNull to check for null values before calling this method. - - The column nameThe value of the specified column. - - - Gets the value of the specified column as a double-precision floating point number. - - No conversions are performed; therefore, the data retrieved must already be a Double object. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal.The value of the specified column. - - - - Gets the Type that is the data type of the object. - - - - - - - Gets the value of the specified column as a single-precision floating point number. - - - No conversions are performed; therefore, the data retrieved must already be a Float object. - - - Call IsDBNull to check for null values before calling this method. - - The column nameThe value of the specified column. - - - - Gets the value of the specified column as a single-precision floating point number. - - - No conversions are performed; therefore, the data retrieved must already be a Float object. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal.The value of the specified column. - - - - - - - - - Gets the value of the specified column as a 16-bit signed integer. - - No conversions are performed; threfore, the data retrieved must already be a 16 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - The column nameThe value of the specified column. - - - Gets the value of the specified column as a 16-bit signed integer. - - No conversions are performed; therefore, the data retrieved must already be a 16 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal.The value of the specified column. - - - Gets the value of the specified column as a 32-bit signed integer. - - No conversions are performed; therefore, the data retrieved must already be a 32 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - The column name.The value of the specified column. - - - Gets the value of the specified column as a 32-bit signed integer. - - No conversions are performed; therefore, the data retrieved must already be a 32 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal.The value of the specified column. - - - Gets the value of the specified column as a 64-bit signed integer. - - No conversions are performed; therefore, the data retrieved must already be a 64 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - The column name.The value of the specified column. - - - Gets the value of the specified column as a 64-bit signed integer. - - No conversions are performed; therefore, the data retrieved must already be a 64 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal.The value of the specified column. - - - - Gets the name of the specified column. - - - - - - - Gets the column ordinal, given the name of the column. - - - - - - - Returns a DataTable that describes the column metadata of the MySqlDataReader. - - - - - - Gets the value of the specified column as a object. - - - No conversions are performed; therefore, the data retrieved must already be a String object. - - - Call IsDBNull to check for null values before calling this method. - - The column name.The value of the specified column. - - - - Gets the value of the specified column as a object. - - - No conversions are performed; therefore, the data retrieved must already be a String object. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal.The value of the specified column. - - - - Gets the value of the specified column as a object. - - - No conversions are performed; therefore, the data retrieved must already be a Time value. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal or column name.The value of the specified column. - - - - Gets the value of the specified column as a object. - - - No conversions are performed; therefore, the data retrieved must already be a Time value. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal or column name.The value of the specified column. - - - - Gets the value of the specified column in its native format. - - - - - - - Gets all attribute columns in the collection for the current row. - - - - - - Gets the value of the specified column as a 16-bit unsigned integer. - - No conversions are performed; therefore, the data retrieved must already be a 16 bit unsigned integer value. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal or column name.The value of the specified column. - - - Gets the value of the specified column as a 16-bit unsigned integer. - - No conversions are performed; therefore, the data retrieved must already be a 16 bit unsigned integer value. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal or column name.The value of the specified column. - - - Gets the value of the specified column as a 32-bit unsigned integer. - - No conversions are performed; therefore, the data retrieved must already be a 32 bit unsigned integer value. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal or column name.The value of the specified column. - - - Gets the value of the specified column as a 32-bit unsigned integer. - - No conversions are performed; therefore, the data retrieved must already be a 32 bit unsigned integer value. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal or column name.The value of the specified column. - - - Gets the value of the specified column as a 64-bit unsigned integer. - - No conversions are performed; therefore, the data retrieved must already be a 64 bit unsigned integer value. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal or column name.The value of the specified column. - - - Gets the value of the specified column as a 64-bit unsigned integer. - - No conversions are performed; therefore, the data retrieved must already be a 64 bit unsigned integer value. - - - Call IsDBNull to check for null values before calling this method. - - The zero-based column ordinal or column name.The value of the specified column. - - - - Gets a value indicating whether the column contains non-existent or missing values. - - - - - - - Advances the data reader to the next result, when reading the results of batch SQL statements. - - - - - - Advances the MySqlDataReader to the next record. - - - - - - Returns an that iterates through the . - - - - - - Gets a value indicating the depth of nesting for the current row. This method is not - supported currently and always returns 0. - - - - - Gets the number of columns in the current row. - - - - - Gets a value indicating whether the MySqlDataReader contains one or more rows. - - - - - Gets a value indicating whether the data reader is closed. - - - - - Gets the number of rows changed, inserted, or deleted by execution of the SQL statement. - - - - - Overloaded. Gets the value of a column in its native format. - In C#, this property is the indexer for the MySqlDataReader class. - - - - - Gets the value of a column in its native format. - [C#] In C#, this property is the indexer for the MySqlDataReader class. - - - - - Serializes the given parameter to the given memory stream - - - This method is called by PrepareSqlBuffers to convert the given - parameter to bytes and write those bytes to the given memory stream. - - - True if the parameter was successfully serialized, false otherwise. - - - Represents a SQL statement to execute against a MySQL database. This class cannot be inherited. - MySqlCommand features the following methods for executing commands at a MySQL database: - - - Item - Description - - - - ExecuteReader - - Executes commands that return rows. - - - - ExecuteNonQuery - - Executes commands such as SQL INSERT, DELETE, and UPDATE statements. - - - - ExecuteScalar - - Retrieves a single value (for example, an aggregate value) from a database. - - - - You can reset the CommandText property and reuse the MySqlCommand - object. However, you must close the MySqlDataReader - before you can execute a new or previous command. - - If a MySqlException is - generated by the method executing a MySqlCommand, the MySqlConnection - remains open. It is the responsibility of the programmer to close the connection. - - - Using the '@' symbol for paramters is now the preferred approach although the old pattern of using - '?' is still supported. Please be aware though that using '@' can cause conflicts when user variables - are also used. To help with this situation please see the documentation on the 'allow user variables' - connection string option. The 'old syntax' connection string option has now been deprecated. - - - The following example creates a MySqlCommand and - a MySqlConnection. The MySqlConnection is opened and set as the Connection - for the MySqlCommand. The example then calls ExecuteNonQuery, - and closes the connection. To accomplish this, the ExecuteNonQuery is - passed a connection string and a query string that is a SQL INSERT - statement. - - Public Sub InsertRow(myConnectionString As String) - " If the connection string is null, use a default. - If myConnectionString = "" Then - myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass" - End If - Dim myConnection As New MySqlConnection(myConnectionString) - Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)" - Dim myCommand As New MySqlCommand(myInsertQuery) - myCommand.Connection = myConnection - myConnection.Open() - myCommand.ExecuteNonQuery() - myCommand.Connection.Close() - End Sub - - - public void InsertRow(string myConnectionString) - { - // If the connection string is null, use a default. - if(myConnectionString == "") - { - myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"; - } - MySqlConnection myConnection = new MySqlConnection(myConnectionString); - string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"; - MySqlCommand myCommand = new MySqlCommand(myInsertQuery); - myCommand.Connection = myConnection; - myConnection.Open(); - myCommand.ExecuteNonQuery(); - myCommand.Connection.Close(); - } - - - - - - - Initializes a new instance of the MySqlCommand class. - - - The following example creates a MySqlCommand and sets some of its properties. - - - This example shows how to use one of the overloaded - versions of the MySqlCommand constructor. For other examples that might be available, - see the individual overload topics. - - - - Public Sub CreateMySqlCommand() - Dim myConnection As New MySqlConnection _ - ("Persist Security Info=False;database=test;server=myServer") - myConnection.Open() - Dim myTrans As MySqlTransaction = myConnection.BeginTransaction() - Dim mySelectQuery As String = "SELECT * FROM MyTable" - Dim myCommand As New MySqlCommand(mySelectQuery, myConnection, myTrans) - myCommand.CommandTimeout = 20 - End Sub - - - public void CreateMySqlCommand() - { - MySqlConnection myConnection = new MySqlConnection("Persist Security Info=False; - database=test;server=myServer"); - myConnection.Open(); - MySqlTransaction myTrans = myConnection.BeginTransaction(); - string mySelectQuery = "SELECT * FROM myTable"; - MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection,myTrans); - myCommand.CommandTimeout = 20; - } - - - public: - void CreateMySqlCommand() - { - MySqlConnection* myConnection = new MySqlConnection(S"Persist Security Info=False; - database=test;server=myServer"); - myConnection->Open(); - MySqlTransaction* myTrans = myConnection->BeginTransaction(); - String* mySelectQuery = S"SELECT * FROM myTable"; - MySqlCommand* myCommand = new MySqlCommand(mySelectQuery, myConnection, myTrans); - myCommand->CommandTimeout = 20; - }; - - - - Initializes a new instance of the MySqlCommand class. - - The base constructor initializes all fields to their default values. The - following table shows initial property values for an instance of . - - - Properties - Initial Value - - - - - - empty string ("") - - - - - - 0 - - - - - - CommandType.Text - - - - - - Null - - - - You can change the value for any of these properties through a separate call to - the property. - - - The following example creates a and - sets some of its properties. - - - Public Sub CreateMySqlCommand() - Dim myCommand As New MySqlCommand() - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - MySqlCommand myCommand = new MySqlCommand(); - myCommand.CommandType = CommandType.Text; - } - - - - - - Initializes a new instance of the class with the text of the query. - The text of the query. - When an instance of is created, - the following read/write properties are set to initial values. - - - - Properties - Initial Value - - - - - - - cmdText - - - - - - - 0 - - - - - - CommandType.Text - - - - - - Null - - - - You can change the value for any of these properties through a separate call to - the property. - - - The following example creates a and - sets some of its properties. - - - Public Sub CreateMySqlCommand() - Dim sql as String = "SELECT * FROM mytable" - Dim myCommand As New MySqlCommand(sql) - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - string sql = "SELECT * FROM mytable"; - MySqlCommand myCommand = new MySqlCommand(sql); - myCommand.CommandType = CommandType.Text; - } - - - - - - Initializes a new instance of the class - with the text of the query and a . - The text of the query. - A that represents the - connection to an instance of SQL Server. - - When an instance of is created, - the following read/write properties are set to initial values. - - - - Properties - Initial Value - - - - - - - cmdText - - - - - - - 0 - - - - - - CommandType.Text - - - - - - - connection - - - - - You can change the value for any of these properties through a separate call to - the property. - - - The following example creates a and - sets some of its properties. - - - Public Sub CreateMySqlCommand() - Dim conn as new MySqlConnection("server=myServer") - Dim sql as String = "SELECT * FROM mytable" - Dim myCommand As New MySqlCommand(sql, conn) - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - MySqlConnection conn = new MySqlConnection("server=myserver") - string sql = "SELECT * FROM mytable"; - MySqlCommand myCommand = new MySqlCommand(sql, conn); - myCommand.CommandType = CommandType.Text; - } - - - - - - Initializes a new instance of the class - with the text of the query, a , and the - . - The text of the query. - A that represents the - connection to an instance of SQL Server. - - The in which the executes. - - When an instance of is created, - the following read/write properties are set to initial values. - - - - Properties - Initial Value - - - - - - - cmdText - - - - - - - 0 - - - - - - CommandType.Text - - - - - - - connection - - - - - You can change the value for any of these properties through a separate call to - the property. - - - The following example creates a and - sets some of its properties. - - - Public Sub CreateMySqlCommand() - Dim conn as new MySqlConnection("server=myServer") - conn.Open(); - Dim txn as MySqlTransaction = conn.BeginTransaction() - Dim sql as String = "SELECT * FROM mytable" - Dim myCommand As New MySqlCommand(sql, conn, txn) - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - MySqlConnection conn = new MySqlConnection("server=myserver") - conn.Open(); - MySqlTransaction txn = conn.BeginTransaction(); - string sql = "SELECT * FROM mytable"; - MySqlCommand myCommand = new MySqlCommand(sql, conn, txn); - myCommand.CommandType = CommandType.Text; - } - - - - - - Attempts to cancel the execution of a currently active command - - - Cancelling a currently active query only works with MySQL versions 5.0.0 and higher. - - - - - Creates a new instance of a object. - - - This method is a strongly-typed version of . - - A object. - - - - - Check the connection to make sure - - it is open - - it is not currently being used by a reader - - and we have the right version of MySQL for the requested command type - - - - - Executes a SQL statement against the connection and returns the number of rows affected. - Number of rows affected - You can use ExecuteNonQuery to perform any type of database operation, - however any resultsets returned will not be available. Any output parameters - used in calling a stored procedure will be populated with data and can be - retrieved after execution is complete. - For UPDATE, INSERT, and DELETE statements, the return value is the number - of rows affected by the command. For all other types of statements, the return - value is -1. - - The following example creates a MySqlCommand and then - executes it using ExecuteNonQuery. The example is passed a string that is a - SQL statement (such as UPDATE, INSERT, or DELETE) and a string to use to - connect to the data source. - - Public Sub CreateMySqlCommand(myExecuteQuery As String, myConnection As MySqlConnection) - Dim myCommand As New MySqlCommand(myExecuteQuery, myConnection) - myCommand.Connection.Open() - myCommand.ExecuteNonQuery() - myConnection.Close() - End Sub - - - public void CreateMySqlCommand(string myExecuteQuery, MySqlConnection myConnection) - { - MySqlCommand myCommand = new MySqlCommand(myExecuteQuery, myConnection); - myCommand.Connection.Open(); - myCommand.ExecuteNonQuery(); - myConnection.Close(); - } - - - - - - Reset SQL_SELECT_LIMIT that could have been modified by CommandBehavior. - - - - - Sends the to the Connection - and builds a . - - A object. - - - When the property is set to StoredProcedure, - the property should be set to the name of the stored - procedure. The command executes this stored procedure when you call - ExecuteReader. - - - While the is in use, the associated - is busy serving the MySqlDataReader. - While in this state, no other operations can be performed on the - MySqlConnection other than closing it. This is the case until the - method of the MySqlDataReader is called. - - - The following example creates a , then executes it by - passing a string that is a SQL SELECT statement, and a string to use to connect to the - data source. - - Public Sub CreateMySqlDataReader(mySelectQuery As String, myConnection As MySqlConnection) - Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) - myConnection.Open() - Dim myReader As MySqlDataReader - myReader = myCommand.ExecuteReader() - Try - While myReader.Read() - Console.WriteLine(myReader.GetString(0)) - End While - Finally - myReader.Close - myConnection.Close - End Try - End Sub - - - public void CreateMySqlDataReader(string mySelectQuery, MySqlConnection myConnection) - { - MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection); - myConnection.Open(); - MMySqlDataReader myReader; - myReader = myCommand.ExecuteReader(); - try - { - while(myReader.Read()) - { - Console.WriteLine(myReader.GetString(0)); - } - } - finally - { - myReader.Close(); - myConnection.Close(); - } - } - - - - - - Sends the to the Connection, - and builds a using one of the values. - - One of the values. - - - When the property is set to StoredProcedure, - the property should be set to the name of the stored - procedure. The command executes this stored procedure when you call - ExecuteReader. - - - The supports a special mode that enables large binary - values to be read efficiently. For more information, see the SequentialAccess - setting for . - - - While the is in use, the associated - is busy serving the MySqlDataReader. - While in this state, no other operations can be performed on the - MySqlConnection other than closing it. This is the case until the - method of the MySqlDataReader is called. - If the MySqlDataReader is created with CommandBehavior set to - CloseConnection, closing the MySqlDataReader closes the connection - automatically. - - - When calling ExecuteReader with the SingleRow behavior, you should be aware that using a limit - clause in your SQL will cause all rows (up to the limit given) to be retrieved by the client. The - method will still return false after the first row but pulling all rows of data - into the client will have a performance impact. If the limit clause is not necessary, it should - be avoided. - - - A object. - - - - - Executes the query, and returns the first column of the first row in the - result set returned by the query. Extra columns or rows are ignored. - - The first column of the first row in the result set, or a null reference if the - result set is empty - - - Use the ExecuteScalar method to retrieve a single value (for example, - an aggregate value) from a database. This requires less code than using the - method, and then performing the operations necessary - to generate the single value using the data returned by a - - - The following example creates a and then - executes it using ExecuteScalar. The example is passed a string that is a - SQL statement that returns an aggregate result, and a string to use to - connect to the data source. - - - Public Sub CreateMySqlCommand(myScalarQuery As String, myConnection As MySqlConnection) - Dim myCommand As New MySqlCommand(myScalarQuery, myConnection) - myCommand.Connection.Open() - myCommand.ExecuteScalar() - myConnection.Close() - End Sub - - - public void CreateMySqlCommand(string myScalarQuery, MySqlConnection myConnection) - { - MySqlCommand myCommand = new MySqlCommand(myScalarQuery, myConnection); - myCommand.Connection.Open(); - myCommand.ExecuteScalar(); - myConnection.Close(); - } - - - public: - void CreateMySqlCommand(String* myScalarQuery, MySqlConnection* myConnection) - { - MySqlCommand* myCommand = new MySqlCommand(myScalarQuery, myConnection); - myCommand->Connection->Open(); - myCommand->ExecuteScalar(); - myConnection->Close(); - } - - - - - - - - - - Creates a prepared version of the command on an instance of MySQL Server. - - - Prepared statements are only supported on MySQL version 4.1 and higher. Calling - prepare while connected to earlier versions of MySQL will succeed but will execute - the statement in the same way as unprepared. - - - The following example demonstrates the use of the Prepare method. - - public sub PrepareExample() - Dim cmd as New MySqlCommand("INSERT INTO mytable VALUES (@val)", myConnection) - cmd.Parameters.Add( "@val", 10 ) - cmd.Prepare() - cmd.ExecuteNonQuery() - - cmd.Parameters(0).Value = 20 - cmd.ExecuteNonQuery() - end sub - - - private void PrepareExample() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO mytable VALUES (@val)", myConnection); - cmd.Parameters.Add( "@val", 10 ); - cmd.Prepare(); - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = 20; - cmd.ExecuteNonQuery(); - } - - - - - - Initiates the asynchronous execution of the SQL statement or stored procedure - that is described by this , and retrieves one or more - result sets from the server. - - An that can be used to poll, wait for results, - or both; this value is also needed when invoking EndExecuteReader, - which returns a instance that can be used to retrieve - the returned rows. - - - - Initiates the asynchronous execution of the SQL statement or stored procedure - that is described by this using one of the - CommandBehavior values. - - One of the values, indicating - options for statement execution and data retrieval. - An that can be used to poll, wait for results, - or both; this value is also needed when invoking EndExecuteReader, - which returns a instance that can be used to retrieve - the returned rows. - - - - Finishes asynchronous execution of a SQL statement, returning the requested - . - - The returned by the call to - . - A MySqlDataReader object that can be used to retrieve the requested rows. - - - - Initiates the asynchronous execution of the SQL statement or stored procedure - that is described by this . - - - An delegate that is invoked when the command's - execution has completed. Pass a null reference (Nothing in Visual Basic) - to indicate that no callback is required. - A user-defined state object that is passed to the - callback procedure. Retrieve this object from within the callback procedure - using the property. - An that can be used to poll or wait for results, - or both; this value is also needed when invoking , - which returns the number of affected rows. - - - - Initiates the asynchronous execution of the SQL statement or stored procedure - that is described by this . - - An that can be used to poll or wait for results, - or both; this value is also needed when invoking , - which returns the number of affected rows. - - - - Finishes asynchronous execution of a SQL statement. - - The returned by the call - to . - - - - - Creates a clone of this MySqlCommand object. CommandText, Connection, and Transaction properties - are included as well as the entire parameter list. - - The cloned MySqlCommand object - - - - - - - Gets or sets the SQL statement to execute at the data source. - - The SQL statement or stored procedure to execute. The default is an empty string. - - - When the property is set to StoredProcedure, - the CommandText property should be set to the name of the stored procedure. - The user may be required to use escape character syntax if the stored procedure name - contains any special characters. The command executes this stored procedure when - you call one of the Execute methods. Starting with Connector/Net 5.0, having both a stored function - and stored procedure with the same name in the same database is not supported. It is - suggested that you provide unqiue names for your stored routines. - - - The following example creates a and sets some of its properties. - - Public Sub CreateMySqlCommand() - Dim myCommand As New MySqlCommand() - myCommand.CommandText = "SELECT * FROM Mytable ORDER BY id" - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - MySqlCommand myCommand = new MySqlCommand(); - myCommand.CommandText = "SELECT * FROM mytable ORDER BY id"; - myCommand.CommandType = CommandType.Text; - } - - - - - - Gets or sets the wait time before terminating the attempt to execute a command - and generating an error. - - The time (in seconds) to wait for the command to execute. The default is 30 - seconds. - - CommandTimeout is dependent on the ability of MySQL to cancel an executing query. - Because of this, CommandTimeout is only supported when connected to MySQL - version 5.0.0 or higher. - - - - - Gets or sets a value indicating how the property is to be interpreted. - - One of the values. The default is Text. - - - When you set the CommandType property to StoredProcedure, you - should set the property to the name of the stored - procedure. The command executes this stored procedure when you call one of the - Execute methods. - - - The following example creates a and sets some of its properties. - - Public Sub CreateMySqlCommand() - Dim myCommand As New MySqlCommand() - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - MySqlCommand myCommand = new MySqlCommand(); - myCommand.CommandType = CommandType.Text; - } - - - - - - - - - Gets or sets the used by this instance of the - . - - The connection to a data source. The default value is a null reference - (Nothing in Visual Basic). - - - If you set Connection while a transaction is in progress and the - property is not null, an - is generated. If the Transaction property is not null and the transaction - has already been committed or rolled back, Transaction is set to - null. - - - The following example creates a and sets some of its properties. - - Public Sub CreateMySqlCommand() - Dim mySelectQuery As String = "SELECT * FROM mytable ORDER BY id" - Dim myConnectString As String = "Persist Security Info=False;database=test;server=myServer" - Dim myCommand As New MySqlCommand(mySelectQuery) - myCommand.Connection = New MySqlConnection(myConnectString) - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - string mySelectQuery = "SELECT * FROM mytable ORDER BY id"; - string myConnectString = "Persist Security Info=False;database=test;server=myServer"; - MySqlCommand myCommand = new MySqlCommand(mySelectQuery); - myCommand.Connection = new MySqlConnection(myConnectString); - myCommand.CommandType = CommandType.Text; - } - - - - - - Get the - - The parameters of the SQL statement or stored procedure. The default is - an empty collection. - - Connector/Net does not support unnamed parameters. Every parameter added to the collection must - have an associated name. - - The following example creates a and displays its parameters. - To accomplish this, the method is passed a , a query string - that is a SQL SELECT statement, and an array of objects. - - Public Sub CreateMySqlCommand(myConnection As MySqlConnection, _ - mySelectQuery As String, myParamArray() As MySqlParameter) - Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) - myCommand.CommandText = "SELECT id, name FROM mytable WHERE age=@age" - myCommand.UpdatedRowSource = UpdateRowSource.Both - myCommand.Parameters.Add(myParamArray) - Dim j As Integer - For j = 0 To myCommand.Parameters.Count - 1 - myCommand.Parameters.Add(myParamArray(j)) - Next j - Dim myMessage As String = "" - Dim i As Integer - For i = 0 To myCommand.Parameters.Count - 1 - myMessage += myCommand.Parameters(i).ToString() & ControlChars.Cr - Next i - Console.WriteLine(myMessage) - End Sub - - - public void CreateMySqlCommand(MySqlConnection myConnection, string mySelectQuery, - MySqlParameter[] myParamArray) - { - MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection); - myCommand.CommandText = "SELECT id, name FROM mytable WHERE age=@age"; - myCommand.Parameters.Add(myParamArray); - for (int j=0; j<myParamArray.Length; j++) - { - myCommand.Parameters.Add(myParamArray[j]) ; - } - string myMessage = ""; - for (int i = 0; i < myCommand.Parameters.Count; i++) - { - myMessage += myCommand.Parameters[i].ToString() + "\n"; - } - MessageBox.Show(myMessage); - } - - - - - - Gets or sets the within which the executes. - - The . The default value is a null reference (Nothing in Visual Basic). - - You cannot set the Transaction property if it is already set to a - specific value, and the command is in the process of executing. If you set the - transaction property to a object that is not connected - to the same as the object, - an exception will be thrown the next time you attempt to execute a statement. - - - - - Gets or sets a value indicating whether the command object should be visible in a Windows Form Designer control. - - - - - Gets or sets how command results are applied to the DataRow when used by the - Update method of the DbDataAdapter. - - - - - Mark - or + signs that are unary ops as no output - - - - - - Summary description for BaseDriver. - - - - - Loads all the current character set names and ids for this server - into the charSets hashtable - - - - - For pooled connections, time when the driver was - put into idle queue - - - - - Returns true if this connection can handle batch SQL natively - This means MySQL 4.1.1 or later. - - - - - return the ordinal for the given column name - - - - - - - Closes the current resultset, dumping any data still on the wire - - - - - Loads the column metadata for the current resultset - - - - - Retrieve the value as the given column index - - The column value to retrieve - The value as the given column - - - - Summary description for MySqlPoolManager. - - - - - Remove drivers that have been idle for too long. - - - - - We are adding a custom installer class to our assembly so our installer - can make proper changes to the machine.config file. - - - - - We override Install so we can add our assembly to the proper - machine.config files. - - - - - - We override Uninstall so we can remove out assembly from the - machine.config files. - - - - - - A strongly-typed resource class, for looking up localized strings, etc. - - - - - Returns the cached ResourceManager instance used by this class. - - - - - Overrides the current thread's CurrentUICulture property for all - resource lookups using this strongly typed resource class. - - - - - Looks up a localized string similar to Improper MySqlCommandBuilder state: adapter is null. - - - - - Looks up a localized string similar to Improper MySqlCommandBuilder state: adapter's SelectCommand is null. - - - - - Looks up a localized string similar to Invalid attempt to access a field before calling Read(). - - - - - Looks up a localized string similar to Version string not in acceptable format. - - - - - Looks up a localized string similar to The buffer cannot be null. - - - - - Looks up a localized string similar to Buffer is not large enough. - - - - - Looks up a localized string similar to Canceling an executing query requires MySQL 5.0 or higher.. - - - - - Looks up a localized string similar to Canceling an active query is only supported on MySQL 5.0.0 and above. . - - - - - Looks up a localized string similar to MySqlCommandBuilder does not support multi-table statements. - - - - - Looks up a localized string similar to MySqlCommandBuilder cannot operate on tables with no unique or key columns. - - - - - Looks up a localized string similar to Chaos isolation level is not supported. - - - - - Looks up a localized string similar to The CommandText property has not been properly initialized.. - - - - - Looks up a localized string similar to The connection is already open.. - - - - - Looks up a localized string similar to Connection unexpectedly terminated.. - - - - - Looks up a localized string similar to Connection must be valid and open. - - - - - Looks up a localized string similar to The connection is not open.. - - - - - Looks up a localized string similar to The connection property has not been set or is null.. - - - - - Looks up a localized string similar to Could not find specified column in results: {0}. - - - - - Looks up a localized string similar to Count cannot be negative. - - - - - Looks up a localized string similar to SetLength is not a valid operation on CompressedStream. - - - - - Looks up a localized string similar to The given value was not in a supported format.. - - - - - Looks up a localized string similar to There is already an open DataReader associated with this Connection which must be closed first.. - - - - - Looks up a localized string similar to The default connection encoding was not found. Please report this as a bug along with your connection string and system details.. - - - - - Looks up a localized string similar to MySQL Connector/Net does not currently support distributed transactions.. - - - - - Looks up a localized string similar to Error creating socket connection. - - - - - Looks up a localized string similar to Fatal error encountered during command execution.. - - - - - Looks up a localized string similar to Fatal error encountered during data read.. - - - - - Looks up a localized string similar to Fatal error encountered attempting to read the resultset.. - - - - - Looks up a localized string similar to From index and length use more bytes than from contains. - - - - - Looks up a localized string similar to From index must be a valid index inside the from buffer. - - - - - Looks up a localized string similar to Call to GetHostEntry failed after {0} while querying for hostname '{1}': SocketErrorCode={2}, ErrorCode={3}, NativeErrorCode={4}.. - - - - - Looks up a localized string similar to Retrieving procedure metadata for {0} from server.. - - - - - Looks up a localized string similar to Value has an unsupported format.. - - - - - Looks up a localized string similar to An incorrect response was received from the server.. - - - - - Looks up a localized string similar to Index and length use more bytes than to has room for. - - - - - Looks up a localized string similar to Index must be a valid position in the buffer. - - - - - Looks up a localized string similar to You have specified an invalid column ordinal.. - - - - - Looks up a localized string similar to The requested value '{0}' is invalid for the given keyword '{1}'.. - - - - - Looks up a localized string similar to Procedure or function '{0}' cannot be found in database '{1}'.. - - - - - Looks up a localized string similar to '{0}' is an illegal value for a boolean option.. - - - - - Looks up a localized string similar to Keyword does not allow null values.. - - - - - Looks up a localized string similar to Keyword not supported.. - - - - - Looks up a localized string similar to ACCESSIBLE - ADD - ALL - ALTER - ANALYZE - AND - AS - ASC - ASENSITIVE - BEFORE - BETWEEN - BIGINT - BINARY - BLOB - BOTH - BY - CALL - CASCADE - CASE - CHANGE - CHAR - CHARACTER - CHECK - COLLATE - COLUMN - CONDITION - CONNECTION - CONSTRAINT - CONTINUE - CONVERT - CREATE - CROSS - CURRENT_DATE - CURRENT_TIME - CURRENT_TIMESTAMP - CURRENT_USER - CURSOR - DATABASE - DATABASES - DAY_HOUR - DAY_MICROSECOND - DAY_MINUTE - DAY_SECOND - DEC - DECIMAL - DECLARE - DEFAULT - DELAYED - DELETE - DESC - DESCRIBE - DETERMINISTIC - DISTINCT - DISTINCTROW - DIV - DOUBLE - DROP - DUAL - EACH - ELSE - ELSEIF - ENCLOSED - ESCAPED - EXISTS - EXIT - EXP [rest of string was truncated]";. - - - - - Looks up a localized string similar to INTERNAL ERROR: More than one output parameter row detected.. - - - - - Looks up a localized string similar to Multiple simultaneous connections or connections with different connection strings inside the same transaction are not currently supported.. - - - - - Looks up a localized string similar to NamedPipeStream does not support seeking. - - - - - Looks up a localized string similar to NamedPipeStream doesn't support SetLength. - - - - - Looks up a localized string similar to Invalid attempt to call NextResult when the reader is closed.. - - - - - Looks up a localized string similar to When calling stored procedures and 'Use Procedure Bodies' is false, all parameters must have their type explicitly set.. - - - - - Looks up a localized string similar to Nested transactions are not supported.. - - - - - Looks up a localized string similar to The host {0} does not support SSL connections.. - - - - - Looks up a localized string similar to The object is not open or has been disposed.. - - - - - Looks up a localized string similar to Offset cannot be negative. - - - - - Looks up a localized string similar to Offset must be a valid position in buffer. - - - - - Looks up a localized string similar to Parameter '{0}' has already been defined.. - - - - - Looks up a localized string similar to Parameter cannot have a negative value. - - - - - Looks up a localized string similar to Parameter cannot be null. - - - - - Looks up a localized string similar to Parameter is invalid.. - - - - - Looks up a localized string similar to Parameter '{0}' must be defined.. - - - - - Looks up a localized string similar to Parameter '{0}' was not found during prepare.. - - - - - Looks up a localized string similar to Password must be valid and contain length characters. - - - - - Looks up a localized string similar to This category includes a series of counters for MySQL.. - - - - - Looks up a localized string similar to .NET Data Provider for MySQL. - - - - - Looks up a localized string similar to The number of times a procedures metadata had to be queried from the server.. - - - - - Looks up a localized string similar to Hard Procedure Queries. - - - - - Looks up a localized string similar to The number of times a procedures metadata was retrieved from the client-side cache.. - - - - - Looks up a localized string similar to Soft Procedure Queries. - - - - - Looks up a localized string similar to same name are not supported.. - - - - - Looks up a localized string similar to Packets larger than max_allowed_packet are not allowed.. - - - - - Looks up a localized string similar to Reading from the stream has failed.. - - - - - Looks up a localized string similar to Invalid attempt to read a prior column using SequentialAccess. - - - - - Looks up a localized string similar to Routine '{0}' cannot be found. Either check the spelling or make sure you have sufficient rights to execute the routine.. - - - - - Looks up a localized string similar to Connector/Net no longer supports server versions prior to 4.1. - - - - - Looks up a localized string similar to Socket streams do not support seeking. - - - - - Looks up a localized string similar to Retrieving procedure metadata for {0} from procedure cache.. - - - - - Looks up a localized string similar to Stored procedures are not supported on this version of MySQL. - - - - - Looks up a localized string similar to The stream has already been closed. - - - - - Looks up a localized string similar to The stream does not support reading. - - - - - Looks up a localized string similar to The stream does not support writing. - - - - - Looks up a localized string similar to Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.. - - - - - Looks up a localized string similar to error connecting: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.. - - - - - Looks up a localized string similar to {0}: Connection Closed. - - - - - Looks up a localized string similar to Unable to trace. There are more than Int32.MaxValue connections in use.. - - - - - Looks up a localized string similar to {0}: Error encountered during row fetch. Number = {1}, Message={2}. - - - - - Looks up a localized string similar to {0}: Connection Opened: connection string = '{1}'. - - - - - Looks up a localized string similar to {0}: Error encountered attempting to open result: Number={1}, Message={2}. - - - - - Looks up a localized string similar to {0}: Query Closed. - - - - - Looks up a localized string similar to {0}: Query Normalized: {2}. - - - - - Looks up a localized string similar to {0}: Query Opened: {2}. - - - - - Looks up a localized string similar to {0}: Resultset Opened: field(s) = {1}, affected rows = {2}, inserted id = {3}. - - - - - Looks up a localized string similar to {0}: Resultset Closed. Total rows={1}, skipped rows={2}, size (bytes)={3}. - - - - - Looks up a localized string similar to {0}: Set Database: {1}. - - - - - Looks up a localized string similar to {0}: Statement closed: statement id = {1}. - - - - - Looks up a localized string similar to {0}: Statement executed: statement id = {1}. - - - - - Looks up a localized string similar to {0}: Statement prepared: sql='{1}', statement id={2}. - - - - - Looks up a localized string similar to {0}: Usage Advisor Warning: Query is using a bad index. - - - - - Looks up a localized string similar to {0}: Usage Advisor Warning: The field '{2}' was converted to the following types: {3}. - - - - - Looks up a localized string similar to {0}: Usage Advisor Warning: Query does not use an index. - - - - - Looks up a localized string similar to {0}: Usage Advisor Warning: The following columns were not accessed: {2}. - - - - - Looks up a localized string similar to {0}: Usage Advisor Warning: Skipped {2} rows. Consider a more focused query.. - - - - - Looks up a localized string similar to {0}: MySql Warning: Level={1}, Code={2}, Message={3}. - - - - - Looks up a localized string similar to Unable to connect to any of the specified MySQL hosts.. - - - - - Looks up a localized string similar to Unable to derive stored routine parameters. The 'Parameters' information schema table is not available and access to the stored procedure body has been disabled.. - - - - - Looks up a localized string similar to An error occured attempting to enumerate the user-defined functions. Do you have SELECT privileges on the mysql.func table?. - - - - - Looks up a localized string similar to Unable to execute stored procedure '{0}'.. - - - - - Looks up a localized string similar to There was an error parsing the foreign key definition.. - - - - - Looks up a localized string similar to Unable to retrieve stored routine parameters. Either grant access to the routine or add the 'Use Procedure Bodies=false' option to your connection string.. - - - - - Looks up a localized string similar to Unable to retrieve stored procedure metadata for routine '{0}'. Either grant SELECT privilege to mysql.proc for this user or use "use procedure bodies=false" with your connection string.. - - - - - Looks up a localized string similar to Unable to start a second async operation while one is running.. - - - - - Looks up a localized string similar to Unix sockets are not supported on Windows. - - - - - Looks up a localized string similar to The requested column value could not be treated as or conveted to a Guid.. - - - - - Looks up a localized string similar to Writing to the stream failed.. - - - - - Looks up a localized string similar to Parameter '{0}' is not found but a parameter with the name '{1}' is found. Parameter names must include the leading parameter marker.. - - - - - Summary description for MySqlPool. - - - - - It is assumed that this method is only called from inside an active lock. - - - - - It is assumed that this method is only called from inside an active lock. - - - - - Removes a connection from the in use pool. The only situations where this method - would be called are when a connection that is in use gets some type of fatal exception - or when the connection is being returned to the pool and it's too old to be - returned. - - - - - - Clears this pool of all idle connections and marks this pool and being cleared - so all other connections are closed when they are returned. - - - - - Remove expired drivers from the idle pool - - - - Closing driver is a potentially lengthy operation involving network - IO. Therefore we do not close expired drivers while holding - idlePool.SyncRoot lock. We just remove the old drivers from the idle - queue and return them to the caller. The caller will need to close - them (or let GC close them) - - - - - It is assumed that this property will only be used from inside an active - lock. - - - - - Indicates whether this pool is being cleared. - - - - - WriteInteger - - - - - - - - - - - - Execute the load operation - - The number of rows inserted. - - - - Gets or sets the connection. - - The connection. - - - - Gets or sets the field terminator. - - The field terminator. - - - - Gets or sets the line terminator. - - The line terminator. - - - - Gets or sets the name of the table. - - The name of the table. - - - - Gets or sets the character set. - - The character set. - - - - Gets or sets the name of the file. - - The name of the file. - - - - Gets or sets the timeout. - - The timeout. - - - - Gets or sets a value indicating whether the filename that is to be loaded - is local to the client or not - - true if local; otherwise, false. - - - - Gets or sets the number of lines to skip. - - The number of lines to skip. - - - - Gets or sets the line prefix. - - The line prefix. - - - - Gets or sets the field quotation character. - - The field quotation character. - - - - Gets or sets a value indicating whether [field quotation optional]. - - - true if [field quotation optional]; otherwise, false. - - - - - Gets or sets the escape character. - - The escape character. - - - - Gets or sets the conflict option. - - The conflict option. - - - - Gets or sets the priority. - - The priority. - - - - Gets the columns. - - The columns. - - - - Gets the expressions. - - The expressions. - - - - - - - - - This is the default and indicates normal priority - - - - - Low priority will cause the load operation to wait until all readers of the table - have finished. This only affects storage engines that use only table-level locking - such as MyISAM, Memory, and Merge. - - - - - Concurrent priority is only relevant for MyISAM tables and signals that if the table - has no free blocks in the middle that other readers can retrieve data from the table - while the load operation is happening. - - - - - - - - - - This is the default and indicates normal operation. In the event of a LOCAL load, this - is the same as ignore. When the data file is on the server, then a key conflict will - cause an error to be thrown and the rest of the data file ignored. - - - - - Replace column values when a key conflict occurs. - - - - - Ignore any rows where the primary key conflicts. - - - - - This method returns the literal value received - - The literal to return - The received value - - - - This method returns the literal value received - - The literal to return - The received value - - - - This method returns the literal value received - - The literal to return - The received value - - - - This method returns the literal value received - - The literal to return - The received value - - - - Performs an unsigned bitwise right shift with the specified number - - Number to operate on - Ammount of bits to shift - The resulting number from the shift operation - - - - Performs an unsigned bitwise right shift with the specified number - - Number to operate on - Ammount of bits to shift - The resulting number from the shift operation - - - - Performs an unsigned bitwise right shift with the specified number - - Number to operate on - Ammount of bits to shift - The resulting number from the shift operation - - - - Performs an unsigned bitwise right shift with the specified number - - Number to operate on - Ammount of bits to shift - The resulting number from the shift operation - - - Reads a number of characters from the current source Stream and writes the data to the target array at the specified index. - The source Stream to read from. - Contains the array of characteres read from the source Stream. - The starting index of the target array. - The maximum number of characters to read from the source Stream. - The number of characters read. The number will be less than or equal to count depending on the data available in the source Stream. Returns -1 if the end of the stream is reached. - - - Reads a number of characters from the current source TextReader and writes the data to the target array at the specified index. - The source TextReader to read from - Contains the array of characteres read from the source TextReader. - The starting index of the target array. - The maximum number of characters to read from the source TextReader. - The number of characters read. The number will be less than or equal to count depending on the data available in the source TextReader. Returns -1 if the end of the stream is reached. - - - - Converts a string to an array of bytes - - The string to be converted - The new array of bytes - - - - Converts an array of bytes to an array of chars - - The array of bytes to convert - The new array of chars - - - - Writes an object to the specified Stream - - The target Stream - The object to be sent - - - - Writes an object to the specified BinaryWriter - - The target BinaryWriter - The object to be sent - - - - Deserializes an object, or an entire graph of connected objects, and returns the object intance - - Reader instance used to read the object - The object instance - - - - Writes the exception stack trace to the received stream - - Exception to obtain information from - Output sream used to write to - - - - Summary description for StoredProcedure. - - - - - Summary description for PreparedStatement. - - - - - Prepares CommandText for use with the Prepare method - - Command text stripped of all paramter names - - Takes the output of TokenizeSql and creates a single string of SQL - that only contains '?' markers for each parameter. It also creates - the parameterMap array list that includes all the paramter names in the - order they appeared in the SQL - - - - - Summary description for ClientParam. - - - - - DB Operations Code - - - - - Specifies MySQL specific data type of a field, property, for use in a . - - - - - - A fixed precision and scale numeric value between -1038 - -1 and 10 38 -1. - - - - - The signed range is -128 to 127. The unsigned - range is 0 to 255. - - - - - A 16-bit signed integer. The signed range is - -32768 to 32767. The unsigned range is 0 to 65535 - - - - - Specifies a 24 (3 byte) signed or unsigned value. - - - - - A 32-bit signed integer - - - - - A 64-bit signed integer. - - - - - A small (single-precision) floating-point - number. Allowable values are -3.402823466E+38 to -1.175494351E-38, - 0, and 1.175494351E-38 to 3.402823466E+38. - - - - - A normal-size (double-precision) - floating-point number. Allowable values are -1.7976931348623157E+308 - to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to - 1.7976931348623157E+308. - - - - - A timestamp. The range is '1970-01-01 00:00:00' to sometime in the - year 2037 - - - - - Date The supported range is '1000-01-01' to '9999-12-31'. - - - - - Time The range is '-838:59:59' to '838:59:59'. - - - - - DateTime The supported range is '1000-01-01 00:00:00' to - '9999-12-31 23:59:59'. - - - - - Datetime The supported range is '1000-01-01 00:00:00' to - '9999-12-31 23:59:59'. - - - - - A year in 2- or 4-digit format (default is 4-digit). The - allowable values are 1901 to 2155, 0000 in the 4-digit year - format, and 1970-2069 if you use the 2-digit format (70-69). - - - - - Obsolete Use Datetime or Date type - - - - - A variable-length string containing 0 to 65535 characters - - - - - Bit-field data type - - - - - New Decimal - - - - - An enumeration. A string object that can have only one value, - chosen from the list of values 'value1', 'value2', ..., NULL - or the special "" error value. An ENUM can have a maximum of - 65535 distinct values - - - - - A set. A string object that can have zero or more values, each - of which must be chosen from the list of values 'value1', 'value2', - ... A SET can have a maximum of 64 members. - - - - - A binary column with a maximum length of 255 (2^8 - 1) - characters - - - - - A binary column with a maximum length of 16777215 (2^24 - 1) bytes. - - - - - A binary column with a maximum length of 4294967295 or - 4G (2^32 - 1) bytes. - - - - - A binary column with a maximum length of 65535 (2^16 - 1) bytes. - - - - - A variable-length string containing 0 to 255 bytes. - - - - - A fixed-length string. - - - - - Geometric (GIS) data type. - - - - - Unsigned 8-bit value. - - - - - Unsigned 16-bit value. - - - - - Unsigned 24-bit value. - - - - - Unsigned 32-bit value. - - - - - Unsigned 64-bit value. - - - - - Fixed length binary string. - - - - - Variable length binary string. - - - - - A text column with a maximum length of 255 (2^8 - 1) characters. - - - - - A text column with a maximum length of 16777215 (2^24 - 1) characters. - - - - - A text column with a maximum length of 4294967295 or - 4G (2^32 - 1) characters. - - - - - A text column with a maximum length of 65535 (2^16 - 1) characters. - - - - - A guid column - - - - - Allows the user to specify the type of connection that should - be used. - - - - - TCP/IP style connection. Works everywhere. - - - - - Named pipe connection. Works only on Windows systems. - - - - - Unix domain socket connection. Works only with Unix systems. - - - - - Shared memory connection. Currently works only with Windows systems. - - - - - SSL options for connection. - - - - - Do not use SSL. - - - - - Use SSL, if server supports it. - - - - - Always use SSL. Deny connection if server does not support SSL. - Do not perform server certificate validation. - - - - - Always use SSL. Validate server SSL certificate, but different host name mismatch. - - - - - Always use SSL and perform full certificate validation. - - - - - Specifies the connection types supported - - - - - Use TCP/IP sockets. - - - - - Use client library. - - - - - Use MySQL embedded server. - - - - - Do not use certificate store - - - - - Use certificate store for the current user - - - - - User certificate store for the machine - - - - - Summary description for Field. - - - - - Summary description for MySqlConversionException. - - - - Ctor - - - - Represents a collection of parameters relevant to a as well as their respective mappings to columns in a . This class cannot be inherited. - - - The number of the parameters in the collection must be equal to the number of - parameter placeholders within the command text, or an exception will be generated. - - The following example creates multiple instances of - through the MySqlParameterCollection collection within the . - These parameters are used to select data within the data source and place the data in - the . This code assumes that a DataSet and a MySqlDataAdapter - have already been created with the appropriate schema, commands, and connection. - - Public Sub AddParameters() - ' ... - ' create myDataSet and myDataAdapter - ' ... - myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters" - myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239 - - myDataAdapter.Fill(myDataSet) - End Sub 'AddSqlParameters - - - public void AddSqlParameters() - { - // ... - // create myDataSet and myDataAdapter - // ... - - myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters"; - myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239; - myDataAdapter.Fill(myDataSet); - - } - - - - - - Adds the specified object to the . - - The to add to the collection. - The newly added object. - - - - Adds a to the given the specified parameter name and value. - - The name of the parameter. - The of the to add to the collection. - The newly added object. - - - - Adds a to the given the parameter name and the data type. - - The name of the parameter. - One of the values. - The newly added object. - - - - Adds a to the with the parameter name, the data type, and the column length. - - The name of the parameter. - One of the values. - The length of the column. - The newly added object. - - - - Adds a to the with the parameter name, the data type, the column length, and the source column name. - - The name of the parameter. - One of the values. - The length of the column. - The name of the source column. - The newly added object. - - - - Adds an array of values to the end of the . - - - - - - Retrieve the parameter with the given name. - - - - - - - Adds the specified object to the . - - The to add to the collection. - The index of the new object. - - - - Removes all items from the collection. - - - - - Gets a value indicating whether a with the specified parameter name exists in the collection. - - The name of the object to find. - true if the collection contains the parameter; otherwise, false. - - - - Gets a value indicating whether a MySqlParameter exists in the collection. - - The value of the object to find. - true if the collection contains the object; otherwise, false. - Gets a value indicating whether a exists in the collection. - - - - Copies MySqlParameter objects from the MySqlParameterCollection to the specified array. - - - - - - - Returns an enumerator that iterates through the . - - - - - - Gets the location of the in the collection with a specific parameter name. - - The name of the object to retrieve. - The zero-based location of the in the collection. - - - - Gets the location of a in the collection. - - The object to locate. - The zero-based location of the in the collection. - Gets the location of a in the collection. - - - - Inserts a MySqlParameter into the collection at the specified index. - - - - - - - Removes the specified MySqlParameter from the collection. - - - - - - Removes the specified from the collection using the parameter name. - - The name of the object to retrieve. - - - - Removes the specified from the collection using a specific index. - - The zero-based index of the parameter. - Removes the specified from the collection. - - - - This method will update all the items in the index hashes when - we insert a parameter somewhere in the middle - - - - - - - Gets the at the specified index. - - Gets the with a specified attribute. - [C#] In C#, this property is the indexer for the class. - - - - - Gets the with the specified name. - - - - - Gets the number of MySqlParameter objects in the collection. - - - - - Gets a value that indicates whether the - has a fixed size. - - - - - Gets a value that indicates whether the - is read-only. - - - - - Gets a value that indicates whether the - is synchronized. - - - - - Gets an object that can be used to synchronize access to the - . - - - - - Stream that supports timeout of IO operations. - This class is used is used to support timeouts for SQL command, where a - typical operation involves several network reads/writes. - Timeout here is defined as the accumulated duration of all IO operations. - - - - - Construct a TimedStream - - Undelying stream - - - - Figure out whether it is necessary to reset timeout on stream. - We track the current value of timeout and try to avoid - changing it too often, because setting Read/WriteTimeout property - on network stream maybe a slow operation that involves a system call - (setsockopt). Therefore, we allow a small difference, and do not - reset timeout if current value is slightly greater than the requested - one (within 0.1 second). - - - - - Common handler for IO exceptions. - Resets timeout to infinity if timeout exception is - detected and stops the times. - - original exception - - - Returns the total number of bytes input so far. - - - Returns the total number of bytes output so far. - - - - GetForeignKeysOnTable retrieves the foreign keys on the given table. - Since MySQL supports foreign keys on versions prior to 5.0, we can't use - information schema. MySQL also does not include any type of SHOW command - for foreign keys so we have to resort to use SHOW CREATE TABLE and parsing - the output. - - The table to store the key info in. - The table to get the foeign key info for. - Only get foreign keys that match this name. - Should column information be included in the table. - - - - Represents a parameter to a , and optionally, its mapping to columns. This class cannot be inherited. - - - - - Initializes a new instance of the MySqlParameter class. - - - - - Initializes a new instance of the class with the parameter name and a value of the new MySqlParameter. - - The name of the parameter to map. - An that is the value of the . - - - - Initializes a new instance of the class with the parameter name and the data type. - - The name of the parameter to map. - One of the values. - - - - Initializes a new instance of the class with the parameter name, the , and the size. - - The name of the parameter to map. - One of the values. - The length of the parameter. - - - - Initializes a new instance of the class with the parameter name, the , the size, and the source column name. - - The name of the parameter to map. - One of the values. - The length of the parameter. - The name of the source column. - - - - Initializes a new instance of the class with the parameter name, the type of the parameter, the size of the parameter, a , the precision of the parameter, the scale of the parameter, the source column, a to use, and the value of the parameter. - - The name of the parameter to map. - One of the values. - The length of the parameter. - One of the values. - true if the value of the field can be null, otherwise false. - The total number of digits to the left and right of the decimal point to which is resolved. - The total number of decimal places to which is resolved. - The name of the source column. - One of the values. - An that is the value of the . - - - - - Overridden. Gets a string containing the . - - - - - - Resets the DbType property to its original settings. - - - - - Gets or sets the of the parameter. - - - - - Gets or sets a value indicating whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter. - As of MySql version 4.1 and earlier, input-only is the only valid choice. - - - - - Gets or sets a value indicating whether the parameter accepts null values. - - - - - Gets or sets the MySqlDbType of the parameter. - - - - - Gets or sets the name of the MySqlParameter. - - - - - Gets or sets the maximum number of digits used to represent the property. - - - - - Gets or sets the number of decimal places to which is resolved. - - - - - Gets or sets the maximum size, in bytes, of the data within the column. - - - - - Gets or sets the name of the source column that is mapped to the and used for loading or returning the . - - - - - Gets or sets the to use when loading . - - - - - Gets or sets the value of the parameter. - - - - - Returns the possible values for this parameter if this parameter is of type - SET or ENUM. Returns null otherwise. - - - - - Sets or gets a value which indicates whether the source column is nullable. - This allows to correctly generate Update statements - for nullable columns. - - - - - Collection of error codes that can be returned by the server - - - - - - - - - - - Error level - - - - - Error code - - - - - Error message - - - - - Provides a reference to error codes returned by MySQL. - - - - - There is already a key with the given values. - - - - - The specified key was not found. - - - - - Given when the connection is unable to successfully connect to host. - - - - - Normally returned when an incorrect password is given - - - - - Duplicate Key Name - - - - - Duplicate Key Entry - - - - - The given host is not allowed to connect - - - - - The anonymous user is not allowed to connect - - - - - The given password is not allowed - - - - - The given password does not match - - - - - An attempt was made to send or receive a packet larger than - max_allowed_packet_size - - - - - Summary description for CompressedStream. - - - - - Helper class to encapsulate shared memory functionality - Also cares of proper cleanup of file mapping object and cew - - - - - Summary description for SharedMemoryStream. - - - - - Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated MySQL database. This class cannot be inherited. - - - The does not automatically generate the SQL statements required to - reconcile changes made to a DataSet with the associated instance of MySQL. - However, you can create a MySqlCommandBuilder object to automatically generate SQL statements for - single-table updates if you set the SelectCommand property - of the MySqlDataAdapter. Then, any additional SQL statements that you do not set are generated by the - MySqlCommandBuilder. - - - - The MySqlCommandBuilder registers itself as a listener for RowUpdating - events whenever you set the property. You can only associate one - MySqlDataAdapter or MySqlCommandBuilder object with each other at one time. - - - - To generate INSERT, UPDATE, or DELETE statements, the MySqlCommandBuilder uses the - SelectCommand property to retrieve a required set of metadata automatically. If you change - the SelectCommand after the metadata has is retrieved (for example, after the first update), you - should call the method to update the metadata. - - - - The SelectCommand must also return at least one primary key or unique - column. If none are present, an InvalidOperation exception is generated, - and the commands are not generated. - - - - The MySqlCommandBuilder also uses the Connection, - CommandTimeout, and Transaction - properties referenced by the SelectCommand. The user should call - RefreshSchema if any of these properties are modified, or if the - SelectCommand itself is replaced. Otherwise the InsertCommand, - UpdateCommand, and - DeleteCommand properties retain - their previous values. - - - - If you call Dispose, the MySqlCommandBuilder is disassociated - from the MySqlDataAdapter, and the generated commands are no longer used. - - - - Caution must be used when using MySqlCOmmandBuilder on MySql 4.0 systems. With MySql 4.0, - database/schema information is not provided to the connector for a query. This means that - a query that pulls columns from two identically named tables in two or more different databases - will not cause an exception to be thrown but will not work correctly. Even more dangerous - is the situation where your select statement references database X but is executed in - database Y and both databases have tables with similar layouts. This situation can cause - unwanted changes or deletes. - This note does not apply to MySQL versions 4.1 and later. - - - - The following example uses the , along - and , to - select rows from a data source. The example is passed an initialized - , a connection string, a - query string that is a SQL SELECT statement, and a string that is the - name of the database table. The example then creates a MySqlCommandBuilder. - - - Public Shared Function SelectRows(myConnection As String, mySelectQuery As String, myTableName As String) As DataSet - Dim myConn As New MySqlConnection(myConnection) - Dim myDataAdapter As New MySqlDataAdapter() - myDataAdapter.SelectCommand = New MySqlCommand(mySelectQuery, myConn) - Dim cb As SqlCommandBuilder = New MySqlCommandBuilder(myDataAdapter) - - myConn.Open() - - Dim ds As DataSet = New DataSet - myDataAdapter.Fill(ds, myTableName) - - ' Code to modify data in DataSet here - - ' Without the MySqlCommandBuilder this line would fail. - myDataAdapter.Update(ds, myTableName) - - myConn.Close() - End Function 'SelectRows - - - public static DataSet SelectRows(string myConnection, string mySelectQuery, string myTableName) - { - MySqlConnection myConn = new MySqlConnection(myConnection); - MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(); - myDataAdapter.SelectCommand = new MySqlCommand(mySelectQuery, myConn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(myDataAdapter); - - myConn.Open(); - - DataSet ds = new DataSet(); - myDataAdapter.Fill(ds, myTableName); - - //code to modify data in DataSet here - - //Without the MySqlCommandBuilder this line would fail - myDataAdapter.Update(ds, myTableName); - - myConn.Close(); - - return ds; - } - - - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class - with the associated object. - - The to use. - - - The registers itself as a listener for - events that are generated by the - specified in this property. - - - When you create a new instance MySqlCommandBuilder, any existing - MySqlCommandBuilder associated with this MySqlDataAdapter - is released. - - - - - - Retrieves parameter information from the stored procedure specified - in the MySqlCommand and populates the Parameters collection of the - specified MySqlCommand object. - This method is not currently supported since stored procedures are - not available in MySql. - - The MySqlCommand referencing the stored - procedure from which the parameter information is to be derived. - The derived parameters are added to the Parameters collection of the - MySqlCommand. - The command text is not - a valid stored procedure name. - - - - Gets the delete command. - - - - - - Gets the update command. - - - - - - Gets the insert command. - - - - - - - - - - - - - Gets or sets a object for which SQL statements are automatically generated. - - A object. - - - The registers itself as a listener for - events that are generated by the - specified in this property. - - - When you create a new instance MySqlCommandBuilder, any existing - MySqlCommandBuilder associated with this MySqlDataAdapter - is released. - - - - - - This class is modeled after .NET Stopwatch. It provides better - performance (no system calls).It is however less precise than - .NET Stopwatch, measuring in milliseconds. It is adequate to use - when high-precision is not required (e.g for measuring IO timeouts), - but not for other tasks. - - - - - Helper class that makes it easier to work with the provider. - - - - - Executes a single command against a MySQL database. The is assumed to be - open when the method is called and remains open after the method completes. - - object to use - SQL command to be executed - Array of objects to use with the command. - - - - - Executes a single command against a MySQL database. A new is created - using the given. - - to use - SQL command to be executed - Array of objects to use with the command. - - - - - Executes a single SQL command and returns the first row of the resultset. A new MySqlConnection object - is created, opened, and closed during this method. - - Settings to be used for the connection - Command to execute - Parameters to use for the command - DataRow containing the first row of the resultset - - - - Executes a single SQL command and returns the resultset in a . - A new MySqlConnection object is created, opened, and closed during this method. - - Settings to be used for the connection - Command to execute - containing the resultset - - - - Executes a single SQL command and returns the resultset in a . - A new MySqlConnection object is created, opened, and closed during this method. - - Settings to be used for the connection - Command to execute - Parameters to use for the command - containing the resultset - - - - Executes a single SQL command and returns the resultset in a . - The state of the object remains unchanged after execution - of this method. - - object to use - Command to execute - containing the resultset - - - - Executes a single SQL command and returns the resultset in a . - The state of the object remains unchanged after execution - of this method. - - object to use - Command to execute - Parameters to use for the command - containing the resultset - - - - Updates the given table with data from the given - - Settings to use for the update - Command text to use for the update - containing the new data to use in the update - Tablename in the dataset to update - - - - Executes a single command against a MySQL database, possibly inside an existing transaction. - - object to use for the command - object to use for the command - Command text to use - Array of objects to use with the command - True if the connection should be preserved, false if not - object ready to read the results of the command - - - - Executes a single command against a MySQL database. - - Settings to use for this command - Command text to use - object ready to read the results of the command - - - - Executes a single command against a MySQL database. - - Settings to use for this command - Command text to use - Array of objects to use with the command - object ready to read the results of the command - - - - Execute a single command against a MySQL database. - - Settings to use for the update - Command text to use for the update - The first column of the first row in the result set, or a null reference if the result set is empty. - - - - Execute a single command against a MySQL database. - - Settings to use for the command - Command text to use for the command - Parameters to use for the command - The first column of the first row in the result set, or a null reference if the result set is empty. - - - - Execute a single command against a MySQL database. - - object to use - Command text to use for the command - The first column of the first row in the result set, or a null reference if the result set is empty. - - - - Execute a single command against a MySQL database. - - object to use - Command text to use for the command - Parameters to use for the command - The first column of the first row in the result set, or a null reference if the result set is empty. - - - - Escapes the string. - - The string to escape - The string with all quotes escaped. - - - - Summary description for MySqlUInt64. - - - - - Return schema information about procedures and functions - Restrictions supported are: - schema, name, type - - - - - - - Return schema information about parameters for procedures and functions - Restrictions supported are: - schema, name, type, parameter name - - - - - Initializes a new row for the procedure parameters table. - - - - - Parses out the elements of a procedure parameter data type. - - - - - Represents an open connection to a MySQL Server database. This class cannot be inherited. - - - A MySqlConnection object represents a session to a MySQL Server - data source. When you create an instance of MySqlConnection, all - properties are set to their initial values. For a list of these values, see the - MySqlConnection constructor. - - - - If the MySqlConnection goes out of scope, it is not closed. Therefore, - you must explicitly close the connection by calling - or . - - - The following example creates a and - a MySqlConnection. The MySqlConnection is opened and set as the - for the MySqlCommand. The example then calls - , and closes the connection. To accomplish this, the ExecuteNonQuery is - passed a connection string and a query string that is a SQL INSERT - statement. - - - Public Sub InsertRow(myConnectionString As String) - ' If the connection string is null, use a default. - If myConnectionString = "" Then - myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass" - End If - Dim myConnection As New MySqlConnection(myConnectionString) - Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)" - Dim myCommand As New MySqlCommand(myInsertQuery) - myCommand.Connection = myConnection - myConnection.Open() - myCommand.ExecuteNonQuery() - myCommand.Connection.Close() - End Sub - - - - - public void InsertRow(string myConnectionString) - { - // If the connection string is null, use a default. - if(myConnectionString == "") - { - myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"; - } - MySqlConnection myConnection = new MySqlConnection(myConnectionString); - string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"; - MySqlCommand myCommand = new MySqlCommand(myInsertQuery); - myCommand.Connection = myConnection; - myConnection.Open(); - myCommand.ExecuteNonQuery(); - myCommand.Connection.Close(); - } - - - - - - - Initializes a new instance of the class. - - When a new instance of is created, the read/write - properties are set to the following initial values unless they are specifically - set using their associated keywords in the property. - - - - Properties - Initial Value - - - - - - empty string ("") - - - - - - 15 - - - - - - empty string ("") - - - - - - empty string ("") - - - - - - empty string ("") - - - - You can change the value for these properties only by using the ConnectionString property. - - - - Initializes a new instance of the class. - - - - - - Initializes a new instance of the class when given a string containing the connection string. - - When a new instance of is created, the read/write - properties are set to the following initial values unless they are specifically - set using their associated keywords in the property. - - - - Properties - Initial Value - - - - - - empty string ("") - - - - - - 15 - - - - - - empty string ("") - - - - - - empty string ("") - - - - - - empty string ("") - - - - You can change the value for these properties only by using the ConnectionString property. - - The connection properties used to open the MySQL database. - - - - Enlists in the specified transaction. - - - A reference to an existing in which to enlist. - - - - Begins a database transaction.An object representing the new transaction.Parallel transactions are not supported. - This command is equivalent to the MySQL BEGIN TRANSACTION command. - - You must explicitly commit or roll back the transaction using the or - method. - - If you do not specify an isolation level, the default isolation level is used. To specify an isolation - level with the method, use the overload that takes the iso parameter. Also - note that any attempt to begin a transaction while a transaction is in progress will throw an exception on MySQL 4.1 and higher. - On MySQL 4.0, an exception will not be thrown because servers 4.0 and earlier did not report their transacation status. - - - - The following example creates a and a - . It also demonstrates how to use the BeginTransaction, a - , and methods. - - Public Sub RunTransaction(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - - Dim myCommand As MySqlCommand = myConnection.CreateCommand() - Dim myTrans As MySqlTransaction - - ' Start a local transaction - myTrans = myConnection.BeginTransaction() - ' Must assign both transaction object and connection - ' to Command object for a pending local transaction - myCommand.Connection = myConnection - myCommand.Transaction = myTrans - - Try - myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')" - myCommand.ExecuteNonQuery() - myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')" - myCommand.ExecuteNonQuery() - myTrans.Commit() - Console.WriteLine("Both records are written to database.") - Catch e As Exception - Try - myTrans.Rollback() - Catch ex As MySqlException - If Not myTrans.Connection Is Nothing Then - Console.WriteLine("An exception of type " + ex.GetType().ToString() + _ - " was encountered while attempting to roll back the transaction.") - End If - End Try - - Console.WriteLine("An exception of type " + e.GetType().ToString() + _ - "was encountered while inserting the data.") - Console.WriteLine("Neither record was written to database.") - Finally - myConnection.Close() - End Try - End Sub - - - public void RunTransaction(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - - MySqlCommand myCommand = myConnection.CreateCommand(); - MySqlTransaction myTrans; - - // Start a local transaction - myTrans = myConnection.BeginTransaction(); - // Must assign both transaction object and connection - // to Command object for a pending local transaction - myCommand.Connection = myConnection; - myCommand.Transaction = myTrans; - - try - { - myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')"; - myCommand.ExecuteNonQuery(); - myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')"; - myCommand.ExecuteNonQuery(); - myTrans.Commit(); - Console.WriteLine("Both records are written to database."); - } - catch(Exception e) - { - try - { - myTrans.Rollback(); - } - catch (SqlException ex) - { - if (myTrans.Connection != null) - { - Console.WriteLine("An exception of type " + ex.GetType() + - " was encountered while attempting to roll back the transaction."); - } - } - - Console.WriteLine("An exception of type " + e.GetType() + - " was encountered while inserting the data."); - Console.WriteLine("Neither record was written to database."); - } - finally - { - myConnection.Close(); - } - } - - - - - Begins a database transaction with the specified isolation level.The isolation level under which the transaction should run. An object representing the new transaction.Parallel exceptions are not supported. - This command is equivalent to the MySQL BEGIN TRANSACTION command. - - You must explicitly commit or roll back the transaction using the or - method. - - If you do not specify an isolation level, the default isolation level is used. To specify an isolation - level with the method, use the overload that takes the iso parameter. - Also note that any attempt to begin a transaction while a transaction is in progress will throw an exception on MySQL 4.1 and higher. - On MySQL 4.0, an exception will not be thrown because servers 4.0 and earlier did not report their transacation status. - - - - The following example creates a and a - . It also demonstrates how to use the BeginTransaction, a - , and methods. - - Public Sub RunTransaction(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - - Dim myCommand As MySqlCommand = myConnection.CreateCommand() - Dim myTrans As MySqlTransaction - - ' Start a local transaction - myTrans = myConnection.BeginTransaction() - ' Must assign both transaction object and connection - ' to Command object for a pending local transaction - myCommand.Connection = myConnection - myCommand.Transaction = myTrans - - Try - myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')" - myCommand.ExecuteNonQuery() - myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')" - myCommand.ExecuteNonQuery() - myTrans.Commit() - Console.WriteLine("Both records are written to database.") - Catch e As Exception - Try - myTrans.Rollback() - Catch ex As MySqlException - If Not myTrans.Connection Is Nothing Then - Console.WriteLine("An exception of type " + ex.GetType().ToString() + _ - " was encountered while attempting to roll back the transaction.") - End If - End Try - - Console.WriteLine("An exception of type " + e.GetType().ToString() + _ - "was encountered while inserting the data.") - Console.WriteLine("Neither record was written to database.") - Finally - myConnection.Close() - End Try - End Sub - - - public void RunTransaction(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - - MySqlCommand myCommand = myConnection.CreateCommand(); - MySqlTransaction myTrans; - - // Start a local transaction - myTrans = myConnection.BeginTransaction(); - // Must assign both transaction object and connection - // to Command object for a pending local transaction - myCommand.Connection = myConnection; - myCommand.Transaction = myTrans; - - try - { - myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')"; - myCommand.ExecuteNonQuery(); - myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')"; - myCommand.ExecuteNonQuery(); - myTrans.Commit(); - Console.WriteLine("Both records are written to database."); - } - catch(Exception e) - { - try - { - myTrans.Rollback(); - } - catch (SqlException ex) - { - if (myTrans.Connection != null) - { - Console.WriteLine("An exception of type " + ex.GetType() + - " was encountered while attempting to roll back the transaction."); - } - } - - Console.WriteLine("An exception of type " + e.GetType() + - " was encountered while inserting the data."); - Console.WriteLine("Neither record was written to database."); - } - finally - { - myConnection.Close(); - } - } - - - - - Changes the current database for an open MySqlConnection.The name of the database to use. - - The value supplied in the database parameter must be a valid database - name. The database parameter cannot contain a null value, an empty - string, or a string with only blank characters. - - - - When you are using connection pooling against MySQL, and you close - the connection, it is returned to the connection pool. The next time the - connection is retrieved from the pool, the reset connection request - executes before the user performs any operations. - - The database name is not valid.The connection is not open.Cannot change the database. - The following example creates a and displays - some of its read-only properties. - - - Public Sub CreateMySqlConnection() - Dim myConnString As String = _ - "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass" - Dim myConnection As New MySqlConnection( myConnString ) - myConnection.Open() - MessageBox.Show( "Server Version: " + myConnection.ServerVersion _ - + ControlChars.NewLine + "Database: " + myConnection.Database ) - myConnection.ChangeDatabase( "test2" ) - MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.NewLine + "Database: " + myConnection.Database ) - myConnection.Close() - End Sub - - - - public void CreateMySqlConnection() - { - string myConnString = - "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"; - MySqlConnection myConnection = new MySqlConnection( myConnString ); - myConnection.Open(); - MessageBox.Show( "Server Version: " + myConnection.ServerVersion - + "\nDatabase: " + myConnection.Database ); - myConnection.ChangeDatabase( "test2" ); - MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion - + "\nDatabase: " + myConnection.Database ); - myConnection.Close(); - } - - - - - - Ping - - - - - Opens a database connection with the property settings specified by the ConnectionString.Cannot open a connection without specifying a data source or server.A connection-level error occurred while opening the connection. - - The draws an open connection from the connection pool if one is available. - Otherwise, it establishes a new connection to an instance of MySQL. - - - The following example creates a , opens it, - displays some of its properties, then closes the connection. - - - Public Sub CreateMySqlConnection(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.Cr + "State: " + myConnection.State.ToString()) - myConnection.Close() - End Sub - - - public void CreateMySqlConnection(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + - "\nState: " + myConnection.State.ToString()); - myConnection.Close(); - } - - - - - - Creates and returns a object associated with the . - - A object. - - - - - Creates a new MySqlConnection object with the exact same ConnectionString value - - A cloned MySqlConnection object - - - Closes the connection to the database. This is the preferred method of closing any open connection. - - The Close method rolls back any pending transactions. It then releases - the connection to the connection pool, or closes the connection if connection - pooling is disabled. - - - An application can call Close more than one time. No exception is - generated. - - - The following example creates a , opens it, - displays some of its properties, then closes the connection. - - - Public Sub CreateMySqlConnection(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.Cr + "State: " + myConnection.State.ToString()) - myConnection.Close() - End Sub - - - public void CreateMySqlConnection(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + - "\nState: " + myConnection.State.ToString()); - myConnection.Close(); - } - - - - - - Sets query timeout. If timeout has been set prior and not - yet cleared ClearCommandTimeout(), it has no effect. - - timeout in seconds - true if - - - - Clears query timeout, allowing next SetCommandTimeout() to succeed. - - - - - Returns schema information for the data source of this . - - A that contains schema information. - - - - 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. - - - - 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. - - - Empties the connection pool associated with the specified connection. - The associated with the pool to be cleared. - - - ClearPool clears the connection pool that is associated with the connection. - If additional connections associated with connection are in use at the time of the call, - they are marked appropriately and are discarded (instead of being returned to the pool) - when Close is called on them. - - - - - Clears all connection pools. - - ClearAllPools essentially performs a on all current connection - pools. - - - - - Occurs when MySQL returns warnings as a result of executing a command or query. - - - - - Returns the id of the server thread this connection is executing on - - - - - Gets the name of the MySQL server to which to connect. - - - - - Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error. - The value set is less than 0. - A value of 0 indicates no limit, and should be avoided in a - because an attempt to connect - will wait indefinitely. - - The following example creates a MySqlConnection - and sets some of its properties in the connection string. - - Public Sub CreateSqlConnection() - Dim myConnection As New MySqlConnection() - myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30" - myConnection.Open() - End Sub - - - public void CreateSqlConnection() - { - MySqlConnection myConnection = new MySqlConnection(); - myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30"; - myConnection.Open(); - } - - - - - Gets the name of the current database or the database to be used after a connection is opened.The name of the current database or the name of the database to be used after a connection is opened. The default value is an empty string. - - The Database property does not update dynamically. - If you change the current database using a SQL statement, then this property - may reflect the wrong value. If you change the current database using the - method, this property is updated to reflect the new database. - - - The following example creates a and displays - some of its read-only properties. - - - Public Sub CreateMySqlConnection() - Dim myConnString As String = _ - "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass" - Dim myConnection As New MySqlConnection( myConnString ) - myConnection.Open() - MessageBox.Show( "Server Version: " + myConnection.ServerVersion _ - + ControlChars.NewLine + "Database: " + myConnection.Database ) - myConnection.ChangeDatabase( "test2" ) - MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.NewLine + "Database: " + myConnection.Database ) - myConnection.Close() - End Sub - - - - public void CreateMySqlConnection() - { - string myConnString = - "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"; - MySqlConnection myConnection = new MySqlConnection( myConnString ); - myConnection.Open(); - MessageBox.Show( "Server Version: " + myConnection.ServerVersion - + "\nDatabase: " + myConnection.Database ); - myConnection.ChangeDatabase( "test2" ); - MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion - + "\nDatabase: " + myConnection.Database ); - myConnection.Close(); - } - - - - - - Indicates if this connection should use compression when communicating with the server. - - - - Gets the current state of the connection. - A bitwise combination of the values. The default is Closed. - - The allowed state changes are: - - - From Closed to Open, using the Open method of the connection object. - - - From Open to Closed, using either the Close method or the Dispose method of the connection object. - - - - The following example creates a , opens it, - displays some of its properties, then closes the connection. - - - Public Sub CreateMySqlConnection(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.Cr + "State: " + myConnection.State.ToString()) - myConnection.Close() - End Sub - - - public void CreateMySqlConnection(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + - "\nState: " + myConnection.State.ToString()); - myConnection.Close(); - } - - - - - Gets a string containing the version of the MySQL server to which the client is connected.The version of the instance of MySQL.The connection is closed. - The following example creates a , opens it, - displays some of its properties, then closes the connection. - - - Public Sub CreateMySqlConnection(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.Cr + "State: " + myConnection.State.ToString()) - myConnection.Close() - End Sub - - - public void CreateMySqlConnection(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + - "\nState: " + myConnection.State.ToString()); - myConnection.Close(); - } - - - - - - Gets or sets the string used to connect to a MySQL Server database. - - - The ConnectionString returned may not be exactly like what was originally - set but will be indentical in terms of keyword/value pairs. Security information - will not be included unless the Persist Security Info value is set to true. - - - You can use the ConnectionString property to connect to a database. - The following example illustrates a typical connection string. - - "Persist Security Info=False;database=MyDB;server=MySqlServer;user id=myUser;Password=myPass" - - The ConnectionString property can be set only when the connection is - closed. Many of the connection string values have corresponding read-only - properties. When the connection string is set, all of these properties are - updated, except when an error is detected. In this case, none of the properties - are updated. properties return only those settings contained in the - ConnectionString. - - - To connect to a local machine, specify "localhost" for the server. If you do not - specify a server, localhost is assumed. - - - Resetting the ConnectionString on a closed connection resets all - connection string values (and related properties) including the password. For - example, if you set a connection string that includes "Database= MyDb", and - then reset the connection string to "Data Source=myserver;User Id=myUser;Password=myPass", - the property is no longer set to MyDb. - - - The connection string is parsed immediately after being set. If errors in - syntax are found when parsing, a runtime exception, such as , - is generated. Other errors can be found only when an attempt is made to open the - connection. - - - The basic format of a connection string consists of a series of keyword/value - pairs separated by semicolons. The equal sign (=) connects each keyword and its - value. To include values that contain a semicolon, single-quote character, or - double-quote character, the value must be enclosed in double quotes. If the - value contains both a semicolon and a double-quote character, the value can be - enclosed in single quotes. The single quote is also useful if the value begins - with a double-quote character. Conversely, the double quote can be used if the - value begins with a single quote. If the value contains both single-quote and - double-quote characters, the quote character used to enclose the value must be - doubled each time it occurs within the value. - - - To include preceding or trailing spaces in the string value, the value must - be enclosed in either single quotes or double quotes. Any leading or trailing - spaces around integer, Boolean, or enumerated values are ignored, even if - enclosed in quotes. However, spaces within a string literal keyword or value are - preserved. Using .NET Framework version 1.1, single or double quotes may be used - within a connection string without using delimiters (for example, Data Source= - my'Server or Data Source= my"Server), unless a quote character is the first or - last character in the value. - - - To include an equal sign (=) in a keyword or value, it must be preceded by - another equal sign. For example, in the hypothetical connection string - - "key==word=value" - - the keyword is "key=word" and the value is "value". - - If a specific keyword in a keyword= value pair occurs multiple times in a - connection string, the last occurrence listed is used in the value set. - - Keywords are not case sensitive. - - The following table lists the valid names for keyword values within the - ConnectionString. - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameDefaultDescription
- Connect Timeout -or- Connection Timeout - 15 - The length of time (in seconds) to wait for a connection to the server before - terminating the attempt and generating an error. -
- Host -or- Server -or- Data Source -or- - DataSource -or- Address -or- Addr -or- - Network Address - localhost - - The name or network address of the instance of MySQL to which to connect. Multiple hosts can be - specified separated by &. This can be useful where multiple MySQL servers are configured for replication - and you are not concerned about the precise server you are connecting to. No attempt is made by the provider to - synchronize writes to the database so care should be taken when using this option. - - - In Unix environment with Mono, this can be a fully qualified path to MySQL socket filename. With this configuration, the Unix socket will be used instead of TCP/IP socket. - Currently only a single socket name can be given so accessing MySQL in a replicated environment using Unix sockets is not currently supported. - -
Port3306 - The port MySQL is using to listen for connections. This value is ignored if the connection protocol - is anything but socket. -
Protocolsocket - Specifies the type of connection to make to the server.Values can be: - socket or tcp for a socket connection
- pipe for a named pipe connection
- unix for a Unix socket connection
- memory to use MySQL shared memory -
- CharSet -or Character Set - - Specifies the character set that should be used to encode all queries sent to the server. - Resultsets are still returned in the character set of the data returned. -
LoggingfalseWhen true, various pieces of information is output to any configured TraceListeners.
Allow Batchtrue - When true, multiple SQL statements can be sent with one command execution.

- -Note-
- Starting with MySQL 4.1.1, batch statements should be separated by the server-defined seperator character.
- Commands sent to earlier versions of MySQL should be seperated with ';'. -
Encryptfalse - When true, SSL/TLS encryption is used for all data sent between the - client and server if the server has a certificate installed. Recognized values - are true, false, yes, and no. -
- Initial Catalog -or- Database - mysqlThe name of the database to use intially
- Password -or- pwd - The password for the MySQL account being used.
Persist Security Infofalse - When set to false or no (strongly recommended), security-sensitive - information, such as the password, is not returned as part of the connection if - the connection is open or has ever been in an open state. Resetting the - connection string resets all connection string values including the password. - Recognized values are true, false, yes, and no. -
- User Id -or- Username -or- Uid -or- User name - The MySQL login account being used.
Shared Memory NameMYSQLThe name of the shared memory object to use for communication if the connection protocol is set to memory.
Allow Zero Datetimefalse - True to have MySqlDataReader.GetValue() return a MySqlDateTime for date or datetime columns that have illegal values. - False will cause a DateTime object to be returned for legal values and an exception will be thrown for illegal values. -
Convert Zero Datetimefalse - True to have MySqlDataReader.GetValue() and MySqlDataReader.GetDateTime() - return DateTime.MinValue for date or datetime columns that have illegal values. -
- Pipe Name -or- Pipe - mysql - When set to the name of a named pipe, the MySqlConnection will attempt to connect to MySQL - on that named pipe.

This settings only applies to the Windows platform. -
- Use Performance Monitor -or- UsePerformanceMonitor - false - Posts performance data that can be tracked using perfmon -
- Procedure Cache Size - 25 - How many stored procedure definitions can be held in the cache -
- Ignore Prepare - true - Instructs the provider to ignore any attempts to prepare commands. This option - was added to allow a user to disable prepared statements in an entire application - without modifying the code. A user might want to do this if errors or bugs are - encountered with MySQL prepared statements. -
Use Procedure Bodiestrue - Instructs the provider to attempt to call the procedure without first resolving the metadata. This - is useful in situations where the calling user does not have access to the mysql.proc table. To - use this mode, the parameters for the procedure must be added to the command in the same order - as they appear in the procedure definition and their types must be explicitly set. -
Auto Enlisttrue - Indicates whether the connection should automatically enlist in the current transaction, - if there is one. -
Respect Binary Flagstrue - Indicates whether the connection should respect all binary flags sent to the client - as part of column metadata. False will cause the connector to behave like - Connector/Net 5.0 and earlier. -
BlobAsUTF8IncludePatternnull - Pattern that should be used to indicate which blob columns should be treated as UTF-8. -
BlobAsUTF8ExcludePatternnull - Pattern that should be used to indicate which blob columns should not be treated as UTF-8. -
Default Command Timeout30 - The default timeout that new MySqlCommand objects will use unless changed. -
Allow User Variablesfalse - Should the provider expect user variables in the SQL. -
Interactive -or- Interactive Sessionfalse - Should this session be considered interactive? -
Functions Return Stringfalse - Set this option to true to force the return value of SQL functions to be string. -
Use Affected Rowsfalse - 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. -
-
- - The following table lists the valid names for connection pooling values within - the ConnectionString. For more information about connection pooling, see - Connection Pooling for the MySql Data Provider. - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameDefaultDescription
Connection Lifetime0 - When a connection is returned to the pool, its creation time is compared with - the current time, and the connection is destroyed if that time span (in seconds) - exceeds the value specified by Connection Lifetime. This is useful in - clustered configurations to force load balancing between a running server and a - server just brought online. - - A value of zero (0) causes pooled connections to have the maximum connection - timeout. - -
Max Pool Size100The maximum number of connections allowed in the pool.
Min Pool Size0The minimum number of connections allowed in the pool.
Poolingtrue - When true, the MySqlConnection object is drawn from the appropriate - pool, or if necessary, is created and added to the appropriate pool. Recognized - values are true, false, yes, and no. -
Connection Resetfalse - Specifies whether the database connection should be reset when being - drawn from the pool. Leaving this as false will yeild much faster - connection opens but the user should understand the side effects - of doing this such as temporary tables and user variables from the previous - session not being cleared out. -
-
- - When setting keyword or connection pooling values that require a Boolean - value, you can use 'yes' instead of 'true', and 'no' instead of 'false'. - - - Note The MySql Data Provider uses the native socket protocol to - communicate with MySQL. Therefore, it does not support the use of an ODBC data source name (DSN) when - connecting to MySQL because it does not add an ODBC layer. - - - CAUTION In this release, the application should use caution when constructing a - connection string based on user input (for example when retrieving user ID and password information from a - dialog box, and appending it to the connection string). The application should - ensure that a user cannot embed extra connection string parameters in these - values (for example, entering a password as "validpassword;database=somedb" in - an attempt to attach to a different database). - -
- The following example creates a and sets some of its properties - - Public Sub CreateConnection() - Dim myConnection As New MySqlConnection() - myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass" - myConnection.Open() - End Sub 'CreateConnection - - - public void CreateConnection() - { - MySqlConnection myConnection = new MySqlConnection(); - myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass"; - myConnection.Open(); - } - - - The following example creates a in Unix environment with Mono installed. MySQL socket filename used in this example is "/var/lib/mysql/mysql.sock". The actual filename depends on your MySQL configuration. - - Public Sub CreateConnection() - Dim myConnection As New MySqlConnection() - myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass" - myConnection.Open() - End Sub 'CreateConnection - - - public void CreateConnection() - { - MySqlConnection myConnection = new MySqlConnection(); - myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass"; - myConnection.Open(); - } - - -
- - - Represents the method that will handle the event of a - . - - - - - Provides data for the InfoMessage event. This class cannot be inherited. - - - - - - - - - - IDisposable wrapper around SetCommandTimeout and ClearCommandTimeout - functionality - - - - - Summary description for MySqlStream. - - - - - ReadPacket is called by NativeDriver to start reading the next - packet on the stream. - - - - - Reads the specified number of bytes from the stream and stores them at given - offset in the buffer. - Throws EndOfStreamException if not all bytes can be read. - - Stream to read from - Array to store bytes read from the stream - The offset in buffer at which to begin storing the data read from the current stream. - Number of bytes to read - - - - LoadPacket loads up and decodes the header of the incoming packet. - - - - - Represents a set of data commands and a database connection that are used to fill a dataset and update a MySQL database. This class cannot be inherited. - - - The MySQLDataAdapter, serves as a bridge between a - and MySQL for retrieving and saving data. The MySQLDataAdapter provides this - bridge by mapping , which changes the data in the - DataSet to match the data in the data source, and , - which changes the data in the data source to match the data in the DataSet, - using the appropriate SQL statements against the data source. - - - When the MySQLDataAdapter fills a DataSet, it will create the necessary - tables and columns for the returned data if they do not already exist. However, primary - key information will not be included in the implicitly created schema unless the - property is set to . - You may also have the MySQLDataAdapter create the schema of the DataSet, - including primary key information, before filling it with data using . - - - MySQLDataAdapter is used in conjunction with - and to increase performance when connecting to a MySQL database. - - - The MySQLDataAdapter also includes the , - , , - , and - properties to facilitate the loading and updating of data. - - - When an instance of MySQLDataAdapter is created, the read/write properties - are set to initial values. For a list of these values, see the MySQLDataAdapter - constructor. - - - Please be aware that the class allows only - Int16, Int32, and Int64 to have the AutoIncrement property set. - If you plan to use autoincremement columns with MySQL, you should consider - using signed integer columns. - - - The following example creates a and a . - The MySqlConnection is opened and set as the for the - MySqlCommand. The example then calls , and closes - the connection. To accomplish this, the ExecuteNonQuery is - passed a connection string and a query string that is a SQL INSERT - statement. - - Public Function SelectRows(dataSet As DataSet, connection As String, query As String) As DataSet - Dim conn As New MySqlConnection(connection) - Dim adapter As New MySqlDataAdapter() - adapter.SelectCommand = new MySqlCommand(query, conn) - adapter.Fill(dataset) - Return dataset - End Function - - - public DataSet SelectRows(DataSet dataset,string connection,string query) - { - MySqlConnection conn = new MySqlConnection(connection); - MySqlDataAdapter adapter = new MySqlDataAdapter(); - adapter.SelectCommand = new MySqlCommand(query, conn); - adapter.Fill(dataset); - return dataset; - } - - - - - - Initializes a new instance of the MySqlDataAdapter class. - - - When an instance of is created, - the following read/write properties are set to the following initial - values. - - - - Properties - Initial Value - - - - - - - MissingMappingAction.Passthrough - - - - - - - - MissingSchemaAction.Add - - - - - You can change the value of any of these properties through a separate call - to the property. - - - The following example creates a and sets some of - its properties. - - Public Sub CreateSqlDataAdapter() - Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _ - "database=test") - Dim da As MySqlDataAdapter = New MySqlDataAdapter - da.MissingSchemaAction = MissingSchemaAction.AddWithKey - - da.SelectCommand = New MySqlCommand("SELECT id, name FROM mytable", conn) - da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ - "VALUES (@id, @name)", conn) - da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ - "WHERE id=@oldId", conn) - da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - End Sub - - - public static void CreateSqlDataAdapter() - { - MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test"); - MySqlDataAdapter da = new MySqlDataAdapter(); - da.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - da.SelectCommand = new MySqlCommand("SELECT id, name FROM mytable", conn); - da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + - "VALUES (@id, @name)", conn); - da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + - "WHERE id=@oldId", conn); - da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - } - - - - - - Initializes a new instance of the class with - the specified as the - property. - - that is a SQL SELECT statement or stored procedure and is set - as the property of the . - - - When an instance of is created, - the following read/write properties are set to the following initial - values. - - - - Properties - Initial Value - - - - - - - MissingMappingAction.Passthrough - - - - - - - - MissingSchemaAction.Add - - - - - You can change the value of any of these properties through a separate call - to the property. - - - When SelectCommand (or any of the other command properties) is assigned - to a previously created , the MySqlCommand is not cloned. - The SelectCommand maintains a reference to the previously created MySqlCommand - object. - - - The following example creates a and sets some of - its properties. - - Public Sub CreateSqlDataAdapter() - Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _ - "database=test") - Dim cmd as new MySqlCommand("SELECT id, name FROM mytable", conn) - Dim da As MySqlDataAdapter = New MySqlDataAdapter(cmd) - da.MissingSchemaAction = MissingSchemaAction.AddWithKey - - da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ - "VALUES (@id, @name)", conn) - da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ - "WHERE id=@oldId", conn) - da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - End Sub - - - public static void CreateSqlDataAdapter() - { - MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test"); - MySqlCommand cmd = new MySqlCommand("SELECT id, name FROM mytable", conn); - MySqlDataAdapter da = new MySqlDataAdapter(cmd); - da.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + - "VALUES (@id, @name)", conn); - da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + - "WHERE id=@oldId", conn); - da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - } - - - - - - Initializes a new instance of the class with - a and a object. - - A String that is a SQL SELECT statement or stored procedure to be used by - the property of the . - - A that represents the connection. - - - This implementation of the opens and closes a - if it is not already open. This can be useful in a an application that must call the - method for two or more MySqlDataAdapter objects. - If the MySqlConnection is already open, you must explicitly call - or to close it. - - - When an instance of is created, - the following read/write properties are set to the following initial - values. - - - - Properties - Initial Value - - - - - - - MissingMappingAction.Passthrough - - - - - - - - MissingSchemaAction.Add - - - - - You can change the value of any of these properties through a separate call - to the property. - - - The following example creates a and sets some of - its properties. - - Public Sub CreateSqlDataAdapter() - Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _ - "database=test") - Dim da As MySqlDataAdapter = New MySqlDataAdapter("SELECT id, name FROM mytable", conn) - da.MissingSchemaAction = MissingSchemaAction.AddWithKey - - da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ - "VALUES (@id, @name)", conn) - da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ - "WHERE id=@oldId", conn) - da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - End Sub - - - public static void CreateSqlDataAdapter() - { - MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test"); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, name FROM mytable", conn); - da.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + - "VALUES (@id, @name)", conn); - da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + - "WHERE id=@oldId", conn); - da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - } - - - - - - Initializes a new instance of the class with - a and a connection string. - - A that is a SQL SELECT statement or stored procedure to - be used by the property of the . - The connection string - - When an instance of is created, - the following read/write properties are set to the following initial - values. - - - - Properties - Initial Value - - - - - - - MissingMappingAction.Passthrough - - - - - - - - MissingSchemaAction.Add - - - - - You can change the value of any of these properties through a separate call - to the property. - - - The following example creates a and sets some of - its properties. - - Public Sub CreateSqlDataAdapter() - Dim da As MySqlDataAdapter = New MySqlDataAdapter("SELECT id, name FROM mytable", "Data Source=localhost;database=test") - Dim conn As MySqlConnection = da.SelectCommand.Connection - da.MissingSchemaAction = MissingSchemaAction.AddWithKey - - da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ - "VALUES (@id, @name)", conn) - da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ - "WHERE id=@oldId", conn) - da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - End Sub - - - public static void CreateSqlDataAdapter() - { - MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, name FROM mytable", "Data Source=localhost;database=test"); - MySqlConnection conn = da.SelectCommand.Connection; - da.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + - "VALUES (@id, @name)", conn); - da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + - "WHERE id=@oldId", conn); - da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - } - - - - - - Overridden. See . - - - - - - - - - - Overridden. See . - - - - - - - - - - Overridden. Raises the RowUpdating event. - - A MySqlRowUpdatingEventArgs that contains the event data. - - - - Overridden. Raises the RowUpdated event. - - A MySqlRowUpdatedEventArgs that contains the event data. - - - - Occurs during Update before a command is executed against the data source. The attempt to update is made, so the event fires. - - - - - Occurs during Update after a command is executed against the data source. The attempt to update is made, so the event fires. - - - - - Gets or sets a SQL statement or stored procedure used to delete records from the data set. - - A used during to delete records in the - database that correspond to deleted rows in the . - - - During , if this property is not set and primary key information - is present in the , the DeleteCommand can be generated - automatically if you set the property and use the - . Then, any additional commands that you do not set are - generated by the MySqlCommandBuilder. This generation logic requires key column - information to be present in the DataSet. - - - When DeleteCommand is assigned to a previously created , - the MySqlCommand is not cloned. The DeleteCommand maintains a reference - to the previously created MySqlCommand object. - - - The following example creates a and sets the - and DeleteCommand properties. It assumes you have already - created a object. - - Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter - - Dim da As MySqlDataAdapter = New MySqlDataAdapter() - Dim cmd As MySqlCommand - Dim parm As MySqlParameter - - ' Create the SelectCommand. - cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) - - da.SelectCommand = cmd - - ' Create the DeleteCommand. - cmd = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) - - parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - parm.SourceVersion = DataRowVersion.Original - - da.DeleteCommand = cmd - - Return da - End Function - - - public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) - { - MySqlDataAdapter da = new MySqlDataAdapter(); - MySqlCommand cmd; - MySqlParameter parm; - - // Create the SelectCommand. - cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); - - da.SelectCommand = cmd; - - // Create the DeleteCommand. - cmd = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); - - parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - parm.SourceVersion = DataRowVersion.Original; - - da.DeleteCommand = cmd; - - return da; - } - - - - - - Gets or sets a SQL statement or stored procedure used to insert records into the data set. - - A used during to insert records into the - database that correspond to new rows in the . - - - During , if this property is not set and primary key information - is present in the , the InsertCommand can be generated - automatically if you set the property and use the - . Then, any additional commands that you do not set are - generated by the MySqlCommandBuilder. This generation logic requires key column - information to be present in the DataSet. - - - When InsertCommand is assigned to a previously created , - the MySqlCommand is not cloned. The InsertCommand maintains a reference - to the previously created MySqlCommand object. - - - If execution of this command returns rows, these rows may be added to the DataSet - depending on how you set the property of the MySqlCommand object. - - - The following example creates a and sets the - and InsertCommand properties. It assumes you have already - created a object. - - Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter - - Dim da As MySqlDataAdapter = New MySqlDataAdapter() - Dim cmd As MySqlCommand - Dim parm As MySqlParameter - - ' Create the SelectCommand. - cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) - - da.SelectCommand = cmd - - ' Create the InsertCommand. - cmd = New MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id, @name)", conn) - - cmd.Parameters.Add( "@id", MySqlDbType.VarChar, 15, "id" ) - cmd.Parameters.Add( "@name", MySqlDbType.VarChar, 15, "name" ) - da.InsertCommand = cmd - - Return da - End Function - - - public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) - { - MySqlDataAdapter da = new MySqlDataAdapter(); - MySqlCommand cmd; - MySqlParameter parm; - - // Create the SelectCommand. - cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); - - da.SelectCommand = cmd; - - // Create the InsertCommand. - cmd = new MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id,@name)", conn); - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15, "id" ); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15, "name" ); - - da.InsertCommand = cmd; - - return da; - } - - - - - - Gets or sets a SQL statement or stored procedure used to select records in the data source. - - A used during to select records from the - database for placement in the . - - - When SelectCommand is assigned to a previously created , - the MySqlCommand is not cloned. The SelectCommand maintains a reference to the - previously created MySqlCommand object. - - - If the SelectCommand does not return any rows, no tables are added to the - , and no exception is raised. - - - The following example creates a and sets the - and InsertCommand properties. It assumes you have already - created a object. - - Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter - - Dim da As MySqlDataAdapter = New MySqlDataAdapter() - Dim cmd As MySqlCommand - Dim parm As MySqlParameter - - ' Create the SelectCommand. - cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) - - da.SelectCommand = cmd - - ' Create the InsertCommand. - cmd = New MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id, @name)", conn) - - cmd.Parameters.Add( "@id", MySqlDbType.VarChar, 15, "id" ) - cmd.Parameters.Add( "@name", MySqlDbType.VarChar, 15, "name" ) - da.InsertCommand = cmd - - Return da - End Function - - - public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) - { - MySqlDataAdapter da = new MySqlDataAdapter(); - MySqlCommand cmd; - MySqlParameter parm; - - // Create the SelectCommand. - cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); - - da.SelectCommand = cmd; - - // Create the InsertCommand. - cmd = new MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id,@name)", conn); - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15, "id" ); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15, "name" ); - - da.InsertCommand = cmd; - - return da; - } - - - - - - Gets or sets a SQL statement or stored procedure used to updated records in the data source. - - A used during to update records in the - database with data from the . - - - During , if this property is not set and primary key information - is present in the , the UpdateCommand can be generated - automatically if you set the property and use the - . Then, any additional commands that you do not set are - generated by the MySqlCommandBuilder. This generation logic requires key column - information to be present in the DataSet. - - - When UpdateCommand is assigned to a previously created , - the MySqlCommand is not cloned. The UpdateCommand maintains a reference - to the previously created MySqlCommand object. - - - If execution of this command returns rows, these rows may be merged with the DataSet - depending on how you set the property of the MySqlCommand object. - - - The following example creates a and sets the - and UpdateCommand properties. It assumes you have already - created a object. - - Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter - - Dim da As MySqlDataAdapter = New MySqlDataAdapter() - Dim cmd As MySqlCommand - Dim parm As MySqlParameter - - ' Create the SelectCommand. - cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) - - da.SelectCommand = cmd - - ' Create the UpdateCommand. - cmd = New MySqlCommand("UPDATE mytable SET id=@id, name=@name WHERE id=@oldId", conn) - - cmd.Parameters.Add( "@id", MySqlDbType.VarChar, 15, "id" ) - cmd.Parameters.Add( "@name", MySqlDbType.VarChar, 15, "name" ) - - parm = cmd.Parameters.Add("@oldId", MySqlDbType.VarChar, 15, "id") - parm.SourceVersion = DataRowVersion.Original - - da.UpdateCommand = cmd - - Return da - End Function - - - public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) - { - MySqlDataAdapter da = new MySqlDataAdapter(); - MySqlCommand cmd; - MySqlParameter parm; - - // Create the SelectCommand. - cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); - - da.SelectCommand = cmd; - - // Create the UpdateCommand. - cmd = new MySqlCommand("UPDATE mytable SET id=@id, name=@name WHERE id=@oldId", conn); - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15, "id" ); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15, "name" ); - - parm = cmd.Parameters.Add( "@oldId", MySqlDbType.VarChar, 15, "id" ); - parm.SourceVersion = DataRowVersion.Original; - - da.UpdateCommand = cmd; - - return da; - } - - - - - - Represents the method that will handle the event of a . - - - - - Represents the method that will handle the event of a . - - - - - Provides data for the RowUpdating event. This class cannot be inherited. - - - - - Initializes a new instance of the MySqlRowUpdatingEventArgs class. - - The to - . - The to execute during . - One of the values that specifies the type of query executed. - The sent through an . - - - - Gets or sets the MySqlCommand to execute when performing the Update. - - - - - Provides data for the RowUpdated event. This class cannot be inherited. - - - - - Initializes a new instance of the MySqlRowUpdatedEventArgs class. - - The sent through an . - The executed when is called. - One of the values that specifies the type of query executed. - The sent through an . - - - - Gets or sets the MySqlCommand executed when Update is called. - - - - - Summary description for StreamCreator. - - - - - Set keepalive + timeout on socket. - - socket - keepalive timeout, in seconds - - - - Represents a SQL transaction to be made in a MySQL database. This class cannot be inherited. - - The application creates a MySqlTransaction object by calling - on the object. All subsequent operations associated with the - transaction (for example, committing or aborting the transaction), are performed on the - MySqlTransaction object. - - The following example creates a and a MySqlTransaction. - It also demonstrates how to use the , - , and methods. - - Public Sub RunTransaction(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - - Dim myCommand As MySqlCommand = myConnection.CreateCommand() - Dim myTrans As MySqlTransaction - - ' Start a local transaction - myTrans = myConnection.BeginTransaction() - ' Must assign both transaction object and connection - ' to Command object for a pending local transaction - myCommand.Connection = myConnection - myCommand.Transaction = myTrans - - Try - myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')" - myCommand.ExecuteNonQuery() - myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')" - myCommand.ExecuteNonQuery() - myTrans.Commit() - Console.WriteLine("Both records are written to database.") - Catch e As Exception - Try - myTrans.Rollback() - Catch ex As MySqlException - If Not myTrans.Connection Is Nothing Then - Console.WriteLine("An exception of type " & ex.GetType().ToString() & _ - " was encountered while attempting to roll back the transaction.") - End If - End Try - - Console.WriteLine("An exception of type " & e.GetType().ToString() & _ - "was encountered while inserting the data.") - Console.WriteLine("Neither record was written to database.") - Finally - myConnection.Close() - End Try - End Sub 'RunTransaction - - - public void RunTransaction(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - - MySqlCommand myCommand = myConnection.CreateCommand(); - MySqlTransaction myTrans; - - // Start a local transaction - myTrans = myConnection.BeginTransaction(); - // Must assign both transaction object and connection - // to Command object for a pending local transaction - myCommand.Connection = myConnection; - myCommand.Transaction = myTrans; - - try - { - myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')"; - myCommand.ExecuteNonQuery(); - myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')"; - myCommand.ExecuteNonQuery(); - myTrans.Commit(); - Console.WriteLine("Both records are written to database."); - } - catch(Exception e) - { - try - { - myTrans.Rollback(); - } - catch (MySqlException ex) - { - if (myTrans.Connection != null) - { - Console.WriteLine("An exception of type " + ex.GetType() + - " was encountered while attempting to roll back the transaction."); - } - } - - Console.WriteLine("An exception of type " + e.GetType() + - " was encountered while inserting the data."); - Console.WriteLine("Neither record was written to database."); - } - finally - { - myConnection.Close(); - } - } - - - - - - Commits the database transaction. - - The Commit method is equivalent to the MySQL SQL statement - COMMIT. - - The following example creates a and a - . It also demonstrates how to use the - , , and Rollback - methods. - - Public Sub RunSqlTransaction(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - - Dim myCommand As MySqlCommand = myConnection.CreateCommand() - Dim myTrans As MySqlTransaction - - ' Start a local transaction - myTrans = myConnection.BeginTransaction() - - ' Must assign both transaction object and connection - ' to Command object for a pending local transaction - myCommand.Connection = myConnection - myCommand.Transaction = myTrans - - Try - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')" - myCommand.ExecuteNonQuery() - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')" - myCommand.ExecuteNonQuery() - myTrans.Commit() - Console.WriteLine("Success.") - Catch e As Exception - Try - myTrans.Rollback() - Catch ex As MySqlException - If Not myTrans.Connection Is Nothing Then - Console.WriteLine("An exception of type " & ex.GetType().ToString() & _ - " was encountered while attempting to roll back the transaction.") - End If - End Try - - Console.WriteLine("An exception of type " & e.GetType().ToString() & _ - "was encountered while inserting the data.") - Console.WriteLine("Neither record was written to database.") - Finally - myConnection.Close() - End Try - End Sub - - - public void RunSqlTransaction(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - - MySqlCommand myCommand = myConnection.CreateCommand(); - MySqlTransaction myTrans; - - // Start a local transaction - myTrans = myConnection.BeginTransaction(); - // Must assign both transaction object and connection - // to Command object for a pending local transaction - myCommand.Connection = myConnection; - myCommand.Transaction = myTrans; - - try - { - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')"; - myCommand.ExecuteNonQuery(); - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')"; - myCommand.ExecuteNonQuery(); - myTrans.Commit(); - Console.WriteLine("Both records are written to database."); - } - catch(Exception e) - { - try - { - myTrans.Rollback(); - } - catch (MySqlException ex) - { - if (myTrans.Connection != null) - { - Console.WriteLine("An exception of type " + ex.GetType() + - " was encountered while attempting to roll back the transaction."); - } - } - - Console.WriteLine("An exception of type " + e.GetType() + - " was encountered while inserting the data."); - Console.WriteLine("Neither record was written to database."); - } - finally - { - myConnection.Close(); - } - } - - - - - - Rolls back a transaction from a pending state. - - The Rollback method is equivalent to the MySQL statement ROLLBACK. - The transaction can only be rolled back from a pending state - (after BeginTransaction has been called, but before Commit is - called). - - The following example creates a and a - . It also demonstrates how to use the - , , and Rollback - methods. - - Public Sub RunSqlTransaction(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - - Dim myCommand As MySqlCommand = myConnection.CreateCommand() - Dim myTrans As MySqlTransaction - - ' Start a local transaction - myTrans = myConnection.BeginTransaction() - - ' Must assign both transaction object and connection - ' to Command object for a pending local transaction - myCommand.Connection = myConnection - myCommand.Transaction = myTrans - - Try - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')" - myCommand.ExecuteNonQuery() - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')" - myCommand.ExecuteNonQuery() - myTrans.Commit() - Console.WriteLine("Success.") - Catch e As Exception - Try - myTrans.Rollback() - Catch ex As MySqlException - If Not myTrans.Connection Is Nothing Then - Console.WriteLine("An exception of type " & ex.GetType().ToString() & _ - " was encountered while attempting to roll back the transaction.") - End If - End Try - - Console.WriteLine("An exception of type " & e.GetType().ToString() & _ - "was encountered while inserting the data.") - Console.WriteLine("Neither record was written to database.") - Finally - myConnection.Close() - End Try - End Sub - - - public void RunSqlTransaction(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - - MySqlCommand myCommand = myConnection.CreateCommand(); - MySqlTransaction myTrans; - - // Start a local transaction - myTrans = myConnection.BeginTransaction(); - // Must assign both transaction object and connection - // to Command object for a pending local transaction - myCommand.Connection = myConnection; - myCommand.Transaction = myTrans; - - try - { - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')"; - myCommand.ExecuteNonQuery(); - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')"; - myCommand.ExecuteNonQuery(); - myTrans.Commit(); - Console.WriteLine("Both records are written to database."); - } - catch(Exception e) - { - try - { - myTrans.Rollback(); - } - catch (MySqlException ex) - { - if (myTrans.Connection != null) - { - Console.WriteLine("An exception of type " + ex.GetType() + - " was encountered while attempting to roll back the transaction."); - } - } - - Console.WriteLine("An exception of type " + e.GetType() + - " was encountered while inserting the data."); - Console.WriteLine("Neither record was written to database."); - } - finally - { - myConnection.Close(); - } - } - - - - - - Gets the object associated with the transaction, or a null reference (Nothing in Visual Basic) if the transaction is no longer valid. - - The object associated with this transaction. - - A single application may have multiple database connections, each - with zero or more transactions. This property enables you to - determine the connection object associated with a particular - transaction created by . - - - - - Specifies the for this transaction. - - - The for this transaction. The default is ReadCommitted. - - - Parallel transactions are not supported. Therefore, the IsolationLevel - applies to the entire transaction. - - - - - Gets or sets the name of the server. - - The server. - - - - Gets or sets the name of the database the connection should - initially connect to. - - - - - Gets or sets the protocol that should be used for communicating - with MySQL. - - - - - Gets or sets the name of the named pipe that should be used - for communicating with MySQL. - - - - - Gets or sets a boolean value that indicates whether this connection - should use compression. - - - - - Gets or sets a boolean value that indicates whether this connection will allow - commands to send multiple SQL statements in one execution. - - - - - Gets or sets a boolean value that indicates whether logging is enabled. - - - - - Gets or sets the base name of the shared memory objects used to - communicate with MySQL when the shared memory protocol is being used. - - - - - Gets or sets a boolean value that indicates whether this connection uses - the old style (@) parameter markers or the new (?) style. - - - - - Gets or sets the port number that is used when the socket - protocol is being used. - - - - - Gets or sets the connection timeout. - - - - - Gets or sets the default command timeout. - - - - - Gets or sets the user id that should be used to connect with. - - - - - Gets or sets the password that should be used to connect with. - - - - - Gets or sets a boolean value that indicates if the password should be persisted - in the connection string. - - - - - Gets or sets a boolean value that indicates if zero date time values are supported. - - - - - Gets or sets a boolean value indicating if zero datetime values should be - converted to DateTime.MinValue. - - - - - Gets or sets a boolean value indicating if the Usage Advisor should be enabled. - - - - - Gets or sets the size of the stored procedure cache. - - - - - Gets or sets a boolean value indicating if the permon hooks should be enabled. - - - - - Gets or sets a boolean value indicating if calls to Prepare() should be ignored. - - - - - Gets or sets the lifetime of a pooled connection. - - - - - Gets or sets a boolean value indicating if connection pooling is enabled. - - - - - Gets the minimum connection pool size. - - - - - Gets or sets the maximum connection pool setting. - - - - - Gets or sets a boolean value indicating if the connection should be reset when retrieved - from the pool. - - - - - Gets or sets the character set that should be used for sending queries to the server. - - - - - Indicates whether the driver should treat binary blobs as UTF8 - - - - - Gets or sets the pattern that matches the columns that should be treated as UTF8 - - - - - Gets or sets the pattern that matches the columns that should not be treated as UTF8 - - - - - Indicates whether to use SSL connections and how to handle server certificate errors. - - - - - Summary description for CharSetMap. - - - - - Returns the text encoding for a given MySQL character set name - - Version of the connection requesting the encoding - Name of the character set to get the encoding for - Encoding object for the given character set name - - - - - - - - - Provides a class capable of executing a SQL script containing - multiple SQL statements including CREATE PROCEDURE statements - that require changing the delimiter - - - - - Initializes a new instance of the - class. - - - - - Initializes a new instance of the - class. - - The connection. - - - - Initializes a new instance of the - class. - - The query. - - - - Initializes a new instance of the - class. - - The connection. - The query. - - - - Executes this instance. - - The number of statements executed as part of the script. - - - - Gets or sets the connection. - - The connection. - - - - Gets or sets the query. - - The query. - - - - Gets or sets the delimiter. - - The delimiter. - - - - - - - - - - - - - - - - - - - Gets the statement text. - - The statement text. - - - - Gets the line. - - The line. - - - - Gets the position. - - The position. - - - - - - - - - Initializes a new instance of the class. - - The exception. - - - - Gets the exception. - - The exception. - - - - Gets or sets a value indicating whether this is ignore. - - true if ignore; otherwise, false. - - - - - - - - - Constructs a new MySqlDateTime object by setting the individual time properties to - the given values. - - The year to use. - The month to use. - The day to use. - The hour to use. - The minute to use. - The second to use. - - - - Constructs a new MySqlDateTime object by using values from the given object. - - The object to copy. - - - - Constructs a new MySqlDateTime object by copying the current value of the given object. - - The MySqlDateTime object to copy. - - - - Enables the contruction of a MySqlDateTime object by parsing a string. - - - - Returns this value as a DateTime - - - Returns a MySQL specific string representation of this value - - - - - - - - - Indicates if this object contains a value that can be represented as a DateTime - - - - Returns the year portion of this datetime - - - Returns the month portion of this datetime - - - Returns the day portion of this datetime - - - Returns the hour portion of this datetime - - - Returns the minute portion of this datetime - - - Returns the second portion of this datetime - - - - Retrieves the millisecond value of this object. - - - - - Returns true if this datetime object has a null value - - - - - Retrieves the value of this as a DateTime object. - - - - - Summary description for Driver. - - - - - Sets the current database for the this connection - - - - - - Retrieve client SSL certificates. Dependent on connection string - settings we use either file or store based certificates. - - - - - Return the appropriate set of connection flags for our - server capabilities and our user requested options. - - - - - Perform an authentication against a 4.1.1 server - - - - - Query is the method that is called to send all queries to the server - - - - - Sends the specified file to the server. - This supports the LOAD DATA LOCAL INFILE - - - - - - FetchDataRow is the method that the data reader calls to see if there is another - row to fetch. In the non-prepared mode, it will simply read the next data packet. - In the prepared mode (statementId > 0), it will - - - - - Execution timeout, in milliseconds. When the accumulated time for network IO exceeds this value - TimeoutException is thrown. This timeout needs to be reset for every new command - - - - - - Summary description for Crypt. - - - - - Simple XOR scramble - - Source array - Index inside source array - Destination array - Index inside destination array - Password used to xor the bits - Number of bytes to scramble - - - - Generate a scrambled password for 4.1.0 using new passwords - - The password to scramble - The seedbytes used to scramble - Array of bytes containing the scrambled password - - - - Generates a proper hash for old style 4.1.0 passwords. This would be used - if a 4.1.0 server contained old 16 byte hashes. - - The password to hash - Seed bytes received from the server - Byte array containing the password hash - - - - Returns a byte array containing the proper encryption of the - given password/seed according to the new 4.1.1 authentication scheme. - - - - - - - - Encrypts a password using the MySql encryption scheme - - The password to encrypt - The encryption seed the server gave us - Indicates if we should use the old or new encryption scheme - - - - - Hashes a password using the algorithm from Monty's code. - The first element in the return is the result of the "old" hash. - The second element is the rest of the "new" hash. - - Password to be hashed - Two element array containing the hashed values - - - - Summary description for API. - - -
-
diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/AssemblyInfo.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/AssemblyInfo.cs deleted file mode 100644 index 4e77216..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; -using System.Security; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyDescription("ADO.Net driver for MySQL")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("MySQL AB")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("Copyright 2004-2007, MySQL AB")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: ComVisible(false)] -[assembly: CLSCompliant(false)] -#if !CF -[assembly: AssemblyTitle("MySql.Data.dll")] -[assembly: AllowPartiallyTrustedCallers()] -#else -[assembly: AssemblyTitle("MySql.Data.CF.dll")] -#endif - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyName("ConnectorNet")] - diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/ReservedWords.txt b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/ReservedWords.txt deleted file mode 100644 index 767d97d..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/ReservedWords.txt +++ /dev/null @@ -1,76 +0,0 @@ -ACCESSIBLE ADD ALL -ALTER ANALYZE AND -AS ASC ASENSITIVE -BEFORE BETWEEN BIGINT -BINARY BLOB BOTH -BY CALL CASCADE -CASE CHANGE CHAR -CHARACTER CHECK COLLATE -COLUMN CONDITION CONNECTION -CONSTRAINT CONTINUE CONTRIBUTORS -CONVERT CREATE CROSS -CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP -CURRENT_USER CURSOR DATABASE -DATABASES DAY_HOUR DAY_MICROSECOND -DAY_MINUTE DAY_SECOND DEC -DECIMAL DECLARE DEFAULT -DELAYED DELETE DESC -DESCRIBE DETERMINISTIC DISTINCT -DISTINCTROW DIV DOUBLE -DROP DUAL EACH -ELSE ELSEIF ENCLOSED -ESCAPED EXISTS EXIT -EXPLAIN FALSE FETCH -FLOAT FLOAT4 FLOAT8 -FOR FORCE FOREIGN -FROM FULLTEXT GRANT -GROUP HAVING HIGH_PRIORITY -HOUR_MICROSECOND HOUR_MINUTE HOUR_SECOND -IF IGNORE IN -INDEX INFILE INNER -INOUT INSENSITIVE INSERT -INT INT1 INT2 -INT3 INT4 INT8 -INTEGER INTERVAL INTO -IS ITERATE JOIN -KEY KEYS KILL -LEADING LEAVE LEFT -LIKE LIMIT LINEAR -LINES LOAD LOCALTIME -LOCALTIMESTAMP LOCK LONG -LONGBLOB LONGTEXT LOOP -LOW_PRIORITY MATCH MEDIUMBLOB -MEDIUMINT MEDIUMTEXT MIDDLEINT -MINUTE_MICROSECOND MINUTE_SECOND MOD -MODIFIES NATURAL NOT -NO_WRITE_TO_BINLOG NULL NUMERIC -ON OPTIMIZE OPTION -OPTIONALLY OR ORDER -OUT OUTER OUTFILE -PRECISION PRIMARY PROCEDURE -PURGE RANGE READ -READS READ_ONLY READ_WRITE -REAL REFERENCES REGEXP -RELEASE RENAME REPEAT -REPLACE REQUIRE RESTRICT -RETURN REVOKE RIGHT -RLIKE SCHEMA SCHEMAS -SECOND_MICROSECOND SELECT SENSITIVE -SEPARATOR SET SHOW -SMALLINT SPATIAL SPECIFIC -SQL SQLEXCEPTION SQLSTATE -SQLWARNING SQL_BIG_RESULT SQL_CALC_FOUND_ROWS -SQL_SMALL_RESULT SSL STARTING -STRAIGHT_JOIN TABLE TERMINATED -THEN TINYBLOB TINYINT -TINYTEXT TO TRAILING -TRIGGER TRUE UNDO -UNION UNIQUE UNLOCK -UNSIGNED UPDATE UPGRADE -USAGE USE USING -UTC_DATE UTC_TIME UTC_TIMESTAMP -VALUES VARBINARY VARCHAR -VARCHARACTER VARYING WHEN -WHERE WHILE WITH -WRITE X509 XOR -YEAR_MONTH ZEROFILL diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/Resources.Designer.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/Resources.Designer.cs deleted file mode 100644 index fb04484..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/Resources.Designer.cs +++ /dev/null @@ -1,1147 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.4927 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace MySql.Data.MySqlClient.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] -#if !CF - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] -#endif - public class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MySql.Data.MySqlClient.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Improper MySqlCommandBuilder state: adapter is null. - /// - public static string AdapterIsNull { - get { - return ResourceManager.GetString("AdapterIsNull", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Improper MySqlCommandBuilder state: adapter's SelectCommand is null. - /// - public static string AdapterSelectIsNull { - get { - return ResourceManager.GetString("AdapterSelectIsNull", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid attempt to access a field before calling Read(). - /// - public static string AttemptToAccessBeforeRead { - get { - return ResourceManager.GetString("AttemptToAccessBeforeRead", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Version string not in acceptable format. - /// - public static string BadVersionFormat { - get { - return ResourceManager.GetString("BadVersionFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The buffer cannot be null. - /// - public static string BufferCannotBeNull { - get { - return ResourceManager.GetString("BufferCannotBeNull", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Buffer is not large enough. - /// - public static string BufferNotLargeEnough { - get { - return ResourceManager.GetString("BufferNotLargeEnough", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Canceling an executing query requires MySQL 5.0 or higher.. - /// - public static string CancelNeeds50 { - get { - return ResourceManager.GetString("CancelNeeds50", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Canceling an active query is only supported on MySQL 5.0.0 and above. . - /// - public static string CancelNotSupported { - get { - return ResourceManager.GetString("CancelNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to MySqlCommandBuilder does not support multi-table statements. - /// - public static string CBMultiTableNotSupported { - get { - return ResourceManager.GetString("CBMultiTableNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to MySqlCommandBuilder cannot operate on tables with no unique or key columns. - /// - public static string CBNoKeyColumn { - get { - return ResourceManager.GetString("CBNoKeyColumn", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Chaos isolation level is not supported. - /// - public static string ChaosNotSupported { - get { - return ResourceManager.GetString("ChaosNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The CommandText property has not been properly initialized.. - /// - public static string CommandTextNotInitialized { - get { - return ResourceManager.GetString("CommandTextNotInitialized", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The connection is already open.. - /// - public static string ConnectionAlreadyOpen { - get { - return ResourceManager.GetString("ConnectionAlreadyOpen", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Connection unexpectedly terminated.. - /// - public static string ConnectionBroken { - get { - return ResourceManager.GetString("ConnectionBroken", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Connection must be valid and open. - /// - public static string ConnectionMustBeOpen { - get { - return ResourceManager.GetString("ConnectionMustBeOpen", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The connection is not open.. - /// - public static string ConnectionNotOpen { - get { - return ResourceManager.GetString("ConnectionNotOpen", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The connection property has not been set or is null.. - /// - public static string ConnectionNotSet { - get { - return ResourceManager.GetString("ConnectionNotSet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Could not find specified column in results: {0}. - /// - public static string CouldNotFindColumnName { - get { - return ResourceManager.GetString("CouldNotFindColumnName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Count cannot be negative. - /// - public static string CountCannotBeNegative { - get { - return ResourceManager.GetString("CountCannotBeNegative", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SetLength is not a valid operation on CompressedStream. - /// - public static string CSNoSetLength { - get { - return ResourceManager.GetString("CSNoSetLength", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The given value was not in a supported format.. - /// - public static string DataNotInSupportedFormat { - get { - return ResourceManager.GetString("DataNotInSupportedFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There is already an open DataReader associated with this Connection which must be closed first.. - /// - public static string DataReaderOpen { - get { - return ResourceManager.GetString("DataReaderOpen", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The default connection encoding was not found. Please report this as a bug along with your connection string and system details.. - /// - public static string DefaultEncodingNotFound { - get { - return ResourceManager.GetString("DefaultEncodingNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to MySQL Connector/Net does not currently support distributed transactions.. - /// - public static string DistributedTxnNotSupported { - get { - return ResourceManager.GetString("DistributedTxnNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Error creating socket connection. - /// - public static string ErrorCreatingSocket { - get { - return ResourceManager.GetString("ErrorCreatingSocket", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fatal error encountered during command execution.. - /// - public static string FatalErrorDuringExecute { - get { - return ResourceManager.GetString("FatalErrorDuringExecute", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fatal error encountered during data read.. - /// - public static string FatalErrorDuringRead { - get { - return ResourceManager.GetString("FatalErrorDuringRead", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fatal error encountered attempting to read the resultset.. - /// - public static string FatalErrorReadingResult { - get { - return ResourceManager.GetString("FatalErrorReadingResult", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to From index and length use more bytes than from contains. - /// - public static string FromAndLengthTooBig { - get { - return ResourceManager.GetString("FromAndLengthTooBig", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to From index must be a valid index inside the from buffer. - /// - public static string FromIndexMustBeValid { - get { - return ResourceManager.GetString("FromIndexMustBeValid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Call to GetHostEntry failed after {0} while querying for hostname '{1}': SocketErrorCode={2}, ErrorCode={3}, NativeErrorCode={4}.. - /// - public static string GetHostEntryFailed { - get { - return ResourceManager.GetString("GetHostEntryFailed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Retrieving procedure metadata for {0} from server.. - /// - public static string HardProcQuery { - get { - return ResourceManager.GetString("HardProcQuery", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Value has an unsupported format.. - /// - public static string ImproperValueFormat { - get { - return ResourceManager.GetString("ImproperValueFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An incorrect response was received from the server.. - /// - public static string IncorrectTransmission { - get { - return ResourceManager.GetString("IncorrectTransmission", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Index and length use more bytes than to has room for. - /// - public static string IndexAndLengthTooBig { - get { - return ResourceManager.GetString("IndexAndLengthTooBig", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Index must be a valid position in the buffer. - /// - public static string IndexMustBeValid { - get { - return ResourceManager.GetString("IndexMustBeValid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to You have specified an invalid column ordinal.. - /// - public static string InvalidColumnOrdinal { - get { - return ResourceManager.GetString("InvalidColumnOrdinal", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The requested value '{0}' is invalid for the given keyword '{1}'.. - /// - public static string InvalidConnectionStringValue { - get { - return ResourceManager.GetString("InvalidConnectionStringValue", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Procedure or function '{0}' cannot be found in database '{1}'.. - /// - public static string InvalidProcName { - get { - return ResourceManager.GetString("InvalidProcName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' is an illegal value for a boolean option.. - /// - public static string InvalidValueForBoolean { - get { - return ResourceManager.GetString("InvalidValueForBoolean", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Keyword does not allow null values.. - /// - public static string KeywordNoNull { - get { - return ResourceManager.GetString("KeywordNoNull", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Keyword not supported.. - /// - public static string KeywordNotSupported { - get { - return ResourceManager.GetString("KeywordNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ACCESSIBLE - ///ADD - ///ALL - ///ALTER - ///ANALYZE - ///AND - ///AS - ///ASC - ///ASENSITIVE - ///BEFORE - ///BETWEEN - ///BIGINT - ///BINARY - ///BLOB - ///BOTH - ///BY - ///CALL - ///CASCADE - ///CASE - ///CHANGE - ///CHAR - ///CHARACTER - ///CHECK - ///COLLATE - ///COLUMN - ///CONDITION - ///CONNECTION - ///CONSTRAINT - ///CONTINUE - ///CONVERT - ///CREATE - ///CROSS - ///CURRENT_DATE - ///CURRENT_TIME - ///CURRENT_TIMESTAMP - ///CURRENT_USER - ///CURSOR - ///DATABASE - ///DATABASES - ///DAY_HOUR - ///DAY_MICROSECOND - ///DAY_MINUTE - ///DAY_SECOND - ///DEC - ///DECIMAL - ///DECLARE - ///DEFAULT - ///DELAYED - ///DELETE - ///DESC - ///DESCRIBE - ///DETERMINISTIC - ///DISTINCT - ///DISTINCTROW - ///DIV - ///DOUBLE - ///DROP - ///DUAL - ///EACH - ///ELSE - ///ELSEIF - ///ENCLOSED - ///ESCAPED - ///EXISTS - ///EXIT - ///EXP [rest of string was truncated]";. - /// - public static string keywords { - get { - return ResourceManager.GetString("keywords", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to INTERNAL ERROR: More than one output parameter row detected.. - /// - public static string MoreThanOneOPRow { - get { - return ResourceManager.GetString("MoreThanOneOPRow", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Multiple simultaneous connections or connections with different connection strings inside the same transaction are not currently supported.. - /// - public static string MultipleConnectionsInTransactionNotSupported { - get { - return ResourceManager.GetString("MultipleConnectionsInTransactionNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to NamedPipeStream does not support seeking. - /// - public static string NamedPipeNoSeek { - get { - return ResourceManager.GetString("NamedPipeNoSeek", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to NamedPipeStream doesn't support SetLength. - /// - public static string NamedPipeNoSetLength { - get { - return ResourceManager.GetString("NamedPipeNoSetLength", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid attempt to call NextResult when the reader is closed.. - /// - public static string NextResultIsClosed { - get { - return ResourceManager.GetString("NextResultIsClosed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to When calling stored procedures and 'Use Procedure Bodies' is false, all parameters must have their type explicitly set.. - /// - public static string NoBodiesAndTypeNotSet { - get { - return ResourceManager.GetString("NoBodiesAndTypeNotSet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Nested transactions are not supported.. - /// - public static string NoNestedTransactions { - get { - return ResourceManager.GetString("NoNestedTransactions", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The host {0} does not support SSL connections.. - /// - public static string NoServerSSLSupport { - get { - return ResourceManager.GetString("NoServerSSLSupport", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The object is not open or has been disposed.. - /// - public static string ObjectDisposed { - get { - return ResourceManager.GetString("ObjectDisposed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Offset cannot be negative. - /// - public static string OffsetCannotBeNegative { - get { - return ResourceManager.GetString("OffsetCannotBeNegative", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Offset must be a valid position in buffer. - /// - public static string OffsetMustBeValid { - get { - return ResourceManager.GetString("OffsetMustBeValid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter '{0}' has already been defined.. - /// - public static string ParameterAlreadyDefined { - get { - return ResourceManager.GetString("ParameterAlreadyDefined", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter cannot have a negative value. - /// - public static string ParameterCannotBeNegative { - get { - return ResourceManager.GetString("ParameterCannotBeNegative", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter cannot be null. - /// - public static string ParameterCannotBeNull { - get { - return ResourceManager.GetString("ParameterCannotBeNull", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter is invalid.. - /// - public static string ParameterIsInvalid { - get { - return ResourceManager.GetString("ParameterIsInvalid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter '{0}' must be defined.. - /// - public static string ParameterMustBeDefined { - get { - return ResourceManager.GetString("ParameterMustBeDefined", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter '{0}' was not found during prepare.. - /// - public static string ParameterNotFoundDuringPrepare { - get { - return ResourceManager.GetString("ParameterNotFoundDuringPrepare", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password must be valid and contain length characters. - /// - public static string PasswordMustHaveLegalChars { - get { - return ResourceManager.GetString("PasswordMustHaveLegalChars", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to This category includes a series of counters for MySQL.. - /// - public static string PerfMonCategoryHelp { - get { - return ResourceManager.GetString("PerfMonCategoryHelp", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to .NET Data Provider for MySQL. - /// - public static string PerfMonCategoryName { - get { - return ResourceManager.GetString("PerfMonCategoryName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The number of times a procedures metadata had to be queried from the server.. - /// - public static string PerfMonHardProcHelp { - get { - return ResourceManager.GetString("PerfMonHardProcHelp", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Hard Procedure Queries. - /// - public static string PerfMonHardProcName { - get { - return ResourceManager.GetString("PerfMonHardProcName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The number of times a procedures metadata was retrieved from the client-side cache.. - /// - public static string PerfMonSoftProcHelp { - get { - return ResourceManager.GetString("PerfMonSoftProcHelp", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Soft Procedure Queries. - /// - public static string PerfMonSoftProcName { - get { - return ResourceManager.GetString("PerfMonSoftProcName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to same name are not supported.. - /// - public static string ProcAndFuncSameName { - get { - return ResourceManager.GetString("ProcAndFuncSameName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Packets larger than max_allowed_packet are not allowed.. - /// - public static string QueryTooLarge { - get { - return ResourceManager.GetString("QueryTooLarge", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Reading from the stream has failed.. - /// - public static string ReadFromStreamFailed { - get { - return ResourceManager.GetString("ReadFromStreamFailed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid attempt to read a prior column using SequentialAccess. - /// - public static string ReadingPriorColumnUsingSeqAccess { - get { - return ResourceManager.GetString("ReadingPriorColumnUsingSeqAccess", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Routine '{0}' cannot be found. Either check the spelling or make sure you have sufficient rights to execute the routine.. - /// - public static string RoutineNotFound { - get { - return ResourceManager.GetString("RoutineNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Connector/Net no longer supports server versions prior to 4.1. - /// - public static string ServerTooOld { - get { - return ResourceManager.GetString("ServerTooOld", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Socket streams do not support seeking. - /// - public static string SocketNoSeek { - get { - return ResourceManager.GetString("SocketNoSeek", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Retrieving procedure metadata for {0} from procedure cache.. - /// - public static string SoftProcQuery { - get { - return ResourceManager.GetString("SoftProcQuery", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Stored procedures are not supported on this version of MySQL. - /// - public static string SPNotSupported { - get { - return ResourceManager.GetString("SPNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The stream has already been closed. - /// - public static string StreamAlreadyClosed { - get { - return ResourceManager.GetString("StreamAlreadyClosed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The stream does not support reading. - /// - public static string StreamNoRead { - get { - return ResourceManager.GetString("StreamNoRead", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The stream does not support writing. - /// - public static string StreamNoWrite { - get { - return ResourceManager.GetString("StreamNoWrite", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.. - /// - public static string Timeout { - get { - return ResourceManager.GetString("Timeout", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to error connecting: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.. - /// - public static string TimeoutGettingConnection { - get { - return ResourceManager.GetString("TimeoutGettingConnection", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Connection Closed. - /// - public static string TraceCloseConnection { - get { - return ResourceManager.GetString("TraceCloseConnection", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unable to trace. There are more than Int32.MaxValue connections in use.. - /// - public static string TraceErrorMoreThanMaxValueConnections { - get { - return ResourceManager.GetString("TraceErrorMoreThanMaxValueConnections", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Error encountered during row fetch. Number = {1}, Message={2}. - /// - public static string TraceFetchError { - get { - return ResourceManager.GetString("TraceFetchError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Connection Opened: connection string = '{1}'. - /// - public static string TraceOpenConnection { - get { - return ResourceManager.GetString("TraceOpenConnection", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Error encountered attempting to open result: Number={1}, Message={2}. - /// - public static string TraceOpenResultError { - get { - return ResourceManager.GetString("TraceOpenResultError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Query Closed. - /// - public static string TraceQueryDone { - get { - return ResourceManager.GetString("TraceQueryDone", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Query Normalized: {2}. - /// - public static string TraceQueryNormalized { - get { - return ResourceManager.GetString("TraceQueryNormalized", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Query Opened: {2}. - /// - public static string TraceQueryOpened { - get { - return ResourceManager.GetString("TraceQueryOpened", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Resultset Opened: field(s) = {1}, affected rows = {2}, inserted id = {3}. - /// - public static string TraceResult { - get { - return ResourceManager.GetString("TraceResult", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Resultset Closed. Total rows={1}, skipped rows={2}, size (bytes)={3}. - /// - public static string TraceResultClosed { - get { - return ResourceManager.GetString("TraceResultClosed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Set Database: {1}. - /// - public static string TraceSetDatabase { - get { - return ResourceManager.GetString("TraceSetDatabase", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Statement closed: statement id = {1}. - /// - public static string TraceStatementClosed { - get { - return ResourceManager.GetString("TraceStatementClosed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Statement executed: statement id = {1}. - /// - public static string TraceStatementExecuted { - get { - return ResourceManager.GetString("TraceStatementExecuted", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Statement prepared: sql='{1}', statement id={2}. - /// - public static string TraceStatementPrepared { - get { - return ResourceManager.GetString("TraceStatementPrepared", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Usage Advisor Warning: Query is using a bad index. - /// - public static string TraceUAWarningBadIndex { - get { - return ResourceManager.GetString("TraceUAWarningBadIndex", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Usage Advisor Warning: The field '{2}' was converted to the following types: {3}. - /// - public static string TraceUAWarningFieldConversion { - get { - return ResourceManager.GetString("TraceUAWarningFieldConversion", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Usage Advisor Warning: Query does not use an index. - /// - public static string TraceUAWarningNoIndex { - get { - return ResourceManager.GetString("TraceUAWarningNoIndex", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Usage Advisor Warning: The following columns were not accessed: {2}. - /// - public static string TraceUAWarningSkippedColumns { - get { - return ResourceManager.GetString("TraceUAWarningSkippedColumns", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: Usage Advisor Warning: Skipped {2} rows. Consider a more focused query.. - /// - public static string TraceUAWarningSkippedRows { - get { - return ResourceManager.GetString("TraceUAWarningSkippedRows", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: MySql Warning: Level={1}, Code={2}, Message={3}. - /// - public static string TraceWarning { - get { - return ResourceManager.GetString("TraceWarning", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unable to connect to any of the specified MySQL hosts.. - /// - public static string UnableToConnectToHost { - get { - return ResourceManager.GetString("UnableToConnectToHost", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unable to derive stored routine parameters. The 'Parameters' information schema table is not available and access to the stored procedure body has been disabled.. - /// - public static string UnableToDeriveParameters { - get { - return ResourceManager.GetString("UnableToDeriveParameters", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An error occured attempting to enumerate the user-defined functions. Do you have SELECT privileges on the mysql.func table?. - /// - public static string UnableToEnumerateUDF { - get { - return ResourceManager.GetString("UnableToEnumerateUDF", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unable to execute stored procedure '{0}'.. - /// - public static string UnableToExecuteSP { - get { - return ResourceManager.GetString("UnableToExecuteSP", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There was an error parsing the foreign key definition.. - /// - public static string UnableToParseFK { - get { - return ResourceManager.GetString("UnableToParseFK", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unable to retrieve stored routine parameters. Either grant access to the routine or add the 'Use Procedure Bodies=false' option to your connection string.. - /// - public static string UnableToRetrieveParameters { - get { - return ResourceManager.GetString("UnableToRetrieveParameters", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unable to retrieve stored procedure metadata for routine '{0}'. Either grant SELECT privilege to mysql.proc for this user or use "use procedure bodies=false" with your connection string.. - /// - public static string UnableToRetrieveSProcData { - get { - return ResourceManager.GetString("UnableToRetrieveSProcData", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unable to start a second async operation while one is running.. - /// - public static string UnableToStartSecondAsyncOp { - get { - return ResourceManager.GetString("UnableToStartSecondAsyncOp", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unix sockets are not supported on Windows. - /// - public static string UnixSocketsNotSupported { - get { - return ResourceManager.GetString("UnixSocketsNotSupported", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The requested column value could not be treated as or conveted to a Guid.. - /// - public static string ValueNotSupportedForGuid { - get { - return ResourceManager.GetString("ValueNotSupportedForGuid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Writing to the stream failed.. - /// - public static string WriteToStreamFailed { - get { - return ResourceManager.GetString("WriteToStreamFailed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter '{0}' is not found but a parameter with the name '{1}' is found. Parameter names must include the leading parameter marker.. - /// - public static string WrongParameterName { - get { - return ResourceManager.GetString("WrongParameterName", resourceCulture); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/Resources.resx b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/Resources.resx deleted file mode 100644 index 2235da9..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/Resources.resx +++ /dev/null @@ -1,460 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Version string not in acceptable format - - - NamedPipeStream does not support seeking - - - The stream has already been closed - - - The buffer cannot be null - - - Buffer is not large enough - - - Offset cannot be negative - - - Count cannot be negative - - - The stream does not support reading - - - NamedPipeStream doesn't support SetLength - - - The stream does not support writing - - - Error creating socket connection - - - Socket streams do not support seeking - - - Unix sockets are not supported on Windows - - - Offset must be a valid position in buffer - - - SetLength is not a valid operation on CompressedStream - - - From index must be a valid index inside the from buffer - - - From index and length use more bytes than from contains - - - Index must be a valid position in the buffer - - - Index and length use more bytes than to has room for - - - Password must be valid and contain length characters - - - Parameter cannot have a negative value - - - Connection must be valid and open - - - There is already an open DataReader associated with this Connection which must be closed first. - - - Stored procedures are not supported on this version of MySQL - - - The connection property has not been set or is null. - - - The connection is not open. - - - Improper MySqlCommandBuilder state: adapter is null - - - Improper MySqlCommandBuilder state: adapter's SelectCommand is null - - - MySqlCommandBuilder does not support multi-table statements - - - MySqlCommandBuilder cannot operate on tables with no unique or key columns - - - Parameter cannot be null - - - Chaos isolation level is not supported - - - Parameter is invalid. - - - The connection is already open. - - - Keyword not supported. - - - Writing to the stream failed. - - - Reading from the stream has failed. - - - Packets larger than max_allowed_packet are not allowed. - - - Unable to execute stored procedure '{0}'. - - - same name are not supported. - - - Keyword does not allow null values. - - - Value has an unsupported format. - - - Procedure or function '{0}' cannot be found in database '{1}'. - - - Retrieving procedure metadata for {0} from server. - - - Retrieving procedure metadata for {0} from procedure cache. - - - Connection unexpectedly terminated. - - - An incorrect response was received from the server. - - - Canceling an active query is only supported on MySQL 5.0.0 and above. - - - Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. - - - Canceling an executing query requires MySQL 5.0 or higher. - - - Nested transactions are not supported. - - - The CommandText property has not been properly initialized. - - - There was an error parsing the foreign key definition. - - - This category includes a series of counters for MySQL. - - - .NET Data Provider for MySQL - - - The number of times a procedures metadata had to be queried from the server. - - - Hard Procedure Queries - - - The number of times a procedures metadata was retrieved from the client-side cache. - - - Soft Procedure Queries - - - Parameter '{0}' is not found but a parameter with the name '{1}' is found. Parameter names must include the leading parameter marker. - - - Unable to connect to any of the specified MySQL hosts. - - - Unable to retrieve stored procedure metadata for routine '{0}'. Either grant SELECT privilege to mysql.proc for this user or use "use procedure bodies=false" with your connection string. - - - Invalid attempt to call NextResult when the reader is closed. - - - When calling stored procedures and 'Use Procedure Bodies' is false, all parameters must have their type explicitly set. - - - error connecting: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. - - - Parameter '{0}' has already been defined. - - - Parameter '{0}' must be defined. - - - The object is not open or has been disposed. - - - Multiple simultaneous connections or connections with different connection strings inside the same transaction are not currently supported. - - - MySQL Connector/Net does not currently support distributed transactions. - - - Fatal error encountered during command execution. - - - Fatal error encountered during data read. - - - Fatal error encountered attempting to read the resultset. - - - Routine '{0}' cannot be found. Either check the spelling or make sure you have sufficient rights to execute the routine. - - - Parameter '{0}' was not found during prepare. - - - The requested column value could not be treated as or conveted to a Guid. - - - Unable to derive stored routine parameters. The 'Parameters' information schema table is not available and access to the stored procedure body has been disabled. - - - Unable to retrieve stored routine parameters. Either grant access to the routine or add the 'Use Procedure Bodies=false' option to your connection string. - - - The default connection encoding was not found. Please report this as a bug along with your connection string and system details. - - - Call to GetHostEntry failed after {0} while querying for hostname '{1}': SocketErrorCode={2}, ErrorCode={3}, NativeErrorCode={4}. - - - An error occured attempting to enumerate the user-defined functions. Do you have SELECT privileges on the mysql.func table? - - - The given value was not in a supported format. - - - The host {0} does not support SSL connections. - - - Could not find specified column in results: {0} - - - You have specified an invalid column ordinal. - - - Invalid attempt to read a prior column using SequentialAccess - - - Invalid attempt to access a field before calling Read() - - - Unable to start a second async operation while one is running. - - - INTERNAL ERROR: More than one output parameter row detected. - - - '{0}' is an illegal value for a boolean option. - - - Connector/Net no longer supports server versions prior to 4.1 - - - The requested value '{0}' is invalid for the given keyword '{1}'. - - - {0}: Connection Closed - - - {0}: Connection Opened: connection string = '{1}' - - - {0}: Query Opened: {2} - - - {0}: Resultset Opened: field(s) = {1}, affected rows = {2}, inserted id = {3} - - - {0}: Query Closed - - - {0}: Set Database: {1} - - - {0}: Usage Advisor Warning: Query is using a bad index - - - {0}: Usage Advisor Warning: Query does not use an index - - - {0}: Resultset Closed. Total rows={1}, skipped rows={2}, size (bytes)={3} - - - {0}: Usage Advisor Warning: Skipped {2} rows. Consider a more focused query. - - - {0}: Usage Advisor Warning: The following columns were not accessed: {2} - - - {0}: Usage Advisor Warning: The field '{2}' was converted to the following types: {3} - - - {0}: Error encountered attempting to open result: Number={1}, Message={2} - - - {0}: Error encountered during row fetch. Number = {1}, Message={2} - - - {0}: MySql Warning: Level={1}, Code={2}, Message={3} - - - Unable to trace. There are more than Int32.MaxValue connections in use. - - - {0}: Statement prepared: sql='{1}', statement id={2} - - - {0}: Statement closed: statement id = {1} - - - {0}: Statement executed: statement id = {1} - - - - keywords.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 - - - {0}: Query Normalized: {2} - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/VersionInfo.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/VersionInfo.cs deleted file mode 100644 index 69175c7..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/VersionInfo.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; -using System.Security; - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("6.2.3")] - diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/keywords.txt b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/keywords.txt deleted file mode 100644 index cd94dc0..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Properties/keywords.txt +++ /dev/null @@ -1,229 +0,0 @@ -ACCESSIBLE -ADD -ALL -ALTER -ANALYZE -AND -AS -ASC -ASENSITIVE -BEFORE -BETWEEN -BIGINT -BINARY -BLOB -BOTH -BY -CALL -CASCADE -CASE -CHANGE -CHAR -CHARACTER -CHECK -COLLATE -COLUMN -CONDITION -CONNECTION -CONSTRAINT -CONTINUE -CONVERT -CREATE -CROSS -CURRENT_DATE -CURRENT_TIME -CURRENT_TIMESTAMP -CURRENT_USER -CURSOR -DATABASE -DATABASES -DAY_HOUR -DAY_MICROSECOND -DAY_MINUTE -DAY_SECOND -DEC -DECIMAL -DECLARE -DEFAULT -DELAYED -DELETE -DESC -DESCRIBE -DETERMINISTIC -DISTINCT -DISTINCTROW -DIV -DOUBLE -DROP -DUAL -EACH -ELSE -ELSEIF -ENCLOSED -ESCAPED -EXISTS -EXIT -EXPLAIN -FALSE -FETCH -FLOAT -FLOAT4 -FLOAT8 -FOR -FORCE -FOREIGN -FROM -FULLTEXT -GOTO -GRANT -GROUP -HAVING -HIGH_PRIORITY -HOUR_MICROSECOND -HOUR_MINUTE -HOUR_SECOND -IF -IGNORE -IN -INDEX -INFILE -INNER -INOUT -INSENSITIVE -INSERT -INT -INT1 -INT2 -INT3 -INT4 -INT8 -INTEGER -INTERVAL -INTO -IS -ITERATE -JOIN -KEY -KEYS -KILL -LABEL -LEADING -LEAVE -LEFT -LIKE -LIMIT -LINEAR -LINES -LOAD -LOCALTIME -LOCALTIMESTAMP -LOCK -LONG -LONGBLOB -LONGTEXT -LOOP -LOW_PRIORITY -MASTER_SSL_VERIFY_SERVER_CERT -MATCH -MEDIUMBLOB -MEDIUMINT -MEDIUMTEXT -MIDDLEINT -MINUTE_MICROSECOND -MINUTE_SECOND -MOD -MODIFIES -NATURAL -NOT -NO_WRITE_TO_BINLOG -NULL -NUMERIC -ON -OPTIMIZE -OPTION -OPTIONALLY -OR -ORDER -OUT -OUTER -OUTFILE -PRECISION -PRIMARY -PROCEDURE -PURGE -RANGE -READ -READS -READ_ONLY -READ_WRITE -REAL -REFERENCES -REGEXP -RELEASE -RENAME -REPEAT -REPLACE -REQUIRE -RESTRICT -RETURN -REVOKE -RIGHT -RLIKE -SCHEMA -SCHEMAS -SECOND_MICROSECOND -SELECT -SENSITIVE -SEPARATOR -SET -SHOW -SMALLINT -SPATIAL -SPECIFIC -SQL -SQLEXCEPTION -SQLSTATE -SQLWARNING -SQL_BIG_RESULT -SQL_CALC_FOUND_ROWS -SQL_SMALL_RESULT -SSL -STARTING -STRAIGHT_JOIN -TABLE -TERMINATED -THEN -TINYBLOB -TINYINT -TINYTEXT -TO -TRAILING -TRIGGER -TRUE -UNDO -UNION -UNIQUE -UNLOCK -UNSIGNED -UPDATE -UPGRADE -USAGE -USE -USING -UTC_DATE -UTC_TIME -UTC_TIMESTAMP -VALUE -VALUES -VARBINARY -VARCHAR -VARCHARACTER -VARYING -WHEN -WHERE -WHILE -WITH -WRITE -XOR -YEAR_MONTH -ZEROFILL \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/BulkLoader.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/BulkLoader.cs deleted file mode 100644 index c281d7d..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/BulkLoader.cs +++ /dev/null @@ -1,391 +0,0 @@ -// Copyright (c) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Text; -using System.IO; -using System.Data; -using System.Collections.Specialized; -using MySql.Data.MySqlClient.Properties; -namespace MySql.Data.MySqlClient -{ - /// - /// - /// - public class MySqlBulkLoader - { - // constant values - private const string defaultFieldTerminator = "\t"; - private const string defaultLineTerminator = "\n"; - private const char defaultEscapeCharacter = '\\'; - - // fields - private string fieldTerminator; - private string lineTerminator; - private string charSet; - private string tableName; - private int numLinesToIgnore; - private MySqlConnection connection; - private string filename; - private int timeout; - private bool local; - private string linePrefix; - private char fieldQuotationCharacter; - private bool fieldQuotationOptional; - private char escapeChar; - private MySqlBulkLoaderPriority priority; - private MySqlBulkLoaderConflictOption conflictOption; - private StringCollection columns; - private StringCollection expressions; - - public MySqlBulkLoader(MySqlConnection connection) - { - Connection = connection; - Local = true; - FieldTerminator = defaultFieldTerminator; - LineTerminator = defaultLineTerminator; - FieldQuotationCharacter = Char.MinValue; - ConflictOption = MySqlBulkLoaderConflictOption.None; - columns = new StringCollection(); - expressions = new StringCollection(); - } - - #region Properties - - /// - /// Gets or sets the connection. - /// - /// The connection. - public MySqlConnection Connection - { - get { return connection; } - set { connection = value; } - } - - /// - /// Gets or sets the field terminator. - /// - /// The field terminator. - public string FieldTerminator - { - get { return fieldTerminator; } - set { fieldTerminator = value; } - } - - /// - /// Gets or sets the line terminator. - /// - /// The line terminator. - public string LineTerminator - { - get { return lineTerminator; } - set { lineTerminator = value; } - } - - /// - /// Gets or sets the name of the table. - /// - /// The name of the table. - public string TableName - { - get { return tableName; } - set { tableName = value; } - } - - /// - /// Gets or sets the character set. - /// - /// The character set. - public string CharacterSet - { - get { return charSet; } - set { charSet = value; } - } - - /// - /// Gets or sets the name of the file. - /// - /// The name of the file. - public string FileName - { - get { return filename; } - set { filename = value; } - } - - /// - /// Gets or sets the timeout. - /// - /// The timeout. - public int Timeout - { - get { return timeout; } - set { timeout = value; } - } - - /// - /// Gets or sets a value indicating whether the filename that is to be loaded - /// is local to the client or not - /// - /// true if local; otherwise, false. - public bool Local - { - get { return local; } - set { local = value; } - } - - /// - /// Gets or sets the number of lines to skip. - /// - /// The number of lines to skip. - public int NumberOfLinesToSkip - { - get { return numLinesToIgnore; } - set { numLinesToIgnore = value; } - } - - /// - /// Gets or sets the line prefix. - /// - /// The line prefix. - public string LinePrefix - { - get { return linePrefix; } - set { linePrefix = value; } - } - - /// - /// Gets or sets the field quotation character. - /// - /// The field quotation character. - public char FieldQuotationCharacter - { - get { return fieldQuotationCharacter; } - set { fieldQuotationCharacter = value; } - } - - /// - /// Gets or sets a value indicating whether [field quotation optional]. - /// - /// - /// true if [field quotation optional]; otherwise, false. - /// - public bool FieldQuotationOptional - { - get { return fieldQuotationOptional; } - set { fieldQuotationOptional = value; } - } - - /// - /// Gets or sets the escape character. - /// - /// The escape character. - public char EscapeCharacter - { - get { return escapeChar; } - set { escapeChar = value; } - } - - /// - /// Gets or sets the conflict option. - /// - /// The conflict option. - public MySqlBulkLoaderConflictOption ConflictOption - { - get { return conflictOption; } - set { conflictOption = value; } - } - - /// - /// Gets or sets the priority. - /// - /// The priority. - public MySqlBulkLoaderPriority Priority - { - get { return priority; } - set { priority = value; } - } - - /// - /// Gets the columns. - /// - /// The columns. - public StringCollection Columns - { - get { return columns; } - } - - /// - /// Gets the expressions. - /// - /// The expressions. - public StringCollection Expressions - { - get { return expressions; } - } - - #endregion - - /// - /// Execute the load operation - /// - /// The number of rows inserted. - public int Load() - { - bool openedConnection = false; - - if (Connection == null) - throw new InvalidOperationException(Resources.ConnectionNotSet); - - // next we open up the connetion if it is not already open - if (connection.State != ConnectionState.Open) - { - openedConnection = true; - connection.Open(); - } - - try - { - string sql = BuildSqlCommand(); - MySqlCommand cmd = new MySqlCommand(sql, Connection); - cmd.CommandTimeout = Timeout; - return cmd.ExecuteNonQuery(); - } - finally - { - if (openedConnection) - connection.Close(); - } - } - - private string BuildSqlCommand() - { - StringBuilder sql = new StringBuilder("LOAD DATA "); - if (Priority == MySqlBulkLoaderPriority.Low) - sql.Append("LOW_PRIORITY "); - else if (Priority == MySqlBulkLoaderPriority.Concurrent) - sql.Append("CONCURRENT "); - - if (Local) - sql.Append("LOCAL "); - sql.Append("INFILE "); - if (Path.DirectorySeparatorChar == '\\') - sql.AppendFormat("'{0}' ", FileName.Replace(@"\", @"\\")); - else - sql.AppendFormat("'{0}' ", FileName); - - if (ConflictOption == MySqlBulkLoaderConflictOption.Ignore) - sql.Append("IGNORE "); - else if (ConflictOption == MySqlBulkLoaderConflictOption.Replace) - sql.Append("REPLACE "); - - sql.AppendFormat("INTO TABLE {0} ", TableName); - - if (CharacterSet != null) - sql.AppendFormat("CHARACTER SET {0} ", CharacterSet); - - StringBuilder optionSql = new StringBuilder(String.Empty); - if (FieldTerminator != defaultFieldTerminator) - optionSql.AppendFormat("TERMINATED BY '{0}' ", FieldTerminator); - if (FieldQuotationCharacter != Char.MinValue) - optionSql.AppendFormat("{0} ENCLOSED BY '{1}' ", - FieldQuotationOptional ? "OPTIONALLY" : "", FieldQuotationCharacter); - if (EscapeCharacter != defaultEscapeCharacter && - EscapeCharacter != Char.MinValue) - optionSql.AppendFormat("ESCAPED BY '{0}' ", EscapeCharacter); - if (optionSql.Length > 0) - sql.AppendFormat("FIELDS {0}", optionSql.ToString()); - - optionSql = new StringBuilder(String.Empty); - if (LinePrefix != null && LinePrefix.Length > 0) - optionSql.AppendFormat("STARTING BY '{0}' ", LinePrefix); - if (LineTerminator != defaultLineTerminator) - optionSql.AppendFormat("TERMINATED BY '{0}' ", LineTerminator); - if (optionSql.Length > 0) - sql.AppendFormat("LINES {0}", optionSql.ToString()); - - if (NumberOfLinesToSkip > 0) - sql.AppendFormat("IGNORE {0} LINES ", NumberOfLinesToSkip); - - if (Columns.Count > 0) - { - sql.Append("("); - sql.Append(Columns[0]); - for (int i = 1; i < Columns.Count; i++) - sql.AppendFormat(",{0}", Columns[i]); - sql.Append(") "); - } - - if (Expressions.Count > 0) - { - sql.Append("SET "); - sql.Append(Expressions[0]); - for (int i = 1; i < Expressions.Count; i++) - sql.AppendFormat(",{0}", Expressions[i]); - } - - return sql.ToString(); - } - } - - /// - /// - /// - public enum MySqlBulkLoaderPriority - { - /// - /// This is the default and indicates normal priority - /// - None, - /// - /// Low priority will cause the load operation to wait until all readers of the table - /// have finished. This only affects storage engines that use only table-level locking - /// such as MyISAM, Memory, and Merge. - /// - Low, - /// - /// Concurrent priority is only relevant for MyISAM tables and signals that if the table - /// has no free blocks in the middle that other readers can retrieve data from the table - /// while the load operation is happening. - /// - Concurrent - } - - /// - /// - /// - public enum MySqlBulkLoaderConflictOption - { - /// - /// This is the default and indicates normal operation. In the event of a LOCAL load, this - /// is the same as ignore. When the data file is on the server, then a key conflict will - /// cause an error to be thrown and the rest of the data file ignored. - /// - None, - /// - /// Replace column values when a key conflict occurs. - /// - Replace, - /// - /// Ignore any rows where the primary key conflicts. - /// - Ignore - } - -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CharSetMap.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CharSetMap.cs deleted file mode 100644 index 535821e..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CharSetMap.cs +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections; -using System.Text; -using MySql.Data.Common; -using System.Collections.Generic; -using System.Data; - -namespace MySql.Data.MySqlClient -{ - /// - /// Summary description for CharSetMap. - /// - internal class CharSetMap - { - private static Dictionary defaultCollations; - private static Dictionary maxLengths; - private static Dictionary mapping; - private static object lockObject; - - // we use a static constructor here since we only want to init - // the mapping once - static CharSetMap() - { - lockObject = new Object(); - InitializeMapping(); - } - - public static CharacterSet GetCharacterSet(DBVersion version, string CharSetName) - { - CharacterSet cs = (CharacterSet) mapping[CharSetName]; - if (cs == null) - throw new MySqlException("Character set '" + CharSetName + "' is not supported"); - return cs; - } - - /// - /// Returns the text encoding for a given MySQL character set name - /// - /// Version of the connection requesting the encoding - /// Name of the character set to get the encoding for - /// Encoding object for the given character set name - public static Encoding GetEncoding(DBVersion version, string CharSetName) - { - try - { - CharacterSet cs = GetCharacterSet(version, CharSetName); - return Encoding.GetEncoding(cs.name); - } - catch (NotSupportedException) - { - return Encoding.GetEncoding(0); - } - } - - /// - /// - /// - private static void InitializeMapping() - { - LoadCharsetMap(); - } - - private static void LoadCharsetMap() - { - mapping = new Dictionary(); - - mapping.Add("latin1", new CharacterSet("latin1", 1)); - mapping.Add("big5", new CharacterSet("big5", 2)); - mapping.Add("dec8", mapping["latin1"]); - mapping.Add("cp850", new CharacterSet("ibm850", 1)); - mapping.Add("hp8", mapping["latin1"]); - mapping.Add("koi8r", new CharacterSet("koi8-u", 1)); - mapping.Add("latin2", new CharacterSet("latin2", 1)); - mapping.Add("swe7", mapping["latin1"]); - mapping.Add("ujis", new CharacterSet("EUC-JP", 3)); - mapping.Add("eucjpms", mapping["ujis"]); - mapping.Add("sjis", new CharacterSet("sjis", 2)); - mapping.Add("cp932", mapping["sjis"]); - mapping.Add("hebrew", new CharacterSet("hebrew", 1)); - mapping.Add("tis620", new CharacterSet("windows-874", 1)); - mapping.Add("euckr", new CharacterSet("euc-kr", 2)); - mapping.Add("euc_kr", mapping["euckr"]); - mapping.Add("koi8u", new CharacterSet("koi8-u", 1)); - mapping.Add("koi8_ru", mapping["koi8u"]); - mapping.Add("gb2312", new CharacterSet("gb2312", 2)); - mapping.Add("gbk", mapping["gb2312"]); - mapping.Add("greek", new CharacterSet("greek", 1)); - mapping.Add("cp1250", new CharacterSet("windows-1250", 1)); - mapping.Add("win1250", mapping["cp1250"]); - mapping.Add("latin5", new CharacterSet("latin5", 1)); - mapping.Add("armscii8", mapping["latin1"]); - mapping.Add("utf8", new CharacterSet("utf-8", 3)); - mapping.Add("ucs2", new CharacterSet("UTF-16BE", 2)); - mapping.Add("cp866", new CharacterSet("cp866", 1)); - mapping.Add("keybcs2", mapping["latin1"]); - mapping.Add("macce", new CharacterSet("x-mac-ce", 1)); - mapping.Add("macroman", new CharacterSet("x-mac-romanian", 1)); - mapping.Add("cp852", new CharacterSet("ibm852", 2)); - mapping.Add("latin7", new CharacterSet("iso-8859-7", 1)); - mapping.Add("cp1251", new CharacterSet("windows-1251", 1)); - mapping.Add("win1251ukr", mapping["cp1251"]); - mapping.Add("cp1251csas", mapping["cp1251"]); - mapping.Add("cp1251cias", mapping["cp1251"]); - mapping.Add("win1251", mapping["cp1251"]); - mapping.Add("cp1256", new CharacterSet("cp1256", 1)); - mapping.Add("cp1257", new CharacterSet("windows-1257", 1)); - mapping.Add("ascii", new CharacterSet("us-ascii", 1)); - mapping.Add("usa7", mapping["ascii"]); - mapping.Add("binary", mapping["ascii"]); - mapping.Add("latin3", new CharacterSet("latin3", 1)); - mapping.Add("latin4", new CharacterSet("latin4", 1)); - mapping.Add("latin1_de", new CharacterSet("iso-8859-1", 1)); - mapping.Add("german1", new CharacterSet("iso-8859-1", 1)); - mapping.Add("danish", new CharacterSet("iso-8859-1", 1)); - mapping.Add("czech", new CharacterSet("iso-8859-2", 1)); - mapping.Add("hungarian", new CharacterSet("iso-8859-2", 1)); - mapping.Add("croat", new CharacterSet("iso-8859-2", 1)); - mapping.Add("latvian", new CharacterSet("iso-8859-13", 1)); - mapping.Add("latvian1", new CharacterSet("iso-8859-13", 1)); - mapping.Add("estonia", new CharacterSet("iso-8859-13", 1)); - mapping.Add("dos", new CharacterSet("ibm437", 1)); - } - - internal static void InitCollections(MySqlConnection connection) - { - defaultCollations = new Dictionary(); - maxLengths = new Dictionary(); - - MySqlCommand cmd = new MySqlCommand("SHOW CHARSET", connection); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - defaultCollations.Add(reader.GetString(0), reader.GetString(2)); - maxLengths.Add(reader.GetString(0), Convert.ToInt32(reader.GetValue(3))); - } - } - } - - internal static string GetDefaultCollation(string charset, MySqlConnection connection) - { - lock (lockObject) - { - if (defaultCollations == null) - InitCollections(connection); - } - if (!defaultCollations.ContainsKey(charset)) - return null; - return defaultCollations[charset]; - } - - internal static int GetMaxLength(string charset, MySqlConnection connection) - { - lock (lockObject) - { - if (maxLengths == null) - InitCollections(connection); - } - - if (!maxLengths.ContainsKey(charset)) - return 1; - return maxLengths[charset]; - } - } - - internal class CharacterSet - { - public string name; - public int byteCount; - - public CharacterSet(string name, int byteCount) - { - this.name = name; - this.byteCount = byteCount; - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CommandBuilder.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CommandBuilder.cs deleted file mode 100644 index 406a4eb..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CommandBuilder.cs +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.ComponentModel; -using System.Data.Common; -using System.Data; -using System.Text; -using MySql.Data.Common; -using System.Collections; -using MySql.Data.Types; -using System.Globalization; -using MySql.Data.MySqlClient.Properties; -using System.Collections.Generic; - -namespace MySql.Data.MySqlClient -{ - /// -#if !CF - [ToolboxItem(false)] - [System.ComponentModel.DesignerCategory("Code")] -#endif - public sealed class MySqlCommandBuilder : DbCommandBuilder - { - /// - public MySqlCommandBuilder() - { - QuotePrefix = QuoteSuffix = "`"; - } - - /// - public MySqlCommandBuilder(MySqlDataAdapter adapter) - : this() - { - DataAdapter = adapter; - } - - /// - public new MySqlDataAdapter DataAdapter - { - get { return (MySqlDataAdapter)base.DataAdapter; } - set { base.DataAdapter = value; } - } - - #region Public Methods - - /// - /// Retrieves parameter information from the stored procedure specified - /// in the MySqlCommand and populates the Parameters collection of the - /// specified MySqlCommand object. - /// This method is not currently supported since stored procedures are - /// not available in MySql. - /// - /// The MySqlCommand referencing the stored - /// procedure from which the parameter information is to be derived. - /// The derived parameters are added to the Parameters collection of the - /// MySqlCommand. - /// The command text is not - /// a valid stored procedure name. - public static void DeriveParameters(MySqlCommand command) - { - if (!command.Connection.driver.Version.isAtLeast(5, 0, 0)) - throw new MySqlException("DeriveParameters is not supported on MySQL versions " + - "prior to 5.0"); - - // retrieve the proc definitino from the cache. - string spName = command.CommandText; - if (spName.IndexOf(".") == -1) - spName = command.Connection.Database + "." + spName; - DataSet ds = command.Connection.ProcedureCache.GetProcedure(command.Connection, spName); - if (!ds.Tables.Contains("Procedure Parameters")) - throw new MySqlException(Resources.UnableToDeriveParameters); - - DataTable parameters = ds.Tables["Procedure Parameters"]; - DataTable procTable = ds.Tables["Procedures"]; - command.Parameters.Clear(); - foreach (DataRow row in parameters.Rows) - { - MySqlParameter p = new MySqlParameter(); - p.ParameterName = String.Format("@{0}", row["PARAMETER_NAME"]); - if (row["ORDINAL_POSITION"].Equals(0) && p.ParameterName == "@") - p.ParameterName = "@RETURN_VALUE"; - p.Direction = GetDirection(row); - bool unsigned = StoredProcedure.GetFlags(row["DTD_IDENTIFIER"].ToString()).IndexOf("UNSIGNED") != -1; - bool real_as_float = procTable.Rows[0]["SQL_MODE"].ToString().IndexOf("REAL_AS_FLOAT") != -1; - p.MySqlDbType = MetaData.NameToType(row["DATA_TYPE"].ToString(), - unsigned, real_as_float, command.Connection); - if (!row["CHARACTER_MAXIMUM_LENGTH"].Equals(DBNull.Value)) - p.Size = (int)row["CHARACTER_MAXIMUM_LENGTH"]; - if (!row["NUMERIC_PRECISION"].Equals(DBNull.Value)) - p.Precision = Convert.ToByte(row["NUMERIC_PRECISION"]); - if (!row["NUMERIC_SCALE"].Equals(DBNull.Value)) - p.Scale = Convert.ToByte(row["NUMERIC_SCALE"]); - if (p.MySqlDbType == MySqlDbType.Set || p.MySqlDbType == MySqlDbType.Enum) - p.PossibleValues = GetPossibleValues(row); - command.Parameters.Add(p); - } - } - - private static List GetPossibleValues(DataRow row) - { - string[] types = new string[] { "ENUM", "SET" }; - string dtdIdentifier = row["DTD_IDENTIFIER"].ToString().Trim(); - - int index = 0; - for (; index < 2; index++) - if (dtdIdentifier.StartsWith(types[index], StringComparison.InvariantCultureIgnoreCase)) - break; - if (index == 2) return null; - dtdIdentifier = dtdIdentifier.Substring(types[index].Length).Trim(); - dtdIdentifier = dtdIdentifier.Trim('(', ')').Trim(); - - List values = new List(); - MySqlTokenizer tokenzier = new MySqlTokenizer(dtdIdentifier); - string token = tokenzier.NextToken(); - int start = tokenzier.StartIndex; - while (true) - { - if (token == null || token == ",") - { - int end = dtdIdentifier.Length - 1; - if (token == ",") - end = tokenzier.StartIndex; - - string value = dtdIdentifier.Substring(start, end - start).Trim('\'', '\"').Trim(); - values.Add(value); - start = tokenzier.StopIndex; - } - if (token == null) break; - token = tokenzier.NextToken(); - } - return values; - } - - private static ParameterDirection GetDirection(DataRow row) - { - string mode = row["PARAMETER_MODE"].ToString(); - int ordinal = Convert.ToInt32(row["ORDINAL_POSITION"]); - - if (0 == ordinal) - return ParameterDirection.ReturnValue; - else if (mode == "IN") - return ParameterDirection.Input; - else if (mode == "OUT") - return ParameterDirection.Output; - return ParameterDirection.InputOutput; - } - - /// - /// Gets the delete command. - /// - /// - public new MySqlCommand GetDeleteCommand() - { - return (MySqlCommand)base.GetDeleteCommand(); - } - - /// - /// Gets the update command. - /// - /// - public new MySqlCommand GetUpdateCommand() - { - return (MySqlCommand)base.GetUpdateCommand(); - } - - /// - /// Gets the insert command. - /// - /// - public new MySqlCommand GetInsertCommand() - { - return (MySqlCommand)GetInsertCommand(false); - } - - public override string QuoteIdentifier(string unquotedIdentifier) - { - if (unquotedIdentifier == null) throw new - ArgumentNullException("unquotedIdentifier"); - - // don't quote again if it is already quoted - if (unquotedIdentifier.StartsWith(QuotePrefix) && - unquotedIdentifier.EndsWith(QuoteSuffix)) - return unquotedIdentifier; - - unquotedIdentifier = unquotedIdentifier.Replace(QuotePrefix, QuotePrefix + QuotePrefix); - - return String.Format("{0}{1}{2}", QuotePrefix, unquotedIdentifier, QuoteSuffix); - } - - public override string UnquoteIdentifier(string quotedIdentifier) - { - if (quotedIdentifier == null) throw new - ArgumentNullException("quotedIdentifier"); - - // don't unquote again if it is already unquoted - if (!quotedIdentifier.StartsWith(QuotePrefix) || - !quotedIdentifier.EndsWith(QuoteSuffix)) - return quotedIdentifier; - - if (quotedIdentifier.StartsWith(QuotePrefix)) - quotedIdentifier = quotedIdentifier.Substring(1); - if (quotedIdentifier.EndsWith(QuoteSuffix)) - quotedIdentifier = quotedIdentifier.Substring(0, quotedIdentifier.Length - 1); - - quotedIdentifier = quotedIdentifier.Replace(QuotePrefix + QuotePrefix, QuotePrefix); - - return quotedIdentifier; - } - - #endregion - - /// - /// - /// - /// - /// - protected override string GetParameterName(string parameterName) - { - StringBuilder sb = new StringBuilder(parameterName); - sb.Replace(" ", ""); - sb.Replace("/", "_per_"); - sb.Replace("-", "_"); - sb.Replace(")", "_cb_"); - sb.Replace("(", "_ob_"); - sb.Replace("%", "_pct_"); - sb.Replace("<", "_lt_"); - sb.Replace(">", "_gt_"); - sb.Replace(".", "_pt_"); - return String.Format("@{0}", sb.ToString()); - } - - protected override void ApplyParameterInfo(DbParameter parameter, DataRow row, - StatementType statementType, bool whereClause) - { - ((MySqlParameter)parameter).MySqlDbType = (MySqlDbType)row["ProviderType"]; - } - - protected override string GetParameterName(int parameterOrdinal) - { - return String.Format("@p{0}", parameterOrdinal.ToString(CultureInfo.InvariantCulture)); - } - - protected override string GetParameterPlaceholder(int parameterOrdinal) - { - return String.Format("@p{0}", parameterOrdinal.ToString(CultureInfo.InvariantCulture)); - } - - protected override void SetRowUpdatingHandler(DbDataAdapter adapter) - { - MySqlDataAdapter myAdapter = (adapter as MySqlDataAdapter); - if (adapter != base.DataAdapter) - myAdapter.RowUpdating += new MySqlRowUpdatingEventHandler(RowUpdating); - else - myAdapter.RowUpdating -= new MySqlRowUpdatingEventHandler(RowUpdating); - } - - private void RowUpdating(object sender, MySqlRowUpdatingEventArgs args) - { - base.RowUpdatingHandler(args); - } - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CompressedStream.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CompressedStream.cs deleted file mode 100644 index 977fe47..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/CompressedStream.cs +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (C) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.IO; -using zlib; -using MySql.Data.MySqlClient.Properties; -using MySql.Data.Common; - -namespace MySql.Data.MySqlClient -{ - /// - /// Summary description for CompressedStream. - /// - internal class CompressedStream : Stream - { - // writing fields - private Stream baseStream; - private MemoryStream cache; - - // reading fields - private byte[] localByte; - private byte[] inBuffer; - private byte[] lengthBytes; - private WeakReference inBufferRef; - private int inPos; - private int maxInPos; - private ZInputStream zInStream; - - public CompressedStream(Stream baseStream) - { - this.baseStream = baseStream; - localByte = new byte[1]; - lengthBytes = new byte[7]; - cache = new MemoryStream(); - inBufferRef = new WeakReference(inBuffer, false); - } - - #region Properties - - - public override bool CanRead - { - get { return baseStream.CanRead; } - } - - public override bool CanWrite - { - get { return baseStream.CanWrite; } - } - - public override bool CanSeek - { - get { return baseStream.CanSeek; } - } - - public override long Length - { - get { return baseStream.Length; } - } - - public override long Position - { - get { return baseStream.Position; } - set { baseStream.Position = value; } - } - - #endregion - - public override void Close() - { - baseStream.Close(); - base.Close(); - } - - public override void SetLength(long value) - { - throw new NotSupportedException(Resources.CSNoSetLength); - } - - public override int ReadByte() - { - try - { - Read(localByte, 0, 1); - return localByte[0]; - } - catch (EndOfStreamException) - { - return -1; - } - } - - public override bool CanTimeout - { - get - { - return baseStream.CanTimeout; - } - } - - public override int ReadTimeout - { - get - { - return baseStream.ReadTimeout; - } - set - { - baseStream.ReadTimeout = value; - } - } - - public override int WriteTimeout - { - get - { - return baseStream.WriteTimeout; - } - set - { - baseStream.WriteTimeout = value; - } - } - - public override int Read(byte[] buffer, int offset, int count) - { - if (buffer == null) - throw new ArgumentNullException("buffer", Resources.BufferCannotBeNull); - if (offset < 0 || offset >= buffer.Length) - throw new ArgumentOutOfRangeException("offset", Resources.OffsetMustBeValid); - if ((offset + count) > buffer.Length) - throw new ArgumentException(Resources.BufferNotLargeEnough, "buffer"); - - if (inPos == maxInPos) - PrepareNextPacket(); - - int countToRead = Math.Min(count, maxInPos - inPos); - int countRead; - if (zInStream != null) - countRead = zInStream.read(buffer, offset, countToRead); - else - countRead = baseStream.Read(buffer, offset, countToRead); - inPos += countRead; - - // release the weak reference - if (inPos == maxInPos) - { - zInStream = null; - if (!Platform.IsMono()) - { - inBufferRef = new WeakReference(inBuffer, false); - inBuffer = null; - } - } - - return countRead; - } - - private void PrepareNextPacket() - { - MySqlStream.ReadFully(baseStream, lengthBytes, 0, 7); - int compressedLength = lengthBytes[0] + (lengthBytes[1] << 8) + (lengthBytes[2] << 16); - // lengthBytes[3] is seq - int unCompressedLength = lengthBytes[4] + (lengthBytes[5] << 8) + - (lengthBytes[6] << 16); - - if (unCompressedLength == 0) - { - unCompressedLength = compressedLength; - zInStream = null; - } - else - { - ReadNextPacket(compressedLength); - MemoryStream ms = new MemoryStream(inBuffer); - zInStream = new ZInputStream(ms); - zInStream.maxInput = compressedLength; - } - - inPos = 0; - maxInPos = unCompressedLength; - } - - private void ReadNextPacket(int len) - { - if (!Platform.IsMono()) - inBuffer = inBufferRef.Target as byte[]; - - if (inBuffer == null || inBuffer.Length < len) - inBuffer = new byte[len]; - MySqlStream.ReadFully(baseStream, inBuffer, 0, len); - } - - private MemoryStream CompressCache() - { - // small arrays almost never yeild a benefit from compressing - if (cache.Length < 50) - return null; - - byte[] cacheBytes = cache.GetBuffer(); - MemoryStream compressedBuffer = new MemoryStream(); - ZOutputStream zos = new ZOutputStream(compressedBuffer, zlibConst.Z_DEFAULT_COMPRESSION); - zos.Write(cacheBytes, 0, (int) cache.Length); - zos.finish(); - - // if the compression hasn't helped, then just return null - if (compressedBuffer.Length >= cache.Length) - return null; - return compressedBuffer; - } - - private void CompressAndSendCache() - { - long compressedLength, uncompressedLength; - - // we need to save the sequence byte that is written - byte[] cacheBuffer = cache.GetBuffer(); - byte seq = cacheBuffer[3]; - cacheBuffer[3] = 0; - - // first we compress our current cache - MemoryStream compressedBuffer = CompressCache(); - - // now we set our compressed and uncompressed lengths - // based on if our compression is going to help or not - if (compressedBuffer == null) - { - compressedLength = cache.Length; - uncompressedLength = 0; - } - else - { - compressedLength = compressedBuffer.Length; - uncompressedLength = cache.Length; - } - - baseStream.WriteByte((byte) (compressedLength & 0xff)); - baseStream.WriteByte((byte) ((compressedLength >> 8) & 0xff)); - baseStream.WriteByte((byte) ((compressedLength >> 16) & 0Xff)); - baseStream.WriteByte(seq); - baseStream.WriteByte((byte) (uncompressedLength & 0xff)); - baseStream.WriteByte((byte) ((uncompressedLength >> 8) & 0xff)); - baseStream.WriteByte((byte) ((uncompressedLength >> 16) & 0Xff)); - - if (compressedBuffer == null) - baseStream.Write(cacheBuffer, 0, (int) cache.Length); - else - { - byte[] compressedBytes = compressedBuffer.GetBuffer(); - baseStream.Write(compressedBytes, 0, (int) compressedBuffer.Length); - } - - baseStream.Flush(); - - cache.SetLength(0); - } - - public override void Flush() - { - if (!InputDone()) return; - - CompressAndSendCache(); - } - - private bool InputDone() - { - // if we have not done so yet, see if we can calculate how many bytes we are expecting - if (cache.Length < 4) return false; - byte[] buf = cache.GetBuffer(); - int expectedLen = buf[0] + (buf[1] << 8) + (buf[2] << 16); - if (cache.Length < (expectedLen + 4)) return false; - return true; - } - - public override void WriteByte(byte value) - { - cache.WriteByte(value); - } - - public override void Write(byte[] buffer, int offset, int count) - { - cache.Write(buffer, offset, count); - } - - public override long Seek(long offset, SeekOrigin origin) - { - return baseStream.Seek(offset, origin); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Connection.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Connection.cs deleted file mode 100644 index db8399d..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Connection.cs +++ /dev/null @@ -1,867 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.ComponentModel; -using System.Data; -using System.Data.Common; -#if !CF -using System.Drawing; -using System.Drawing.Design; -using System.Transactions; -#endif -using System.Text; -using IsolationLevel=System.Data.IsolationLevel; -using MySql.Data.Common; -using System.Diagnostics; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.MySqlClient -{ - /// -#if !CF - [ToolboxBitmap(typeof (MySqlConnection), "MySqlClient.resources.connection.bmp")] - [DesignerCategory("Code")] - [ToolboxItem(true)] -#endif - public sealed class MySqlConnection : DbConnection, ICloneable - { - internal ConnectionState connectionState; - internal Driver driver; - private MySqlConnectionStringBuilder settings; - private bool hasBeenOpen; - private SchemaProvider schemaProvider; - private ProcedureCache procedureCache; -#if !CF - private PerformanceMonitor perfMonitor; -#endif - private bool abortOnTimeout; - private string database; - private int commandTimeout; - - /// - public event MySqlInfoMessageEventHandler InfoMessage; - - private static Cache connectionStringCache = - new Cache(0, 25); - - /// - public MySqlConnection() - { - //TODO: add event data to StateChange docs - settings = new MySqlConnectionStringBuilder(); - database = String.Empty; - } - - /// - public MySqlConnection(string connectionString) - : this() - { - ConnectionString = connectionString; - } - - #region Interal Methods & Properties - -#if !CF - internal PerformanceMonitor PerfMonitor - { - get { return perfMonitor; } - } - -#endif - - internal ProcedureCache ProcedureCache - { - get { return procedureCache; } - } - - internal MySqlConnectionStringBuilder Settings - { - get { return settings; } - } - - internal MySqlDataReader Reader - { - get - { - if (driver == null) - return null; - return driver.reader; - - } - - set - { - driver.reader = value; - } - } - - internal void OnInfoMessage(MySqlInfoMessageEventArgs args) - { - if (InfoMessage != null) - { - InfoMessage(this, args); - } - } - - - internal bool SoftClosed - { - get - { -#if !CF - return (State == ConnectionState.Closed) && - driver != null && - driver.CurrentTransaction != null; -#else - return false; -#endif - } - } - - #endregion - - #region Properties - - /// - /// Returns the id of the server thread this connection is executing on - /// -#if !CF - [Browsable(false)] -#endif - public int ServerThread - { - get { return driver.ThreadID; } - } - - /// - /// Gets the name of the MySQL server to which to connect. - /// -#if !CF - [Browsable(true)] -#endif - public override string DataSource - { - get { return settings.Server; } - } - - /// -#if !CF - [Browsable(true)] -#endif - public override int ConnectionTimeout - { - get { return (int) settings.ConnectionTimeout; } - } - - /// -#if !CF - [Browsable(true)] -#endif - public override string Database - { - get { return database; } - } - - /// - /// Indicates if this connection should use compression when communicating with the server. - /// -#if !CF - [Browsable(false)] -#endif - public bool UseCompression - { - get { return settings.UseCompression; } - } - - /// -#if !CF - [Browsable(false)] -#endif - public override ConnectionState State - { - get { return connectionState; } - } - - /// -#if !CF - [Browsable(false)] -#endif - public override string ServerVersion - { - get { return driver.Version.ToString(); } - } - - /// -#if !CF - [Editor("MySql.Data.MySqlClient.Design.ConnectionStringTypeEditor,MySqlClient.Design", typeof (UITypeEditor))] - [Browsable(true)] - [Category("Data")] - [Description( - "Information used to connect to a DataSource, such as 'Server=xxx;UserId=yyy;Password=zzz;Database=dbdb'.")] -#endif - public override string ConnectionString - { - get - { - // Always return exactly what the user set. - // Security-sensitive information may be removed. - return settings.GetConnectionString(!hasBeenOpen || settings.PersistSecurityInfo); - } - set - { - if (State != ConnectionState.Closed) - throw new MySqlException( - "Not allowed to change the 'ConnectionString' property while the connection (state=" + State + - ")."); - - MySqlConnectionStringBuilder newSettings; - lock (connectionStringCache) - { - if (value == null) - newSettings = new MySqlConnectionStringBuilder(); - else - { - newSettings = (MySqlConnectionStringBuilder)connectionStringCache[value]; - if (null == newSettings) - { - newSettings = new MySqlConnectionStringBuilder(value); - connectionStringCache.Add(value, newSettings); - } - } - } - - settings = newSettings; - - if (settings.Database != null && settings.Database.Length > 0) - this.database = settings.Database; - - if (driver != null) - driver.Settings = newSettings; - } - } - -#if !CF && !__MonoCS__ - - protected override DbProviderFactory DbProviderFactory - { - get - { - return MySqlClientFactory.Instance; - } - } - -#endif - - #endregion - - #region Transactions - -#if !MONO && !CF - /// - /// 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; - } - } -#endif - - /// - public new MySqlTransaction BeginTransaction() - { - return BeginTransaction(IsolationLevel.RepeatableRead); - } - - /// - public new MySqlTransaction BeginTransaction(IsolationLevel iso) - { - //TODO: check note in help - if (State != ConnectionState.Open) - throw new InvalidOperationException(Resources.ConnectionNotOpen); - - // First check to see if we are in a current transaction - if (driver.HasStatus(ServerStatusFlags.InTransaction)) - throw new InvalidOperationException(Resources.NoNestedTransactions); - - MySqlTransaction t = new MySqlTransaction(this, iso); - - MySqlCommand cmd = new MySqlCommand("", this); - - cmd.CommandText = "SET SESSION TRANSACTION ISOLATION LEVEL "; - switch (iso) - { - case IsolationLevel.ReadCommitted: - cmd.CommandText += "READ COMMITTED"; - break; - case IsolationLevel.ReadUncommitted: - cmd.CommandText += "READ UNCOMMITTED"; - break; - case IsolationLevel.RepeatableRead: - cmd.CommandText += "REPEATABLE READ"; - break; - case IsolationLevel.Serializable: - cmd.CommandText += "SERIALIZABLE"; - break; - case IsolationLevel.Chaos: - throw new NotSupportedException(Resources.ChaosNotSupported); - } - - cmd.ExecuteNonQuery(); - - cmd.CommandText = "BEGIN"; - cmd.ExecuteNonQuery(); - - return t; - } - - #endregion - - /// - public override void ChangeDatabase(string databaseName) - { - if (databaseName == null || databaseName.Trim().Length == 0) - throw new ArgumentException(Resources.ParameterIsInvalid, "databaseName"); - - if (State != ConnectionState.Open) - throw new InvalidOperationException(Resources.ConnectionNotOpen); - - // This lock prevents promotable transaction rollback to run - // in parallel - lock (driver) - { -#if !CF - if (Transaction.Current != null && - Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) - { - throw new TransactionAbortedException(); - } -#endif - // We use default command timeout for SetDatabase - using (new CommandTimer(this, (int)Settings.DefaultCommandTimeout)) - { - driver.SetDatabase(databaseName); - } - } - this.database = databaseName; - } - - internal void SetState(ConnectionState newConnectionState, bool broadcast) - { - if (newConnectionState == connectionState && !broadcast) - return; - ConnectionState oldConnectionState = connectionState; - connectionState = newConnectionState; - if (broadcast) - OnStateChange(new StateChangeEventArgs(oldConnectionState, connectionState)); - } - - /// - /// Ping - /// - /// - public bool Ping() - { - if (driver != null && driver.Ping()) - return true; - driver = null; - SetState(ConnectionState.Closed, true); - return false; - } - - /// - public override void Open() - { - if (State == ConnectionState.Open) - throw new InvalidOperationException(Resources.ConnectionAlreadyOpen); - - SetState(ConnectionState.Connecting, true); - -#if !CF - // if we are auto enlisting in a current transaction, then we will be - // treating the connection as pooled - if (settings.AutoEnlist && Transaction.Current != null) - { - driver = DriverTransactionManager.GetDriverInTransaction(Transaction.Current); - if (driver != null && - (driver.IsInActiveUse || - !driver.Settings.EquivalentTo(this.Settings))) - throw new NotSupportedException(Resources.MultipleConnectionsInTransactionNotSupported); - } -#endif - - try - { - if (settings.Pooling) - { - MySqlPool pool = MySqlPoolManager.GetPool(settings); - if (driver == null) - driver = pool.GetConnection(); - procedureCache = pool.ProcedureCache; - } - else - { - if (driver == null) - driver = Driver.Create(settings); - procedureCache = new ProcedureCache((int) settings.ProcedureCacheSize); - } - } - catch (Exception) - { - SetState(ConnectionState.Closed, true); - throw; - } - - // if the user is using old syntax, let them know - if (driver.Settings.UseOldSyntax) - MySqlTrace.LogWarning(ServerThread, - "You are using old syntax that will be removed in future versions"); - - SetState(ConnectionState.Open, false); - driver.Configure(this); - if (settings.Database != null && settings.Database != String.Empty) - ChangeDatabase(settings.Database); - - // setup our schema provider - if (driver.Version.isAtLeast(5, 0, 0)) - schemaProvider = new ISSchemaProvider(this); - else - schemaProvider = new SchemaProvider(this); -#if !CF - perfMonitor = new PerformanceMonitor(this); -#endif - - // if we are opening up inside a current transaction, then autoenlist - // TODO: control this with a connection string option -#if !MONO && !CF - if (Transaction.Current != null && settings.AutoEnlist) - EnlistTransaction(Transaction.Current); -#endif - - hasBeenOpen = true; - SetState(ConnectionState.Open, true); - } - - /// - public new MySqlCommand CreateCommand() - { - // Return a new instance of a command object. - MySqlCommand c = new MySqlCommand(); - c.Connection = this; - return c; - } - - #region ICloneable - - /// - /// Creates a new MySqlConnection object with the exact same ConnectionString value - /// - /// A cloned MySqlConnection object - public MySqlConnection Clone() - { - MySqlConnection clone = new MySqlConnection(); - string connectionString = settings.ConnectionString; - if (connectionString != null) - clone.ConnectionString = connectionString; - return clone; - } - - object ICloneable.Clone() - { - return this.Clone(); - } - - #endregion - - #region IDisposeable - - protected override void Dispose(bool disposing) - { - if (State == ConnectionState.Open) - Close(); - base.Dispose(disposing); - } - - #endregion - - protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) - { - if (isolationLevel == IsolationLevel.Unspecified) - return BeginTransaction(); - return BeginTransaction(isolationLevel); - } - - protected override DbCommand CreateDbCommand() - { - return CreateCommand(); - } - - internal void Abort() - { - try - { - if (settings.Pooling) - MySqlPoolManager.ReleaseConnection(driver); - else - driver.Close(); - } - catch (Exception) - { - } - SetState(ConnectionState.Closed, true); - } - - internal void CloseFully() - { - if (settings.Pooling && driver.IsOpen) - { - // if we are in a transaction, roll it back - if (driver.HasStatus(ServerStatusFlags.InTransaction)) - { - MySqlTransaction t = new MySqlTransaction(this, IsolationLevel.Unspecified); - t.Rollback(); - } - - MySqlPoolManager.ReleaseConnection(driver); - } - else - driver.Close(); - driver = null; - } - - /// - public override void Close() - { - if (State == ConnectionState.Closed) return; - - if (Reader != null) - Reader.Close(); - - // if the reader was opened with CloseConnection then driver - // will be null on the second time through - if (driver != null) - { -#if !CF - if (driver.CurrentTransaction == null) -#endif - CloseFully(); -#if !CF - else - driver.IsInActiveUse = false; -#endif - } - - SetState(ConnectionState.Closed, true); - } - - internal string CurrentDatabase() - { - if (Database != null && Database.Length > 0) - return Database; - MySqlCommand cmd = new MySqlCommand("SELECT database()", this); - return cmd.ExecuteScalar().ToString(); - } - - - - internal void HandleTimeout(TimeoutException tex) - { - bool isFatal = false; - - if (abortOnTimeout) - { - // Special connection started to cancel a query. - // Timeout handler is disabled to prevent recursive connection - // spawning when original query and KILL time out. - Abort(); - throw new MySqlException(Resources.Timeout, true , tex); - } - - try - { - - // Do a fast cancel.The reason behind small values for connection - // and command timeout is that we do not want user to wait longer - // after command has already expired. - // Microsoft's SqlClient seems to be using 5 seconds timeouts - // here as well. - // Read the error packet with "interrupted" message. - CancelQuery(5); - driver.ResetTimeout(5000); - if (Reader != null) - { - Reader.Close(); - Reader = null; - } - } - catch (Exception ex) - { - MySqlTrace.LogWarning(ServerThread, "Could not kill query in timeout handler, " + - " aborting connection. Exception was " + ex.Message); - Abort(); - isFatal = true; - } - throw new MySqlException(Resources.Timeout, isFatal, tex); - } - - public void CancelQuery(int timeout) - { - if (!driver.Version.isAtLeast(5, 0, 0)) - throw new NotSupportedException(Resources.CancelNotSupported); - - MySqlConnectionStringBuilder cb = new MySqlConnectionStringBuilder( - Settings.ConnectionString); - cb.Pooling = false; - cb.ConnectionTimeout = (uint) timeout; - - using(MySqlConnection c = new MySqlConnection(cb.ConnectionString)) - { - c.abortOnTimeout = true; - c.Open(); - string commandText = "KILL QUERY " + ServerThread; - MySqlCommand cmd = new MySqlCommand(commandText, c); - cmd.CommandTimeout = timeout; - cmd.ExecuteNonQuery(); - } - } - -#region Routines for timeout support. - - // Problem description: - // Sometimes, ExecuteReader is called recursively. This is the case if - // command behaviors are used and we issue "set sql_select_limit" - // before and after command. This is also the case with prepared - // statements , where we set session variables. In these situations, we - // have to prevent recursive ExecuteReader calls from overwriting - // timeouts set by the top level command. - - // To solve the problem, SetCommandTimeout() and ClearCommandTimeout() are - // introduced . Query timeout here is "sticky", that is once set with - // SetCommandTimeout, it only be overwritten after ClearCommandTimeout - // (SetCommandTimeout would return false if it timeout has not been - // cleared). - - // The proposed usage pattern of there routines is following: - // When timed operations starts, issue SetCommandTimeout(). When it - // finishes, issue ClearCommandTimeout(), but _only_ if call to - // SetCommandTimeout() was successful. - - - /// - /// Sets query timeout. If timeout has been set prior and not - /// yet cleared ClearCommandTimeout(), it has no effect. - /// - /// timeout in seconds - /// true if - internal bool SetCommandTimeout(int value) - { - if (!hasBeenOpen) - // Connection timeout is handled by driver - return false; - - if (commandTimeout != 0) - // someone is trying to set a timeout while command is already - // running. It could be for example recursive call to ExecuteReader - // Ignore the request, as only top-level (non-recursive commands) - // can set timeouts. - return false; - - if (driver == null) - return false; - - commandTimeout = value; - driver.ResetTimeout(commandTimeout * 1000); - return true; - } - - /// - /// Clears query timeout, allowing next SetCommandTimeout() to succeed. - /// - internal void ClearCommandTimeout() - { - if (!hasBeenOpen) - return; - commandTimeout = 0; - if (driver != null) - { - driver.ResetTimeout(0); - } - } -#endregion - - - #region GetSchema Support - - /// - /// 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); - DataTable dt = schemaProvider.GetSchema(collectionName, restrictions); - return dt; - } - - #endregion - - #region Pool Routines - - /// - public static void ClearPool(MySqlConnection connection) - { - MySqlPoolManager.ClearPool(connection.Settings); - } - - /// - public static void ClearAllPools() - { - MySqlPoolManager.ClearAllPools(); - } - - #endregion - } - - /// - /// Represents the method that will handle the event of a - /// . - /// - public delegate void MySqlInfoMessageEventHandler(object sender, MySqlInfoMessageEventArgs args); - - /// - /// Provides data for the InfoMessage event. This class cannot be inherited. - /// - public class MySqlInfoMessageEventArgs : EventArgs - { - /// - /// - /// - public MySqlError[] errors; - } - - /// - /// IDisposable wrapper around SetCommandTimeout and ClearCommandTimeout - /// functionality - /// - internal class CommandTimer:IDisposable - { - bool timeoutSet; - MySqlConnection connection; - - public CommandTimer(MySqlConnection connection, int timeout) - { - this.connection = connection; - if (connection != null) - { - timeoutSet = connection.SetCommandTimeout(timeout); - } - } - - #region IDisposable Members - public void Dispose() - { - if (timeoutSet) - { - timeoutSet = false; - connection.ClearCommandTimeout(); - connection = null; - } - } - #endregion - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Crypt.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Crypt.cs deleted file mode 100644 index 4695b92..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Crypt.cs +++ /dev/null @@ -1,338 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Globalization; -using System.Text; -using MySql.Data.Common; -using MySql.Data.MySqlClient.Properties; -//using System.Security.Cryptography; -//#if CF -//using OpenNETCF.Security.Cryptography; -//#endif - -namespace MySql.Data.MySqlClient -{ - /// - /// Summary description for Crypt. - /// - internal class Crypt - { - // private ctor to prevent creating a default one - private Crypt() - { - } - -/* private void Create41Password( string password ) - { - SHA1 sha = new SHA1CryptoServiceProvider(); - byte[] firstPassBytes = sha.ComputeHash( System.Text.Encoding.Default.GetBytes( password )); - - byte[] salt = packet.GetBuffer(); - byte[] input = new byte[ firstPassBytes.Length + 4 ]; - salt.CopyTo( input, 0 ); - firstPassBytes.CopyTo( input, 4 ); - byte[] outPass = new byte[100]; - byte[] secondPassBytes = sha.ComputeHash( input ); - - byte[] cryptSalt = new byte[20]; - Security.ArrayCrypt( salt, 4, cryptSalt, 0, secondPassBytes, 20 ); - - Security.ArrayCrypt( cryptSalt, 0, firstPassBytes, 0, firstPassBytes, 20 ); - - // send the packet - packet = CreatePacket(null); - packet.Write( firstPassBytes, 0, 20 ); - SendPacket(packet); - } -*/ - - /// - /// Simple XOR scramble - /// - /// Source array - /// Index inside source array - /// Destination array - /// Index inside destination array - /// Password used to xor the bits - /// Number of bytes to scramble - private static void XorScramble(byte[] from, int fromIndex, byte[] to, int toIndex, - byte[] password, int length) - { - // make sure we were called properly - if (fromIndex < 0 || fromIndex >= from.Length) - throw new ArgumentException(Resources.IndexMustBeValid, "fromIndex"); - if ((fromIndex + length) > from.Length) - throw new ArgumentException(Resources.FromAndLengthTooBig, "fromIndex"); - if (from == null) - throw new ArgumentException(Resources.BufferCannotBeNull, "from"); - if (to == null) - throw new ArgumentException(Resources.BufferCannotBeNull, "to"); - if (toIndex < 0 || toIndex >= to.Length) - throw new ArgumentException(Resources.IndexMustBeValid, "toIndex"); - if ((toIndex + length) > to.Length) - throw new ArgumentException(Resources.IndexAndLengthTooBig, "toIndex"); - if (password == null || password.Length < length) - throw new ArgumentException(Resources.PasswordMustHaveLegalChars, "password"); - if (length < 0) - throw new ArgumentException(Resources.ParameterCannotBeNegative, "count"); - - // now perform the work - for (int i = 0; i < length; i++) - to[toIndex++] = (byte) (from[fromIndex++] ^ password[i]); - } - - /// - /// Generate a scrambled password for 4.1.0 using new passwords - /// - /// The password to scramble - /// The seedbytes used to scramble - /// Array of bytes containing the scrambled password - public static byte[] Get410Password(string password, byte[] seedBytes) - { - SHA1Hash sha = new SHA1Hash(); - //SHA1 sha = new SHA1CryptoServiceProvider(); - - // clean it and then digest it - password = password.Replace(" ", "").Replace("\t", ""); - byte[] passBytes = Encoding.Default.GetBytes(password); - byte[] firstPass = sha.ComputeHash(passBytes); - - byte[] input = new byte[24]; - Array.Copy(seedBytes, 0, input, 0, 4); - Array.Copy(firstPass, 0, input, 4, 20); - byte[] secondPass = sha.ComputeHash(input); - - byte[] scrambledBuff = new byte[20]; - XorScramble(seedBytes, 4, scrambledBuff, 0, secondPass, 20); - - byte[] finalBuff = new byte[20]; - XorScramble(scrambledBuff, 0, finalBuff, 0, firstPass, 20); - - return finalBuff; - } - - /// - /// Generates a proper hash for old style 4.1.0 passwords. This would be used - /// if a 4.1.0 server contained old 16 byte hashes. - /// - /// The password to hash - /// Seed bytes received from the server - /// Byte array containing the password hash - public static byte[] GetOld410Password(string password, byte[] seedBytes) - { - long[] passwordHash = Hash(password); - string passHex = String.Format(CultureInfo.InvariantCulture, - "{0,8:X}{1,8:X}", passwordHash[0], passwordHash[1]); - - int[] salt = getSaltFromPassword(passHex); - - // compute binary password - byte[] binaryPassword = new byte[20]; - int offset = 0; - for (int i = 0; i < 2; i++) - { - int val = salt[i]; - - for (int t = 3; t >= 0; t--) - { - binaryPassword[t + offset] = (byte) (val%256); - val >>= 8; /* Scroll 8 bits to get next part*/ - } - - offset += 4; - } - - //SHA1 sha = new SHA1CryptoServiceProvider(); - SHA1Hash sha = new SHA1Hash(); - byte[] temp = new byte[8]; - Buffer.BlockCopy(binaryPassword, 0, temp, 0, 8); - byte[] binaryHash = sha.ComputeHash(temp); - - byte[] scrambledBuff = new byte[20]; - XorScramble(seedBytes, 4, scrambledBuff, 0, binaryHash, 20); - - string scrambleString = Encoding.Default.GetString(scrambledBuff, 0, scrambledBuff.Length).Substring(0, 8); - - long[] hashPass = Hash(password); - long[] hashMessage = Hash(scrambleString); - - long max = 0x3FFFFFFFL; - byte[] to = new byte[20]; - int msgPos = 0; - int msgLength = scrambleString.Length; - int toPos = 0; - long seed1 = (hashPass[0] ^ hashMessage[0])%max; - long seed2 = (hashPass[1] ^ hashMessage[1])%max; - - while (msgPos++ < msgLength) - to[toPos++] = (byte) (Math.Floor(rand(ref seed1, ref seed2, max)*31) + 64); - - /* Make it harder to break */ - byte extra = (byte) (Math.Floor(rand(ref seed1, ref seed2, max)*31)); - - for (int i = 0; i < 8; i++) - to[i] ^= extra; - - return to; - } - - /// - /// Returns a byte array containing the proper encryption of the - /// given password/seed according to the new 4.1.1 authentication scheme. - /// - /// - /// - /// - public static byte[] Get411Password(string password, string seed) - { - // if we have no password, then we just return 1 zero byte - if (password.Length == 0) return new byte[1]; - - //SHA1 sha = new SHA1CryptoServiceProvider(); - SHA1Hash sha = new SHA1Hash(); - - byte[] firstHash = sha.ComputeHash(Encoding.Default.GetBytes(password)); - byte[] secondHash = sha.ComputeHash(firstHash); - byte[] seedBytes = Encoding.Default.GetBytes(seed); - - byte[] input = new byte[seedBytes.Length + secondHash.Length]; - Array.Copy(seedBytes, 0, input, 0, seedBytes.Length); - Array.Copy(secondHash, 0, input, seedBytes.Length, secondHash.Length); - byte[] thirdHash = sha.ComputeHash(input); - - byte[] finalHash = new byte[thirdHash.Length + 1]; - finalHash[0] = 0x14; - Array.Copy(thirdHash, 0, finalHash, 1, thirdHash.Length); - - for (int i = 1; i < finalHash.Length; i++) - finalHash[i] = (byte) (finalHash[i] ^ firstHash[i - 1]); - return finalHash; - } - - private static int[] getSaltFromPassword(String password) - { - int[] result = new int[6]; - - if (password == null || password.Length == 0) - return result; - - int resultPos = 0; - int pos = 0; - - while (pos < password.Length) - { - int val = 0; - - for (int i = 0; i < 8; i++) - val = (val << 4) + HexValue(password[pos++]); - - result[resultPos++] = val; - } - - return result; - } - - private static int HexValue(char c) - { - if (c >= 'A' && c <= 'Z') return (c - 'A') + 10; - if (c >= 'a' && c <= 'z') return (c - 'a') + 10; - return c - '0'; - } - - - private static double rand(ref long seed1, ref long seed2, long max) - { - seed1 = (seed1*3) + seed2; - seed1 %= max; - seed2 = (seed1 + seed2 + 33)%max; - return (seed1/(double) max); - } - - /// - /// Encrypts a password using the MySql encryption scheme - /// - /// The password to encrypt - /// The encryption seed the server gave us - /// Indicates if we should use the old or new encryption scheme - /// - public static String EncryptPassword(String password, String seed, bool new_ver) - { - long max = 0x3fffffff; - if (! new_ver) - max = 0x01FFFFFF; - if (password == null || password.Length == 0) - return password; - - long[] hash_seed = Hash(seed); - long[] hash_pass = Hash(password); - - long seed1 = (hash_seed[0] ^ hash_pass[0])%max; - long seed2 = (hash_seed[1] ^ hash_pass[1])%max; - if (! new_ver) - seed2 = seed1/2; - - char[] scrambled = new char[seed.Length]; - for (int x = 0; x < seed.Length; x++) - { - double r = rand(ref seed1, ref seed2, max); - scrambled[x] = (char) (Math.Floor(r*31) + 64); - } - - if (new_ver) - { - /* Make it harder to break */ - char extra = (char) Math.Floor(rand(ref seed1, ref seed2, max)*31); - for (int x = 0; x < scrambled.Length; x++) - scrambled[x] ^= extra; - } - - return new string(scrambled); - } - - /// - /// Hashes a password using the algorithm from Monty's code. - /// The first element in the return is the result of the "old" hash. - /// The second element is the rest of the "new" hash. - /// - /// Password to be hashed - /// Two element array containing the hashed values - private static long[] Hash(String P) - { - long val1 = 1345345333; - long val2 = 0x12345671; - long inc = 7; - - for (int i = 0; i < P.Length; i++) - { - if (P[i] == ' ' || P[i] == '\t') continue; - long temp = (0xff & P[i]); - val1 ^= (((val1 & 63) + inc)*temp) + (val1 << 8); - val2 += (val2 << 8) ^ val1; - inc += temp; - } - - long[] hash = new long[2]; - hash[0] = val1 & 0x7fffffff; - hash[1] = val2 & 0x7fffffff; - return hash; - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Driver.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Driver.cs deleted file mode 100644 index f2f570d..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Driver.cs +++ /dev/null @@ -1,513 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections; -using System.Globalization; -using System.Text; -using MySql.Data.Common; -using MySql.Data.Types; -using MySql.Data.MySqlClient.Properties; -using System.Diagnostics; -using System.Collections.Generic; - -namespace MySql.Data.MySqlClient -{ - /// - /// Summary description for BaseDriver. - /// - internal class Driver : IDisposable - { - protected Encoding encoding; - protected MySqlConnectionStringBuilder connectionString; - protected ClientFlags serverCaps; - protected bool isOpen; - protected DateTime creationTime; - protected string serverCharSet; - protected int serverCharSetIndex; - protected Hashtable serverProps; - protected Hashtable charSets; - protected long maxPacketSize; - private DateTime idleSince; - -#if !CF - protected MySqlPromotableTransaction currentTransaction; - protected bool inActiveUse; -#endif - protected MySqlPool pool; - private bool firstResult; - protected IDriver handler; - internal MySqlDataReader reader; - - /// - /// For pooled connections, time when the driver was - /// put into idle queue - /// - public DateTime IdleSince - { - get { return idleSince; } - set { idleSince = value; } - } - - public Driver(MySqlConnectionStringBuilder settings) - { - encoding = Encoding.GetEncoding(1252); - if (encoding == null) - throw new MySqlException(Resources.DefaultEncodingNotFound); - connectionString = settings; - serverCharSet = "latin1"; - serverCharSetIndex = -1; - maxPacketSize = 1024; - handler = new NativeDriver(this); - } - - ~Driver() - { - Close(); - } - - #region Properties - - public int ThreadID - { - get { return handler.ThreadId; } - } - - public DBVersion Version - { - get { return handler.Version; } - } - - public MySqlConnectionStringBuilder Settings - { - get { return connectionString; } - set { connectionString = value; } - } - - public Encoding Encoding - { - get { return encoding; } - set { encoding = value; } - } - -#if !CF - public MySqlPromotableTransaction CurrentTransaction - { - get { return currentTransaction; } - set { currentTransaction = value; } - } - - public bool IsInActiveUse - { - get { return inActiveUse; } - set { inActiveUse = value; } - } -#endif - public bool IsOpen - { - get { return isOpen; } - } - - public MySqlPool Pool - { - get { return pool; } - set { pool = value; } - } - - public long MaxPacketSize - { - get { return maxPacketSize; } - } - - internal int ConnectionCharSetIndex - { - get { return serverCharSetIndex; } - set { serverCharSetIndex = value; } - } - - internal Hashtable CharacterSets - { - get { return charSets; } - } - - public bool SupportsOutputParameters - { - get { return Version.isAtLeast(6,0,8); } - } - - /// - /// Returns true if this connection can handle batch SQL natively - /// This means MySQL 4.1.1 or later. - /// - public bool SupportsBatch - { - get - { - if ((handler.Flags & ClientFlags.MULTI_STATEMENTS) != 0) - { - if (Version.isAtLeast(4, 1, 0) && !Version.isAtLeast(4, 1, 10)) - { - object qtType = serverProps["query_cache_type"]; - object qtSize = serverProps["query_cache_size"]; - if (qtType != null && qtType.Equals("ON") && - (qtSize != null && !qtSize.Equals("0"))) - return false; - } - return true; - } - return false; - } - } - - #endregion - - public string Property(string key) - { - return (string) serverProps[key]; - } - - public bool ConnectionLifetimeExpired() - { - TimeSpan ts = DateTime.Now.Subtract(creationTime); - if (Settings.ConnectionLifeTime != 0 && - ts.TotalSeconds > Settings.ConnectionLifeTime) - return true; - return false; - } - - public static Driver Create(MySqlConnectionStringBuilder settings) - { - Driver d = null; - -#if !CF - if (settings.Logging || settings.UseUsageAdvisor) - d = new TracingDriver(settings); - else -#endif - d = new Driver(settings); - d.Open(); - return d; - } - - public bool HasStatus(ServerStatusFlags flag) - { - return (handler.ServerStatus & flag) != 0; - } - - public virtual void Open() - { - creationTime = DateTime.Now; - handler.Open(); - isOpen = true; - } - - public virtual void Close() - { - Dispose(); - } - - public virtual void Configure(MySqlConnection connection) - { - bool firstConfigure = false; - // if we have not already configured our server variables - // then do so now - if (serverProps == null) - { - firstConfigure = true; - // load server properties - serverProps = new Hashtable(); - MySqlCommand cmd = new MySqlCommand("SHOW VARIABLES", connection); - - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - try - { - while (reader.Read()) - { - string key = reader.GetString(0); - string value = reader.GetString(1); - serverProps[key] = value; - } - } - catch (Exception ex) - { - MySqlTrace.LogError(ThreadID, ex.Message); - throw; - } - } - - if (serverProps.Contains("max_allowed_packet")) - maxPacketSize = Convert.ToInt64(serverProps["max_allowed_packet"]); - - LoadCharacterSets(connection); - } - -#if AUTHENTICATED - string licenseType = serverProps["license"]; - if (licenseType == null || licenseType.Length == 0 || - licenseType != "commercial") - throw new MySqlException( "This client library licensed only for use with commercially-licensed MySQL servers." ); -#endif - // if the user has indicated that we are not to reset - // the connection and this is not our first time through, - // then we are done. - if (!Settings.ConnectionReset && !firstConfigure) return; - - string charSet = connectionString.CharacterSet; - if (charSet == null || charSet.Length == 0) - { - if (serverCharSetIndex >= 0) - charSet = (string) charSets[serverCharSetIndex]; - else - charSet = serverCharSet; - } - - // now tell the server which character set we will send queries in and which charset we - // want results in - MySqlCommand charSetCmd = new MySqlCommand("SET character_set_results=NULL", - connection); - object clientCharSet = serverProps["character_set_client"]; - object connCharSet = serverProps["character_set_connection"]; - if ((clientCharSet != null && clientCharSet.ToString() != charSet) || - (connCharSet != null && connCharSet.ToString() != charSet)) - { - MySqlCommand setNamesCmd = new MySqlCommand("SET NAMES " + charSet, connection); - setNamesCmd.ExecuteNonQuery(); - } - charSetCmd.ExecuteNonQuery(); - - if (charSet != null) - Encoding = CharSetMap.GetEncoding(Version, charSet); - else - Encoding = CharSetMap.GetEncoding(Version, "latin1"); - - handler.Configure(); - } - - /// - /// Loads all the current character set names and ids for this server - /// into the charSets hashtable - /// - private void LoadCharacterSets(MySqlConnection connection) - { - MySqlCommand cmd = new MySqlCommand("SHOW COLLATION", connection); - - // now we load all the currently active collations - try - { - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - charSets = new Hashtable(); - while (reader.Read()) - { - charSets[Convert.ToInt32(reader["id"], NumberFormatInfo.InvariantInfo)] = - reader.GetString(reader.GetOrdinal("charset")); - } - } - } - catch (Exception ex) - { - MySqlTrace.LogError(ThreadID, ex.Message); - throw; - } - } - - public virtual List ReportWarnings(MySqlConnection connection) - { - List warnings = new List(); - - MySqlCommand cmd = new MySqlCommand("SHOW WARNINGS", connection); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - warnings.Add(new MySqlError(reader.GetString(0), - reader.GetInt32(1), reader.GetString(2))); - } - } - - MySqlInfoMessageEventArgs args = new MySqlInfoMessageEventArgs(); - args.errors = warnings.ToArray(); - if (connection != null) - connection.OnInfoMessage(args); - return warnings; - } - - public virtual void SendQuery(MySqlPacket p) - { - handler.SendQuery(p); - firstResult = true; - } - - public virtual ResultSet NextResult(int statementId) - { - if (!firstResult && !HasStatus(ServerStatusFlags.AnotherQuery | ServerStatusFlags.MoreResults)) - return null; - firstResult = false; - - int affectedRows = -1, insertedId = -1, warnings = 0; - int fieldCount = GetResult(statementId, ref affectedRows, ref insertedId); - if (fieldCount == -1) - return null; - if (fieldCount > 0) - return new ResultSet(this, statementId, fieldCount); - else - return new ResultSet(affectedRows, insertedId); - } - - protected virtual int GetResult(int statementId, ref int affectedRows, ref int insertedId) - { - return handler.GetResult(ref affectedRows, ref insertedId); - } - - public virtual bool FetchDataRow(int statementId, int columns) - { - return handler.FetchDataRow(statementId, columns); - } - - public virtual bool SkipDataRow() - { - return FetchDataRow(-1, 0); - } - - public virtual void ExecuteDirect(string sql) - { - MySqlPacket p = new MySqlPacket(Encoding); - p.WriteString(sql); - SendQuery(p); - NextResult(0); - } - - public MySqlField[] GetColumns(int count) - { - MySqlField[] fields = new MySqlField[count]; - for (int i = 0; i < count; i++) - fields[i] = new MySqlField(this); - handler.GetColumnsData(fields); - - return fields; - } - - public virtual int PrepareStatement(string sql, ref MySqlField[] parameters) - { - return handler.PrepareStatement(sql, ref parameters); - } - - public IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue value) - { - return handler.ReadColumnValue(index, field, value); - } - - public void SkipColumnValue(IMySqlValue valObject) - { - handler.SkipColumnValue(valObject); - } - - public void ResetTimeout(int timeoutMilliseconds) - { - handler.ResetTimeout(timeoutMilliseconds); - } - - public bool Ping() - { - return handler.Ping(); - } - - public virtual void SetDatabase(string dbName) - { - handler.SetDatabase(dbName); - } - - public virtual void ExecuteStatement(MySqlPacket packetToExecute) - { - handler.ExecuteStatement(packetToExecute); - } - - - public virtual void CloseStatement(int id) - { - handler.CloseStatement(id); - } - - public virtual void Reset() - { - handler.Reset(); - } - - public virtual void CloseQuery(MySqlConnection connection, int statementId) - { - if (handler.WarningCount > 0) - ReportWarnings(connection); - } - - #region IDisposable Members - - protected virtual void Dispose(bool disposing) - { - ResetTimeout(1000); - if (disposing) - handler.Close(isOpen); - // if we are pooling, then release ourselves - if (connectionString.Pooling) - MySqlPoolManager.RemoveConnection(this); - - isOpen = false; - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - internal bool isExecutingBuggyQuery; - internal bool IsExecutingBuggyQuery - { - get { return isExecutingBuggyQuery; } - set { isExecutingBuggyQuery = value; } - } - #endregion - } - - internal interface IDriver - { - int ThreadId { get; } - DBVersion Version { get; } - ServerStatusFlags ServerStatus { get; } - ClientFlags Flags { get; } - void Configure(); - void Open(); - void SendQuery(MySqlPacket packet); - void Close(bool isOpen); - bool Ping(); - int GetResult(ref int affectedRows, ref int insertedId); - bool FetchDataRow(int statementId, int columns); - int PrepareStatement(string sql, ref MySqlField[] parameters); - void ExecuteStatement(MySqlPacket packet); - void CloseStatement(int statementId); - void SetDatabase(string dbName); - void Reset(); - IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue valObject); - void SkipColumnValue(IMySqlValue valueObject); - void GetColumnsData(MySqlField[] columns); - void ResetTimeout(int timeout); - int WarningCount { get; } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Exception.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Exception.cs deleted file mode 100644 index f1f1e6a..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Exception.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data.Common; -#if !CF -using System.Runtime.Serialization; -#endif - -namespace MySql.Data.MySqlClient -{ - /// - /// The exception that is thrown when MySQL returns an error. This class cannot be inherited. - /// - /// -#if !CF - [Serializable] -#endif - public sealed class MySqlException : DbException - { - private int errorCode; - private bool isFatal; - - internal MySqlException() - { - } - - internal MySqlException(string msg) : base(msg) - { - } - - internal MySqlException(string msg, Exception ex) : base(msg, ex) - { - } - - internal MySqlException(string msg, bool isFatal, Exception inner) : base (msg, inner) - { - this.isFatal = isFatal; - } - - internal MySqlException(string msg, int errno, Exception inner) - : this(msg, inner) - { - errorCode = errno; -#if !CF - Data.Add("Server Error Code", errno); -#endif - } - - internal MySqlException(string msg, int errno) - : this(msg, errno, null) - { - } - -#if !CF - private MySqlException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } -#endif - - /// - /// Gets a number that identifies the type of error. - /// - public int Number - { - get { return errorCode; } - } - - /// - /// True if this exception was fatal and cause the closing of the connection, false otherwise. - /// - internal bool IsFatal - { - get { return isFatal; } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Field.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Field.cs deleted file mode 100644 index d15f4d2..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Field.cs +++ /dev/null @@ -1,417 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System.Text; -using MySql.Data.Common; -using MySql.Data.Types; -using System.Globalization; -using System.Text.RegularExpressions; -using System; -using System.Collections; -using System.Collections.Generic; - -namespace MySql.Data.MySqlClient -{ - internal enum ColumnFlags : int - { - NOT_NULL = 1, - PRIMARY_KEY = 2, - UNIQUE_KEY = 4, - MULTIPLE_KEY = 8, - BLOB = 16, - UNSIGNED = 32, - ZERO_FILL = 64, - BINARY = 128, - ENUM = 256, - AUTO_INCREMENT = 512, - TIMESTAMP = 1024, - SET = 2048, - NUMBER = 32768 - } ; - - /// - /// Summary description for Field. - /// - internal class MySqlField - { - #region Fields - - // public fields - public string CatalogName; - public int ColumnLength; - public string ColumnName; - public string OriginalColumnName; - public string TableName; - public string RealTableName; - public string DatabaseName; - public Encoding Encoding; - public int maxLength; - - // protected fields - protected ColumnFlags colFlags; - protected int charSetIndex; - protected byte precision; - protected byte scale; - protected MySqlDbType mySqlDbType; - protected DBVersion connVersion; - protected Driver driver; - protected bool binaryOk; - protected List typeConversions = new List(); - - #endregion - - public MySqlField(Driver driver) - { - this.driver = driver; - connVersion = driver.Version; - maxLength = 1; - binaryOk = true; - } - - #region Properties - - public int CharacterSetIndex - { - get { return charSetIndex; } - set { charSetIndex = value; SetFieldEncoding(); } - } - - public MySqlDbType Type - { - get { return mySqlDbType; } - } - - public byte Precision - { - get { return precision; } - set { precision = value; } - } - - public byte Scale - { - get { return scale; } - set { scale = value; } - } - - public int MaxLength - { - get { return maxLength; } - set { maxLength = value; } - } - - public ColumnFlags Flags - { - get { return colFlags; } - } - - public bool IsAutoIncrement - { - get { return (colFlags & ColumnFlags.AUTO_INCREMENT) > 0; } - } - - public bool IsNumeric - { - get { return (colFlags & ColumnFlags.NUMBER) > 0; } - } - - public bool AllowsNull - { - get { return (colFlags & ColumnFlags.NOT_NULL) == 0; } - } - - public bool IsUnique - { - get { return (colFlags & ColumnFlags.UNIQUE_KEY) > 0; } - } - - public bool IsPrimaryKey - { - get { return (colFlags & ColumnFlags.PRIMARY_KEY) > 0; } - } - - public bool IsBlob - { - get - { - return (mySqlDbType >= MySqlDbType.TinyBlob && - mySqlDbType <= MySqlDbType.Blob) || - (mySqlDbType >= MySqlDbType.TinyText && - mySqlDbType <= MySqlDbType.Text) || - (colFlags & ColumnFlags.BLOB) > 0; - } - } - - public bool IsBinary - { - get - { - return binaryOk && (CharacterSetIndex == 63); - } - } - - public bool IsUnsigned - { - get { return (colFlags & ColumnFlags.UNSIGNED) > 0; } - } - - public bool IsTextField - { - get - { - return Type == MySqlDbType.VarString || Type == MySqlDbType.VarChar || - (IsBlob && !IsBinary); - } - } - - public int CharacterLength - { - get { return ColumnLength / MaxLength; } - } - - public List TypeConversions - { - get { return typeConversions; } - } - - #endregion - - public void SetTypeAndFlags(MySqlDbType type, ColumnFlags flags) - { - colFlags = flags; - mySqlDbType = type; - - if (String.IsNullOrEmpty(TableName) && String.IsNullOrEmpty(RealTableName) && - driver.Settings.FunctionsReturnString) - { - mySqlDbType = MySqlDbType.VarString; - // we are treating a binary as string so we have to choose some - // charset index. Connection seems logical. - CharacterSetIndex = driver.ConnectionCharSetIndex; - binaryOk = false; - } - - // if our type is an unsigned number, then we need - // to bump it up into our unsigned types - // we're trusting that the server is not going to set the UNSIGNED - // flag unless we are a number - if (IsUnsigned) - { - switch (type) - { - case MySqlDbType.Byte: - mySqlDbType = MySqlDbType.UByte; - return; - case MySqlDbType.Int16: - mySqlDbType = MySqlDbType.UInt16; - return; - case MySqlDbType.Int24: - mySqlDbType = MySqlDbType.UInt24; - return; - case MySqlDbType.Int32: - mySqlDbType = MySqlDbType.UInt32; - return; - case MySqlDbType.Int64: - mySqlDbType = MySqlDbType.UInt64; - return; - } - } - - if (IsBlob) - { - // handle blob to UTF8 conversion if requested. This is only activated - // on binary blobs - if (IsBinary && driver.Settings.TreatBlobsAsUTF8) - { - bool convertBlob = false; - Regex includeRegex = driver.Settings.GetBlobAsUTF8IncludeRegex(); - Regex excludeRegex = driver.Settings.GetBlobAsUTF8ExcludeRegex(); - if (includeRegex != null && includeRegex.IsMatch(ColumnName)) - convertBlob = true; - else if (includeRegex == null && excludeRegex != null && - !excludeRegex.IsMatch(ColumnName)) - convertBlob = true; - - if (convertBlob) - { - binaryOk = false; - Encoding = System.Text.Encoding.GetEncoding("UTF-8"); - charSetIndex = -1; // lets driver know we are in charge of encoding - maxLength = 4; - } - } - - if (!IsBinary) - { - if (type == MySqlDbType.TinyBlob) - mySqlDbType = MySqlDbType.TinyText; - else if (type == MySqlDbType.MediumBlob) - mySqlDbType = MySqlDbType.MediumText; - else if (type == MySqlDbType.Blob) - mySqlDbType = MySqlDbType.Text; - else if (type == MySqlDbType.LongBlob) - mySqlDbType = MySqlDbType.LongText; - } - } - - // now determine if we really should be binary - if (driver.Settings.RespectBinaryFlags) - CheckForExceptions(); - - if (Type == MySqlDbType.String && CharacterLength == 36 && !driver.Settings.OldGuids) - mySqlDbType = MySqlDbType.Guid; - - if (!IsBinary) return; - - if (driver.Settings.RespectBinaryFlags) - { - if (type == MySqlDbType.String) - mySqlDbType = MySqlDbType.Binary; - else if (type == MySqlDbType.VarChar || - type == MySqlDbType.VarString) - mySqlDbType = MySqlDbType.VarBinary; - } - - if (CharacterSetIndex == 63) - CharacterSetIndex = driver.ConnectionCharSetIndex; - - if (Type == MySqlDbType.Binary && ColumnLength == 16 && driver.Settings.OldGuids) - mySqlDbType = MySqlDbType.Guid; - } - - public void AddTypeConversion(Type t) - { - if (TypeConversions.Contains(t)) return; - TypeConversions.Add(t); - } - - private void CheckForExceptions() - { - string colName = String.Empty; - if (OriginalColumnName != null) - colName = OriginalColumnName.ToUpper(CultureInfo.InvariantCulture); - if (colName.StartsWith("CHAR(")) - binaryOk = false; - else if (driver.IsExecutingBuggyQuery) - binaryOk = false; - } - - public IMySqlValue GetValueObject() - { - IMySqlValue v = GetIMySqlValue(Type); - if (v is MySqlByte && ColumnLength == 1 && driver.Settings.TreatTinyAsBoolean) - { - MySqlByte b = (MySqlByte)v; - b.TreatAsBoolean = true; - v = b; - } - else if (v is MySqlGuid) - { - MySqlGuid g = (MySqlGuid)v; - g.OldGuids = driver.Settings.OldGuids; - v = g; - } - return v; - } - - public static IMySqlValue GetIMySqlValue(MySqlDbType type) - { - switch (type) - { - case MySqlDbType.Byte: - return new MySqlByte(); - case MySqlDbType.UByte: - return new MySqlUByte(); - case MySqlDbType.Int16: - return new MySqlInt16(); - case MySqlDbType.UInt16: - return new MySqlUInt16(); - case MySqlDbType.Int24: - case MySqlDbType.Int32: - case MySqlDbType.Year: - return new MySqlInt32(type, true); - case MySqlDbType.UInt24: - case MySqlDbType.UInt32: - return new MySqlUInt32(type, true); - case MySqlDbType.Bit: - return new MySqlBit(); - case MySqlDbType.Int64: - return new MySqlInt64(); - case MySqlDbType.UInt64: - return new MySqlUInt64(); - case MySqlDbType.Time: - return new MySqlTimeSpan(); - case MySqlDbType.Date: - case MySqlDbType.DateTime: - case MySqlDbType.Newdate: - case MySqlDbType.Timestamp: - return new MySqlDateTime(type, true); - case MySqlDbType.Decimal: - case MySqlDbType.NewDecimal: - return new MySqlDecimal(); - case MySqlDbType.Float: - return new MySqlSingle(); - case MySqlDbType.Double: - return new MySqlDouble(); - case MySqlDbType.Set: - case MySqlDbType.Enum: - case MySqlDbType.String: - case MySqlDbType.VarString: - case MySqlDbType.VarChar: - case MySqlDbType.Text: - case MySqlDbType.TinyText: - case MySqlDbType.MediumText: - case MySqlDbType.LongText: - case (MySqlDbType) Field_Type.NULL: - return new MySqlString(type, true); - case MySqlDbType.Geometry: - case MySqlDbType.Blob: - case MySqlDbType.MediumBlob: - case MySqlDbType.LongBlob: - case MySqlDbType.TinyBlob: - case MySqlDbType.Binary: - case MySqlDbType.VarBinary: - return new MySqlBinary(type, true); - case MySqlDbType.Guid: - return new MySqlGuid(); - default: - throw new MySqlException("Unknown data type"); - } - } - - private void SetFieldEncoding() - { - Hashtable charSets = driver.CharacterSets; - DBVersion version = driver.Version; - - if (charSets == null || CharacterSetIndex == -1) return; - if (charSets[CharacterSetIndex] == null) return; - - CharacterSet cs = CharSetMap.GetCharacterSet(version, (string)charSets[CharacterSetIndex]); - // starting with 6.0.4 utf8 has a maxlen of 4 instead of 3. The old - // 3 byte utf8 is utf8mb3 - if (cs.name.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "utf-8" && - version.Major >= 6) - MaxLength = 4; - else - MaxLength = cs.byteCount; - Encoding = CharSetMap.GetEncoding(version, (string)charSets[CharacterSetIndex]); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ISSchemaProvider.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ISSchemaProvider.cs deleted file mode 100644 index deb2c5e..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ISSchemaProvider.cs +++ /dev/null @@ -1,694 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Text; -using MySql.Data.Common; -using System.Globalization; -using System.Diagnostics; -using System.Data.SqlTypes; -using MySql.Data.Types; -using System.Collections; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.MySqlClient -{ - internal class ISSchemaProvider : SchemaProvider - { - public ISSchemaProvider(MySqlConnection connection) : base(connection) - { - } - - protected override DataTable GetCollections() - { - DataTable dt = base.GetCollections(); - - object[][] collections = new object[][] - { - new object[] {"Views", 2, 3}, - new object[] {"ViewColumns", 3, 4}, - new object[] {"Procedure Parameters", 5, 1}, - new object[] {"Procedures", 4, 3}, - new object[] {"Triggers", 2, 4} - }; - - FillTable(dt, collections); - return dt; - } - - protected override DataTable GetRestrictions() - { - DataTable dt = base.GetRestrictions(); - - object[][] restrictions = new object[][] - { - new object[] {"Procedure Parameters", "Database", "", 0}, - new object[] {"Procedure Parameters", "Schema", "", 1}, - new object[] {"Procedure Parameters", "Name", "", 2}, - new object[] {"Procedure Parameters", "Type", "", 3}, - new object[] {"Procedure Parameters", "Parameter", "", 4}, - new object[] {"Procedures", "Database", "", 0}, - new object[] {"Procedures", "Schema", "", 1}, - new object[] {"Procedures", "Name", "", 2}, - new object[] {"Procedures", "Type", "", 3}, - new object[] {"Views", "Database", "", 0}, - new object[] {"Views", "Schema", "", 1}, - new object[] {"Views", "Table", "", 2}, - new object[] {"ViewColumns", "Database", "", 0}, - new object[] {"ViewColumns", "Schema", "", 1}, - new object[] {"ViewColumns", "Table", "", 2}, - new object[] {"ViewColumns", "Column", "", 3}, - new object[] {"Triggers", "Database", "", 0}, - new object[] {"Triggers", "Schema", "", 1}, - new object[] {"Triggers", "Name", "", 2}, - new object[] {"Triggers", "EventObjectTable", "", 3}, - }; - FillTable(dt, restrictions); - return dt; - } - - public override DataTable GetDatabases(string[] restrictions) - { - string[] keys = new string[1]; - keys[0] = "SCHEMA_NAME"; - DataTable dt = Query("SCHEMATA", "", keys, restrictions); - dt.Columns[1].ColumnName = "database_name"; - dt.TableName = "Databases"; - return dt; - } - - public override DataTable GetTables(string[] restrictions) - { - string[] keys = new string[4]; - keys[0] = "TABLE_CATALOG"; - keys[1] = "TABLE_SCHEMA"; - keys[2] = "TABLE_NAME"; - keys[3] = "TABLE_TYPE"; - DataTable dt = Query("TABLES", "TABLE_TYPE != 'VIEW'", keys, restrictions); - dt.TableName = "Tables"; - return dt; - } - - public override DataTable GetColumns(string[] restrictions) - { - string[] keys = new string[4]; - keys[0] = "TABLE_CATALOG"; - keys[1] = "TABLE_SCHEMA"; - keys[2] = "TABLE_NAME"; - keys[3] = "COLUMN_NAME"; - DataTable dt = Query("COLUMNS", null, keys, restrictions); - dt.Columns.Remove("CHARACTER_OCTET_LENGTH"); - dt.TableName = "Columns"; - return dt; - } - - private DataTable GetViews(string[] restrictions) - { - string[] keys = new string[3]; - keys[0] = "TABLE_CATALOG"; - keys[1] = "TABLE_SCHEMA"; - keys[2] = "TABLE_NAME"; - DataTable dt = Query("VIEWS", null, keys, restrictions); - dt.TableName = "Views"; - return dt; - } - - private DataTable GetViewColumns(string[] restrictions) - { - StringBuilder where = new StringBuilder(); - StringBuilder sql = new StringBuilder( - "SELECT C.* FROM information_schema.columns C"); - sql.Append(" JOIN information_schema.views V "); - sql.Append("ON C.table_schema=V.table_schema AND C.table_name=V.table_name "); - if (restrictions != null && restrictions.Length >= 2 && - restrictions[1] != null) - where.AppendFormat(CultureInfo.InvariantCulture, "C.table_schema='{0}' ", restrictions[1]); - if (restrictions != null && restrictions.Length >= 3 && - restrictions[2] != null) - { - if (where.Length > 0) - where.Append("AND "); - where.AppendFormat(CultureInfo.InvariantCulture, "C.table_name='{0}' ", restrictions[2]); - } - if (restrictions != null && restrictions.Length == 4 && - restrictions[3] != null) - { - if (where.Length > 0) - where.Append("AND "); - where.AppendFormat(CultureInfo.InvariantCulture, "C.column_name='{0}' ", restrictions[3]); - } - if (where.Length > 0) - sql.AppendFormat(CultureInfo.InvariantCulture, " WHERE {0}", where); - DataTable dt = GetTable(sql.ToString()); - dt.TableName = "ViewColumns"; - dt.Columns[0].ColumnName = "VIEW_CATALOG"; - dt.Columns[1].ColumnName = "VIEW_SCHEMA"; - dt.Columns[2].ColumnName = "VIEW_NAME"; - return dt; - } - - private DataTable GetTriggers(string[] restrictions) - { - string[] keys = new string[4]; - keys[0] = "TRIGGER_CATALOG"; - keys[1] = "TRIGGER_SCHEMA"; - keys[2] = "EVENT_OBJECT_TABLE"; - keys[3] = "TRIGGER_NAME"; - DataTable dt = Query("TRIGGERS", null, keys, restrictions); - dt.TableName = "Triggers"; - return dt; - } - - /// - /// Return schema information about procedures and functions - /// Restrictions supported are: - /// schema, name, type - /// - /// - /// - public override DataTable GetProcedures(string[] restrictions) - { - // if the user has said that we have access to mysql.proc then - // we use that as it is a lot faster -// if (connection.HasProcAccess) - // return base.GetProcedures(restrictions); - - string[] keys = new string[4]; - keys[0] = "ROUTINE_CATALOG"; - keys[1] = "ROUTINE_SCHEMA"; - keys[2] = "ROUTINE_NAME"; - keys[3] = "ROUTINE_TYPE"; - - DataTable dt = Query("ROUTINES", null, keys, restrictions); - dt.TableName = "Procedures"; - return dt; - } - - private DataTable GetProceduresWithParameters(string[] restrictions) - { - DataTable dt = GetProcedures(restrictions); - dt.Columns.Add("ParameterList", typeof(string)); - - foreach (DataRow row in dt.Rows) - { - row["ParameterList"] = GetProcedureParameterLine(row); - } - return dt; - } - - private string GetProcedureParameterLine(DataRow isRow) - { - string sql = "SHOW CREATE {0} `{1}`.`{2}`"; - sql = String.Format(sql, isRow["ROUTINE_TYPE"], isRow["ROUTINE_SCHEMA"], - isRow["ROUTINE_NAME"]); - MySqlCommand cmd = new MySqlCommand(sql, connection); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - - // if we are not the owner of this proc or have permissions - // then we will get null for the body - if (reader.IsDBNull(2)) return null; - - string sql_mode = reader.GetString(1); - - string body = reader.GetString(2); - MySqlTokenizer tokenizer = new MySqlTokenizer(body); - tokenizer.AnsiQuotes = sql_mode.IndexOf("ANSI_QUOTES") != -1; - tokenizer.BackslashEscapes = sql_mode.IndexOf("NO_BACKSLASH_ESCAPES") == -1; - - string token = tokenizer.NextToken(); - while (token != "(") - token = tokenizer.NextToken(); - int start = tokenizer.StartIndex + 1; - token = tokenizer.NextToken(); - while (token != ")" || tokenizer.Quoted) - { - token = tokenizer.NextToken(); - // if we see another ( and we are not quoted then we - // are in a size element and we need to look for the closing paren - if (token == "(" && !tokenizer.Quoted) - { - while (token != ")" || tokenizer.Quoted) - token = tokenizer.NextToken(); - token = tokenizer.NextToken(); - } - } - return body.Substring(start, tokenizer.StartIndex - start); - } - } - - private void GetParametersForRoutineFromIS(DataTable dt, string[] restrictions) - { - Debug.Assert(dt != null); - - string[] keys = new string[5]; - keys[0] = "SPECIFIC_CATALOG"; - keys[1] = "SPECIFIC_SCHEMA"; - keys[2] = "SPECIFIC_NAME"; - keys[3] = "ROUTINE_TYPE"; - keys[4] = "PARAMETER_NAME"; - - StringBuilder sql = new StringBuilder(@"SELECT * FROM INFORMATION_SCHEMA.PARAMETERS"); - // now get our where clause and append it if there is one - string where = GetWhereClause(null, keys, restrictions); - if (!String.IsNullOrEmpty(where)) - sql.AppendFormat(CultureInfo.InvariantCulture, " WHERE {0}", where); - - MySqlDataAdapter da = new MySqlDataAdapter(sql.ToString(), connection); - da.Fill(dt); - } - - private DataTable GetParametersFromIS(string[] restrictions, DataTable routines) - { - DataTable parms = new DataTable(); - - if (routines == null || routines.Rows.Count == 0) - { - if (restrictions == null) - { - // first fill our table with the proper structure - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE 1=2", connection); - da.Fill(parms); - } - else - GetParametersForRoutineFromIS(parms, restrictions); - } - else foreach (DataRow routine in routines.Rows) - { - if (restrictions != null && restrictions.Length >= 3) - restrictions[2] = routine["ROUTINE_NAME"].ToString(); - - GetParametersForRoutineFromIS(parms, restrictions); - } - parms.TableName = "Procedure Parameters"; - return parms; - } - - internal DataTable CreateParametersTable() - { - DataTable dt = new DataTable("Procedure Parameters"); - dt.Columns.Add("SPECIFIC_CATALOG", typeof(string)); - dt.Columns.Add("SPECIFIC_SCHEMA", typeof(string)); - dt.Columns.Add("SPECIFIC_NAME", typeof(string)); - dt.Columns.Add("ORDINAL_POSITION", typeof(Int32)); - dt.Columns.Add("PARAMETER_MODE", typeof(string)); - dt.Columns.Add("PARAMETER_NAME", typeof(string)); - dt.Columns.Add("DATA_TYPE", typeof(string)); - dt.Columns.Add("CHARACTER_MAXIMUM_LENGTH", typeof(Int32)); - dt.Columns.Add("CHARACTER_OCTET_LENGTH", typeof(Int32)); - dt.Columns.Add("NUMERIC_PRECISION", typeof(byte)); - dt.Columns.Add("NUMERIC_SCALE", typeof(Int32)); - dt.Columns.Add("CHARACTER_SET_NAME", typeof(string)); - dt.Columns.Add("COLLATION_NAME", typeof(string)); - dt.Columns.Add("DTD_IDENTIFIER", typeof(string)); - dt.Columns.Add("ROUTINE_TYPE", typeof(string)); - return dt; - } - - /// - /// Return schema information about parameters for procedures and functions - /// Restrictions supported are: - /// schema, name, type, parameter name - /// - public virtual DataTable GetProcedureParameters(string[] restrictions, - DataTable routines) - { - if (connection.driver.Version.isAtLeast(6, 0, 6)) - return GetParametersFromIS(restrictions, routines); - try - { - DataTable dt = CreateParametersTable(); - GetParametersFromShowCreate(dt, restrictions, routines); - return dt; - } - catch (InvalidOperationException ioe) - { - throw new InvalidOperationException(Resources.UnableToRetrieveParameters, ioe); - } - } - - protected override DataTable GetSchemaInternal(string collection, string[] restrictions) - { - DataTable dt = base.GetSchemaInternal(collection, restrictions); - if (dt != null) - return dt; - - switch (collection) - { - case "VIEWS": - return GetViews(restrictions); - case "PROCEDURES": - return GetProcedures(restrictions); - case "PROCEDURES WITH PARAMETERS": - return GetProceduresWithParameters(restrictions); - case "PROCEDURE PARAMETERS": - return GetProcedureParameters(restrictions, null); - case "TRIGGERS": - return GetTriggers(restrictions); - case "VIEWCOLUMNS": - return GetViewColumns(restrictions); - } - return null; - } - - private static string GetWhereClause(string initial_where, string[] keys, string[] values) - { - StringBuilder where = new StringBuilder(initial_where); - if (values != null) - { - for (int i = 0; i < keys.Length; i++) - { - if (i >= values.Length) break; - if (values[i] == null || values[i] == String.Empty) continue; - if (where.Length > 0) - where.Append(" AND "); - where.AppendFormat(CultureInfo.InvariantCulture, - "{0} LIKE '{1}'", keys[i], values[i]); - } - } - return where.ToString(); - } - - private DataTable Query(string table_name, string initial_where, - string[] keys, string[] values) - { - StringBuilder query = new StringBuilder("SELECT * FROM INFORMATION_SCHEMA."); - query.Append(table_name); - - string where = GetWhereClause(initial_where, keys, values); - - if (where.Length > 0) - query.AppendFormat(CultureInfo.InvariantCulture, " WHERE {0}", where); - - return GetTable(query.ToString()); - } - - private DataTable GetTable(string sql) - { - DataTable table = new DataTable(); - MySqlDataAdapter da = new MySqlDataAdapter(sql, connection); - da.Fill(table); - return table; - } - - public override DataTable GetForeignKeys(string[] restrictions) - { - if (!connection.driver.Version.isAtLeast(5, 1, 16)) - return base.GetForeignKeys(restrictions); - - string sql = @"SELECT rc.constraint_catalog, rc.constraint_schema, - rc.constraint_name, kcu.table_catalog, kcu.table_schema, rc.table_name, - rc.match_option, rc.update_rule, rc.delete_rule, - NULL as referenced_table_catalog, - kcu.referenced_table_schema, rc.referenced_table_name - FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc - LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu ON - kcu.constraint_catalog <=> rc.constraint_catalog AND - kcu.constraint_schema <=> rc.constraint_schema AND - kcu.constraint_name <=> rc.constraint_name AND - kcu.ORDINAL_POSITION=1 WHERE 1=1"; - - StringBuilder where =new StringBuilder(); - if (restrictions.Length >= 2 && !String.IsNullOrEmpty(restrictions[1])) - where.AppendFormat(CultureInfo.InvariantCulture, - " AND rc.constraint_schema LIKE '{0}'", restrictions[1]); - if (restrictions.Length >= 3 && !String.IsNullOrEmpty(restrictions[2])) - where.AppendFormat(CultureInfo.InvariantCulture, - " AND rc.table_name LIKE '{0}'", restrictions[2]); - if (restrictions.Length >= 4 && !String.IsNullOrEmpty(restrictions[3])) - where.AppendFormat(CultureInfo.InvariantCulture, - " AND rc.constraint_name LIKE '{0}'", restrictions[2]); - - sql += where.ToString(); - - return GetTable(sql); - } - - public override DataTable GetForeignKeyColumns(string[] restrictions) - { - if (!connection.driver.Version.isAtLeast(5, 0, 6)) - return base.GetForeignKeyColumns(restrictions); - - string sql = @"SELECT kcu.* FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu - WHERE kcu.referenced_table_name IS NOT NULL"; - - StringBuilder where = new StringBuilder(); - if (restrictions.Length >= 2 && !String.IsNullOrEmpty(restrictions[1])) - where.AppendFormat(CultureInfo.InvariantCulture, - " AND kcu.constraint_schema LIKE '{0}'", restrictions[1]); - if (restrictions.Length >= 3 && !String.IsNullOrEmpty(restrictions[2])) - where.AppendFormat(CultureInfo.InvariantCulture, - " AND kcu.table_name LIKE '{0}'", restrictions[2]); - if (restrictions.Length >= 4 && !String.IsNullOrEmpty(restrictions[3])) - where.AppendFormat(CultureInfo.InvariantCulture, - " AND kcu.constraint_name LIKE '{0}'", restrictions[3]); - - sql += where.ToString(); - - return GetTable(sql); - } - - #region Procedures Support Rouines - - internal void GetParametersFromShowCreate(DataTable parametersTable, - string[] restrictions, DataTable routines) - { - // this allows us to pass in a pre-populated routines table - // and avoid the querying for them again. - // we use this when calling a procedure or function - if (routines == null) - routines = GetSchema("procedures", restrictions); - - MySqlCommand cmd = connection.CreateCommand(); - - foreach (DataRow routine in routines.Rows) - { - string showCreateSql = String.Format("SHOW CREATE {0} `{1}`.`{2}`", - routine["ROUTINE_TYPE"], routine["ROUTINE_SCHEMA"], - routine["ROUTINE_NAME"]); - cmd.CommandText = showCreateSql; - try - { - string nameToRestrict = null; - if (restrictions != null && restrictions.Length == 5 && - restrictions[4] != null) - nameToRestrict = restrictions[4]; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - string body = reader.GetString(2); - reader.Close(); - ParseProcedureBody(parametersTable, body, routine, nameToRestrict); - } - } - catch (SqlNullValueException snex) - { - throw new InvalidOperationException( - String.Format(Resources.UnableToRetrieveSProcData, routine["ROUTINE_NAME"]), snex); - } - } - } - - private void ParseProcedureBody(DataTable parametersTable, string body, - DataRow row, string nameToRestrict) - { - ArrayList modes = new ArrayList(new string[3] { "IN", "OUT", "INOUT" }); - - string sqlMode = row["SQL_MODE"].ToString(); - - int pos = 1; - MySqlTokenizer tokenizer = new MySqlTokenizer(body); - tokenizer.AnsiQuotes = sqlMode.IndexOf("ANSI_QUOTES") != -1; - tokenizer.BackslashEscapes = sqlMode.IndexOf("NO_BACKSLASH_ESCAPES") == -1; - tokenizer.ReturnComments = false; - string token = tokenizer.NextToken(); - - // this block will scan for the opening paren while also determining - // if this routine is a function. If so, then we need to add a - // parameter row for the return parameter since it is ordinal position - // 0 and should appear first. - while (token != "(") - { - if (String.Compare(token, "FUNCTION", true) == 0 && - nameToRestrict == null) - { - parametersTable.Rows.Add(parametersTable.NewRow()); - InitParameterRow(row, parametersTable.Rows[0]); - } - token = tokenizer.NextToken(); - } - token = tokenizer.NextToken(); // now move to the next token past the ( - - while (token != ")") - { - DataRow parmRow = parametersTable.NewRow(); - InitParameterRow(row, parmRow); - parmRow["ORDINAL_POSITION"] = pos++; - - // handle mode and name for the parameter - string mode = token.ToUpper(CultureInfo.InvariantCulture); - if (!tokenizer.Quoted && modes.Contains(mode)) - { - parmRow["PARAMETER_MODE"] = mode; - token = tokenizer.NextToken(); - } - if (tokenizer.Quoted) - token = token.Substring(1, token.Length - 2); - parmRow["PARAMETER_NAME"] = token; - - // now parse data type - token = ParseDataType(parmRow, tokenizer); - if (token == ",") - token = tokenizer.NextToken(); - - // now determine if we should include this row after all - // we need to parse it before this check so we are correctly - // positioned for the next parameter - if (nameToRestrict == null || - String.Compare(parmRow["PARAMETER_NAME"].ToString(), nameToRestrict, true) == 0) - parametersTable.Rows.Add(parmRow); - } - - // now parse out the return parameter if there is one. - token = tokenizer.NextToken().ToUpper(CultureInfo.InvariantCulture); - if (String.Compare(token, "RETURNS", true) == 0) - { - DataRow parameterRow = parametersTable.Rows[0]; - parameterRow["PARAMETER_NAME"] = "RETURN_VALUE"; - ParseDataType(parameterRow, tokenizer); - } - } - - /// - /// Initializes a new row for the procedure parameters table. - /// - private static void InitParameterRow(DataRow procedure, DataRow parameter) - { - parameter["SPECIFIC_CATALOG"] = null; - parameter["SPECIFIC_SCHEMA"] = procedure["ROUTINE_SCHEMA"]; - parameter["SPECIFIC_NAME"] = procedure["ROUTINE_NAME"]; - parameter["PARAMETER_MODE"] = "IN"; - parameter["ORDINAL_POSITION"] = 0; - parameter["ROUTINE_TYPE"] = procedure["ROUTINE_TYPE"]; - } - - /// - /// Parses out the elements of a procedure parameter data type. - /// - private string ParseDataType(DataRow row, MySqlTokenizer tokenizer) - { - StringBuilder dtd = new StringBuilder( - tokenizer.NextToken().ToUpper(CultureInfo.InvariantCulture)); - row["DATA_TYPE"] = dtd.ToString(); - string type = row["DATA_TYPE"].ToString(); - - string token = tokenizer.NextToken(); - if (token == "(") - { - token = tokenizer.ReadParenthesis(); - dtd.AppendFormat(CultureInfo.InvariantCulture, "{0}", token); - if (type != "ENUM" && type != "SET") - ParseDataTypeSize(row, token); - token = tokenizer.NextToken(); - } - else - dtd.Append(GetDataTypeDefaults(type, row)); - - while (token != ")" && - token != "," && - String.Compare(token, "begin", true) != 0 && - String.Compare(token, "return", true) != 0) - { - if (String.Compare(token, "CHARACTER", true) == 0 || - String.Compare(token, "BINARY", true) == 0) - { } // we don't need to do anything with this - else if (String.Compare(token, "SET", true) == 0 || - String.Compare(token, "CHARSET", true) == 0) - row["CHARACTER_SET_NAME"] = tokenizer.NextToken(); - else if (String.Compare(token, "ASCII", true) == 0) - row["CHARACTER_SET_NAME"] = "latin1"; - else if (String.Compare(token, "UNICODE", true) == 0) - row["CHARACTER_SET_NAME"] = "ucs2"; - else if (String.Compare(token, "COLLATE", true) == 0) - row["COLLATION_NAME"] = tokenizer.NextToken(); - else - dtd.AppendFormat(CultureInfo.InvariantCulture, " {0}", token); - token = tokenizer.NextToken(); - } - - if (dtd.Length > 0) - row["DTD_IDENTIFIER"] = dtd.ToString(); - - // now default the collation if one wasn't given - if (row["COLLATION_NAME"].ToString().Length == 0 && - row["CHARACTER_SET_NAME"].ToString().Length > 0) - row["COLLATION_NAME"] = CharSetMap.GetDefaultCollation( - row["CHARACTER_SET_NAME"].ToString(), connection); - - // now set the octet length - if (row["CHARACTER_MAXIMUM_LENGTH"] != DBNull.Value) - row["CHARACTER_OCTET_LENGTH"] = - CharSetMap.GetMaxLength(row["CHARACTER_SET_NAME"].ToString(), connection) * - (int)row["CHARACTER_MAXIMUM_LENGTH"]; - - return token; - } - - private static string GetDataTypeDefaults(string type, DataRow row) - { - string format = "({0},{1})"; - - if (MetaData.IsNumericType(type) && - row["NUMERIC_PRECISION"].ToString().Length == 0) - { - row["NUMERIC_PRECISION"] = 10; - row["NUMERIC_SCALE"] = 0; - if (!MetaData.SupportScale(type)) - format = "({0})"; - return String.Format(format, row["NUMERIC_PRECISION"], - row["NUMERIC_SCALE"]); - } - return String.Empty; - } - - private static void ParseDataTypeSize(DataRow row, string size) - { - size = size.Trim('(', ')'); - string[] parts = size.Split(','); - - if (!MetaData.IsNumericType(row["DATA_TYPE"].ToString())) - { - row["CHARACTER_MAXIMUM_LENGTH"] = Int32.Parse(parts[0]); - // will set octet length in a minute - } - else - { - row["NUMERIC_PRECISION"] = Int32.Parse(parts[0]); - if (parts.Length == 2) - row["NUMERIC_SCALE"] = Int32.Parse(parts[1]); - } - } - - #endregion - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Installer.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Installer.cs deleted file mode 100644 index f8c41ce..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Installer.cs +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -#if !MONO && !PocketPC - -using System.Configuration.Install; -using System.ComponentModel; -using System.Reflection; -using System; -using Microsoft.Win32; -using System.Xml; -using System.IO; -using System.Diagnostics; -using System.Security; -using System.Security.Permissions; - -namespace MySql.Data.MySqlClient -{ - /// - /// We are adding a custom installer class to our assembly so our installer - /// can make proper changes to the machine.config file. - /// - [RunInstaller(true)] - public class CustomInstaller : Installer - { - /// - /// We override Install so we can add our assembly to the proper - /// machine.config files. - /// - /// - public override void Install(System.Collections.IDictionary stateSaver) - { - base.Install(stateSaver); - - AddProviderToMachineConfig(); - } - - private static void AddProviderToMachineConfig() - { - object installRoot = Registry.GetValue( - @"HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\", - "InstallRoot", null); - if (installRoot == null) - throw new Exception("Unable to retrieve install root for .NET framework"); - - AddProviderToMachineConfigInDir(installRoot.ToString()); - - string installRoot64 = installRoot.ToString(); - installRoot64 = installRoot64.Substring(0, installRoot64.Length - 1); - installRoot64 = string.Format("{0}64{1}", installRoot64, - Path.DirectorySeparatorChar); - if (Directory.Exists(installRoot64)) - AddProviderToMachineConfigInDir(installRoot64); - } - - private static void AddProviderToMachineConfigInDir(string path) - { - string configPath = String.Format(@"{0}v2.0.50727\CONFIG\machine.config", - path); - - // now read the config file into memory - StreamReader sr = new StreamReader(configPath); - string configXML = sr.ReadToEnd(); - sr.Close(); - - // load the XML into the XmlDocument - XmlDocument doc = new XmlDocument(); - doc.LoadXml(configXML); - - // create our new node - XmlElement newNode = (XmlElement)doc.CreateNode(XmlNodeType.Element, "add", ""); - - // add the proper attributes - newNode.SetAttribute("name", "MySQL Data Provider"); - newNode.SetAttribute("invariant", "MySql.Data.MySqlClient"); - newNode.SetAttribute("description", ".Net Framework Data Provider for MySQL"); - - // add the type attribute by reflecting on the executing assembly - Assembly a = Assembly.GetExecutingAssembly(); - string type = String.Format("MySql.Data.MySqlClient.MySqlClientFactory, {0}", a.FullName); - newNode.SetAttribute("type", type); - - XmlNodeList nodes = doc.GetElementsByTagName("DbProviderFactories"); - - foreach (XmlNode node in nodes[0].ChildNodes) - { - if (node.Attributes == null) continue; - foreach (XmlAttribute attr in node.Attributes) - { - if (attr.Name == "invariant" && attr.Value == "MySql.Data.MySqlClient") - { - nodes[0].RemoveChild(node); - break; - } - } - } - - nodes[0].AppendChild(newNode); - - // Save the document to a file and auto-indent the output. - XmlTextWriter writer = new XmlTextWriter(configPath, null); - writer.Formatting = Formatting.Indented; - doc.Save(writer); - writer.Flush(); - writer.Close(); - } - - /// - /// We override Uninstall so we can remove out assembly from the - /// machine.config files. - /// - /// - public override void Uninstall(System.Collections.IDictionary savedState) - { - base.Uninstall(savedState); - - RemoveProviderFromMachineConfig(); - } - - private static void RemoveProviderFromMachineConfig() - { - object installRoot = Registry.GetValue( - @"HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\", - "InstallRoot", null); - if (installRoot == null) - throw new Exception("Unable to retrieve install root for .NET framework"); - - - RemoveProviderFromMachineConfigInDir(installRoot.ToString()); - - string installRoot64 = installRoot.ToString(); - installRoot64 = installRoot64.Substring(0, installRoot64.Length - 1); - installRoot64 = string.Format("{0}64{1}", installRoot64, - Path.DirectorySeparatorChar); - if (Directory.Exists(installRoot64)) - RemoveProviderFromMachineConfigInDir(installRoot64); - } - - private static void RemoveProviderFromMachineConfigInDir(string path) - { - string configPath = String.Format(@"{0}v2.0.50727\CONFIG\machine.config", - path); - - // now read the config file into memory - StreamReader sr = new StreamReader(configPath); - string configXML = sr.ReadToEnd(); - sr.Close(); - - // load the XML into the XmlDocument - XmlDocument doc = new XmlDocument(); - doc.LoadXml(configXML); - - XmlNodeList nodes = doc.GetElementsByTagName("DbProviderFactories"); - foreach (XmlNode node in nodes[0].ChildNodes) - { - if (node.Attributes == null) continue; - string name = node.Attributes["name"].Value; - if (name == "MySQL Data Provider") - { - nodes[0].RemoveChild(node); - break; - } - } - - // Save the document to a file and auto-indent the output. - XmlTextWriter writer = new XmlTextWriter(configPath, null); - writer.Formatting = Formatting.Indented; - doc.Save(writer); - writer.Flush(); - writer.Close(); - } - } -} - -#endif diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlClientFactory.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlClientFactory.cs deleted file mode 100644 index 998e8e1..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlClientFactory.cs +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -#if !PocketPC - -using System.Data.Common; -using System; -using System.Reflection; - -namespace MySql.Data.MySqlClient -{ - /// - /// DBProviderFactory implementation for MysqlClient. - /// - public sealed class MySqlClientFactory : DbProviderFactory, IServiceProvider - { - /// - /// Gets an instance of the . - /// This can be used to retrieve strongly typed data objects. - /// - public static MySqlClientFactory Instance = new MySqlClientFactory(); - private Type dbServicesType; - private FieldInfo mySqlDbProviderServicesInstance; - - /// - /// Returns a strongly typed instance. - /// - /// A new strongly typed instance of DbCommandBuilder. - public override DbCommandBuilder CreateCommandBuilder() - { - return new MySqlCommandBuilder(); - } - - /// - /// Returns a strongly typed instance. - /// - /// A new strongly typed instance of DbCommand. - public override DbCommand CreateCommand() - { - return new MySqlCommand(); - } - - /// - /// Returns a strongly typed instance. - /// - /// A new strongly typed instance of DbConnection. - public override DbConnection CreateConnection() - { - return new MySqlConnection(); - } - - /// - /// Returns a strongly typed instance. - /// - /// A new strongly typed instance of DbDataAdapter. - public override DbDataAdapter CreateDataAdapter() - { - return new MySqlDataAdapter(); - } - - /// - /// Returns a strongly typed instance. - /// - /// A new strongly typed instance of DbParameter. - public override DbParameter CreateParameter() - { - return new MySqlParameter(); - } - - /// - /// Returns a strongly typed instance. - /// - /// A new strongly typed instance of DbConnectionStringBuilder. - public override DbConnectionStringBuilder CreateConnectionStringBuilder() - { - return new MySqlConnectionStringBuilder(); - } - - /// - /// Returns true if a MySqlDataSourceEnumerator can be created; - /// otherwise false. - /// - public override bool CanCreateDataSourceEnumerator - { - get { return false; } - } - - #region IServiceProvider Members - - /// - /// Provide a simple caching layer - /// - private Type DbServicesType - { - get - { - if (dbServicesType == null) - { - // Get the type this way so we don't have to reference System.Data.Entity - // from our core provider - dbServicesType = Type.GetType( - @"System.Data.Common.DbProviderServices, System.Data.Entity, - Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", - false); - } - return dbServicesType; - } - } - - private FieldInfo MySqlDbProviderServicesInstance - { - get - { - if (mySqlDbProviderServicesInstance == null) - { - string fullName = Assembly.GetExecutingAssembly().FullName; - fullName = fullName.Replace("MySql.Data", "MySql.Data.Entity"); - fullName = String.Format("MySql.Data.MySqlClient.MySqlProviderServices, {0}", fullName); - - Type providerServicesType = Type.GetType(fullName, false); - mySqlDbProviderServicesInstance = providerServicesType.GetField("Instance", - BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); - } - return mySqlDbProviderServicesInstance; - } - } - - object IServiceProvider.GetService(Type serviceType) - { - // DbProviderServices is the only service we offer up right now - if (serviceType != DbServicesType) return null; - - if (MySqlDbProviderServicesInstance == null) return null; - - return MySqlDbProviderServicesInstance.GetValue(null); - } - - #endregion - } -} - -#endif diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs deleted file mode 100644 index 5c00615..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlConnectionStringBuilder.cs +++ /dev/null @@ -1,929 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data.Common; -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; -using System.Text.RegularExpressions; -using System.Text; -using MySql.Data.MySqlClient.Properties; -using System.Collections; -using System.Globalization; - -namespace MySql.Data.MySqlClient -{ - public class MySqlConnectionStringBuilder : DbConnectionStringBuilder - { - private static Dictionary validKeywords = - new Dictionary(StringComparer.OrdinalIgnoreCase); - private static Dictionary defaultValues = - new Dictionary(StringComparer.OrdinalIgnoreCase); - private Dictionary values = - new Dictionary(StringComparer.OrdinalIgnoreCase); - - static MySqlConnectionStringBuilder() - { - // load up our valid keywords and default values only once - Initialize(); - } - - public MySqlConnectionStringBuilder() - { - Clear(); - } - - public MySqlConnectionStringBuilder(string connStr) - : this() - { - ConnectionString = connStr; - } - - #region Server Properties - - /// - /// Gets or sets the name of the server. - /// - /// The server. - [Category("Connection")] - [Description("Server to connect to")] - [DefaultValue("")] - [ValidKeywords("host, data source, datasource, address, addr, network address")] - [RefreshProperties(RefreshProperties.All)] - public string Server - { - get { return values["server"] as string; } - set { SetValue("server", value); } - } - - /// - /// Gets or sets the name of the database the connection should - /// initially connect to. - /// - [Category("Connection")] - [Description("Database to use initially")] - [DefaultValue("")] - [ValidKeywords("initial catalog")] - [RefreshProperties(RefreshProperties.All)] - public string Database - { - get { return values["database"] as string; } - set { SetValue("database", value); } - } - - /// - /// Gets or sets the protocol that should be used for communicating - /// with MySQL. - /// - [Category("Connection")] - [DisplayName("Connection Protocol")] - [Description("Protocol to use for connection to MySQL")] - [DefaultValue(MySqlConnectionProtocol.Sockets)] - [ValidKeywords("protocol")] - [RefreshProperties(RefreshProperties.All)] - public MySqlConnectionProtocol ConnectionProtocol - { - get { return (MySqlConnectionProtocol)values["Connection Protocol"]; } - set { SetValue("Connection Protocol", value); } - } - - /// - /// Gets or sets the name of the named pipe that should be used - /// for communicating with MySQL. - /// - [Category("Connection")] - [DisplayName("Pipe Name")] - [Description("Name of pipe to use when connecting with named pipes (Win32 only)")] - [DefaultValue("MYSQL")] - [ValidKeywords("pipe")] - [RefreshProperties(RefreshProperties.All)] - public string PipeName - { - get { return (string)values["Pipe Name"]; } - set { SetValue("Pipe Name", value); } - } - - /// - /// Gets or sets a boolean value that indicates whether this connection - /// should use compression. - /// - [Category("Connection")] - [DisplayName("Use Compression")] - [Description("Should the connection ues compression")] - [DefaultValue(false)] - [ValidKeywords("compress")] - [RefreshProperties(RefreshProperties.All)] - public bool UseCompression - { - get { return (bool)values["Use Compression"]; } - set { SetValue("Use Compression", value); } - } - - /// - /// Gets or sets a boolean value that indicates whether this connection will allow - /// commands to send multiple SQL statements in one execution. - /// - [Category("Connection")] - [DisplayName("Allow Batch")] - [Description("Allows execution of multiple SQL commands in a single statement")] - [DefaultValue(true)] - [RefreshProperties(RefreshProperties.All)] - public bool AllowBatch - { - get { return (bool)values["Allow Batch"]; } - set { SetValue("Allow Batch", value); } - } - - /// - /// Gets or sets a boolean value that indicates whether logging is enabled. - /// - [Category("Connection")] - [Description("Enables output of diagnostic messages")] - [DefaultValue(false)] - [RefreshProperties(RefreshProperties.All)] - public bool Logging - { - get { return (bool)values["Logging"]; } - set { SetValue("Logging", value); } - } - - /// - /// Gets or sets the base name of the shared memory objects used to - /// communicate with MySQL when the shared memory protocol is being used. - /// - [Category("Connection")] - [DisplayName("Shared Memory Name")] - [Description("Name of the shared memory object to use")] - [DefaultValue("MYSQL")] - [RefreshProperties(RefreshProperties.All)] - public string SharedMemoryName - { - get { return (string)values["Shared Memory Name"]; } - set { SetValue("Shared Memory Name", value); } - } - - /// - /// Gets or sets a boolean value that indicates whether this connection uses - /// the old style (@) parameter markers or the new (?) style. - /// - [Category("Connection")] - [DisplayName("Use Old Syntax")] - [Description("Allows the use of old style @ syntax for parameters")] - [DefaultValue(false)] - [ValidKeywords("old syntax, oldsyntax")] - [RefreshProperties(RefreshProperties.All)] - [Obsolete("Use Old Syntax is no longer needed. See documentation")] - public bool UseOldSyntax - { - get { return (bool)values["Use Old Syntax"]; } - set { SetValue("Use Old Syntax", value); } - } - - /// - /// Gets or sets the port number that is used when the socket - /// protocol is being used. - /// - [Category("Connection")] - [Description("Port to use for TCP/IP connections")] - [DefaultValue(3306)] - [RefreshProperties(RefreshProperties.All)] - public uint Port - { - get { return (uint)values["Port"]; } - set { SetValue("Port", value); } - } - - /// - /// Gets or sets the connection timeout. - /// - [Category("Connection")] - [DisplayName("Connect Timeout")] - [Description("The length of time (in seconds) to wait for a connection " + - "to the server before terminating the attempt and generating an error.")] - [DefaultValue(15)] - [ValidKeywords("connection timeout")] - [RefreshProperties(RefreshProperties.All)] - public uint ConnectionTimeout - { - get { return (uint)values["Connect Timeout"]; } - - set - { - // Timeout in milliseconds should not exceed maximum for 32 bit - // signed integer (~24 days). We truncate the value if it exceeds - // maximum (MySqlCommand.CommandTimeout uses the same technique - uint timeout = Math.Min(value, Int32.MaxValue / 1000); - if (timeout != value) - { - MySqlTrace.LogWarning(-1, "Connection timeout value too large (" - + value + " seconds). Changed to max. possible value" + - + timeout + " seconds)"); - } - SetValue("Connect Timeout", timeout); - } - } - - /// - /// Gets or sets the default command timeout. - /// - [Category("Connection")] - [DisplayName("Default Command Timeout")] - [Description(@"The default timeout that MySqlCommand objects will use - unless changed.")] - [DefaultValue(30)] - [ValidKeywords("command timeout")] - [RefreshProperties(RefreshProperties.All)] - public uint DefaultCommandTimeout - { - get { return (uint)values["Default Command Timeout"]; } - set { SetValue("Default Command Timeout", value); } - } - - #endregion - - #region Authentication Properties - - /// - /// Gets or sets the user id that should be used to connect with. - /// - [Category("Security")] - [DisplayName("User Id")] - [Description("Indicates the user ID to be used when connecting to the data source.")] - [DefaultValue("")] - [ValidKeywords("uid, username, user name, user")] - [RefreshProperties(RefreshProperties.All)] - public string UserID - { - get { return (string)values["User Id"]; } - set { SetValue("User Id", value); } - } - - /// - /// Gets or sets the password that should be used to connect with. - /// - [Category("Security")] - [Description("Indicates the password to be used when connecting to the data source.")] - [PasswordPropertyText(true)] - [DefaultValue("")] - [ValidKeywords("pwd")] - [RefreshProperties(RefreshProperties.All)] - public string Password - { - get { return (string)values["Password"]; } - set { SetValue("Password", value); } - } - - /// - /// Gets or sets a boolean value that indicates if the password should be persisted - /// in the connection string. - /// - [Category("Security")] - [DisplayName("Persist Security Info")] - [Description("When false, security-sensitive information, such as the password, " + - "is not returned as part of the connection if the connection is open or " + - "has ever been in an open state.")] - [DefaultValue(false)] - [RefreshProperties(RefreshProperties.All)] - public bool PersistSecurityInfo - { - get { return (bool)values["Persist Security Info"]; } - set { SetValue("Persist Security Info", value); } - } - - [Category("Authentication")] - [Description("Should the connection use SSL.")] - [DefaultValue(false)] - [Obsolete("Use Ssl Mode instead.")] - internal bool Encrypt - { - get { return SslMode != MySqlSslMode.None; } - set - { - SetValue("Ssl Mode", value ? MySqlSslMode.Prefered : MySqlSslMode.None); - } - } - - [Category("Authentication")] - [DisplayName("Certificate File")] - [Description("Certificate file in PKCS#12 format (.pfx)")] - [DefaultValue(null)] - public string CertificateFile - { - get { return (string) values["Certificate File"];} - set - { - SetValue("Certificate File", value); - } - } - - [Category("Authentication")] - [DisplayName("Certificate Password")] - [Description("Password for certificate file")] - [DefaultValue(null)] - public string CertificatePassword - { - get { return (string)values["Certificate Password"];} - set - { - SetValue("Certificate Password", value); - } - } - - [Category("Authentication")] - [DisplayName("Certificate Store Location")] - [Description("Certificate Store Location for client certificates")] - [DefaultValue(MySqlCertificateStoreLocation.None)] - public MySqlCertificateStoreLocation CertificateStoreLocation - { - get { return (MySqlCertificateStoreLocation)values["Certificate Store Location"]; } - set - { - SetValue("Certificate Store Location", value); - } - } - - [Category("Authentication")] - [DisplayName("Certificate Thumbprint")] - [Description("Certificate thumbprint. Can be used together with Certificate "+ - "Store Location parameter to uniquely identify certificate to be used "+ - "for SSL authentication.")] - [DefaultValue(null)] - public string CertificateThumbprint - { - get { return (string)values["Certificate Thumbprint"]; } - set - { - SetValue("Certificate Thumbprint", value); - } - } - #endregion - - #region Other Properties - - /// - /// Gets or sets a boolean value that indicates if zero date time values are supported. - /// - [Category("Advanced")] - [DisplayName("Allow Zero Datetime")] - [Description("Should zero datetimes be supported")] - [DefaultValue(false)] - [RefreshProperties(RefreshProperties.All)] - public bool AllowZeroDateTime - { - get { return (bool)values["Allow Zero Datetime"]; } - set { SetValue("Allow Zero DateTime", value); } - } - - /// - /// Gets or sets a boolean value indicating if zero datetime values should be - /// converted to DateTime.MinValue. - /// - [Category("Advanced")] - [DisplayName("Convert Zero Datetime")] - [Description("Should illegal datetime values be converted to DateTime.MinValue")] - [DefaultValue(false)] - [RefreshProperties(RefreshProperties.All)] - public bool ConvertZeroDateTime - { - get { return (bool)values["Convert Zero Datetime"]; } - set { SetValue("Convert Zero DateTime", value); } - } - - /// - /// Gets or sets a boolean value indicating if the Usage Advisor should be enabled. - /// - [Category("Advanced")] - [DisplayName("Use Usage Advisor")] - [Description("Logs inefficient database operations")] - [DefaultValue(false)] - [ValidKeywords("usage advisor")] - [RefreshProperties(RefreshProperties.All)] - public bool UseUsageAdvisor - { - get { return (bool)values["Use Usage Advisor"]; } - set { SetValue("Use Usage Advisor", value); } - } - - /// - /// Gets or sets the size of the stored procedure cache. - /// - [Category("Advanced")] - [DisplayName("Procedure Cache Size")] - [Description("Indicates how many stored procedures can be cached at one time. " + - "A value of 0 effectively disables the procedure cache.")] - [DefaultValue(25)] - [ValidKeywords("procedure cache, procedurecache")] - [RefreshProperties(RefreshProperties.All)] - public uint ProcedureCacheSize - { - get { return (uint)values["Procedure Cache Size"]; } - set { SetValue("Procedure Cache Size", value); } - } - - /// - /// Gets or sets a boolean value indicating if the permon hooks should be enabled. - /// - [Category("Advanced")] - [DisplayName("Use Performance Monitor")] - [Description("Indicates that performance counters should be updated during execution.")] - [DefaultValue(false)] - [ValidKeywords("userperfmon, perfmon")] - [RefreshProperties(RefreshProperties.All)] - public bool UsePerformanceMonitor - { - get { return (bool)values["Use Performance Monitor"]; } - set { SetValue("Use Performance Monitor", value); } - } - - /// - /// Gets or sets a boolean value indicating if calls to Prepare() should be ignored. - /// - [Category("Advanced")] - [DisplayName("Ignore Prepare")] - [Description("Instructs the provider to ignore any attempts to prepare a command.")] - [DefaultValue(true)] - [RefreshProperties(RefreshProperties.All)] - public bool IgnorePrepare - { - get { return (bool)values["Ignore Prepare"]; } - set { SetValue("Ignore Prepare", value); } - } - - [Category("Advanced")] - [DisplayName("Use Procedure Bodies")] - [Description("Indicates if stored procedure bodies will be available for parameter detection.")] - [DefaultValue(true)] - [ValidKeywords("procedure bodies")] - [RefreshProperties(RefreshProperties.All)] - public bool UseProcedureBodies - { - get { return (bool)values["Use Procedure Bodies"]; } - set { SetValue("Use Procedure Bodies", value); } - } - - [Category("Advanced")] - [DisplayName("Auto Enlist")] - [Description("Should the connetion automatically enlist in the active connection, if there are any.")] - [DefaultValue(true)] - [RefreshProperties(RefreshProperties.All)] - public bool AutoEnlist - { - get { return (bool)values["Auto Enlist"]; } - set { SetValue("Auto Enlist", value); } - } - - [Category("Advanced")] - [DisplayName("Respect Binary Flags")] - [Description("Should binary flags on column metadata be respected.")] - [DefaultValue(true)] - [RefreshProperties(RefreshProperties.All)] - public bool RespectBinaryFlags - { - get { return (bool)values["Respect Binary Flags"]; } - set { SetValue("Respect Binary Flags", value); } - } - - [Category("Advanced")] - [DisplayName("Treat Tiny As Boolean")] - [Description("Should the provider treat TINYINT(1) columns as boolean.")] - [DefaultValue(true)] - [RefreshProperties(RefreshProperties.All)] - public bool TreatTinyAsBoolean - { - get { return (bool)values["Treat Tiny As Boolean"]; } - set { SetValue("Treat Tiny As Boolean", value); } - } - - [Category("Advanced")] - [DisplayName("Allow User Variables")] - [Description("Should the provider expect user variables to appear in the SQL.")] - [DefaultValue(false)] - [RefreshProperties(RefreshProperties.All)] - public bool AllowUserVariables - { - get { return (bool)values["Allow User Variables"]; } - set { SetValue("Allow User Variables", value); } - } - - [Category("Advanced")] - [DisplayName("Interactive Session")] - [Description("Should this session be considered interactive?")] - [DefaultValue(false)] - [ValidKeywords("interactive")] - [RefreshProperties(RefreshProperties.All)] - public bool InteractiveSession - { - get { return (bool)values["Interactive Session"]; } - set { SetValue("Interactive Session", value); } - } - - [Category("Advanced")] - [DisplayName("Functions Return String")] - [Description("Should all server functions be treated as returning string?")] - [DefaultValue(false)] - public bool FunctionsReturnString - { - get { return (bool)values["Functions Return String"]; } - set { SetValue("Functions Return String", value); } - } - - [Category("Advanced")] - [DisplayName("Use Affected Rows")] - [Description("Should the returned affected row count reflect affected rows instead of found rows?")] - [DefaultValue(false)] - public bool UseAffectedRows - { - get { return (bool)values["Use Affected Rows"]; } - set { SetValue("Use Affected Rows", value); } - } - - - [Category("Advanced")] - [DisplayName("Old Guids")] - [Description("Treat binary(16) columns as guids")] - [DefaultValue(false)] - public bool OldGuids - { - get { return (bool)values["Old Guids"]; } - set { SetValue("Old Guids", value); } - } - - [DisplayName("Keep Alive")] - [Description("For TCP connections, idle connection time measured in seconds, before the first keepalive packet is sent." + - "A value of 0 indicates that keepalive is not used.")] - [DefaultValue(0)] - public uint Keepalive - { - get { return (uint)values["Keep Alive"]; } - set { SetValue("Keep Alive", value); } - } - - #endregion - - #region Pooling Properties - - /// - /// Gets or sets the lifetime of a pooled connection. - /// - [Category("Pooling")] - [DisplayName("Connection Lifetime")] - [Description("The minimum amount of time (in seconds) for this connection to " + - "live in the pool before being destroyed.")] - [DefaultValue(0)] - [RefreshProperties(RefreshProperties.All)] - public uint ConnectionLifeTime - { - get { return (uint)values["Connection LifeTime"]; } - set { SetValue("Connection LifeTime", value); } - } - - /// - /// Gets or sets a boolean value indicating if connection pooling is enabled. - /// - [Category("Pooling")] - [Description("When true, the connection object is drawn from the appropriate " + - "pool, or if necessary, is created and added to the appropriate pool.")] - [DefaultValue(true)] - [RefreshProperties(RefreshProperties.All)] - public bool Pooling - { - get { return (bool)values["Pooling"]; } - set { SetValue("Pooling", value); } - } - - /// - /// Gets the minimum connection pool size. - /// - [Category("Pooling")] - [DisplayName("Minimum Pool Size")] - [Description("The minimum number of connections allowed in the pool.")] - [DefaultValue(0)] - [ValidKeywords("min pool size")] - [RefreshProperties(RefreshProperties.All)] - public uint MinimumPoolSize - { - get { return (uint)values["Minimum Pool Size"]; } - set { SetValue("Minimum Pool Size", value); } - } - - /// - /// Gets or sets the maximum connection pool setting. - /// - [Category("Pooling")] - [DisplayName("Maximum Pool Size")] - [Description("The maximum number of connections allowed in the pool.")] - [DefaultValue(100)] - [ValidKeywords("max pool size")] - [RefreshProperties(RefreshProperties.All)] - public uint MaximumPoolSize - { - get { return (uint)values["Maximum Pool Size"]; } - set { SetValue("Maximum Pool Size", value); } - } - - /// - /// Gets or sets a boolean value indicating if the connection should be reset when retrieved - /// from the pool. - /// - [Category("Pooling")] - [DisplayName("Connection Reset")] - [Description("When true, indicates the connection state is reset when " + - "removed from the pool.")] - [DefaultValue(false)] - [RefreshProperties(RefreshProperties.All)] - public bool ConnectionReset - { - get { return (bool)values["Connection Reset"]; } - set { SetValue("Connection Reset", value); } - } - - #endregion - - #region Language and Character Set Properties - - /// - /// Gets or sets the character set that should be used for sending queries to the server. - /// - [DisplayName("Character Set")] - [Category("Advanced")] - [Description("Character set this connection should use")] - [DefaultValue("")] - [ValidKeywords("charset")] - [RefreshProperties(RefreshProperties.All)] - public string CharacterSet - { - get { return (string)values["Character Set"]; } - set { SetValue("Character Set", value); } - } - - /// - /// Indicates whether the driver should treat binary blobs as UTF8 - /// - [DisplayName("Treat Blobs As UTF8")] - [Category("Advanced")] - [Description("Should binary blobs be treated as UTF8")] - [DefaultValue(false)] - [RefreshProperties(RefreshProperties.All)] - public bool TreatBlobsAsUTF8 - { - get { return (bool)values["Treat Blobs As UTF8"]; } - set { SetValue("Treat Blobs As UTF8", value); } - } - - /// - /// Gets or sets the pattern that matches the columns that should be treated as UTF8 - /// - [Category("Advanced")] - [Description("Pattern that matches columns that should be treated as UTF8")] - [DefaultValue("")] - [RefreshProperties(RefreshProperties.All)] - public string BlobAsUTF8IncludePattern - { - get { return (string)values["BlobAsUTF8IncludePattern"]; } - set { SetValue("BlobAsUTF8IncludePattern", value); } - } - - /// - /// Gets or sets the pattern that matches the columns that should not be treated as UTF8 - /// - [Category("Advanced")] - [Description("Pattern that matches columns that should not be treated as UTF8")] - [DefaultValue("")] - [RefreshProperties(RefreshProperties.All)] - public string BlobAsUTF8ExcludePattern - { - get { return (string)values["BlobAsUTF8ExcludePattern"]; } - set { SetValue("BlobAsUTF8ExcludePattern", value); } - } - - /// - /// Indicates whether to use SSL connections and how to handle server certificate errors. - /// - [DisplayName("Ssl Mode")] - [Category("Security")] - [Description("SSL properties for connection")] - [DefaultValue(MySqlSslMode.None)] - public MySqlSslMode SslMode - { - get { return (MySqlSslMode)values["Ssl Mode"]; } - set { SetValue("Ssl Mode", value); } - } - - #endregion - - internal Regex GetBlobAsUTF8IncludeRegex() - { - if (String.IsNullOrEmpty(BlobAsUTF8IncludePattern)) return null; - return new Regex(BlobAsUTF8IncludePattern); - } - - internal Regex GetBlobAsUTF8ExcludeRegex() - { - if (String.IsNullOrEmpty(BlobAsUTF8ExcludePattern)) return null; - return new Regex(BlobAsUTF8ExcludePattern); - } - - public override object this[string keyword] - { - get { return values[validKeywords[keyword]]; } - set - { - ValidateKeyword(keyword); - if (value == null) - Remove(keyword); - else - SetValue(keyword, value); - } - } - - public override void Clear() - { - base.Clear(); - - // make a copy of our default values array - foreach (string key in defaultValues.Keys) - values[key] = defaultValues[key].DefaultValue; - } - -#if !CF - - public override bool Remove(string keyword) - { - ValidateKeyword(keyword); - string primaryKey = validKeywords[keyword]; - - values.Remove(primaryKey); - base.Remove(primaryKey); - - values[primaryKey] = defaultValues[primaryKey].DefaultValue; - return true; - } - - public override bool TryGetValue(string keyword, out object value) - { - ValidateKeyword(keyword); - return values.TryGetValue(validKeywords[keyword], out value); - } - -#endif - - public string GetConnectionString(bool includePass) - { - if (includePass) return ConnectionString; - - StringBuilder conn = new StringBuilder(); - string delimiter = ""; - foreach (string key in this.Keys) - { - if (String.Compare(key, "password", true) == 0 || - String.Compare(key, "pwd", true) == 0) continue; - conn.AppendFormat(CultureInfo.CurrentCulture, "{0}{1}={2}", - delimiter, key, this[key]); - delimiter = ";"; - } - return conn.ToString(); - } - - private void SetValue(string keyword, object value) - { - ValidateKeyword(keyword); - keyword = validKeywords[keyword]; - - Remove(keyword); - - object val = null; - if (value is string && defaultValues[keyword].DefaultValue is Enum) - val = ParseEnum(defaultValues[keyword].Type, (string)value, keyword); - else - val = ChangeType(value, defaultValues[keyword].Type); - values[keyword] = val; - base[keyword] = val; - } - - private object ParseEnum(Type t, string requestedValue, string key) - { - try - { - return Enum.Parse(t, requestedValue, true); - } - catch (ArgumentException) - { - throw new InvalidOperationException(String.Format( - Resources.InvalidConnectionStringValue, requestedValue, key)); - } - } - - private object ChangeType(object value, Type t) - { - if (t == typeof(bool) && value is string) - { - string s = value.ToString().ToLower(CultureInfo.InvariantCulture); - if (s == "yes" || s == "true") return true; - if (s == "no" || s == "false") return false; - throw new FormatException(String.Format(Resources.InvalidValueForBoolean, value)); - } - else - return Convert.ChangeType(value, t, CultureInfo.CurrentCulture); - } - - private void ValidateKeyword(string keyword) - { - string key = keyword.ToLower(CultureInfo.InvariantCulture); - if (!validKeywords.ContainsKey(key)) - throw new ArgumentException(Resources.KeywordNotSupported, keyword); - if (validKeywords[key] == "Use Old Syntax") - MySqlTrace.LogWarning(-1, "Use Old Syntax is now obsolete. Please see documentation"); - if (validKeywords[key] == "Encrypt") - MySqlTrace.LogWarning(-1, "Encrypt is now obsolete. Use Ssl Mode instead"); - } - - private static void Initialize() - { - PropertyInfo[] properties = typeof(MySqlConnectionStringBuilder).GetProperties(); - foreach (PropertyInfo pi in properties) - AddKeywordFromProperty(pi); - - // remove this starting with 6.4 - PropertyInfo encrypt = typeof(MySqlConnectionStringBuilder).GetProperty( - "Encrypt", BindingFlags.Instance | BindingFlags.NonPublic); - AddKeywordFromProperty(encrypt); - } - - private static void AddKeywordFromProperty(PropertyInfo pi) - { - string name = pi.Name.ToLower(CultureInfo.InvariantCulture); - string displayName = name; - - // now see if we have defined a display name for this property - object[] attr = pi.GetCustomAttributes(false); - foreach (Attribute a in attr) - if (a is DisplayNameAttribute) - { - displayName = (a as DisplayNameAttribute).DisplayName; - break; - } - - validKeywords[name] = displayName; - validKeywords[displayName] = displayName; - - foreach (Attribute a in attr) - { - if (a is ValidKeywordsAttribute) - { - foreach (string keyword in (a as ValidKeywordsAttribute).Keywords) - validKeywords[keyword.ToLower(CultureInfo.InvariantCulture).Trim()] = displayName; - } - else if (a is DefaultValueAttribute) - { - defaultValues[displayName] = new PropertyDefaultValue(pi.PropertyType, - Convert.ChangeType((a as DefaultValueAttribute).Value, pi.PropertyType, CultureInfo.CurrentCulture)); - } - } - } - } - - internal struct PropertyDefaultValue - { - public PropertyDefaultValue(Type t, object v) - { - Type = t; - DefaultValue = v; - } - - public Type Type; - public object DefaultValue; - } - - internal class ValidKeywordsAttribute : Attribute - { - private string keywords; - - public ValidKeywordsAttribute(string keywords) - { - this.keywords = keywords.ToLower(CultureInfo.InvariantCulture); - } - - public string[] Keywords - { - get { return keywords.Split(','); } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlError.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlError.cs deleted file mode 100644 index 7b941ee..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlError.cs +++ /dev/null @@ -1,351 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -namespace MySql.Data.MySqlClient -{ - /// - /// Collection of error codes that can be returned by the server - /// - public class MySqlError - { - private string level; - private int code; - private string message; - - /// - /// - /// - /// - public MySqlError(string level, int code, string message) - { - this.level = level; - this.code = code; - this.message = message; - } - - /// - /// Error level - /// - public string Level - { - get { return level; } - } - - /// - /// Error code - /// - public int Code - { - get { return code; } - } - - /// - /// Error message - /// - public string Message - { - get { return message; } - } - }; - - /// - /// Provides a reference to error codes returned by MySQL. - /// - public enum MySqlErrorCode - { - None = 0, -/* ER_HASHCHK=1000, - ER_NISAMCHK=1001, - ER_NO=1002, - ER_YES 1003 - ER_CANT_CREATE_FILE 1004 - ER_CANT_CREATE_TABLE 1005 - ER_CANT_CREATE_DB 1006 - ER_DB_CREATE_EXISTS 1007 - ER_DB_DROP_EXISTS 1008 - ER_DB_DROP_DELETE 1009 - ER_DB_DROP_RMDIR 1010 - ER_CANT_DELETE_FILE 1011 - ER_CANT_FIND_SYSTEM_REC 1012 - ER_CANT_GET_STAT 1013 - ER_CANT_GET_WD 1014 - ER_CANT_LOCK 1015 - ER_CANT_OPEN_FILE 1016 - ER_FILE_NOT_FOUND 1017 - ER_CANT_READ_DIR 1018 - ER_CANT_SET_WD 1019 - ER_CHECKREAD 1020 - ER_DISK_FULL 1021 - */ - /// - /// There is already a key with the given values. - /// - DuplicateKey = 1022, - - /* ER_ERROR_ON_CLOSE 1023 - ER_ERROR_ON_READ 1024 - ER_ERROR_ON_RENAME 1025 - ER_ERROR_ON_WRITE 1026 - ER_FILE_USED 1027 - ER_FILSORT_ABORT 1028 - ER_FORM_NOT_FOUND 1029 - ER_GET_ERRNO 1030 - ER_ILLEGAL_HA 1031*/ - /// - /// The specified key was not found. - /// - KeyNotFound = 1032, - /* ER_NOT_FORM_FILE 1033 - ER_NOT_KEYFILE 1034 - ER_OLD_KEYFILE 1035 - ER_OPEN_AS_READONLY 1036 - ER_OUTOFMEMORY 1037 - ER_OUT_OF_SORTMEMORY 1038 - ER_UNEXPECTED_EOF 1039 - ER_CON_COUNT_ERROR 1040 - ER_OUT_OF_RESOURCES 1041*/ - /// - /// Given when the connection is unable to successfully connect to host. - /// - UnableToConnectToHost = 1042, -/* ER_HANDSHAKE_ERROR 1043 - ER_DBACCESS_DENIED_ERROR 1044*/ - /// - /// Normally returned when an incorrect password is given - /// - AccessDenied = 1045, - /* ER_NO_DB_ERROR 1046 - ER_UNKNOWN_COM_ERROR 1047 - ER_BAD_NULL_ERROR 1048*/ - UnknownDatabase = 1049, - /*ER_BAD_DB_ERROR 1049 - ER_TABLE_EXISTS_ERROR 1050 - ER_BAD_TABLE_ERROR 1051 - ER_NON_UNIQ_ERROR 1052 - ER_SERVER_SHUTDOWN 1053 - ER_BAD_FIELD_ERROR 1054 - ER_WRONG_FIELD_WITH_GROUP 1055 - ER_WRONG_GROUP_FIELD 1056 - ER_WRONG_SUM_SELECT 1057 - ER_WRONG_VALUE_COUNT 1058 - ER_TOO_LONG_IDENT 1059 - ER_DUP_FIELDNAME 1060*/ - /// - /// Duplicate Key Name - /// - DuplicateKeyName = 1061, - /// - /// Duplicate Key Entry - /// - DuplicateKeyEntry = 1062, - - /* ER_WRONG_FIELD_SPEC 1063 - ER_PARSE_ERROR 1064 - ER_EMPTY_QUERY 1065 - ER_NONUNIQ_TABLE 1066 - ER_INVALID_DEFAULT 1067 - ER_MULTIPLE_PRI_KEY 1068 - ER_TOO_MANY_KEYS 1069 - ER_TOO_MANY_KEY_PARTS 1070 - ER_TOO_LONG_KEY 1071 - ER_KEY_COLUMN_DOES_NOT_EXITS 1072 - ER_BLOB_USED_AS_KEY 1073 - ER_TOO_BIG_FIELDLENGTH 1074 - ER_WRONG_AUTO_KEY 1075 - ER_READY 1076 - ER_NORMAL_SHUTDOWN 1077 - ER_GOT_SIGNAL 1078 - ER_SHUTDOWN_COMPLETE 1079 - ER_FORCING_CLOSE 1080 - ER_IPSOCK_ERROR 1081 - ER_NO_SUCH_INDEX 1082 - ER_WRONG_FIELD_TERMINATORS 1083 - ER_BLOBS_AND_NO_TERMINATED 1084 - ER_TEXTFILE_NOT_READABLE 1085 - ER_FILE_EXISTS_ERROR 1086 - ER_LOAD_INFO 1087 - ER_ALTER_INFO 1088 - ER_WRONG_SUB_KEY 1089 - ER_CANT_REMOVE_ALL_FIELDS 1090 - ER_CANT_DROP_FIELD_OR_KEY 1091 - ER_INSERT_INFO 1092 - ER_INSERT_TABLE_USED 1093 - ER_NO_SUCH_THREAD 1094 - ER_KILL_DENIED_ERROR 1095 - ER_NO_TABLES_USED 1096 - ER_TOO_BIG_SET 1097 - ER_NO_UNIQUE_LOGFILE 1098 - ER_TABLE_NOT_LOCKED_FOR_WRITE 1099 - ER_TABLE_NOT_LOCKED 1100 - ER_BLOB_CANT_HAVE_DEFAULT 1101 - ER_WRONG_DB_NAME 1102 - ER_WRONG_TABLE_NAME 1103 - ER_TOO_BIG_SELECT 1104 - ER_UNKNOWN_ERROR 1105 - ER_UNKNOWN_PROCEDURE 1106 - ER_WRONG_PARAMCOUNT_TO_PROCEDURE 1107 - ER_WRONG_PARAMETERS_TO_PROCEDURE 1108 - ER_UNKNOWN_TABLE 1109 - ER_FIELD_SPECIFIED_TWICE 1110 - ER_INVALID_GROUP_FUNC_USE 1111 - ER_UNSUPPORTED_EXTENSION 1112 - ER_TABLE_MUST_HAVE_COLUMNS 1113 - ER_RECORD_FILE_FULL 1114 - ER_UNKNOWN_CHARACTER_SET 1115 - ER_TOO_MANY_TABLES 1116 - ER_TOO_MANY_FIELDS 1117 - ER_TOO_BIG_ROWSIZE 1118 - ER_STACK_OVERRUN 1119 - ER_WRONG_OUTER_JOIN 1120 - ER_NULL_COLUMN_IN_INDEX 1121 - ER_CANT_FIND_UDF 1122 - ER_CANT_INITIALIZE_UDF 1123 - ER_UDF_NO_PATHS 1124 - ER_UDF_EXISTS 1125 - ER_CANT_OPEN_LIBRARY 1126 - ER_CANT_FIND_DL_ENTRY 1127 - ER_FUNCTION_NOT_DEFINED 1128 - ER_HOST_IS_BLOCKED 1129 - */ - /// - /// The given host is not allowed to connect - /// - HostNotPrivileged = 1130, - /// - /// The anonymous user is not allowed to connect - /// - AnonymousUser = 1131, - /// - /// The given password is not allowed - /// - PasswordNotAllowed = 1132, - /// - /// The given password does not match - /// - PasswordNoMatch = 1133, - /* ER_UPDATE_INFO 1134 - ER_CANT_CREATE_THREAD 1135 - ER_WRONG_VALUE_COUNT_ON_ROW 1136 - ER_CANT_REOPEN_TABLE 1137 - ER_INVALID_USE_OF_NULL 1138 - ER_REGEXP_ERROR 1139 - ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140 - ER_NONEXISTING_GRANT 1141*/ TableAccessDenied = 1142, ColumnAccessDenied = 1143, IllegalGrantForTable = 1144,/* ER_GRANT_WRONG_HOST_OR_USER 1145 */ NoSuchTable = 1146, - NonExistingTableGrant = 1147, - -/* ER_NOT_ALLOWED_COMMAND 1148 - ER_SYNTAX_ERROR 1149 - ER_DELAYED_CANT_CHANGE_LOCK 1150 - ER_TOO_MANY_DELAYED_THREADS 1151 - ER_ABORTING_CONNECTION 1152 - */ - /// - /// An attempt was made to send or receive a packet larger than - /// max_allowed_packet_size - /// - PacketTooLarge=1153 - /* - ER_NET_READ_ERROR_FROM_PIPE 1154 - ER_NET_FCNTL_ERROR 1155 - ER_NET_PACKETS_OUT_OF_ORDER 1156 - ER_NET_UNCOMPRESS_ERROR 1157 - ER_NET_READ_ERROR 1158 - ER_NET_READ_INTERRUPTED 1159 - ER_NET_ERROR_ON_WRITE 1160 - ER_NET_WRITE_INTERRUPTED 1161 - ER_TOO_LONG_STRING 1162 - ER_TABLE_CANT_HANDLE_BLOB 1163 - ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164 - ER_DELAYED_INSERT_TABLE_LOCKED 1165 - ER_WRONG_COLUMN_NAME 1166 - ER_WRONG_KEY_COLUMN 1167 - ER_WRONG_MRG_TABLE 1168 - ER_DUP_UNIQUE 1169 - ER_BLOB_KEY_WITHOUT_LENGTH 1170 - ER_PRIMARY_CANT_HAVE_NULL 1171 - ER_TOO_MANY_ROWS 1172 - ER_REQUIRES_PRIMARY_KEY 1173 - ER_NO_RAID_COMPILED 1174 - ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175 - ER_KEY_DOES_NOT_EXITS 1176 - ER_CHECK_NO_SUCH_TABLE 1177 - ER_CHECK_NOT_IMPLEMENTED 1178 - ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179 - ER_ERROR_DURING_COMMIT 1180 - ER_ERROR_DURING_ROLLBACK 1181 - ER_ERROR_DURING_FLUSH_LOGS 1182 - ER_ERROR_DURING_CHECKPOINT 1183 - ER_NEW_ABORTING_CONNECTION 1184 - ER_DUMP_NOT_IMPLEMENTED 1185 - ER_FLUSH_MASTER_BINLOG_CLOSED 1186 - ER_INDEX_REBUILD 1187 - ER_MASTER 1188 - ER_MASTER_NET_READ 1189 - ER_MASTER_NET_WRITE 1190 - ER_FT_MATCHING_KEY_NOT_FOUND 1191 - ER_LOCK_OR_ACTIVE_TRANSACTION 1192 - ER_UNKNOWN_SYSTEM_VARIABLE 1193 - ER_CRASHED_ON_USAGE 1194 - ER_CRASHED_ON_REPAIR 1195 - ER_WARNING_NOT_COMPLETE_ROLLBACK 1196 - ER_TRANS_CACHE_FULL 1197 - ER_SLAVE_MUST_STOP 1198 - ER_SLAVE_NOT_RUNNING 1199 - ER_BAD_SLAVE 1200 - ER_MASTER_INFO 1201 - ER_SLAVE_THREAD 1202 - ER_TOO_MANY_USER_CONNECTIONS 1203 - ER_SET_CONSTANTS_ONLY 1204 - ER_LOCK_WAIT_TIMEOUT 1205 - ER_LOCK_TABLE_FULL 1206 - ER_READ_ONLY_TRANSACTION 1207 - ER_DROP_DB_WITH_READ_LOCK 1208 - ER_CREATE_DB_WITH_READ_LOCK 1209 - ER_WRONG_ARGUMENTS 1210 - ER_NO_PERMISSION_TO_CREATE_USER 1211 - ER_UNION_TABLES_IN_DIFFERENT_DIR 1212 - ER_LOCK_DEADLOCK 1213 - ER_TABLE_CANT_HANDLE_FULLTEXT 1214 - ER_CANNOT_ADD_FOREIGN 1215 - ER_NO_REFERENCED_ROW 1216 - ER_ROW_IS_REFERENCED 1217 - ER_CONNECT_TO_MASTER 1218 - ER_QUERY_ON_MASTER 1219 - ER_ERROR_WHEN_EXECUTING_COMMAND 1220 - ER_WRONG_USAGE 1221 - ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1222 - ER_CANT_UPDATE_WITH_READLOCK 1223 - ER_MIXING_NOT_ALLOWED 1224 - ER_DUP_ARGUMENT 1225 - ER_USER_LIMIT_REACHED 1226 - ER_SPECIFIC_ACCESS_DENIED_ERROR 1227 - ER_LOCAL_VARIABLE 1228 - ER_GLOBAL_VARIABLE 1229 - ER_NO_DEFAULT 1230 - ER_WRONG_VALUE_FOR_VAR 1231 - ER_WRONG_TYPE_FOR_VAR 1232 - ER_VAR_CANT_BE_READ 1233 - ER_CANT_USE_OPTION_HERE 1234 - ER_NOT_SUPPORTED_YET 1235 - ER_MASTER_FATAL_ERROR_READING_BINLOG 1236 - ER_SLAVE_IGNORED_TABLE 1237 // only the slave SQL thread can be sent this - ER_ERROR_MESSAGES 238*/ - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlHelper.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlHelper.cs deleted file mode 100644 index 6798df1..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlHelper.cs +++ /dev/null @@ -1,406 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System.Data; -using MySql.Data.MySqlClient; -using System.Text; - -namespace MySql.Data.MySqlClient -{ - /// - /// Helper class that makes it easier to work with the provider. - /// - public sealed class MySqlHelper - { - private static string stringOfBackslashChars = "\u005c\u00a5\u0160\u20a9\u2216\ufe68\uff3c"; - private static string stringOfQuoteChars = - "\u0027\u0060\u00b4\u02b9\u02ba\u02bb\u02bc\u02c8\u02ca\u02cb\u02d9\u0300\u0301\u2018\u2019\u201a\u2032\u2035\u275b\u275c\uff07"; - - // this class provides only static methods - private MySqlHelper() - { - } - - #region ExecuteNonQuery - - /// - /// Executes a single command against a MySQL database. The is assumed to be - /// open when the method is called and remains open after the method completes. - /// - /// object to use - /// SQL command to be executed - /// Array of objects to use with the command. - /// - public static int ExecuteNonQuery( MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters ) - { - //create a command and prepare it for execution - MySqlCommand cmd = new MySqlCommand(); - cmd.Connection = connection; - cmd.CommandText = commandText; - cmd.CommandType = CommandType.Text; - - if (commandParameters != null) - foreach (MySqlParameter p in commandParameters) - cmd.Parameters.Add( p ); - - int result = cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); - - return result; - } - - /// - /// Executes a single command against a MySQL database. A new is created - /// using the given. - /// - /// to use - /// SQL command to be executed - /// Array of objects to use with the command. - /// - public static int ExecuteNonQuery( string connectionString, string commandText, params MySqlParameter[] parms ) - { - //create & open a SqlConnection, and dispose of it after we are done. - using (MySqlConnection cn = new MySqlConnection(connectionString)) - { - cn.Open(); - - //call the overload that takes a connection in place of the connection string - return ExecuteNonQuery(cn, commandText, parms ); - } - } - #endregion - - #region ExecuteDataSet - - /// - /// Executes a single SQL command and returns the first row of the resultset. A new MySqlConnection object - /// is created, opened, and closed during this method. - /// - /// Settings to be used for the connection - /// Command to execute - /// Parameters to use for the command - /// DataRow containing the first row of the resultset - public static DataRow ExecuteDataRow( string connectionString, string commandText, params MySqlParameter[] parms ) - { - DataSet ds = ExecuteDataset( connectionString, commandText, parms ); - if (ds == null) return null; - if (ds.Tables.Count == 0) return null; - if (ds.Tables[0].Rows.Count == 0) return null; - return ds.Tables[0].Rows[0]; - } - - /// - /// Executes a single SQL command and returns the resultset in a . - /// A new MySqlConnection object is created, opened, and closed during this method. - /// - /// Settings to be used for the connection - /// Command to execute - /// containing the resultset - public static DataSet ExecuteDataset(string connectionString, string commandText) - { - //pass through the call providing null for the set of SqlParameters - return ExecuteDataset(connectionString, commandText, (MySqlParameter[])null); - } - - /// - /// Executes a single SQL command and returns the resultset in a . - /// A new MySqlConnection object is created, opened, and closed during this method. - /// - /// Settings to be used for the connection - /// Command to execute - /// Parameters to use for the command - /// containing the resultset - public static DataSet ExecuteDataset(string connectionString, string commandText, params MySqlParameter[] commandParameters) - { - //create & open a SqlConnection, and dispose of it after we are done. - using (MySqlConnection cn = new MySqlConnection(connectionString)) - { - cn.Open(); - - //call the overload that takes a connection in place of the connection string - return ExecuteDataset(cn, commandText, commandParameters); - } - } - - /// - /// Executes a single SQL command and returns the resultset in a . - /// The state of the object remains unchanged after execution - /// of this method. - /// - /// object to use - /// Command to execute - /// containing the resultset - public static DataSet ExecuteDataset(MySqlConnection connection, string commandText) - { - //pass through the call providing null for the set of SqlParameters - return ExecuteDataset(connection, commandText, (MySqlParameter[])null); - } - - /// - /// Executes a single SQL command and returns the resultset in a . - /// The state of the object remains unchanged after execution - /// of this method. - /// - /// object to use - /// Command to execute - /// Parameters to use for the command - /// containing the resultset - public static DataSet ExecuteDataset(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters) - { - //create a command and prepare it for execution - MySqlCommand cmd = new MySqlCommand(); - cmd.Connection = connection; - cmd.CommandText = commandText; - cmd.CommandType = CommandType.Text; - - if (commandParameters != null) - foreach (MySqlParameter p in commandParameters) - cmd.Parameters.Add( p ); - - //create the DataAdapter & DataSet - MySqlDataAdapter da = new MySqlDataAdapter(cmd); - DataSet ds = new DataSet(); - - //fill the DataSet using default values for DataTable names, etc. - da.Fill(ds); - - // detach the MySqlParameters from the command object, so they can be used again. - cmd.Parameters.Clear(); - - //return the dataset - return ds; - } - - /// - /// Updates the given table with data from the given - /// - /// Settings to use for the update - /// Command text to use for the update - /// containing the new data to use in the update - /// Tablename in the dataset to update - public static void UpdateDataSet( string connectionString, string commandText, DataSet ds, string tablename ) - { - MySqlConnection cn = new MySqlConnection( connectionString ); - cn.Open(); - MySqlDataAdapter da = new MySqlDataAdapter( commandText, cn ); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - cb.ToString(); - da.Update( ds, tablename ); - cn.Close(); - } - - #endregion - - #region ExecuteDataReader - - /// - /// Executes a single command against a MySQL database, possibly inside an existing transaction. - /// - /// object to use for the command - /// object to use for the command - /// Command text to use - /// Array of objects to use with the command - /// True if the connection should be preserved, false if not - /// object ready to read the results of the command - private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string commandText, MySqlParameter[] commandParameters, bool ExternalConn ) - { - //create a command and prepare it for execution - MySqlCommand cmd = new MySqlCommand(); - cmd.Connection = connection; - cmd.Transaction = transaction; - cmd.CommandText = commandText; - cmd.CommandType = CommandType.Text; - - if (commandParameters != null) - foreach (MySqlParameter p in commandParameters) - cmd.Parameters.Add( p ); - - //create a reader - MySqlDataReader dr; - - // call ExecuteReader with the appropriate CommandBehavior - if (ExternalConn) - { - dr = cmd.ExecuteReader(); - } - else - { - dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); - } - - // detach the SqlParameters from the command object, so they can be used again. - cmd.Parameters.Clear(); - - return dr; - } - - /// - /// Executes a single command against a MySQL database. - /// - /// Settings to use for this command - /// Command text to use - /// object ready to read the results of the command - public static MySqlDataReader ExecuteReader(string connectionString, string commandText) - { - //pass through the call providing null for the set of SqlParameters - return ExecuteReader(connectionString, commandText, (MySqlParameter[])null); - } - - /// - /// Executes a single command against a MySQL database. - /// - /// Settings to use for this command - /// Command text to use - /// Array of objects to use with the command - /// object ready to read the results of the command - public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters) - { - //create & open a SqlConnection - MySqlConnection cn = new MySqlConnection(connectionString); - cn.Open(); - - try - { - //call the private overload that takes an internally owned connection in place of the connection string - return ExecuteReader(cn, null, commandText, commandParameters, false ); - } - catch - { - //if we fail to return the SqlDatReader, we need to close the connection ourselves - cn.Close(); - throw; - } - } - #endregion - - #region ExecuteScalar - - /// - /// Execute a single command against a MySQL database. - /// - /// Settings to use for the update - /// Command text to use for the update - /// The first column of the first row in the result set, or a null reference if the result set is empty. - public static object ExecuteScalar(string connectionString, string commandText) - { - //pass through the call providing null for the set of MySqlParameters - return ExecuteScalar(connectionString, commandText, (MySqlParameter[])null); - } - - /// - /// Execute a single command against a MySQL database. - /// - /// Settings to use for the command - /// Command text to use for the command - /// Parameters to use for the command - /// The first column of the first row in the result set, or a null reference if the result set is empty. - public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters) - { - //create & open a SqlConnection, and dispose of it after we are done. - using (MySqlConnection cn = new MySqlConnection(connectionString)) - { - cn.Open(); - - //call the overload that takes a connection in place of the connection string - return ExecuteScalar(cn, commandText, commandParameters); - } - } - - /// - /// Execute a single command against a MySQL database. - /// - /// object to use - /// Command text to use for the command - /// The first column of the first row in the result set, or a null reference if the result set is empty. - public static object ExecuteScalar(MySqlConnection connection, string commandText) - { - //pass through the call providing null for the set of MySqlParameters - return ExecuteScalar(connection, commandText, (MySqlParameter[])null); - } - - /// - /// Execute a single command against a MySQL database. - /// - /// object to use - /// Command text to use for the command - /// Parameters to use for the command - /// The first column of the first row in the result set, or a null reference if the result set is empty. - public static object ExecuteScalar(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters) - { - //create a command and prepare it for execution - MySqlCommand cmd = new MySqlCommand(); - cmd.Connection = connection; - cmd.CommandText = commandText; - cmd.CommandType = CommandType.Text; - - if (commandParameters != null) - foreach (MySqlParameter p in commandParameters) - cmd.Parameters.Add( p ); - - //execute the command & return the results - object retval = cmd.ExecuteScalar(); - - // detach the SqlParameters from the command object, so they can be used again. - cmd.Parameters.Clear(); - return retval; - - } - - #endregion - - #region Utility methods - - /// - /// Escapes the string. - /// - /// The string to escape - /// The string with all quotes escaped. - public static string EscapeString(string value) - { - StringBuilder sb = new StringBuilder(); - foreach (char c in value) - { - if (stringOfQuoteChars.IndexOf(c) >= 0 || - //sb.Append(c); - //else if ( - stringOfBackslashChars.IndexOf(c) >= 0) - sb.Append("\\"); - sb.Append(c); - } - return sb.ToString(); - } - - public static string DoubleQuoteString(string value) - { - StringBuilder sb = new StringBuilder(); - foreach (char c in value) - { - if (stringOfQuoteChars.IndexOf(c) >= 0) - sb.Append(c); - else if (stringOfBackslashChars.IndexOf(c) >= 0) - sb.Append("\\"); - sb.Append(c); - } - return sb.ToString(); - } - - #endregion - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPacket.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPacket.cs deleted file mode 100644 index 9d551c1..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPacket.cs +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Diagnostics; -using System.Text; -using System.IO; -using MySql.Data.Common; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.MySqlClient -{ - class MySqlPacket - { - private byte[] tempBuffer = new byte[256]; - private Encoding encoding; - private MemoryStream buffer = new MemoryStream(5); - private DBVersion version; - - private MySqlPacket() - { - Clear(); - } - - public MySqlPacket(Encoding enc) : this() - { - Encoding = enc; - } - - public MySqlPacket(MemoryStream stream) - : this() - { - buffer = stream; - } - - #region Properties - - public Encoding Encoding - { - get { return encoding; } - set - { - Debug.Assert(value != null); - encoding = value; - } - } - - public bool HasMoreData - { - get { return buffer.Position < buffer.Length; } - } - - public int Position - { - get { return (int)buffer.Position; } - set { buffer.Position = (long)value; } - } - - public int Length - { - get { return (int)buffer.Length; } - set { buffer.SetLength(value); } - } - - public bool IsLastPacket - { - get - { - byte[] bits = buffer.GetBuffer(); - return bits[0] == 0xfe && Length <= 5; - } - } - - public byte[] Buffer - { - get { return buffer.GetBuffer(); } - } - - public DBVersion Version - { - get { return version; } - set { version = value; } - } - - #endregion - - public void Clear() - { - Position = 4; - } - - - #region Byte methods - - public byte ReadByte() - { - return (byte)buffer.ReadByte(); - } - - public int Read(byte[] byteBuffer, int offset, int count) - { - return buffer.Read(byteBuffer, offset, count); - } - - public void WriteByte(byte b) - { - buffer.WriteByte(b); - } - - public void Write(byte[] bytesToWrite) - { - Write(bytesToWrite, 0, bytesToWrite.Length); - } - - public void Write(byte[] bytesToWrite, int offset, int countToWrite) - { - buffer.Write(bytesToWrite, offset, countToWrite); - } - - public int ReadNBytes() - { - byte c = ReadByte(); - if (c < 1 || c > 4) - throw new MySqlException(Resources.IncorrectTransmission); - return ReadInteger(c); - } - - #endregion - - #region Integer methods - - public int ReadFieldLength() - { - byte c = ReadByte(); - - switch (c) - { - case 251: return -1; - case 252: return ReadInteger(2); - case 253: return ReadInteger(3); - case 254: return ReadInteger(8); - default: return c; - } - } - - public ulong ReadBitValue(int numbytes) - { - ulong value = 0; - - int pos = (int)buffer.Position; - byte[] bits = buffer.GetBuffer(); - int shift = 0; - - for (int i = 0; i < numbytes; i++) - { - value <<= shift; - value |= bits[pos++]; - shift = 8; - } - buffer.Position += numbytes; - return value; - } - - public long ReadLong(int numbytes) - { - Debug.Assert((buffer.Position + numbytes) <= buffer.Length); - byte[] bytes = buffer.GetBuffer(); - int pos = (int)buffer.Position; - buffer.Position += numbytes; - switch (numbytes) - { - case 2: return BitConverter.ToUInt16(bytes, pos); - case 4: return BitConverter.ToUInt32(bytes, pos); - case 8: return BitConverter.ToInt64(bytes, pos); - } - throw new NotSupportedException("Only byte lengths of 2, 4, or 8 are supported"); - } - - public ulong ReadULong(int numbytes) - { - Debug.Assert((buffer.Position + numbytes) <= buffer.Length); - byte[] bytes = buffer.GetBuffer(); - int pos = (int)buffer.Position; - buffer.Position += numbytes; - switch (numbytes) - { - case 2: return BitConverter.ToUInt16(bytes, pos); - case 4: return BitConverter.ToUInt32(bytes, pos); - case 8: return BitConverter.ToUInt64(bytes, pos); - } - throw new NotSupportedException("Only byte lengths of 2, 4, or 8 are supported"); - } - - public int Read3ByteInt() - { - int value = 0; - - int pos = (int)buffer.Position; - byte[] bits = buffer.GetBuffer(); - int shift = 0; - - for (int i = 0; i < 3; i++) - { - value |= (int)(bits[pos++] << shift); - shift += 8; - } - buffer.Position += 3; - return value; - } - - public int ReadInteger(int numbytes) - { - if (numbytes == 3) - return Read3ByteInt(); - Debug.Assert(numbytes <= 4); - return (int)ReadLong(numbytes); - } - - /// - /// WriteInteger - /// - /// - /// - public void WriteInteger(long v, int numbytes) - { - long val = v; - - Debug.Assert(numbytes > 0 && numbytes < 9); - - for (int x = 0; x < numbytes; x++) - { - tempBuffer[x] = (byte)(val & 0xff); - val >>= 8; - } - Write(tempBuffer, 0, numbytes); - } - - public int ReadPackedInteger() - { - byte c = ReadByte(); - - switch (c) - { - case 251: return -1; - case 252: return ReadInteger(2); - case 253: return ReadInteger(3); - case 254: return ReadInteger(4); - default: return c; - } - } - - public void WriteLength(long length) - { - if (length < 251) - WriteByte((byte)length); - else if (length < 65536L) - { - WriteByte(252); - WriteInteger(length, 2); - } - else if (length < 16777216L) - { - WriteByte(253); - WriteInteger(length, 3); - } - else - { - WriteByte(254); - WriteInteger(length, 4); - } - } - - #endregion - - #region String methods - - public void WriteLenString(string s) - { - byte[] bytes = encoding.GetBytes(s); - WriteLength(bytes.Length); - Write(bytes, 0, bytes.Length); - } - - public void WriteStringNoNull(string v) - { - byte[] bytes = encoding.GetBytes(v); - Write(bytes, 0, bytes.Length); - } - - public void WriteString(string v) - { - WriteStringNoNull(v); - WriteByte(0); - } - - public string ReadLenString() - { - long len = ReadPackedInteger(); - return ReadString(len); - } - - public string ReadAsciiString(long length) - { - if (length == 0) - return String.Empty; - // byte[] buf = new byte[length]; - Read(tempBuffer, 0, (int)length); - return ASCIIEncoding.ASCII.GetString(tempBuffer, 0, (int)length); - //return encoding.GetString(tempBuffer, 0, (int)length); //buf.Length); - } - - public string ReadString(long length) - { - if (length == 0) - return String.Empty; - if (tempBuffer == null || length > tempBuffer.Length) - tempBuffer = new byte[length]; - Read(tempBuffer, 0, (int)length); - return encoding.GetString(tempBuffer, 0, (int)length); - } - - public string ReadString() - { - byte[] bits = buffer.GetBuffer(); - int end = (int)buffer.Position; - - while (end < (int)buffer.Length && - bits[end] != 0 && (int)bits[end] != -1) - end++; - - string s = encoding.GetString(bits, - (int)buffer.Position, end - (int)buffer.Position); - buffer.Position = end + 1; - return s; - } - - #endregion - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPool.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPool.cs deleted file mode 100644 index afcf776..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPool.cs +++ /dev/null @@ -1,330 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.MySqlClient -{ - - - /// - /// Summary description for MySqlPool. - /// - internal sealed class MySqlPool - { - private List inUsePool; - private Queue idlePool; - private MySqlConnectionStringBuilder settings; - private uint minSize; - private uint maxSize; - private ProcedureCache procedureCache; - private bool beingCleared; - private int available; - private AutoResetEvent autoEvent; - - private void EnqueueIdle(Driver driver) - { - driver.IdleSince = DateTime.Now; - idlePool.Enqueue(driver); - } - public MySqlPool(MySqlConnectionStringBuilder settings) - { - minSize = settings.MinimumPoolSize; - maxSize = settings.MaximumPoolSize; - - available = (int)maxSize; - autoEvent = new AutoResetEvent(false); - - if (minSize > maxSize) - minSize = maxSize; - this.settings = settings; - inUsePool = new List((int)maxSize); - idlePool = new Queue((int)maxSize); - - // prepopulate the idle pool to minSize - for (int i = 0; i < minSize; i++) - EnqueueIdle(CreateNewPooledConnection()); - - procedureCache = new ProcedureCache((int)settings.ProcedureCacheSize); - } - - #region Properties - - public MySqlConnectionStringBuilder Settings - { - get { return settings; } - set { settings = value; } - } - - public ProcedureCache ProcedureCache - { - get { return procedureCache; } - } - - /// - /// It is assumed that this property will only be used from inside an active - /// lock. - /// - private bool HasIdleConnections - { - get { return idlePool.Count > 0; } - } - - private int NumConnections - { - get { return idlePool.Count + inUsePool.Count; } - } - - /// - /// Indicates whether this pool is being cleared. - /// - public bool BeingCleared - { - get { return beingCleared; } - } - - #endregion - - /// - /// It is assumed that this method is only called from inside an active lock. - /// - private Driver GetPooledConnection() - { - Driver driver = null; - - // if we don't have an idle connection but we have room for a new - // one, then create it here. - lock ((idlePool as ICollection).SyncRoot) - { - if (HasIdleConnections) - driver = idlePool.Dequeue(); - } - - // Obey the connection timeout - if (driver != null) - { - try - { - driver.ResetTimeout((int)Settings.ConnectionTimeout * 1000); - } - catch (Exception) - { - driver.Close(); - driver = null; - } - } - - if (driver != null) - { - // first check to see that the server is still alive - if (!driver.Ping()) - { - driver.Close(); - driver = null; - } - else if (settings.ConnectionReset) - // if the user asks us to ping/reset pooled connections - // do so now - driver.Reset(); - } - if (driver == null) - driver = CreateNewPooledConnection(); - - Debug.Assert(driver != null); - lock ((inUsePool as ICollection).SyncRoot) - { - inUsePool.Add(driver); - } - return driver; - } - - /// - /// It is assumed that this method is only called from inside an active lock. - /// - private Driver CreateNewPooledConnection() - { - Debug.Assert((maxSize - NumConnections) > 0, "Pool out of sync."); - - Driver driver = Driver.Create(settings); - driver.Pool = this; - return driver; - } - - public void ReleaseConnection(Driver driver) - { - lock ((inUsePool as ICollection).SyncRoot) - { - if (inUsePool.Contains(driver)) - inUsePool.Remove(driver); - } - - if (driver.ConnectionLifetimeExpired() || beingCleared) - { - driver.Close(); - Debug.Assert(!idlePool.Contains(driver)); - } - else - { - lock ((idlePool as ICollection).SyncRoot) - { - EnqueueIdle(driver); - } - } - - Interlocked.Increment(ref available); - autoEvent.Set(); - } - - /// - /// Removes a connection from the in use pool. The only situations where this method - /// would be called are when a connection that is in use gets some type of fatal exception - /// or when the connection is being returned to the pool and it's too old to be - /// returned. - /// - /// - public void RemoveConnection(Driver driver) - { - lock ((inUsePool as ICollection).SyncRoot) - { - if (inUsePool.Contains(driver)) - { - inUsePool.Remove(driver); - Interlocked.Increment(ref available); - autoEvent.Set(); - } - } - - // if we are being cleared and we are out of connections then have - // the manager destroy us. - if (beingCleared && NumConnections == 0) - MySqlPoolManager.RemoveClearedPool(this); - } - - private Driver TryToGetDriver() - { - int count = Interlocked.Decrement(ref available); - if (count < 0) - { - Interlocked.Increment(ref available); - return null; - } - try - { - Driver driver = GetPooledConnection(); - return driver; - } - catch (Exception ex) - { - MySqlTrace.LogError(-1, ex.Message); - Interlocked.Increment(ref available); - throw; - } - } - - public Driver GetConnection() - { - int fullTimeOut = (int)settings.ConnectionTimeout * 1000; - int timeOut = fullTimeOut; - - DateTime start = DateTime.Now; - - while (timeOut > 0) - { - Driver driver = TryToGetDriver(); - if (driver != null) return driver; - - // We have no tickets right now, lets wait for one. - if (!autoEvent.WaitOne(timeOut, false)) break; - timeOut = fullTimeOut - (int)DateTime.Now.Subtract(start).TotalMilliseconds; - } - throw new MySqlException(Resources.TimeoutGettingConnection); - } - - /// - /// Clears this pool of all idle connections and marks this pool and being cleared - /// so all other connections are closed when they are returned. - /// - internal void Clear() - { - lock ((idlePool as ICollection).SyncRoot) - { - // first, mark ourselves as being cleared - beingCleared = true; - - // then we remove all connections sitting in the idle pool - while (idlePool.Count > 0) - { - Driver d = idlePool.Dequeue(); - d.Close(); - } - - // there is nothing left to do here. Now we just wait for all - // in use connections to be returned to the pool. When they are - // they will be closed. When the last one is closed, the pool will - // be destroyed. - } - } - - /// - /// Remove expired drivers from the idle pool - /// - /// - /// - /// Closing driver is a potentially lengthy operation involving network - /// IO. Therefore we do not close expired drivers while holding - /// idlePool.SyncRoot lock. We just remove the old drivers from the idle - /// queue and return them to the caller. The caller will need to close - /// them (or let GC close them) - /// - internal List RemoveOldIdleConnections() - { - List oldDrivers = new List(); - DateTime now = DateTime.Now; - - lock ((idlePool as ICollection).SyncRoot) - { - // The drivers appear to be ordered by their age, i.e it is - // sufficient to remove them until the first element is not - // too old. - while(idlePool.Count > minSize) - { - Driver d = idlePool.Peek(); - DateTime expirationTime = d.IdleSince.Add( - new TimeSpan(0,0, MySqlPoolManager.maxConnectionIdleTime)); - if (expirationTime.CompareTo(now) < 0) - { - oldDrivers.Add(d); - idlePool.Dequeue(); - } - else - { - break; - } - } - } - return oldDrivers; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPoolManager.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPoolManager.cs deleted file mode 100644 index 9dc6827..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPoolManager.cs +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System.Collections; -using System.Diagnostics; -using System.Collections.Generic; -using System.Threading; - -namespace MySql.Data.MySqlClient -{ - /// - /// Summary description for MySqlPoolManager. - /// - internal class MySqlPoolManager - { - private static Hashtable pools = new Hashtable(); - private static List clearingPools = new List(); - - // Timeout in seconds, after which an unused (idle) connection - // should be closed. - static internal int maxConnectionIdleTime = 180; - - - private static Timer timer = new Timer(new TimerCallback(CleanIdleConnections), - null, maxConnectionIdleTime*1000, maxConnectionIdleTime*1000); - - public static MySqlPool GetPool(MySqlConnectionStringBuilder settings) - { - string text = settings.ConnectionString; - - lock (pools.SyncRoot) - { - MySqlPool pool = (pools[text] as MySqlPool); - - if (pool == null) - { - pool = new MySqlPool(settings); - pools.Add(text, pool); - } - else - pool.Settings = settings; - - return pool; - } - } - - public static void RemoveConnection(Driver driver) - { - Debug.Assert(driver != null); - - MySqlPool pool = driver.Pool; - if (pool == null) return; - - pool.RemoveConnection(driver); - } - - public static void ReleaseConnection(Driver driver) - { - Debug.Assert(driver != null); - - MySqlPool pool = driver.Pool; - if (pool == null) return; - - pool.ReleaseConnection(driver); - } - - public static void ClearPool(MySqlConnectionStringBuilder settings) - { - Debug.Assert(settings != null); - - string text = settings.ConnectionString; - ClearPoolByText(text); - } - - private static void ClearPoolByText(string key) - { - lock (pools.SyncRoot) - { - // if pools doesn't have it, then this pool must already have been cleared - if (!pools.ContainsKey(key)) return; - - // add the pool to our list of pools being cleared - MySqlPool pool = (pools[key] as MySqlPool); - clearingPools.Add(pool); - - // now tell the pool to clear itself - pool.Clear(); - - // and then remove the pool from the active pools list - pools.Remove(key); - } - } - - public static void ClearAllPools() - { - lock (pools.SyncRoot) - { - // Create separate keys list. - List keys = new List(pools.Count); - - foreach (string key in pools.Keys) - keys.Add(key); - - // Remove all pools by key. - foreach (string key in keys) - ClearPoolByText(key); - } - } - - public static void RemoveClearedPool(MySqlPool pool) - { - Debug.Assert(clearingPools.Contains(pool)); - clearingPools.Remove(pool); - } - - /// - /// Remove drivers that have been idle for too long. - /// - public static void CleanIdleConnections(object obj) - { - List oldDrivers = new List(); - lock (pools.SyncRoot) - { - foreach (string key in pools.Keys) - { - MySqlPool pool = (pools[key] as MySqlPool); - oldDrivers.AddRange(pool.RemoveOldIdleConnections()); - } - } - foreach(Driver driver in oldDrivers) - { - driver.Close(); - } - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPromotableTransaction.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPromotableTransaction.cs deleted file mode 100644 index d1d563d..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlPromotableTransaction.cs +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Transactions; -using System.Collections; -using System.Data; - -namespace MySql.Data.MySqlClient -{ - internal sealed class MySqlPromotableTransaction : IPromotableSinglePhaseNotification, ITransactionPromoter - { - private MySqlConnection connection; - private Transaction baseTransaction; - private MySqlTransaction simpleTransaction; - - public MySqlPromotableTransaction(MySqlConnection connection, Transaction baseTransaction) - { - this.connection = connection; - this.baseTransaction = baseTransaction; - } - - public Transaction BaseTransaction - { - get { return baseTransaction; } - } - - void IPromotableSinglePhaseNotification.Initialize() - { - string valueName = Enum.GetName( - typeof(System.Transactions.IsolationLevel), baseTransaction.IsolationLevel); - System.Data.IsolationLevel dataLevel = (System.Data.IsolationLevel)Enum.Parse( - typeof(System.Data.IsolationLevel), valueName); - simpleTransaction = connection.BeginTransaction(dataLevel); - } - - void IPromotableSinglePhaseNotification.Rollback(SinglePhaseEnlistment singlePhaseEnlistment) - { - // prevent commands in main thread to run concurrently - Driver driver = connection.driver; - lock (driver) - { - while (connection.Reader != null) - { - // wait for reader to finish. Maybe we should not wait - // forever and cancel it after some time? - System.Threading.Thread.Sleep(100); - } - simpleTransaction.Rollback(); - singlePhaseEnlistment.Aborted(); - DriverTransactionManager.RemoveDriverInTransaction(baseTransaction); - - driver.CurrentTransaction = null; - - if (connection.State == ConnectionState.Closed) - connection.CloseFully(); - } - } - - void IPromotableSinglePhaseNotification.SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment) - { - simpleTransaction.Commit(); - singlePhaseEnlistment.Committed(); - DriverTransactionManager.RemoveDriverInTransaction(baseTransaction); - - connection.driver.CurrentTransaction = null; - - if (connection.State == ConnectionState.Closed) - connection.CloseFully(); - } - - byte[] ITransactionPromoter.Promote() - { - throw new NotSupportedException(); - } - } - - internal class DriverTransactionManager - { - private static Hashtable driversInUse = new Hashtable(); - - public static Driver GetDriverInTransaction(Transaction transaction) - { - lock (driversInUse.SyncRoot) - { - Driver d = (Driver)driversInUse[transaction.GetHashCode()]; - return d; - } - } - - public static void SetDriverInTransaction(Driver driver) - { - lock (driversInUse.SyncRoot) - { - driversInUse[driver.CurrentTransaction.BaseTransaction.GetHashCode()] = driver; - } - } - - public static void RemoveDriverInTransaction(Transaction transaction) - { - lock (driversInUse.SyncRoot) - { - driversInUse.Remove(transaction.GetHashCode()); - } - } - } -} - diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlScript.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlScript.cs deleted file mode 100644 index a986a44..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlScript.cs +++ /dev/null @@ -1,433 +0,0 @@ -// Copyright (c) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using MySql.Data.Common; -using System.Collections.Generic; -using System.Text; -using System; -using System.Data; -using System.Globalization; -using System.IO; -using MySql.Data.MySqlClient.Properties; -namespace MySql.Data.MySqlClient -{ - /// - /// Provides a class capable of executing a SQL script containing - /// multiple SQL statements including CREATE PROCEDURE statements - /// that require changing the delimiter - /// - public class MySqlScript - { - private MySqlConnection connection; - private string query; - private string delimiter; - - public event MySqlStatementExecutedEventHandler StatementExecuted; - public event MySqlScriptErrorEventHandler Error; - public event EventHandler ScriptCompleted; - - #region Constructors - - /// - /// Initializes a new instance of the - /// class. - /// - public MySqlScript() - { - Delimiter = ";"; - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// The connection. - public MySqlScript(MySqlConnection connection) : this() - { - this.connection = connection; - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// The query. - public MySqlScript(string query) : this() - { - this.query = query; - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// The connection. - /// The query. - public MySqlScript(MySqlConnection connection, string query) - :this() - { - this.connection = connection; - this.query = query; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the connection. - /// - /// The connection. - public MySqlConnection Connection - { - get { return connection; } - set { connection = value; } - } - - /// - /// Gets or sets the query. - /// - /// The query. - public string Query - { - get { return query; } - set { query = value; } - } - - /// - /// Gets or sets the delimiter. - /// - /// The delimiter. - public string Delimiter - { - get { return delimiter; } - set { delimiter = value; } - } - - #endregion - - #region Public Methods - - /// - /// Executes this instance. - /// - /// The number of statements executed as part of the script. - public int Execute() - { - bool openedConnection = false; - - if (connection == null) - throw new InvalidOperationException(Resources.ConnectionNotSet); - if (query == null || query.Length == 0) - return 0; - - // next we open up the connetion if it is not already open - if (connection.State != ConnectionState.Open) - { - openedConnection = true; - connection.Open(); - } - - // since we don't allow setting of parameters on a script we can - // therefore safely allow the use of user variables. no one should be using - // this connection while we are using it so we can temporarily tell it - // to allow the use of user variables - bool allowUserVars = connection.Settings.AllowUserVariables; - connection.Settings.AllowUserVariables = true; - - try - { - string mode = connection.driver.Property("sql_mode"); - mode = mode.ToUpper(CultureInfo.InvariantCulture); - bool ansiQuotes = mode.IndexOf("ANSI_QUOTES") != -1; - bool noBackslashEscapes = mode.IndexOf("NO_BACKSLASH_ESCAPES") != -1; - - // first we break the query up into smaller queries - List statements = BreakIntoStatements(ansiQuotes, noBackslashEscapes); - - int count = 0; - MySqlCommand cmd = new MySqlCommand(null, connection); - foreach (ScriptStatement statement in statements) - { - if (String.IsNullOrEmpty(statement.text)) continue; - cmd.CommandText = statement.text; - try - { - cmd.ExecuteNonQuery(); - count++; - OnQueryExecuted(statement); - } - catch (Exception ex) - { - if (Error == null) - throw; - if (!OnScriptError(ex)) - break; - } - } - OnScriptCompleted(); - return count; - } - finally - { - connection.Settings.AllowUserVariables = allowUserVars; - if (openedConnection) - { - connection.Close(); - } - } - } - - #endregion - - private void OnQueryExecuted(ScriptStatement statement) - { - if (StatementExecuted != null) - { - MySqlScriptEventArgs args = new MySqlScriptEventArgs(); - args.Statement = statement; - StatementExecuted(this, args); - } - } - - private void OnScriptCompleted() - { - if (ScriptCompleted != null) - ScriptCompleted(this, EventArgs.Empty); - } - - private bool OnScriptError(Exception ex) - { - if (Error != null) - { - MySqlScriptErrorEventArgs args = new MySqlScriptErrorEventArgs(ex); - Error(this, args); - return args.Ignore; - } - return false; - } - - private List BreakScriptIntoLines() - { - List lineNumbers = new List(); - - StringReader sr = new StringReader(query); - string line = sr.ReadLine(); - int pos = 0; - while (line != null) - { - lineNumbers.Add(pos); - pos += line.Length; - line = sr.ReadLine(); - } - return lineNumbers; - } - - private static int FindLineNumber(int position, List lineNumbers) - { - int i = 0; - while (i < lineNumbers.Count && position < lineNumbers[i]) - i++; - return i; - } - - private List BreakIntoStatements(bool ansiQuotes, bool noBackslashEscapes) - { - string currentDelimiter = Delimiter; - int startPos = 0; - List statements = new List(); - List lineNumbers = BreakScriptIntoLines(); - MySqlTokenizer tokenizer = new MySqlTokenizer(query); - - tokenizer.AnsiQuotes = ansiQuotes; - tokenizer.BackslashEscapes = !noBackslashEscapes; - - string token = tokenizer.NextToken(); - while (token != null) - { - if (!tokenizer.Quoted) - { - if (token.ToLower(CultureInfo.InvariantCulture) == "delimiter") - { - tokenizer.NextToken(); - AdjustDelimiterEnd(tokenizer); - currentDelimiter = query.Substring(tokenizer.StartIndex, - tokenizer.StopIndex - tokenizer.StartIndex + 1).Trim(); - startPos = tokenizer.StopIndex; - } - else - { - // this handles the case where our tokenizer reads part of the - // delimiter - if (currentDelimiter.StartsWith(token)) - { - if ((tokenizer.StartIndex + currentDelimiter.Length) <= query.Length) - { - if (query.Substring(tokenizer.StartIndex, currentDelimiter.Length) == currentDelimiter) - { - token = currentDelimiter; - tokenizer.Position = tokenizer.StartIndex + currentDelimiter.Length; - tokenizer.StopIndex = tokenizer.Position; - } - } - } - - int delimiterPos = token.IndexOf(currentDelimiter, StringComparison.InvariantCultureIgnoreCase); - if (delimiterPos != -1) - { - int endPos = tokenizer.StopIndex - token.Length + delimiterPos; - if (tokenizer.StopIndex == query.Length - 1) - endPos++; - string currentQuery = query.Substring(startPos, endPos - startPos); - ScriptStatement statement = new ScriptStatement(); - statement.text = currentQuery.Trim(); - statement.line = FindLineNumber(startPos, lineNumbers); - statement.position = startPos - lineNumbers[statement.line]; - statements.Add(statement); - startPos = endPos + currentDelimiter.Length; - } - } - } - token = tokenizer.NextToken(); - } - - // now clean up the last statement - if (startPos < query.Length-1) - { - string sqlLeftOver = query.Substring(startPos).Trim(); - if (!String.IsNullOrEmpty(sqlLeftOver)) - { - ScriptStatement statement = new ScriptStatement(); - statement.text = sqlLeftOver; - statement.line = FindLineNumber(startPos, lineNumbers); - statement.position = startPos - lineNumbers[statement.line]; - statements.Add(statement); - } - } - return statements; - } - - private void AdjustDelimiterEnd(MySqlTokenizer tokenizer) - { - int pos = tokenizer.StopIndex; - char c = query[pos]; - - while (!Char.IsWhiteSpace(c) && pos < (query.Length-1)) - { - c = query[++pos]; - } - tokenizer.StopIndex = pos; - tokenizer.Position = pos; - } - } - - /// - /// - /// - public delegate void MySqlStatementExecutedEventHandler(object sender, MySqlScriptEventArgs args); - /// - /// - /// - public delegate void MySqlScriptErrorEventHandler(object sender, MySqlScriptErrorEventArgs args); - - /// - /// - /// - public class MySqlScriptEventArgs : EventArgs - { - private ScriptStatement statement; - - internal ScriptStatement Statement - { - set { this.statement = value; } - } - - /// - /// Gets the statement text. - /// - /// The statement text. - public string StatementText - { - get { return statement.text; } - } - - /// - /// Gets the line. - /// - /// The line. - public int Line - { - get { return statement.line; } - } - - /// - /// Gets the position. - /// - /// The position. - public int Position - { - get { return statement.position; } - } - } - - /// - /// - /// - public class MySqlScriptErrorEventArgs : MySqlScriptEventArgs - { - private Exception exception; - private bool ignore; - - /// - /// Initializes a new instance of the class. - /// - /// The exception. - public MySqlScriptErrorEventArgs(Exception exception) : base() - { - this.exception = exception; - } - - /// - /// Gets the exception. - /// - /// The exception. - public Exception Exception - { - get { return exception; } - } - - /// - /// Gets or sets a value indicating whether this is ignore. - /// - /// true if ignore; otherwise, false. - public bool Ignore - { - get { return ignore; } - set { ignore = value; } - } - } - - struct ScriptStatement - { - public string text; - public int line; - public int position; - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlStream.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlStream.cs deleted file mode 100644 index c51adf0..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlStream.cs +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.IO; -using System.Diagnostics; -using System.Text; -using MySql.Data.Common; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.MySqlClient -{ - /// - /// Summary description for MySqlStream. - /// - internal class MySqlStream - { - private byte sequenceByte; - private MemoryStream bufferStream; - private int maxBlockSize; - private ulong maxPacketSize; - private byte[] packetHeader = new byte[4]; - MySqlPacket packet; - TimedStream timedStream; - Stream inStream; - Stream outStream; - - - public MySqlStream(Encoding encoding) - { - // we have no idea what the real value is so we start off with the max value - // The real value will be set in NativeDriver.Configure() - maxPacketSize = ulong.MaxValue; - - // we default maxBlockSize to MaxValue since we will get the 'real' value in - // the authentication handshake and we know that value will not exceed - // true maxBlockSize prior to that. - maxBlockSize = Int32.MaxValue; - - packet = new MySqlPacket(encoding); - bufferStream = new MemoryStream(); - } - - public MySqlStream(Stream baseStream, Encoding encoding, bool compress) - : this(encoding) - { - timedStream = new TimedStream(baseStream); - Stream stream; - if (compress) - stream = new CompressedStream(timedStream); - else - stream = timedStream; - - inStream = new BufferedStream(stream); - outStream = stream; - } - - public void Close() - { - outStream.Close(); - inStream.Close(); - timedStream.Close(); - } - - #region Properties - - public Encoding Encoding - { - get { return packet.Encoding; } - set { packet.Encoding = value; } - } - - public void ResetTimeout(int timeout) - { - timedStream.ResetTimeout(timeout); - } - - public byte SequenceByte - { - get { return sequenceByte; } - set { sequenceByte = value; } - } - - public int MaxBlockSize - { - get { return maxBlockSize; } - set { maxBlockSize = value; } - } - - public ulong MaxPacketSize - { - get { return maxPacketSize; } - set { maxPacketSize = value; } - } - - #endregion - - #region Packet methods - - /// - /// ReadPacket is called by NativeDriver to start reading the next - /// packet on the stream. - /// - public MySqlPacket ReadPacket() - { - //Debug.Assert(packet.Position == packet.Length); - - // make sure we have read all the data from the previous packet - //Debug.Assert(HasMoreData == false, "HasMoreData is true in OpenPacket"); - - LoadPacket(); - - // now we check if this packet is a server error - if (packet.Buffer[0] == 0xff) - { - packet.ReadByte(); // read off the 0xff - - int code = packet.ReadInteger(2); - string msg = packet.ReadString(); - if (msg.StartsWith("#")) - { - msg.Substring(1, 5); /* state code */ - msg = msg.Substring(6); - } - throw new MySqlException(msg, code); - } - return packet; - } - - /// - /// Reads the specified number of bytes from the stream and stores them at given - /// offset in the buffer. - /// Throws EndOfStreamException if not all bytes can be read. - /// - /// Stream to read from - /// Array to store bytes read from the stream - /// The offset in buffer at which to begin storing the data read from the current stream. - /// Number of bytes to read - internal static void ReadFully(Stream stream, byte[] buffer, int offset, int count) - { - int numRead = 0; - int numToRead = count; - while (numToRead > 0) - { - int read = stream.Read(buffer, offset + numRead, numToRead); - if (read == 0) - { - throw new EndOfStreamException(); - } - numRead += read; - numToRead -= read; - } - } - - /// - /// LoadPacket loads up and decodes the header of the incoming packet. - /// - public void LoadPacket() - { - try - { - packet.Length = 0; - int offset = 0; - while (true) - { - ReadFully(inStream, packetHeader, 0, 4); - sequenceByte = (byte)(packetHeader[3]+1); - int length = (int)(packetHeader[0] + (packetHeader[1] << 8) + - (packetHeader[2] << 16)); - - // make roo for the next block - packet.Length += length; - - ReadFully(inStream, packet.Buffer, offset, length); - offset += length; - - // if this block was < maxBlock then it's last one in a multipacket series - if (length < maxBlockSize) break; - } - packet.Position = 0; - } - catch (IOException ioex) - { - throw new MySqlException(Resources.ReadFromStreamFailed, true, ioex); - } - } - - public void SendPacket(MySqlPacket packet) - { - byte[] buffer = packet.Buffer; - int length = packet.Position-4; - - if ((ulong)length > maxPacketSize) - throw new MySqlException(Resources.QueryTooLarge, (int)MySqlErrorCode.PacketTooLarge); - - int offset = 0; - while (length > 0) - { - int lenToSend = length > maxBlockSize ? maxBlockSize : length; - buffer[offset] = (byte)(lenToSend & 0xff); - buffer[offset+1] = (byte)((lenToSend >> 8) & 0xff); - buffer[offset+2] = (byte)((lenToSend >> 16) & 0xff); - buffer[offset+3] = sequenceByte++; - - outStream.Write(buffer, offset, lenToSend + 4); - outStream.Flush(); - length -= lenToSend; - offset += lenToSend; - } - } - - public void SendEntirePacketDirectly(byte[] buffer, int count) - { - buffer[0] = (byte)(count & 0xff); - buffer[1] = (byte)((count >> 8) & 0xff); - buffer[2] = (byte)((count >> 16) & 0xff); - buffer[3] = sequenceByte++; - outStream.Write(buffer, 0, count + 4); - outStream.Flush(); - } - - #endregion - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlTrace.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlTrace.cs deleted file mode 100644 index 4268d89..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MySqlTrace.cs +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) 2009-2010 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections.Generic; -using System.Text; -using System.Diagnostics; - -namespace MySql.Data.MySqlClient -{ - public class MySqlTrace - { -#if !CF - private static TraceSource source = new TraceSource("mysql"); - - public static TraceListenerCollection Listeners - { - get { return source.Listeners; } - } - - public static SourceSwitch Switch - { - get { return source.Switch; } - set { source.Switch = value; } - } - - internal static TraceSource Source - { - get { return source; } - } -#endif - - internal static void LogInformation(int id, string msg) - { -#if !CF - Source.TraceEvent(TraceEventType.Information, id, msg, MySqlTraceEventType.NonQuery, -1); - Trace.TraceInformation(msg); -#endif - } - - internal static void LogWarning(int id, string msg) - { -#if !CF - Source.TraceEvent(TraceEventType.Warning, id, msg, MySqlTraceEventType.NonQuery, -1); - Trace.TraceWarning(msg); -#endif - } - - internal static void LogError(int id, string msg) - { -#if !CF - Source.TraceEvent(TraceEventType.Error, id, msg, MySqlTraceEventType.NonQuery, -1); - Trace.TraceError(msg); -#endif - } - -#if !CF - internal static void TraceEvent(TraceEventType eventType, - MySqlTraceEventType mysqlEventType, string msgFormat, params object[] args) - { - Source.TraceEvent(eventType, (int)mysqlEventType, msgFormat, args); - } -#endif - } - - public enum MySqlTraceEventType : int - { - ConnectionOpened = 1, - ConnectionClosed, - QueryOpened, - ResultOpened, - ResultClosed, - QueryClosed, - StatementPrepared, - StatementExecuted, - StatementClosed, - NonQuery, - UsageAdvisorWarning, - Warning, - Error, - QueryNormalized - } - - public enum UsageAdvisorWarningFlags - { - NoIndex = 1, - BadIndex, - SkippedRows, - SkippedColumns, - FieldConversion - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MysqlDefs.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MysqlDefs.cs deleted file mode 100644 index 0e76f34..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/MysqlDefs.cs +++ /dev/null @@ -1,410 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; - -namespace MySql.Data.MySqlClient -{ - /// - /// Summary description for ClientParam. - /// - [Flags] - internal enum ClientFlags : ulong - { - LONG_PASSWORD = 1, // new more secure passwords - FOUND_ROWS = 2, // found instead of affected rows - LONG_FLAG = 4, // Get all column flags - CONNECT_WITH_DB = 8, // One can specify db on connect - NO_SCHEMA = 16, // Don't allow db.table.column - COMPRESS = 32, // Client can use compression protocol - ODBC = 64, // ODBC client - LOCAL_FILES = 128, // Can use LOAD DATA LOCAL - IGNORE_SPACE = 256, // Ignore spaces before '(' - PROTOCOL_41 = 512, // Support new 4.1 protocol - INTERACTIVE = 1024, // This is an interactive client - SSL = 2048, // Switch to SSL after handshake - IGNORE_SIGPIPE = 4096, // IGNORE sigpipes - TRANSACTIONS = 8192, // Client knows about transactions - RESERVED = 16384, // old 4.1 protocol flag - SECURE_CONNECTION = 32768, // new 4.1 authentication - MULTI_STATEMENTS = 65536, // Allow multi-stmt support - MULTI_RESULTS = 131072, // Allow multiple resultsets - PS_MULTI_RESULTS = 1UL << 18 // allow multi results using PS protocol - } - - [Flags] - internal enum ServerStatusFlags - { - InTransaction = 1, // Transaction has started - AutoCommitMode = 2, // Server in auto_commit mode - MoreResults = 4, // More results on server - AnotherQuery = 8, // Multi query - next query exists - BadIndex = 16, - NoIndex = 32, - CursorExists = 64, - LastRowSent = 128, - OutputParameters = 4096 - } - - - /// - /// DB Operations Code - /// - internal enum DBCmd : byte - { - SLEEP = 0, - QUIT = 1, - INIT_DB = 2, - QUERY = 3, - FIELD_LIST = 4, - CREATE_DB = 5, - DROP_DB = 6, - RELOAD = 7, - SHUTDOWN = 8, - STATISTICS = 9, - PROCESS_INFO = 10, - CONNECT = 11, - PROCESS_KILL = 12, - DEBUG = 13, - PING = 14, - TIME = 15, - DELAYED_INSERT = 16, - CHANGE_USER = 17, - BINLOG_DUMP = 18, - TABLE_DUMP = 19, - CONNECT_OUT = 20, - REGISTER_SLAVE = 21, - PREPARE = 22, - EXECUTE = 23, - LONG_DATA = 24, - CLOSE_STMT = 25, - RESET_STMT = 26, - SET_OPTION = 27, - FETCH = 28 - } - - - /// - /// Specifies MySQL specific data type of a field, property, for use in a . - /// - public enum MySqlDbType - { - /// - /// - /// A fixed precision and scale numeric value between -1038 - /// -1 and 10 38 -1. - /// - Decimal = 0, - /// - /// The signed range is -128 to 127. The unsigned - /// range is 0 to 255. - /// - Byte = 1, - /// - /// A 16-bit signed integer. The signed range is - /// -32768 to 32767. The unsigned range is 0 to 65535 - /// - Int16 = 2, - /// - /// Specifies a 24 (3 byte) signed or unsigned value. - /// - Int24 = 9, - /// - /// A 32-bit signed integer - /// - Int32 = 3, - /// - /// A 64-bit signed integer. - /// - Int64 = 8, - /// - /// A small (single-precision) floating-point - /// number. Allowable values are -3.402823466E+38 to -1.175494351E-38, - /// 0, and 1.175494351E-38 to 3.402823466E+38. - /// - Float = 4, - /// - /// A normal-size (double-precision) - /// floating-point number. Allowable values are -1.7976931348623157E+308 - /// to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to - /// 1.7976931348623157E+308. - /// - Double = 5, - /// - /// A timestamp. The range is '1970-01-01 00:00:00' to sometime in the - /// year 2037 - /// - Timestamp = 7, - /// - ///Date The supported range is '1000-01-01' to '9999-12-31'. - /// - Date = 10, - /// - /// Time The range is '-838:59:59' to '838:59:59'. - /// - Time = 11, - /// - ///DateTime The supported range is '1000-01-01 00:00:00' to - ///'9999-12-31 23:59:59'. - /// - DateTime = 12, - /// - ///Datetime The supported range is '1000-01-01 00:00:00' to - ///'9999-12-31 23:59:59'. - /// - [Obsolete("The Datetime enum value is obsolete. Please use DateTime.")] - Datetime = 12, - /// - /// A year in 2- or 4-digit format (default is 4-digit). The - /// allowable values are 1901 to 2155, 0000 in the 4-digit year - /// format, and 1970-2069 if you use the 2-digit format (70-69). - /// - Year = 13, - /// - /// Obsolete Use Datetime or Date type - /// - Newdate = 14, - /// - /// A variable-length string containing 0 to 65535 characters - /// - VarString = 15, - /// - /// Bit-field data type - /// - Bit = 16, - /// - /// New Decimal - /// - NewDecimal = 246, - /// - /// An enumeration. A string object that can have only one value, - /// chosen from the list of values 'value1', 'value2', ..., NULL - /// or the special "" error value. An ENUM can have a maximum of - /// 65535 distinct values - /// - Enum = 247, - /// - /// A set. A string object that can have zero or more values, each - /// of which must be chosen from the list of values 'value1', 'value2', - /// ... A SET can have a maximum of 64 members. - /// - Set = 248, - /// - /// A binary column with a maximum length of 255 (2^8 - 1) - /// characters - /// - TinyBlob = 249, - /// - /// A binary column with a maximum length of 16777215 (2^24 - 1) bytes. - /// - MediumBlob = 250, - /// - /// A binary column with a maximum length of 4294967295 or - /// 4G (2^32 - 1) bytes. - /// - LongBlob = 251, - /// - /// A binary column with a maximum length of 65535 (2^16 - 1) bytes. - /// - Blob = 252, - /// - /// A variable-length string containing 0 to 255 bytes. - /// - VarChar = 253, - /// - /// A fixed-length string. - /// - String = 254, - /// - /// Geometric (GIS) data type. - /// - Geometry = 255, - /// - /// Unsigned 8-bit value. - /// - UByte = 501, - /// - /// Unsigned 16-bit value. - /// - UInt16 = 502, - /// - /// Unsigned 24-bit value. - /// - UInt24 = 509, - /// - /// Unsigned 32-bit value. - /// - UInt32 = 503, - /// - /// Unsigned 64-bit value. - /// - UInt64 = 508, - /// - /// Fixed length binary string. - /// - Binary = 600, - /// - /// Variable length binary string. - /// - VarBinary = 601, - /// - /// A text column with a maximum length of 255 (2^8 - 1) characters. - /// - TinyText = 749, - /// - /// A text column with a maximum length of 16777215 (2^24 - 1) characters. - /// - MediumText = 750, - /// - /// A text column with a maximum length of 4294967295 or - /// 4G (2^32 - 1) characters. - /// - LongText = 751, - /// - /// A text column with a maximum length of 65535 (2^16 - 1) characters. - /// - Text = 752, - /// - /// A guid column - /// - Guid = 800 - } ; - - - internal enum Field_Type : byte - { - DECIMAL = 0, - BYTE = 1, - SHORT = 2, - LONG = 3, - FLOAT = 4, - DOUBLE = 5, - NULL = 6, - TIMESTAMP = 7, - LONGLONG = 8, - INT24 = 9, - DATE = 10, - TIME = 11, - DATETIME = 12, - YEAR = 13, - NEWDATE = 14, - ENUM = 247, - SET = 248, - TINY_BLOB = 249, - MEDIUM_BLOB = 250, - LONG_BLOB = 251, - BLOB = 252, - VAR_STRING = 253, - STRING = 254, - } - - /// - /// Allows the user to specify the type of connection that should - /// be used. - /// - public enum MySqlConnectionProtocol - { - /// - /// TCP/IP style connection. Works everywhere. - /// - Sockets = 1, - Socket = 1, - Tcp = 1, - /// - /// Named pipe connection. Works only on Windows systems. - /// - Pipe = 2, - NamedPipe = 2, - /// - /// Unix domain socket connection. Works only with Unix systems. - /// - UnixSocket = 3, - Unix = 3, - /// - /// Shared memory connection. Currently works only with Windows systems. - /// - SharedMemory = 4, - Memory = 4 - } - - /// - /// SSL options for connection. - /// - public enum MySqlSslMode - { - /// - /// Do not use SSL. - /// - None, - /// - /// Use SSL, if server supports it. - /// - Preferred, - Prefered = Preferred, - /// - /// Always use SSL. Deny connection if server does not support SSL. - /// Do not perform server certificate validation. - /// - Required, - /// - /// Always use SSL. Validate server SSL certificate, but different host name mismatch. - /// - VerifyCA, - /// - /// Always use SSL and perform full certificate validation. - /// - VerifyFull - } - - /// - /// Specifies the connection types supported - /// - public enum MySqlDriverType - { - /// - /// Use TCP/IP sockets. - /// - Native, - /// - /// Use client library. - /// - Client, - /// - /// Use MySQL embedded server. - /// - Embedded - } - - public enum MySqlCertificateStoreLocation - { - /// - /// Do not use certificate store - /// - None, - /// - /// Use certificate store for the current user - /// - CurrentUser, - /// - /// User certificate store for the machine - /// - LocalMachine - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/NativeDriver.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/NativeDriver.cs deleted file mode 100644 index 22ed344..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/NativeDriver.cs +++ /dev/null @@ -1,880 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections; -using System.Diagnostics; -using System.IO; -using MySql.Data.Common; -using MySql.Data.Types; -using System.Security.Cryptography.X509Certificates; -using MySql.Data.MySqlClient.Properties; -using System.Text; -#if !CF -using System.Net.Security; -using System.Security.Authentication; -using System.Globalization; -using System.Text; -#endif - -namespace MySql.Data.MySqlClient -{ - /// - /// Summary description for Driver. - /// - internal class NativeDriver : IDriver - { - private DBVersion version; - private int threadId; - protected String encryptionSeed; - protected ServerStatusFlags serverStatus; - protected MySqlStream stream; - protected Stream baseStream; - private BitArray nullMap; - private MySqlPacket packet; - private ClientFlags connectionFlags; - private Driver owner; - private int warnings; - - public NativeDriver(Driver owner) - { - this.owner = owner; - threadId = -1; - } - - public ClientFlags Flags - { - get { return connectionFlags; } - } - - public int ThreadId - { - get { return threadId; } - } - - public DBVersion Version - { - get { return version; } - } - - public ServerStatusFlags ServerStatus - { - get { return serverStatus; } - } - - public int WarningCount - { - get { return warnings; } - } - - public MySqlPacket Packet - { - get { return packet; } - } - - private MySqlConnectionStringBuilder Settings - { - get { return owner.Settings; } - } - - private Encoding Encoding - { - get { return owner.Encoding; } - } - - private void HandleException(MySqlException ex) - { - if (ex.IsFatal) - owner.Close(); - } - - private void ReadOk(bool read) - { - try - { - if (read) - packet = stream.ReadPacket(); - byte marker = (byte) packet.ReadByte(); - if (marker != 0) - throw new MySqlException("Out of sync with server", true, null); - - packet.ReadFieldLength(); /* affected rows */ - packet.ReadFieldLength(); /* last insert id */ - if (packet.HasMoreData) - { - serverStatus = (ServerStatusFlags) packet.ReadInteger(2); - packet.ReadInteger(2); /* warning count */ - if (packet.HasMoreData) - { - packet.ReadLenString(); /* message */ - } - } - } - catch (MySqlException ex) - { - HandleException(ex); - throw; - } - } - - /// - /// Sets the current database for the this connection - /// - /// - public void SetDatabase(string dbName) - { - byte[] dbNameBytes = Encoding.GetBytes(dbName); - - packet.Clear(); - packet.WriteByte((byte)DBCmd.INIT_DB); - packet.Write(dbNameBytes); - ExecutePacket(packet); - - ReadOk(true); - } - - public void Configure() - { - stream.MaxPacketSize = (ulong)owner.MaxPacketSize; - stream.Encoding = Encoding; - } - - public void Open() - { - // connect to one of our specified hosts - try - { -#if !CF - if (Settings.ConnectionProtocol == MySqlConnectionProtocol.SharedMemory) - { - SharedMemoryStream str = new SharedMemoryStream(Settings.SharedMemoryName); - str.Open(Settings.ConnectionTimeout); - baseStream = str; - } - else - { -#endif - string pipeName = Settings.PipeName; - if (Settings.ConnectionProtocol != MySqlConnectionProtocol.NamedPipe) - pipeName = null; - StreamCreator sc = new StreamCreator(Settings.Server, Settings.Port, pipeName, - Settings.Keepalive); - baseStream = sc.GetStream(Settings.ConnectionTimeout); -#if !CF - } -#endif - } - catch (Exception ex) - { - throw new MySqlException(Resources.UnableToConnectToHost, - (int) MySqlErrorCode.UnableToConnectToHost, ex); - } - - if (baseStream == null) - throw new MySqlException(Resources.UnableToConnectToHost, - (int)MySqlErrorCode.UnableToConnectToHost); - - int maxSinglePacket = 255*255*255; - stream = new MySqlStream(baseStream, Encoding, false); - - stream.ResetTimeout((int)Settings.ConnectionTimeout*1000); - - // read off the welcome packet and parse out it's values - packet = stream.ReadPacket(); - int protocol = packet.ReadByte(); - string versionString = packet.ReadString(); - version = DBVersion.Parse(versionString); - if (!version.isAtLeast(4, 1, 1)) - throw new NotSupportedException(Resources.ServerTooOld); - threadId = packet.ReadInteger(4); - encryptionSeed = packet.ReadString(); - - maxSinglePacket = (256*256*256) - 1; - - // read in Server capabilities if they are provided - ClientFlags serverCaps = 0; - if (packet.HasMoreData) - serverCaps = (ClientFlags) packet.ReadInteger(2); - - /* New protocol with 16 bytes to describe server characteristics */ - owner.ConnectionCharSetIndex = (int)packet.ReadByte(); - - serverStatus = (ServerStatusFlags) packet.ReadInteger(2); - packet.Position += 13; - string seedPart2 = packet.ReadString(); - encryptionSeed += seedPart2; - - // based on our settings, set our connection flags - SetConnectionFlags(serverCaps); - - packet.Clear(); - packet.WriteInteger((int) connectionFlags, 4); - -#if !CF - if ((serverCaps & ClientFlags.SSL) ==0) - { - if ((Settings.SslMode != MySqlSslMode.None) - && (Settings.SslMode != MySqlSslMode.Preferred)) - { - // Client requires SSL connections. - string message = String.Format(Resources.NoServerSSLSupport, - Settings.Server); - throw new MySqlException(message); - } - } - else if (Settings.SslMode != MySqlSslMode.None) - { - stream.SendPacket(packet); - StartSSL(); - packet.Clear(); - packet.WriteInteger((int) connectionFlags, 4); - } -#endif - - packet.WriteInteger(maxSinglePacket, 4); - packet.WriteByte(8); - packet.Write(new byte[23]); - - Authenticate(); - - // if we are using compression, then we use our CompressedStream class - // to hide the ugliness of managing the compression - if ((connectionFlags & ClientFlags.COMPRESS) != 0) - stream = new MySqlStream(baseStream, Encoding, true); - - // give our stream the server version we are connected to. - // We may have some fields that are read differently based - // on the version of the server we are connected to. - packet.Version = version; - stream.MaxBlockSize = maxSinglePacket; - } - -#if !CF - - #region SSL - - /// - /// Retrieve client SSL certificates. Dependent on connection string - /// settings we use either file or store based certificates. - /// - private X509CertificateCollection GetClientCertificates() - { - X509CertificateCollection certs = new X509CertificateCollection(); - - // Check for file-based certificate - if (Settings.CertificateFile != null) - { - X509Certificate2 clientCert = new X509Certificate2(Settings.CertificateFile, - Settings.CertificatePassword); - certs.Add(clientCert); - return certs; - } - - if (Settings.CertificateStoreLocation == MySqlCertificateStoreLocation.None) - return certs; - - StoreLocation location = - (Settings.CertificateStoreLocation == MySqlCertificateStoreLocation.CurrentUser) ? - StoreLocation.CurrentUser : StoreLocation.LocalMachine; - - // Check for store-based certificate - X509Store store = new X509Store(StoreName.My, location); - store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); - - - if (Settings.CertificateThumbprint == null) - { - // Return all certificates from the store. - certs.AddRange(store.Certificates); - return certs; - } - - // Find certificate with given thumbprint - certs.AddRange(store.Certificates.Find(X509FindType.FindByThumbprint, - Settings.CertificateThumbprint, true)); - - if (certs.Count == 0) - { - throw new MySqlException("Certificate with Thumbprint " + - Settings.CertificateThumbprint + " not found"); - } - return certs; - } - - - private void StartSSL() - { - RemoteCertificateValidationCallback sslValidateCallback = - new RemoteCertificateValidationCallback(ServerCheckValidation); - SslStream ss = new SslStream(baseStream, true, sslValidateCallback, null); - X509CertificateCollection certs = GetClientCertificates(); - ss.AuthenticateAsClient(Settings.Server, certs, SslProtocols.Default, false); - baseStream = ss; - stream = new MySqlStream(ss, Encoding, false); - stream.SequenceByte = 2; - - } - - private bool ServerCheckValidation(object sender, X509Certificate certificate, - X509Chain chain, SslPolicyErrors sslPolicyErrors) - { - if (sslPolicyErrors == SslPolicyErrors.None) - return true; - - if (Settings.SslMode == MySqlSslMode.Preferred || - Settings.SslMode == MySqlSslMode.Required) - { - //Tolerate all certificate errors. - return true; - } - - if (Settings.SslMode == MySqlSslMode.VerifyCA && - sslPolicyErrors == SslPolicyErrors.RemoteCertificateNameMismatch) - { - // Tolerate name mismatch in certificate, if full validation is not requested. - return true; - } - - return false; - } - - - #endregion - -#endif - - #region Authentication - - /// - /// Return the appropriate set of connection flags for our - /// server capabilities and our user requested options. - /// - private void SetConnectionFlags(ClientFlags serverCaps) - { - // allow load data local infile - ClientFlags flags = ClientFlags.LOCAL_FILES; - - if (!Settings.UseAffectedRows) - flags |= ClientFlags.FOUND_ROWS; - - flags |= ClientFlags.PROTOCOL_41; - // Need this to get server status values - flags |= ClientFlags.TRANSACTIONS; - - // user allows/disallows batch statements - if (Settings.AllowBatch) - flags |= ClientFlags.MULTI_STATEMENTS; - - // We always allow multiple result sets - flags |= ClientFlags.MULTI_RESULTS; - - // if the server allows it, tell it that we want long column info - if ((serverCaps & ClientFlags.LONG_FLAG) != 0) - flags |= ClientFlags.LONG_FLAG; - - // if the server supports it and it was requested, then turn on compression - if ((serverCaps & ClientFlags.COMPRESS) != 0 && Settings.UseCompression) - flags |= ClientFlags.COMPRESS; - - flags |= ClientFlags.LONG_PASSWORD; // for long passwords - - // did the user request an interactive session? - if (Settings.InteractiveSession) - flags |= ClientFlags.INTERACTIVE; - - // if the server allows it and a database was specified, then indicate - // that we will connect with a database name - if ((serverCaps & ClientFlags.CONNECT_WITH_DB) != 0 && - Settings.Database != null && Settings.Database.Length > 0) - flags |= ClientFlags.CONNECT_WITH_DB; - - // if the server is requesting a secure connection, then we oblige - if ((serverCaps & ClientFlags.SECURE_CONNECTION) != 0) - flags |= ClientFlags.SECURE_CONNECTION; - - // if the server is capable of SSL and the user is requesting SSL - if ((serverCaps & ClientFlags.SSL) != 0 && Settings.SslMode != MySqlSslMode.None) - flags |= ClientFlags.SSL; - - // if the server supports output parameters, then we do too - //if ((serverCaps & ClientFlags.PS_MULTI_RESULTS) != 0) - flags |= ClientFlags.PS_MULTI_RESULTS; - - connectionFlags = flags; - } - - /// - /// Perform an authentication against a 4.1.1 server - /// - private void AuthenticateNew() - { - if ((connectionFlags & ClientFlags.SECURE_CONNECTION) == 0) - AuthenticateOld(); - - packet.Write(Crypt.Get411Password(Settings.Password, encryptionSeed)); - if ((connectionFlags & ClientFlags.CONNECT_WITH_DB) != 0 && Settings.Database != null) - packet.WriteString(Settings.Database); - - stream.SendPacket(packet); - - // this result means the server wants us to send the password using - // old encryption - packet = stream.ReadPacket(); - if (packet.IsLastPacket) - { - packet.Clear(); - packet.WriteString(Crypt.EncryptPassword( - Settings.Password, encryptionSeed.Substring(0, 8), true)); - stream.SendPacket(packet); - ReadOk(true); - } - else - ReadOk(false); - } - - private void AuthenticateOld() - { - packet.WriteString(Crypt.EncryptPassword( - Settings.Password, encryptionSeed, true)); - if ((connectionFlags & ClientFlags.CONNECT_WITH_DB) != 0 && Settings.Database != null) - packet.WriteString(Settings.Database); - - stream.SendPacket(packet); - ReadOk(true); - } - - public void Authenticate() - { - // write the user id to the auth packet - packet.WriteString(Settings.UserID); - AuthenticateNew(); - } - - #endregion - - public void Reset() - { - warnings = 0; - stream.SequenceByte = 0; - packet.Clear(); - packet.WriteByte((byte)DBCmd.CHANGE_USER); - Authenticate(); - } - - /// - /// Query is the method that is called to send all queries to the server - /// - public void SendQuery(MySqlPacket queryPacket) - { - warnings = 0; - queryPacket.Buffer[4] = (byte)DBCmd.QUERY; - ExecutePacket(queryPacket); - // the server will respond in one of several ways with the first byte indicating - // the type of response. - // 0 == ok packet. This indicates non-select queries - // 0xff == error packet. This is handled in stream.OpenPacket - // > 0 = number of columns in select query - // We don't actually read the result here since a single query can generate - // multiple resultsets and we don't want to duplicate code. See ReadResult - // Instead we set our internal server status flag to indicate that we have a query waiting. - // This flag will be maintained by ReadResult - serverStatus |= ServerStatusFlags.AnotherQuery; - } - - public void Close(bool isOpen) - { - try - { - if (isOpen) - { - try - { - packet.Clear(); - packet.WriteByte((byte)DBCmd.QUIT); - ExecutePacket(packet); - } - catch (Exception) - { - // Eat exception here. We should try to closing - // the stream anyway. - } - } - - if (stream != null) - stream.Close(); - stream = null; - } - catch (Exception) - { - // we are just going to eat any exceptions - // generated here - } - } - - public bool Ping() - { - try - { - packet.Clear(); - packet.WriteByte((byte)DBCmd.PING); - ExecutePacket(packet); - ReadOk(true); - return true; - } - catch (Exception) - { - return false; - } - } - - public int GetResult(ref int affectedRow, ref int insertedId) - { - try - { - packet = stream.ReadPacket(); - } - catch (TimeoutException) - { - // Do not reset serverStatus, allow to reenter, e.g when - // ResultSet is closed. - throw; - } - catch (Exception) - { - serverStatus = 0; - throw; - } - - int fieldCount = (int)packet.ReadFieldLength(); - if (-1 == fieldCount) - { - string filename = packet.ReadString(); - SendFileToServer(filename); - - return GetResult(ref affectedRow, ref insertedId); - } - else if (fieldCount == 0) - { - // the code to read last packet will set these server status vars - // again if necessary. - serverStatus &= ~(ServerStatusFlags.AnotherQuery | - ServerStatusFlags.MoreResults); - affectedRow = (int)packet.ReadFieldLength(); - insertedId = (int)packet.ReadFieldLength(); - - serverStatus = (ServerStatusFlags)packet.ReadInteger(2); - warnings += packet.ReadInteger(2); - if (packet.HasMoreData) - { - packet.ReadLenString(); //TODO: server message - } - } - return fieldCount; - } - - /// - /// Sends the specified file to the server. - /// This supports the LOAD DATA LOCAL INFILE - /// - /// - private void SendFileToServer(string filename) - { - byte[] buffer = new byte[8196]; - - long len = 0; - try - { - using (FileStream fs = new FileStream(filename, FileMode.Open, - FileAccess.Read)) - { - len = fs.Length; - while (len > 0) - { - int count = fs.Read(buffer, 4, (int)(len > 8192 ? 8192 : len)); - stream.SendEntirePacketDirectly(buffer, count); - len -= count; - } - stream.SendEntirePacketDirectly(buffer, 0); - } - } - catch (Exception ex) - { - throw new MySqlException("Error during LOAD DATA LOCAL INFILE", ex); - } - } - - private void ReadNullMap(int fieldCount) - { - // if we are binary, then we need to load in our null bitmap - nullMap = null; - byte[] nullMapBytes = new byte[(fieldCount + 9)/8]; - packet.ReadByte(); - packet.Read(nullMapBytes, 0, nullMapBytes.Length); - nullMap = new BitArray(nullMapBytes); - } - - public IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue valObject) - { - long length = -1; - bool isNull; - - if (nullMap != null) - isNull = nullMap[index + 2]; - else - { - length = packet.ReadFieldLength(); - isNull = length == -1; - } - - packet.Encoding = field.Encoding; - packet.Version = version; - return valObject.ReadValue(packet, length, isNull); - } - - public void SkipColumnValue(IMySqlValue valObject) - { - int length = -1; - if (nullMap == null) - { - length = packet.ReadFieldLength(); - if (length == -1) return; - } - if (length > -1) - packet.Position += length; - else - valObject.SkipValue(packet); - } - - public void GetColumnsData(MySqlField[] columns) - { - for (int i = 0; i < columns.Length; i++) - GetColumnData(columns[i]); - ReadEOF(); - } - - private void GetColumnData(MySqlField field) - { - stream.Encoding = Encoding; - packet = stream.ReadPacket(); - field.Encoding = Encoding; - field.CatalogName = packet.ReadLenString(); - field.DatabaseName = packet.ReadLenString(); - field.TableName = packet.ReadLenString(); - field.RealTableName = packet.ReadLenString(); - field.ColumnName = packet.ReadLenString(); - field.OriginalColumnName = packet.ReadLenString(); - packet.ReadByte(); - field.CharacterSetIndex = packet.ReadInteger(2); - field.ColumnLength = packet.ReadInteger(4); - MySqlDbType type = (MySqlDbType)packet.ReadByte(); - ColumnFlags colFlags; - if ((connectionFlags & ClientFlags.LONG_FLAG) != 0) - colFlags = (ColumnFlags)packet.ReadInteger(2); - else - colFlags = (ColumnFlags)packet.ReadByte(); - field.Scale = (byte)packet.ReadByte(); - - if (packet.HasMoreData) - { - packet.ReadInteger(2); // reserved - } - - if (type == MySqlDbType.Decimal || type == MySqlDbType.NewDecimal) - { - field.Precision = (byte)(field.ColumnLength - (int)field.Scale); - if ((colFlags & ColumnFlags.UNSIGNED) != 0) - field.Precision++; - } - - field.SetTypeAndFlags(type, colFlags); - } - - private void ExecutePacket(MySqlPacket packetToExecute) - { - try - { - warnings = 0; - stream.SequenceByte = 0; - stream.SendPacket(packetToExecute); - } - catch (MySqlException ex) - { - HandleException(ex); - throw; - } - } - - public void ExecuteStatement(MySqlPacket packetToExecute) - { - warnings = 0; - packetToExecute.Buffer[4] = (byte)DBCmd.EXECUTE; - ExecutePacket(packetToExecute); - serverStatus |= ServerStatusFlags.AnotherQuery; - } - - private void CheckEOF() - { - if (!packet.IsLastPacket) - throw new MySqlException("Expected end of data packet"); - - packet.ReadByte(); // read off the 254 - - if (packet.HasMoreData) - { - warnings += packet.ReadInteger(2); - serverStatus = (ServerStatusFlags)packet.ReadInteger(2); - - // if we are at the end of this cursor based resultset, then we remove - // the last row sent status flag so our next fetch doesn't abort early - // and we remove this command result from our list of active CommandResult objects. - // if ((serverStatus & ServerStatusFlags.LastRowSent) != 0) - // { - // serverStatus &= ~ServerStatusFlags.LastRowSent; - // commandResults.Remove(lastCommandResult); - // } - } - } - - private void ReadEOF() - { - packet = stream.ReadPacket(); - CheckEOF(); - } - - public int PrepareStatement(string sql, ref MySqlField[] parameters) - { - //TODO: check this - //ClearFetchedRow(); - - packet.Length = sql.Length*4 + 5; - byte[] buffer = packet.Buffer; - int len = Encoding.GetBytes(sql, 0, sql.Length, packet.Buffer, 5); - packet.Position = len + 5; - buffer[4] = (byte)DBCmd.PREPARE; - ExecutePacket(packet); - - packet = stream.ReadPacket(); - - int marker = packet.ReadByte(); - if (marker != 0) - throw new MySqlException("Expected prepared statement marker"); - - int statementId = packet.ReadInteger(4); - int numCols = packet.ReadInteger(2); - int numParams = packet.ReadInteger(2); - //TODO: find out what this is needed for - packet.ReadInteger(3); - if (numParams > 0) - { - parameters = owner.GetColumns(numParams); - // we set the encoding for each parameter back to our connection encoding - // since we can't trust what is coming back from the server - for (int i = 0; i < parameters.Length; i++) - parameters[i].Encoding = Encoding; - } - - if (numCols > 0) - { - while (numCols-- > 0) - { - packet = stream.ReadPacket(); - //TODO: handle streaming packets - } - - ReadEOF(); - } - - return statementId; - } - - // private void ClearFetchedRow() - // { - // if (lastCommandResult == 0) return; - - //TODO - /* CommandResult result = (CommandResult)commandResults[lastCommandResult]; - result.ReadRemainingColumns(); - - stream.OpenPacket(); - if (! stream.IsLastPacket) - throw new MySqlException("Cursor reading out of sync"); - - ReadEOF(false); - lastCommandResult = 0;*/ - // } - - /// - /// FetchDataRow is the method that the data reader calls to see if there is another - /// row to fetch. In the non-prepared mode, it will simply read the next data packet. - /// In the prepared mode (statementId > 0), it will - /// - public bool FetchDataRow(int statementId, int columns) - { - /* ClearFetchedRow(); - - if (!commandResults.ContainsKey(statementId)) return false; - - if ( (serverStatus & ServerStatusFlags.LastRowSent) != 0) - return false; - - stream.StartPacket(9, true); - stream.WriteByte((byte)DBCmd.FETCH); - stream.WriteInteger(statementId, 4); - stream.WriteInteger(1, 4); - stream.Flush(); - - lastCommandResult = statementId; - */ - packet = stream.ReadPacket(); - if (packet.IsLastPacket) - { - CheckEOF(); - return false; - } - nullMap = null; - if (statementId > 0) - ReadNullMap(columns); - - return true; - } - - public void CloseStatement(int statementId) - { - packet.Clear(); - packet.WriteByte((byte)DBCmd.CLOSE_STMT); - packet.WriteInteger((long)statementId, 4); - stream.SequenceByte = 0; - stream.SendPacket(packet); - } - - /// - /// Execution timeout, in milliseconds. When the accumulated time for network IO exceeds this value - /// TimeoutException is thrown. This timeout needs to be reset for every new command - /// - /// - public void ResetTimeout(int timeout) - { - if (stream != null) - stream.ResetTimeout(timeout); - } - - } - -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/PerformanceMonitor.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/PerformanceMonitor.cs deleted file mode 100644 index 417f6a1..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/PerformanceMonitor.cs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Diagnostics; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.MySqlClient -{ - internal class PerformanceMonitor - { - private MySqlConnection connection; - private static PerformanceCounter procedureHardQueries; - private static PerformanceCounter procedureSoftQueries; - - public PerformanceMonitor(MySqlConnection connection) - { - this.connection = connection; - - string categoryName = Resources.PerfMonCategoryName; - - if (connection.Settings.UsePerformanceMonitor && procedureHardQueries == null) - { - try - { - procedureHardQueries = new PerformanceCounter(categoryName, - "HardProcedureQueries", false); - procedureSoftQueries = new PerformanceCounter(categoryName, - "SoftProcedureQueries", false); - } - catch (Exception ex) - { - MySqlTrace.LogError(connection.ServerThread, ex.Message); - } - } - } - -#if DEBUG - private void EnsurePerfCategoryExist() - { - CounterCreationDataCollection ccdc = new CounterCreationDataCollection(); - CounterCreationData ccd = new CounterCreationData(); - ccd.CounterType = PerformanceCounterType.NumberOfItems32; - ccd.CounterName = "HardProcedureQueries"; - ccdc.Add(ccd); - - ccd = new CounterCreationData(); - ccd.CounterType = PerformanceCounterType.NumberOfItems32; - ccd.CounterName = "SoftProcedureQueries"; - ccdc.Add(ccd); - - if (!PerformanceCounterCategory.Exists(Resources.PerfMonCategoryName)) - PerformanceCounterCategory.Create(Resources.PerfMonCategoryName, null, ccdc); - } -#endif - - public void AddHardProcedureQuery() - { - if (!connection.Settings.UsePerformanceMonitor || - procedureHardQueries == null) return; - procedureHardQueries.Increment(); - } - - public void AddSoftProcedureQuery() - { - if (!connection.Settings.UsePerformanceMonitor || - procedureSoftQueries == null) return; - procedureSoftQueries.Increment(); - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/PreparableStatement.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/PreparableStatement.cs deleted file mode 100644 index 5315141..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/PreparableStatement.cs +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections; -using System.Text; -using System.Collections.Generic; -using MySql.Data.MySqlClient.Properties; -using System.Data; - -namespace MySql.Data.MySqlClient -{ - /// - /// Summary description for PreparedStatement. - /// - internal class PreparableStatement : Statement - { - private int executionCount; - private int statementId; - BitArray nullMap; - List parametersToSend = new List(); - MySqlPacket packet; - int dataPosition; - int nullMapPosition; - - public PreparableStatement(MySqlCommand command, string text) - : base(command, text) - { - } - - #region Properties - - public int ExecutionCount - { - get { return executionCount; } - set { executionCount = value; } - } - - public bool IsPrepared - { - get { return statementId > 0; } - } - - public int StatementId - { - get { return statementId; } - } - - #endregion - - public virtual void Prepare() - { - // strip out names from parameter markers - string text; - List parameter_names = PrepareCommandText(out text); - - // ask our connection to send the prepare command - MySqlField[] paramList = null; - statementId = Driver.PrepareStatement(text, ref paramList); - - // now we need to assign our field names since we stripped them out - // for the prepare - for (int i = 0; i < parameter_names.Count; i++) - { - //paramList[i].ColumnName = (string) parameter_names[i]; - string parameterName = (string)parameter_names[i]; - int index = Parameters.IndexOf(parameterName); - if (index == -1) - throw new InvalidOperationException( - String.Format(Resources.ParameterNotFoundDuringPrepare, parameterName)); - MySqlParameter p = Parameters[index]; - p.Encoding = paramList[i].Encoding; - parametersToSend.Add(p); - } - - // now prepare our null map - int numNullBytes = 0; - if (paramList != null && paramList.Length > 0) - { - nullMap = new BitArray(paramList.Length); - numNullBytes = (nullMap.Count + 7) / 8; - } - - packet = new MySqlPacket(Driver.Encoding); - - // write out some values that do not change run to run - packet.WriteByte(0); - packet.WriteInteger(statementId, 4); - packet.WriteByte((byte)0); // flags; always 0 for 4.1 - packet.WriteInteger(1, 4); // interation count; 1 for 4.1 - nullMapPosition = packet.Position; - packet.Position += numNullBytes; // leave room for our null map - packet.WriteByte(1); // rebound flag - // write out the parameter types - foreach (MySqlParameter p in parametersToSend) - packet.WriteInteger(p.GetPSType(), 2); - dataPosition = packet.Position; - } - - public override void Execute() - { - // if we are not prepared, then call down to our base - if (!IsPrepared) - { - base.Execute(); - return; - } - - //TODO: support long data here - // create our null bitmap - - // we check this because Mono doesn't ignore the case where nullMapBytes - // is zero length. -// if (nullMapBytes.Length > 0) - // { - // byte[] bits = packet.Buffer; - // nullMap.CopyTo(bits, - // nullMap.CopyTo(nullMapBytes, 0); - - // start constructing our packet -// if (Parameters.Count > 0) - // nullMap.CopyTo(packet.Buffer, nullMapPosition); - //if (parameters != null && parameters.Count > 0) - //else - // packet.WriteByte( 0 ); - //TODO: only send rebound if parms change - - // now write out all non-null values - packet.Position = dataPosition; - for (int i = 0; i < parametersToSend.Count; i++) - { - MySqlParameter p = parametersToSend[i]; - nullMap[i] = (p.Value == DBNull.Value || p.Value == null) || - p.Direction == ParameterDirection.Output; - if (nullMap[i]) continue; - packet.Encoding = p.Encoding; - p.Serialize(packet, true, Connection.Settings); - } - if (nullMap != null) - nullMap.CopyTo(packet.Buffer, nullMapPosition); - - executionCount++; - - Driver.ExecuteStatement(packet); - } - - public override bool ExecuteNext() - { - if (!IsPrepared) - return base.ExecuteNext(); - return false; - } - - /// - /// Prepares CommandText for use with the Prepare method - /// - /// Command text stripped of all paramter names - /// - /// Takes the output of TokenizeSql and creates a single string of SQL - /// that only contains '?' markers for each parameter. It also creates - /// the parameterMap array list that includes all the paramter names in the - /// order they appeared in the SQL - /// - private List PrepareCommandText(out string stripped_sql) - { - StringBuilder newSQL = new StringBuilder(); - List parameterMap = new List(); - - int startPos = 0; - string sql = ResolvedCommandText; - MySqlTokenizer tokenizer = new MySqlTokenizer(sql); - string parameter = tokenizer.NextParameter(); - while (parameter != null) - { - newSQL.Append(sql.Substring(startPos, tokenizer.StartIndex - startPos)); - newSQL.Append("?"); - parameterMap.Add(parameter); - startPos = tokenizer.StopIndex; - parameter = tokenizer.NextParameter(); - } - newSQL.Append(sql.Substring(startPos)); - stripped_sql = newSQL.ToString(); - return parameterMap; - } - - public virtual void CloseStatement() - { - if (!IsPrepared) return; - - Driver.CloseStatement(statementId); - statementId = 0; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ProcedureCache.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ProcedureCache.cs deleted file mode 100644 index bac5752..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ProcedureCache.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections; -using System.Data; -using System.Collections.Generic; -using MySql.Data.MySqlClient.Properties; -using System.Diagnostics; - -namespace MySql.Data.MySqlClient -{ - internal class ProcedureCache - { - private Hashtable procHash; - private Queue hashQueue; - private int maxSize; - - public ProcedureCache(int size) - { - maxSize = size; - hashQueue = new Queue(maxSize); - procHash = new Hashtable(maxSize); - } - - public DataSet GetProcedure(MySqlConnection conn, string spName) - { - int hash = spName.GetHashCode(); - - DataSet ds = null; - lock (procHash.SyncRoot) - { - ds = (DataSet)procHash[hash]; - } - if (ds == null) - { - ds = AddNew(conn, spName); -#if !CF - conn.PerfMonitor.AddHardProcedureQuery(); -#endif - MySqlTrace.LogInformation(conn.ServerThread, - String.Format(Resources.HardProcQuery, spName)); - } - else - { -#if !CF - conn.PerfMonitor.AddSoftProcedureQuery(); -#endif - MySqlTrace.LogInformation(conn.ServerThread, - String.Format(Resources.SoftProcQuery, spName)); - } - return ds; - } - - private DataSet AddNew(MySqlConnection connection, string spName) - { - DataSet procData = GetProcData(connection, spName); - if (maxSize > 0) - { - int hash = spName.GetHashCode(); - lock (procHash.SyncRoot) - { - if (procHash.Keys.Count >= maxSize) - TrimHash(); - if (!procHash.ContainsKey(hash)) - { - procHash[hash] = procData; - hashQueue.Enqueue(hash); - } - } - } - return procData; - } - - private void TrimHash() - { - int oldestHash = hashQueue.Dequeue(); - procHash.Remove(oldestHash); - } - - private static DataSet GetProcData(MySqlConnection connection, string spName) - { - string schema = String.Empty; - string name = spName; - - int dotIndex = spName.IndexOf("."); - if (dotIndex != -1) - { - schema = spName.Substring(0, dotIndex); - name = spName.Substring(dotIndex + 1, spName.Length - dotIndex - 1); - } - - string[] restrictions = new string[4]; - restrictions[1] = schema.Length > 0 ? schema : connection.CurrentDatabase(); - restrictions[2] = name; - DataTable procTable = connection.GetSchema("procedures", restrictions); - if (procTable.Rows.Count > 1) - throw new MySqlException(Resources.ProcAndFuncSameName); - if (procTable.Rows.Count == 0) - throw new MySqlException(String.Format(Resources.InvalidProcName, name, schema)); - - DataSet ds = new DataSet(); - ds.Tables.Add(procTable); - - // we don't use GetSchema here because that would cause another - // query of procedures and we don't need that since we already - // know the procedure we care about. - ISSchemaProvider isp = new ISSchemaProvider(connection); - string[] rest = isp.CleanRestrictions(restrictions); - try - { - DataTable parametersTable = isp.GetProcedureParameters(rest, procTable); - ds.Tables.Add(parametersTable); - } - catch (Exception) { } - - return ds; - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ResultSet.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ResultSet.cs deleted file mode 100644 index b44c83a..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/ResultSet.cs +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright (c) 2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections; -using System.Data; -using MySql.Data.MySqlClient.Properties; -using MySql.Data.Types; -using System.Diagnostics; - -namespace MySql.Data.MySqlClient -{ - internal class ResultSet - { - private Driver driver; - private bool hasRows; - private bool[] uaFieldsUsed; - private MySqlField[] fields; - private IMySqlValue[] values; - private Hashtable fieldHashCS; - private Hashtable fieldHashCI; - private int rowIndex; - private bool readDone; - private bool isSequential; - private int seqIndex; - private bool isOutputParameters; - private int affectedRows; - private int insertedId; - private int statementId; - private int totalRows; - private int skippedRows; - - public ResultSet(int affectedRows, int insertedId) - { - this.affectedRows = affectedRows; - this.insertedId = insertedId; - readDone = true; - } - - public ResultSet(Driver d, int statementId, int numCols) - { - affectedRows = -1; - insertedId = -1; - driver = d; - this.statementId = statementId; - rowIndex = -1; - LoadColumns(numCols); - isOutputParameters = driver.HasStatus(ServerStatusFlags.OutputParameters); - hasRows = GetNextRow(); - readDone = !hasRows; - } - - #region Properties - - public bool HasRows - { - get { return hasRows; } - } - - public int Size - { - get { return fields == null ? 0 : fields.Length; } - } - - public MySqlField[] Fields - { - get { return fields; } - } - - public IMySqlValue[] Values - { - get { return values; } - } - - public bool IsOutputParameters - { - get { return isOutputParameters; } - set { isOutputParameters = value; } - } - - public int AffectedRows - { - get { return affectedRows; } - } - - public int InsertedId - { - get { return insertedId; } - } - - public int TotalRows - { - get { return totalRows; } - } - - public int SkippedRows - { - get { return skippedRows; } - } - - #endregion - - /// - /// return the ordinal for the given column name - /// - /// - /// - public int GetOrdinal(string name) - { - // first we try a quick hash lookup - object ordinal = fieldHashCS[name]; - if (ordinal != null) - return (int)ordinal; - - // ok that failed so we use our CI hash - ordinal = fieldHashCI[name]; - if (ordinal != null) - return (int)ordinal; - - // Throw an exception if the ordinal cannot be found. - throw new IndexOutOfRangeException( - String.Format(Resources.CouldNotFindColumnName, name)); - } - - /// - /// Retrieve the value as the given column index - /// - /// The column value to retrieve - /// The value as the given column - public IMySqlValue this[int index] - { - get - { - if (rowIndex < 0) - throw new MySqlException(Resources.AttemptToAccessBeforeRead); - - // keep count of how many columns we have left to access - uaFieldsUsed[index] = true; - - if (isSequential && index != seqIndex) - { - if (index < seqIndex) - throw new MySqlException(Resources.ReadingPriorColumnUsingSeqAccess); - while (seqIndex < (index - 1)) - driver.SkipColumnValue(values[++seqIndex]); - values[index] = driver.ReadColumnValue(index, fields[index], values[index]); - seqIndex = index; - } - - return values[index]; - } - } - - private bool GetNextRow() - { - bool fetched = driver.FetchDataRow(statementId, Size); - if (fetched) - totalRows++; - return fetched; - } - - - public bool NextRow(CommandBehavior behavior) - { - if (readDone) return false; - - if ((behavior & CommandBehavior.SingleRow) != 0 && rowIndex == 0) - return false; - - isSequential = (behavior & CommandBehavior.SequentialAccess) != 0; - seqIndex = -1; - - // if we are at row index >= 0 then we need to fetch the data row and load it - if (rowIndex >= 0) - { - bool fetched = false; - try - { - fetched = GetNextRow(); - } - catch (MySqlException ex) - { - if (ex.Number == 1317) fetched = false; - } - - if (!fetched) - { - readDone = true; - return false; - } - } - - if (!isSequential) ReadColumnData(false); - rowIndex++; - return true; - } - - /// - /// Closes the current resultset, dumping any data still on the wire - /// - public void Close() - { - if (readDone) return; - - // if we have rows but the user didn't read the first one then mark it as skipped - if (HasRows && rowIndex == -1) - skippedRows++; - while (driver.SkipDataRow()) - { - totalRows++; - skippedRows++; - } - readDone = true; - } - - public bool FieldRead(int index) - { - Debug.Assert(Size > index); - return uaFieldsUsed[index]; - } - - public void SetValueObject(int i, IMySqlValue valueObject) - { - Debug.Assert(values != null); - Debug.Assert(i < values.Length); - values[i] = valueObject; - } - - /// - /// Loads the column metadata for the current resultset - /// - private void LoadColumns(int numCols) - { - fields = driver.GetColumns(numCols); - - values = new IMySqlValue[numCols]; - uaFieldsUsed = new bool[numCols]; - fieldHashCS = new Hashtable(); - fieldHashCI = new Hashtable(StringComparer.InvariantCultureIgnoreCase); - - for (int i = 0; i < fields.Length; i++) - { - string columnName = fields[i].ColumnName; - if (!fieldHashCS.ContainsKey(columnName)) - fieldHashCS.Add(columnName, i); - if (!fieldHashCI.ContainsKey(columnName)) - fieldHashCI.Add(columnName, i); - values[i] = fields[i].GetValueObject(); - } - } - - private void ReadColumnData(bool outputParms) - { - for (int i = 0; i < Size; i++) - values[i] = driver.ReadColumnValue(i, fields[i], values[i]); - if (outputParms) - { - bool rowExists = driver.FetchDataRow(statementId, fields.Length); - rowIndex = 0; - if (rowExists) - throw new MySqlException(Resources.MoreThanOneOPRow); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Runtime.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Runtime.cs deleted file mode 100644 index 3aa045f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Runtime.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace MySql.Web.Security -{ - internal static class Runtime - { - private static bool inited; - private static bool isMono; - - public static bool IsMono - { - get - { - if (!inited) - Init(); - return isMono; - } - } - - private static void Init() - { - Type t = Type.GetType("Mono.Runtime"); - isMono = t != null; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/SchemaProvider.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/SchemaProvider.cs deleted file mode 100644 index 4aa0e5c..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/SchemaProvider.cs +++ /dev/null @@ -1,1030 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Data.Common; -using System.Globalization; -using System.IO; -using System.Reflection; -using System.Text; -using MySql.Data.Common; -using MySql.Data.Types; -using System.Collections.Specialized; -using System.Collections; -using System.Text.RegularExpressions; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.MySqlClient -{ - internal class SchemaProvider - { - protected MySqlConnection connection; - public static string MetaCollection = "MetaDataCollections"; - - public SchemaProvider(MySqlConnection connectionToUse) - { - connection = connectionToUse; - } - - public virtual DataTable GetSchema(string collection, String[] restrictions) - { - if (connection.State != ConnectionState.Open) - throw new MySqlException("GetSchema can only be called on an open connection."); - - collection = collection.ToUpper(CultureInfo.InvariantCulture); - - DataTable dt = GetSchemaInternal(collection, restrictions); - - if (dt == null) - throw new MySqlException("Invalid collection name"); - return dt; - } - - public virtual DataTable GetDatabases(string[] restrictions) - { - Regex regex = null; - int caseSetting = Int32.Parse(connection.driver.Property("lower_case_table_names")); - - string sql = "SHOW DATABASES"; - - // if lower_case_table_names is zero, then case lookup should be sensitive - // so we can use LIKE to do the matching. - if (caseSetting == 0) - { - if (restrictions != null && restrictions.Length >= 1) - sql = sql + " LIKE '" + restrictions[0] + "'"; - } - else if (restrictions != null && restrictions.Length >= 1 && restrictions[0] != null) - regex = new Regex(restrictions[0], RegexOptions.IgnoreCase); - - MySqlDataAdapter da = new MySqlDataAdapter(sql, connection); - DataTable dt = new DataTable(); - da.Fill(dt); - - DataTable table = new DataTable("Databases"); - table.Columns.Add("CATALOG_NAME", typeof (string)); - table.Columns.Add("SCHEMA_NAME", typeof (string)); - - foreach (DataRow row in dt.Rows) - { - if (caseSetting != 0 && regex != null && - !regex.Match(row[0].ToString()).Success) continue; - - DataRow newRow = table.NewRow(); - newRow[1] = row[0]; - table.Rows.Add(newRow); - } - - return table; - } - - public virtual DataTable GetTables(string[] restrictions) - { - DataTable dt = new DataTable("Tables"); - dt.Columns.Add("TABLE_CATALOG", typeof (string)); - dt.Columns.Add("TABLE_SCHEMA", typeof (string)); - dt.Columns.Add("TABLE_NAME", typeof (string)); - dt.Columns.Add("TABLE_TYPE", typeof (string)); - dt.Columns.Add("ENGINE", typeof (string)); - dt.Columns.Add("VERSION", typeof (ulong)); - dt.Columns.Add("ROW_FORMAT", typeof (string)); - dt.Columns.Add("TABLE_ROWS", typeof (ulong)); - dt.Columns.Add("AVG_ROW_LENGTH", typeof (ulong)); - dt.Columns.Add("DATA_LENGTH", typeof (ulong)); - dt.Columns.Add("MAX_DATA_LENGTH", typeof (ulong)); - dt.Columns.Add("INDEX_LENGTH", typeof (ulong)); - dt.Columns.Add("DATA_FREE", typeof (ulong)); - dt.Columns.Add("AUTO_INCREMENT", typeof (ulong)); - dt.Columns.Add("CREATE_TIME", typeof (DateTime)); - dt.Columns.Add("UPDATE_TIME", typeof (DateTime)); - dt.Columns.Add("CHECK_TIME", typeof (DateTime)); - dt.Columns.Add("TABLE_COLLATION", typeof (string)); - dt.Columns.Add("CHECKSUM", typeof (ulong)); - dt.Columns.Add("CREATE_OPTIONS", typeof (string)); - dt.Columns.Add("TABLE_COMMENT", typeof (string)); - - // we have to new up a new restriction array here since - // GetDatabases takes the database in the first slot - string[] dbRestriction = new string[4]; - if (restrictions != null && restrictions.Length >= 2) - dbRestriction[0] = restrictions[1]; - DataTable databases = GetDatabases(dbRestriction); - - if (restrictions != null) - Array.Copy(restrictions, dbRestriction, - Math.Min(dbRestriction.Length, restrictions.Length)); - - foreach (DataRow db in databases.Rows) - { - dbRestriction[1] = db["SCHEMA_NAME"].ToString(); - FindTables(dt, dbRestriction); - } - return dt; - } - - public virtual DataTable GetColumns(string[] restrictions) - { - DataTable dt = new DataTable("Columns"); - dt.Columns.Add("TABLE_CATALOG", typeof (string)); - dt.Columns.Add("TABLE_SCHEMA", typeof (string)); - dt.Columns.Add("TABLE_NAME", typeof (string)); - dt.Columns.Add("COLUMN_NAME", typeof (string)); - dt.Columns.Add("ORDINAL_POSITION", typeof (ulong)); - dt.Columns.Add("COLUMN_DEFAULT", typeof (string)); - dt.Columns.Add("IS_NULLABLE", typeof (string)); - dt.Columns.Add("DATA_TYPE", typeof (string)); - dt.Columns.Add("CHARACTER_MAXIMUM_LENGTH", typeof (ulong)); - dt.Columns.Add("CHARACTER_OCTET_LENGTH", typeof (ulong)); - dt.Columns.Add("NUMERIC_PRECISION", typeof (ulong)); - dt.Columns.Add("NUMERIC_SCALE", typeof (ulong)); - dt.Columns.Add("CHARACTER_SET_NAME", typeof (string)); - dt.Columns.Add("COLLATION_NAME", typeof (string)); - dt.Columns.Add("COLUMN_TYPE", typeof (string)); - dt.Columns.Add("COLUMN_KEY", typeof (string)); - dt.Columns.Add("EXTRA", typeof (string)); - dt.Columns.Add("PRIVILEGES", typeof (string)); - dt.Columns.Add("COLUMN_COMMENT", typeof (string)); - - // we don't allow restricting on table type here - string columnName = null; - if (restrictions != null && restrictions.Length == 4) - { - columnName = restrictions[3]; - restrictions[3] = null; - } - DataTable tables = GetTables(restrictions); - - foreach (DataRow row in tables.Rows) - LoadTableColumns(dt, row["TABLE_SCHEMA"].ToString(), - row["TABLE_NAME"].ToString(), columnName); - - return dt; - } - - private void LoadTableColumns(DataTable dt, string schema, - string tableName, string columnRestriction) - { - string sql = String.Format("SHOW FULL COLUMNS FROM `{0}`.`{1}`", - schema, tableName); - MySqlCommand cmd = new MySqlCommand(sql, connection); - - int pos = 1; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - string colName = reader.GetString(0); - if (columnRestriction != null && colName != columnRestriction) - continue; - DataRow row = dt.NewRow(); - row["TABLE_CATALOG"] = DBNull.Value; - row["TABLE_SCHEMA"] = schema; - row["TABLE_NAME"] = tableName; - row["COLUMN_NAME"] = colName; - row["ORDINAL_POSITION"] = pos++; - row["COLUMN_DEFAULT"] = reader.GetValue(5); - row["IS_NULLABLE"] = reader.GetString(3); - row["DATA_TYPE"] = reader.GetString(1); - row["CHARACTER_MAXIMUM_LENGTH"] = DBNull.Value; - row["CHARACTER_OCTET_LENGTH"] = DBNull.Value; - row["NUMERIC_PRECISION"] = DBNull.Value; - row["NUMERIC_SCALE"] = DBNull.Value; - row["CHARACTER_SET_NAME"] = reader.GetValue(2); - row["COLLATION_NAME"] = row["CHARACTER_SET_NAME"]; - row["COLUMN_TYPE"] = reader.GetString(1); - row["COLUMN_KEY"] = reader.GetString(4); - row["EXTRA"] = reader.GetString(6); - row["PRIVILEGES"] = reader.GetString(7); - row["COLUMN_COMMENT"] = reader.GetString(8); - ParseColumnRow(row); - dt.Rows.Add(row); - } - } - } - - private static void ParseColumnRow(DataRow row) - { - // first parse the character set name - string charset = row["CHARACTER_SET_NAME"].ToString(); - int index = charset.IndexOf('_'); - if (index != -1) - row["CHARACTER_SET_NAME"] = charset.Substring(0, index); - - // now parse the data type - string dataType = row["DATA_TYPE"].ToString(); - index = dataType.IndexOf('('); - if (index == -1) - return; - row["DATA_TYPE"] = dataType.Substring(0, index); - int stop = dataType.IndexOf(')', index); - string dataLen = dataType.Substring(index + 1, stop - (index + 1)); - string lowerType = row["DATA_TYPE"].ToString().ToLower(); - if (lowerType == "char" || lowerType == "varchar") - row["CHARACTER_MAXIMUM_LENGTH"] = dataLen; - else if (lowerType == "real" || lowerType == "decimal") - { - string[] lenparts = dataLen.Split(new char[] {','}); - row["NUMERIC_PRECISION"] = lenparts[0]; - if (lenparts.Length == 2) - row["NUMERIC_SCALE"] = lenparts[1]; - } - } - - public virtual DataTable GetIndexes(string[] restrictions) - { - DataTable dt = new DataTable("Indexes"); - dt.Columns.Add("INDEX_CATALOG", typeof (string)); - dt.Columns.Add("INDEX_SCHEMA", typeof (string)); - dt.Columns.Add("INDEX_NAME", typeof (string)); - dt.Columns.Add("TABLE_NAME", typeof (string)); - dt.Columns.Add("UNIQUE", typeof (bool)); - dt.Columns.Add("PRIMARY", typeof (bool)); - dt.Columns.Add("TYPE", typeof(string)); - dt.Columns.Add("COMMENT", typeof(string)); - - // Get the list of tables first - int max = restrictions == null ? 4 : restrictions.Length; - string[] tableRestrictions = new string[Math.Max(max, 4)]; - if (restrictions != null) - restrictions.CopyTo(tableRestrictions, 0); - tableRestrictions[3] = "BASE TABLE"; - DataTable tables = GetTables(tableRestrictions); - - foreach (DataRow table in tables.Rows) - { - string sql = String.Format("SHOW INDEX FROM `{0}`.`{1}`", - MySqlHelper.DoubleQuoteString((string)table["TABLE_SCHEMA"]), - MySqlHelper.DoubleQuoteString((string)table["TABLE_NAME"])); - MySqlDataAdapter da = new MySqlDataAdapter(sql, connection); - DataTable indexes = new DataTable(); - da.Fill(indexes); - foreach (DataRow index in indexes.Rows) - { - long seq_index = (long) index["SEQ_IN_INDEX"]; - if (seq_index != 1) continue; - if (restrictions != null && restrictions.Length == 4 && - restrictions[3] != null && - !index["KEY_NAME"].Equals(restrictions[3])) continue; - DataRow row = dt.NewRow(); - row["INDEX_CATALOG"] = null; - row["INDEX_SCHEMA"] = table["TABLE_SCHEMA"]; - row["INDEX_NAME"] = index["KEY_NAME"]; - row["TABLE_NAME"] = index["TABLE"]; - row["UNIQUE"] = (long) index["NON_UNIQUE"] == 0; - row["PRIMARY"] = index["KEY_NAME"].Equals("PRIMARY"); - row["TYPE"] = index["INDEX_TYPE"]; - row["COMMENT"] = index["COMMENT"]; - dt.Rows.Add(row); - } - } - - return dt; - } - - public virtual DataTable GetIndexColumns(string[] restrictions) - { - DataTable dt = new DataTable("IndexColumns"); - dt.Columns.Add("INDEX_CATALOG", typeof (string)); - dt.Columns.Add("INDEX_SCHEMA", typeof (string)); - dt.Columns.Add("INDEX_NAME", typeof (string)); - dt.Columns.Add("TABLE_NAME", typeof (string)); - dt.Columns.Add("COLUMN_NAME", typeof (string)); - dt.Columns.Add("ORDINAL_POSITION", typeof (int)); - dt.Columns.Add("SORT_ORDER", typeof(string)); - - int max = restrictions == null ? 4 : restrictions.Length; - string[] tableRestrictions = new string[Math.Max(max, 4)]; - if (restrictions != null) - restrictions.CopyTo(tableRestrictions, 0); - tableRestrictions[3] = "BASE TABLE"; - DataTable tables = GetTables(tableRestrictions); - - foreach (DataRow table in tables.Rows) - { - string sql = String.Format("SHOW INDEX FROM `{0}`.`{1}`", - table["TABLE_SCHEMA"], table["TABLE_NAME"]); - MySqlCommand cmd = new MySqlCommand(sql, connection); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - string key_name = GetString(reader, reader.GetOrdinal("KEY_NAME")); - string col_name = GetString(reader, reader.GetOrdinal("COLUMN_NAME")); - - if (restrictions != null) - { - if (restrictions.Length >= 4 && restrictions[3] != null && - key_name != restrictions[3]) continue; - if (restrictions.Length >= 5 && restrictions[4] != null && - col_name != restrictions[4]) continue; - } - DataRow row = dt.NewRow(); - row["INDEX_CATALOG"] = null; - row["INDEX_SCHEMA"] = table["TABLE_SCHEMA"]; - row["INDEX_NAME"] = key_name; - row["TABLE_NAME"] = GetString(reader, reader.GetOrdinal("TABLE")); - row["COLUMN_NAME"] = col_name; - row["ORDINAL_POSITION"] = reader.GetValue(reader.GetOrdinal("SEQ_IN_INDEX")); - row["SORT_ORDER"] = reader.GetString("COLLATION"); - dt.Rows.Add(row); - } - } - } - - return dt; - } - - public virtual DataTable GetForeignKeys(string[] restrictions) - { - DataTable dt = new DataTable("Foreign Keys"); - dt.Columns.Add("CONSTRAINT_CATALOG", typeof (string)); - dt.Columns.Add("CONSTRAINT_SCHEMA", typeof (string)); - dt.Columns.Add("CONSTRAINT_NAME", typeof (string)); - dt.Columns.Add("TABLE_CATALOG", typeof(string)); - dt.Columns.Add("TABLE_SCHEMA", typeof (string)); - dt.Columns.Add("TABLE_NAME", typeof (string)); - dt.Columns.Add("MATCH_OPTION", typeof(string)); - dt.Columns.Add("UPDATE_RULE", typeof(string)); - dt.Columns.Add("DELETE_RULE", typeof(string)); - dt.Columns.Add("REFERENCED_TABLE_CATALOG", typeof (string)); - dt.Columns.Add("REFERENCED_TABLE_SCHEMA", typeof (string)); - dt.Columns.Add("REFERENCED_TABLE_NAME", typeof (string)); - - // first we use our restrictions to get a list of tables that should be - // consulted. We save the keyname restriction since GetTables doesn't - // understand that. - string keyName = null; - if (restrictions != null && restrictions.Length >= 4) - { - keyName = restrictions[3]; - restrictions[3] = null; - } - - DataTable tables = GetTables(restrictions); - - // now for each table retrieved, we call our helper function to - // parse it's foreign keys - foreach (DataRow table in tables.Rows) - GetForeignKeysOnTable(dt, table, keyName, false); - - return dt; - } - - public virtual DataTable GetForeignKeyColumns(string[] restrictions) - { - DataTable dt = new DataTable("Foreign Keys"); - dt.Columns.Add("CONSTRAINT_CATALOG", typeof(string)); - dt.Columns.Add("CONSTRAINT_SCHEMA", typeof(string)); - dt.Columns.Add("CONSTRAINT_NAME", typeof(string)); - dt.Columns.Add("TABLE_CATALOG", typeof(string)); - dt.Columns.Add("TABLE_SCHEMA", typeof(string)); - dt.Columns.Add("TABLE_NAME", typeof(string)); - dt.Columns.Add("COLUMN_NAME", typeof(string)); - dt.Columns.Add("ORDINAL_POSITION", typeof(int)); - dt.Columns.Add("REFERENCED_TABLE_CATALOG", typeof(string)); - dt.Columns.Add("REFERENCED_TABLE_SCHEMA", typeof(string)); - dt.Columns.Add("REFERENCED_TABLE_NAME", typeof(string)); - dt.Columns.Add("REFERENCED_COLUMN_NAME", typeof(string)); - - // first we use our restrictions to get a list of tables that should be - // consulted. We save the keyname restriction since GetTables doesn't - // understand that. - string keyName = null; - if (restrictions != null && restrictions.Length >= 4) - { - keyName = restrictions[3]; - restrictions[3] = null; - } - - DataTable tables = GetTables(restrictions); - - // now for each table retrieved, we call our helper function to - // parse it's foreign keys - foreach (DataRow table in tables.Rows) - GetForeignKeysOnTable(dt, table, keyName, true); - return dt; - } - - - private string GetSqlMode() - { - MySqlCommand cmd = new MySqlCommand("SELECT @@SQL_MODE", connection); - return cmd.ExecuteScalar().ToString(); - } - - #region Foreign Key routines - - /// - /// GetForeignKeysOnTable retrieves the foreign keys on the given table. - /// Since MySQL supports foreign keys on versions prior to 5.0, we can't use - /// information schema. MySQL also does not include any type of SHOW command - /// for foreign keys so we have to resort to use SHOW CREATE TABLE and parsing - /// the output. - /// - /// The table to store the key info in. - /// The table to get the foeign key info for. - /// Only get foreign keys that match this name. - /// Should column information be included in the table. - private void GetForeignKeysOnTable(DataTable fkTable, DataRow tableToParse, - string filterName, bool includeColumns) - { - string sqlMode = GetSqlMode(); - - if (filterName != null) - filterName = filterName.ToLower(CultureInfo.InvariantCulture); - - string sql = string.Format("SHOW CREATE TABLE `{0}`.`{1}`", - tableToParse["TABLE_SCHEMA"], tableToParse["TABLE_NAME"]); - string lowerBody = null, body = null; - MySqlCommand cmd = new MySqlCommand(sql, connection); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - body = reader.GetString(1); - lowerBody = body.ToLower(CultureInfo.InvariantCulture); - } - - MySqlTokenizer tokenizer = new MySqlTokenizer(lowerBody); - tokenizer.AnsiQuotes = sqlMode.IndexOf("ANSI_QUOTES") != -1; - tokenizer.BackslashEscapes = sqlMode.IndexOf("NO_BACKSLASH_ESCAPES") != -1; - - while (true) - { - string token = tokenizer.NextToken(); - // look for a starting contraint - while (token != null && (token != "constraint" || tokenizer.Quoted)) - token = tokenizer.NextToken(); - if (token == null) break; - - ParseConstraint(fkTable, tableToParse, tokenizer, includeColumns); - } - } - - private static void ParseConstraint(DataTable fkTable, DataRow table, - MySqlTokenizer tokenizer, bool includeColumns) - { - string name = tokenizer.NextToken(); - DataRow row = fkTable.NewRow(); - - // make sure this constraint is a FK - string token = tokenizer.NextToken(); - if (token != "foreign" || tokenizer.Quoted) - return; - tokenizer.NextToken(); // read off the 'KEY' symbol - tokenizer.NextToken(); // read off the '(' symbol - - row["CONSTRAINT_CATALOG"] = table["TABLE_CATALOG"]; - row["CONSTRAINT_SCHEMA"] = table["TABLE_SCHEMA"]; - row["TABLE_CATALOG"] = table["TABLE_CATALOG"]; - row["TABLE_SCHEMA"] = table["TABLE_SCHEMA"]; - row["TABLE_NAME"] = table["TABLE_NAME"]; - row["REFERENCED_TABLE_CATALOG"] = null; - row["CONSTRAINT_NAME"] = name.Trim(new char[] { '\'', '`' }); - - ArrayList srcColumns = includeColumns ? ParseColumns(tokenizer) : null; - - // now look for the references section - while (token != "references" || tokenizer.Quoted) - token = tokenizer.NextToken(); - string target1 = tokenizer.NextToken(); - string target2 = tokenizer.NextToken(); - if (target2.StartsWith(".")) - { - row["REFERENCED_TABLE_SCHEMA"] = target1; - row["REFERENCED_TABLE_NAME"] = target2.Substring(1).Trim(new char[] { '\'', '`' }); - tokenizer.NextToken(); // read off the '(' - } - else - { - row["REFERENCED_TABLE_SCHEMA"] = table["TABLE_SCHEMA"]; - row["REFERENCED_TABLE_NAME"] = target1.Substring(1).Trim(new char[] { '\'', '`' }); ; - } - - // if we are supposed to include columns, read the target columns - ArrayList targetColumns = includeColumns ? ParseColumns(tokenizer) : null; - - if (includeColumns) - ProcessColumns(fkTable, row, srcColumns, targetColumns); - else - fkTable.Rows.Add(row); - } - - private static ArrayList ParseColumns(MySqlTokenizer tokenizer) - { - ArrayList sc = new ArrayList(); - string token = tokenizer.NextToken(); - while (token != ")") - { - if (token != ",") - sc.Add(token); - token = tokenizer.NextToken(); - } - return sc; - } - - private static void ProcessColumns(DataTable fkTable, DataRow row, - ArrayList srcColumns, ArrayList targetColumns) - { - for (int i = 0; i < srcColumns.Count; i++) - { - DataRow newRow = fkTable.NewRow(); - newRow.ItemArray = row.ItemArray; - newRow["COLUMN_NAME"] = (string)srcColumns[i]; - newRow["ORDINAL_POSITION"] = i; - newRow["REFERENCED_COLUMN_NAME"] = (string)targetColumns[i]; - fkTable.Rows.Add(newRow); - } - } - - #endregion - - public virtual DataTable GetUsers(string[] restrictions) - { - StringBuilder sb = new StringBuilder("SELECT Host, User FROM mysql.user"); - if (restrictions != null && restrictions.Length > 0) - sb.AppendFormat(CultureInfo.InvariantCulture, " WHERE User LIKE '{0}'", restrictions[0]); - - MySqlDataAdapter da = new MySqlDataAdapter(sb.ToString(), connection); - DataTable dt = new DataTable(); - da.Fill(dt); - dt.TableName = "Users"; - dt.Columns[0].ColumnName = "HOST"; - dt.Columns[1].ColumnName = "USERNAME"; - - return dt; - } - - public virtual DataTable GetProcedures(string[] restrictions) - { - DataTable dt = new DataTable("Procedures"); - dt.Columns.Add(new DataColumn("SPECIFIC_NAME", typeof(string))); - dt.Columns.Add(new DataColumn("ROUTINE_CATALOG", typeof(string))); - dt.Columns.Add(new DataColumn("ROUTINE_SCHEMA", typeof(string))); - dt.Columns.Add(new DataColumn("ROUTINE_NAME", typeof(string))); - dt.Columns.Add(new DataColumn("ROUTINE_TYPE", typeof(string))); - dt.Columns.Add(new DataColumn("DTD_IDENTIFIER", typeof(string))); - dt.Columns.Add(new DataColumn("ROUTINE_BODY", typeof(string))); - dt.Columns.Add(new DataColumn("ROUTINE_DEFINITION", typeof(string))); - dt.Columns.Add(new DataColumn("EXTERNAL_NAME", typeof(string))); - dt.Columns.Add(new DataColumn("EXTERNAL_LANGUAGE", typeof(string))); - dt.Columns.Add(new DataColumn("PARAMETER_STYLE", typeof(string))); - dt.Columns.Add(new DataColumn("IS_DETERMINISTIC", typeof(string))); - dt.Columns.Add(new DataColumn("SQL_DATA_ACCESS", typeof(string))); - dt.Columns.Add(new DataColumn("SQL_PATH", typeof(string))); - dt.Columns.Add(new DataColumn("SECURITY_TYPE", typeof(string))); - dt.Columns.Add(new DataColumn("CREATED", typeof(DateTime))); - dt.Columns.Add(new DataColumn("LAST_ALTERED", typeof(DateTime))); - dt.Columns.Add(new DataColumn("SQL_MODE", typeof(string))); - dt.Columns.Add(new DataColumn("ROUTINE_COMMENT", typeof(string))); - dt.Columns.Add(new DataColumn("DEFINER", typeof(string))); - - StringBuilder sql = new StringBuilder("SELECT * FROM mysql.proc WHERE 1=1"); - if (restrictions != null) - { - if (restrictions.Length >= 2 && restrictions[1] != null) - sql.AppendFormat(CultureInfo.InvariantCulture, - " AND db LIKE '{0}'", restrictions[1]); - if (restrictions.Length >= 3 && restrictions[2] != null) - sql.AppendFormat(CultureInfo.InvariantCulture, - " AND name LIKE '{0}'", restrictions[2]); - if (restrictions.Length >= 4 && restrictions[3] != null) - sql.AppendFormat(CultureInfo.InvariantCulture, - " AND type LIKE '{0}'", restrictions[3]); - } - - MySqlCommand cmd = new MySqlCommand(sql.ToString(), connection); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - DataRow row = dt.NewRow(); - row["SPECIFIC_NAME"] = reader.GetString("specific_name"); - row["ROUTINE_CATALOG"] = DBNull.Value; - row["ROUTINE_SCHEMA"] = reader.GetString("db"); - row["ROUTINE_NAME"] = reader.GetString("name"); - string routineType = reader.GetString("type"); - row["ROUTINE_TYPE"] = routineType; - row["DTD_IDENTIFIER"] = routineType.ToLower(CultureInfo.InvariantCulture) == "function" ? - (object)reader.GetString("returns") : DBNull.Value; - row["ROUTINE_BODY"] = "SQL"; - row["ROUTINE_DEFINITION"] = reader.GetString("body"); - row["EXTERNAL_NAME"] = DBNull.Value; - row["EXTERNAL_LANGUAGE"] = DBNull.Value; - row["PARAMETER_STYLE"] = "SQL"; - row["IS_DETERMINISTIC"] = reader.GetString("is_deterministic"); - row["SQL_DATA_ACCESS"] = reader.GetString("sql_data_access"); - row["SQL_PATH"] = DBNull.Value; - row["SECURITY_TYPE"] = reader.GetString("security_type"); - row["CREATED"] = reader.GetDateTime("created"); - row["LAST_ALTERED"] = reader.GetDateTime("modified"); - row["SQL_MODE"] = reader.GetString("sql_mode"); - row["ROUTINE_COMMENT"] = reader.GetString("comment"); - row["DEFINER"] = reader.GetString("definer"); - dt.Rows.Add(row); - } - } - - return dt; - } - - protected virtual DataTable GetCollections() - { - object[][] collections = new object[][] - { - new object[] {"MetaDataCollections", 0, 0}, - new object[] {"DataSourceInformation", 0, 0}, - new object[] {"DataTypes", 0, 0}, - new object[] {"Restrictions", 0, 0}, - new object[] {"ReservedWords", 0, 0}, - new object[] {"Databases", 1, 1}, - new object[] {"Tables", 4, 2}, - new object[] {"Columns", 4, 4}, - new object[] {"Users", 1, 1}, - new object[] {"Foreign Keys", 4, 3}, - new object[] {"IndexColumns", 5, 4}, - new object[] {"Indexes", 4, 3}, - new object[] {"Foreign Key Columns", 4, 3}, - new object[] {"UDF", 1, 1} - }; - - DataTable dt = new DataTable("MetaDataCollections"); - dt.Columns.Add(new DataColumn("CollectionName", typeof (string))); - dt.Columns.Add(new DataColumn("NumberOfRestrictions", typeof(int))); - dt.Columns.Add(new DataColumn("NumberOfIdentifierParts", typeof (int))); - - FillTable(dt, collections); - - return dt; - } - - private DataTable GetDataSourceInformation() - { -#if CF - throw new NotSupportedException(); -#else - DataTable dt = new DataTable("DataSourceInformation"); - dt.Columns.Add("CompositeIdentifierSeparatorPattern", typeof (string)); - dt.Columns.Add("DataSourceProductName", typeof (string)); - dt.Columns.Add("DataSourceProductVersion", typeof (string)); - dt.Columns.Add("DataSourceProductVersionNormalized", typeof (string)); - dt.Columns.Add("GroupByBehavior", typeof (GroupByBehavior)); - dt.Columns.Add("IdentifierPattern", typeof (string)); - dt.Columns.Add("IdentifierCase", typeof (IdentifierCase)); - dt.Columns.Add("OrderByColumnsInSelect", typeof (bool)); - dt.Columns.Add("ParameterMarkerFormat", typeof (string)); - dt.Columns.Add("ParameterMarkerPattern", typeof (string)); - dt.Columns.Add("ParameterNameMaxLength", typeof (int)); - dt.Columns.Add("ParameterNamePattern", typeof (string)); - dt.Columns.Add("QuotedIdentifierPattern", typeof (string)); - dt.Columns.Add("QuotedIdentifierCase", typeof (IdentifierCase)); - dt.Columns.Add("StatementSeparatorPattern", typeof (string)); - dt.Columns.Add("StringLiteralPattern", typeof (string)); - dt.Columns.Add("SupportedJoinOperators", typeof (SupportedJoinOperators)); - - DBVersion v = connection.driver.Version; - string ver = String.Format("{0:0}.{1:0}.{2:0}", - v.Major, v.Minor, v.Build); - - DataRow row = dt.NewRow(); - row["CompositeIdentifierSeparatorPattern"] = "\\."; - row["DataSourceProductName"] = "MySQL"; - row["DataSourceProductVersion"] = connection.ServerVersion; - row["DataSourceProductVersionNormalized"] = ver; - row["GroupByBehavior"] = GroupByBehavior.Unrelated; - row["IdentifierPattern"] = - @"(^\`\p{Lo}\p{Lu}\p{Ll}_@#][\p{Lo}\p{Lu}\p{Ll}\p{Nd}@$#_]*$)|(^\`[^\`\0]|\`\`+\`$)|(^\"" + [^\""\0]|\""\""+\""$)"; - row["IdentifierCase"] = IdentifierCase.Insensitive; - row["OrderByColumnsInSelect"] = false; - row["ParameterMarkerFormat"] = "{0}"; - row["ParameterMarkerPattern"] = "(@[A-Za-z0-9_$#]*)"; - row["ParameterNameMaxLength"] = 128; - row["ParameterNamePattern"] = - @"^[\p{Lo}\p{Lu}\p{Ll}\p{Lm}_@#][\p{Lo}\p{Lu}\p{Ll}\p{Lm}\p{Nd}\uff3f_@#\$]*(?=\s+|$)"; - row["QuotedIdentifierPattern"] = @"(([^\`]|\`\`)*)"; - row["QuotedIdentifierCase"] = IdentifierCase.Sensitive; - row["StatementSeparatorPattern"] = ";"; - row["StringLiteralPattern"] = "'(([^']|'')*)'"; - row["SupportedJoinOperators"] = 15; - dt.Rows.Add(row); - - return dt; -#endif - } - - private static DataTable GetDataTypes() - { - DataTable dt = new DataTable("DataTypes"); - dt.Columns.Add(new DataColumn("TypeName", typeof (string))); - dt.Columns.Add(new DataColumn("ProviderDbType", typeof (int))); - dt.Columns.Add(new DataColumn("ColumnSize", typeof (long))); - dt.Columns.Add(new DataColumn("CreateFormat", typeof (string))); - dt.Columns.Add(new DataColumn("CreateParameters", typeof (string))); - dt.Columns.Add(new DataColumn("DataType", typeof (string))); - dt.Columns.Add(new DataColumn("IsAutoincrementable", typeof (bool))); - dt.Columns.Add(new DataColumn("IsBestMatch", typeof (bool))); - dt.Columns.Add(new DataColumn("IsCaseSensitive", typeof (bool))); - dt.Columns.Add(new DataColumn("IsFixedLength", typeof (bool))); - dt.Columns.Add(new DataColumn("IsFixedPrecisionScale", typeof (bool))); - dt.Columns.Add(new DataColumn("IsLong", typeof (bool))); - dt.Columns.Add(new DataColumn("IsNullable", typeof (bool))); - dt.Columns.Add(new DataColumn("IsSearchable", typeof (bool))); - dt.Columns.Add(new DataColumn("IsSearchableWithLike", typeof (bool))); - dt.Columns.Add(new DataColumn("IsUnsigned", typeof (bool))); - dt.Columns.Add(new DataColumn("MaximumScale", typeof (short))); - dt.Columns.Add(new DataColumn("MinimumScale", typeof (short))); - dt.Columns.Add(new DataColumn("IsConcurrencyType", typeof (bool))); - dt.Columns.Add(new DataColumn("IsLiteralSupported", typeof (bool))); - dt.Columns.Add(new DataColumn("LiteralPrefix", typeof (string))); - dt.Columns.Add(new DataColumn("LiteralSuffix", typeof (string))); - dt.Columns.Add(new DataColumn("NativeDataType", typeof (string))); - - // have each one of the types contribute to the datatypes collection - MySqlBit.SetDSInfo(dt); - MySqlBinary.SetDSInfo(dt); - MySqlDateTime.SetDSInfo(dt); - MySqlTimeSpan.SetDSInfo(dt); - MySqlString.SetDSInfo(dt); - MySqlDouble.SetDSInfo(dt); - MySqlSingle.SetDSInfo(dt); - MySqlByte.SetDSInfo(dt); - MySqlInt16.SetDSInfo(dt); - MySqlInt32.SetDSInfo(dt); - MySqlInt64.SetDSInfo(dt); - MySqlDecimal.SetDSInfo(dt); - MySqlUByte.SetDSInfo(dt); - MySqlUInt16.SetDSInfo(dt); - MySqlUInt32.SetDSInfo(dt); - MySqlUInt64.SetDSInfo(dt); - - return dt; - } - - protected virtual DataTable GetRestrictions() - { - object[][] restrictions = new object[][] - { - new object[] {"Users", "Name", "", 0}, - new object[] {"Databases", "Name", "", 0}, - new object[] {"Tables", "Database", "", 0}, - new object[] {"Tables", "Schema", "", 1}, - new object[] {"Tables", "Table", "", 2}, - new object[] {"Tables", "TableType", "", 3}, - new object[] {"Columns", "Database", "", 0}, - new object[] {"Columns", "Schema", "", 1}, - new object[] {"Columns", "Table", "", 2}, - new object[] {"Columns", "Column", "", 3}, - new object[] {"Indexes", "Database", "", 0}, - new object[] {"Indexes", "Schema", "", 1}, - new object[] {"Indexes", "Table", "", 2}, - new object[] {"Indexes", "Name", "", 3}, - new object[] {"IndexColumns", "Database", "", 0}, - new object[] {"IndexColumns", "Schema", "", 1}, - new object[] {"IndexColumns", "Table", "", 2}, - new object[] {"IndexColumns", "ConstraintName", "", 3}, - new object[] {"IndexColumns", "Column", "", 4}, - new object[] {"Foreign Keys", "Database", "", 0}, - new object[] {"Foreign Keys", "Schema", "", 1}, - new object[] {"Foreign Keys", "Table", "", 2}, - new object[] {"Foreign Keys", "Constraint Name", "", 3}, - new object[] {"Foreign Key Columns", "Catalog", "", 0}, - new object[] {"Foreign Key Columns", "Schema", "", 1}, - new object[] {"Foreign Key Columns", "Table", "", 2}, - new object[] {"Foreign Key Columns", "Constraint Name", "", 3}, - new object[] {"UDF", "Name", "", 0} - }; - - DataTable dt = new DataTable("Restrictions"); - dt.Columns.Add(new DataColumn("CollectionName", typeof (string))); - dt.Columns.Add(new DataColumn("RestrictionName", typeof (string))); - dt.Columns.Add(new DataColumn("RestrictionDefault", typeof (string))); - dt.Columns.Add(new DataColumn("RestrictionNumber", typeof (int))); - - FillTable(dt, restrictions); - - return dt; - } - - private static DataTable GetReservedWords() - { - DataTable dt = new DataTable("ReservedWords"); - dt.Columns.Add(new DataColumn(DbMetaDataColumnNames.ReservedWord, typeof(string))); - - Stream str = Assembly.GetExecutingAssembly().GetManifestResourceStream( - "MySql.Data.MySqlClient.Properties.ReservedWords.txt"); - StreamReader sr = new StreamReader(str); - string line = sr.ReadLine(); - while (line != null) - { - string[] keywords = line.Split(new char[] {' '}); - foreach (string s in keywords) - { - if (String.IsNullOrEmpty(s)) continue; - DataRow row = dt.NewRow(); - row[0] = s; - dt.Rows.Add(row); - } - line = sr.ReadLine(); - } - sr.Close(); - str.Close(); - - return dt; - } - - protected static void FillTable(DataTable dt, object[][] data) - { - foreach (object[] dataItem in data) - { - DataRow row = dt.NewRow(); - for (int i = 0; i < dataItem.Length; i++) - row[i] = dataItem[i]; - dt.Rows.Add(row); - } - } - - private void FindTables(DataTable schemaTable, string[] restrictions) - { - StringBuilder sql = new StringBuilder(); - StringBuilder where = new StringBuilder(); - sql.AppendFormat(CultureInfo.InvariantCulture, - "SHOW TABLE STATUS FROM `{0}`", restrictions[1]); - if (restrictions != null && restrictions.Length >= 3 && - restrictions[2] != null) - where.AppendFormat(CultureInfo.InvariantCulture, - " LIKE '{0}'", restrictions[2]); - sql.Append(where.ToString()); - - string table_type = restrictions[1].ToLower() == "information_schema" - ? - "SYSTEM VIEW" - : "BASE TABLE"; - - MySqlCommand cmd = new MySqlCommand(sql.ToString(), connection); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - DataRow row = schemaTable.NewRow(); - row["TABLE_CATALOG"] = null; - row["TABLE_SCHEMA"] = restrictions[1]; - row["TABLE_NAME"] = reader.GetString(0); - row["TABLE_TYPE"] = table_type; - row["ENGINE"] = GetString(reader, 1); - row["VERSION"] = reader.GetValue(2); - row["ROW_FORMAT"] = GetString(reader, 3); - row["TABLE_ROWS"] = reader.GetValue(4); - row["AVG_ROW_LENGTH"] = reader.GetValue(5); - row["DATA_LENGTH"] = reader.GetValue(6); - row["MAX_DATA_LENGTH"] = reader.GetValue(7); - row["INDEX_LENGTH"] = reader.GetValue(8); - row["DATA_FREE"] = reader.GetValue(9); - row["AUTO_INCREMENT"] = reader.GetValue(10); - row["CREATE_TIME"] = reader.GetValue(11); - row["UPDATE_TIME"] = reader.GetValue(12); - row["CHECK_TIME"] = reader.GetValue(13); - row["TABLE_COLLATION"] = GetString(reader, 14); - row["CHECKSUM"] = reader.GetValue(15); - row["CREATE_OPTIONS"] = GetString(reader, 16); - row["TABLE_COMMENT"] = GetString(reader, 17); - schemaTable.Rows.Add(row); - } - } - } - - private static string GetString(MySqlDataReader reader, int index) - { - if (reader.IsDBNull(index)) - return null; - return reader.GetString(index); - } - - public virtual DataTable GetUDF(string[] restrictions) - { - string sql = "SELECT name,ret,dl FROM mysql.func"; - if (restrictions != null) - { - if (restrictions.Length >= 1 && !String.IsNullOrEmpty(restrictions[0])) - sql += String.Format(" WHERE name LIKE '{0}'", restrictions[0]); - } - - DataTable dt = new DataTable("User-defined Functions"); - dt.Columns.Add("NAME", typeof(string)); - dt.Columns.Add("RETURN_TYPE", typeof(int)); - dt.Columns.Add("LIBRARY_NAME", typeof(string)); - - MySqlCommand cmd = new MySqlCommand(sql, connection); - try - { - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - DataRow row = dt.NewRow(); - row[0] = reader.GetString(0); - row[1] = reader.GetInt32(1); - row[2] = reader.GetString(2); - dt.Rows.Add(row); - } - } - } - catch (MySqlException ex) - { - if (ex.Number != (int)MySqlErrorCode.TableAccessDenied) - throw; - throw new MySqlException(Resources.UnableToEnumerateUDF, ex); - } - - return dt; - } - - protected virtual DataTable GetSchemaInternal(string collection, string[] restrictions) - { - switch (collection) - { - // common collections - case "METADATACOLLECTIONS": - return GetCollections(); - case "DATASOURCEINFORMATION": - return GetDataSourceInformation(); - case "DATATYPES": - return GetDataTypes(); - case "RESTRICTIONS": - return GetRestrictions(); - case "RESERVEDWORDS": - return GetReservedWords(); - - // collections specific to our provider - case "USERS": - return GetUsers(restrictions); - case "DATABASES": - return GetDatabases(restrictions); - case "UDF": - return GetUDF(restrictions); - } - - // if we have a current database and our users have - // not specified a database, then default to the currently - // selected one. - if (restrictions == null) - restrictions = new string[2]; - if (connection != null && - connection.Database != null && - connection.Database.Length > 0 && - restrictions.Length > 1 && - restrictions[1] == null) - restrictions[1] = connection.Database; - - switch (collection) - { - case "TABLES": - return GetTables(restrictions); - case "COLUMNS": - return GetColumns(restrictions); - case "INDEXES": - return GetIndexes(restrictions); - case "INDEXCOLUMNS": - return GetIndexColumns(restrictions); - case "FOREIGN KEYS": - return GetForeignKeys(restrictions); - case "FOREIGN KEY COLUMNS": - return GetForeignKeyColumns(restrictions); - } - return null; - } - - internal string[] CleanRestrictions(string[] restrictionValues) - { - string[] restrictions = null; - if (restrictionValues != null) - { - restrictions = (string[])restrictionValues.Clone(); - - for (int x = 0; x < restrictions.Length; x++) - { - string s = restrictions[x]; - if (s == null) continue; - restrictions[x] = s.Trim('`'); - } - } - return restrictions; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Statement.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Statement.cs deleted file mode 100644 index 27ff376..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Statement.cs +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections; -using System.IO; -using System.Text; -using MySql.Data.Common; -using System.Data; -using MySql.Data.MySqlClient.Properties; -using System.Collections.Generic; - -namespace MySql.Data.MySqlClient -{ - internal abstract class Statement - { - protected MySqlCommand command; - protected string commandText; - private ArrayList buffers; - - private Statement(MySqlCommand cmd) - { - command = cmd; - buffers = new ArrayList(); - } - - public Statement(MySqlCommand cmd, string text) : this(cmd) - { - commandText = text; - } - - #region Properties - - public virtual string ResolvedCommandText - { - get { return commandText; } - } - - protected Driver Driver - { - get { return command.Connection.driver; } - } - - protected MySqlConnection Connection - { - get { return command.Connection; } - } - - protected MySqlParameterCollection Parameters - { - get { return command.Parameters; } - } - - #endregion - - public virtual void Close(MySqlDataReader reader) - { - } - - public virtual void Resolve(bool preparing) - { - } - - public virtual void Execute() - { - // we keep a reference to this until we are done - BindParameters(); - ExecuteNext(); - } - - public virtual bool ExecuteNext() - { - if (buffers.Count == 0) - return false; - - MySqlPacket packet = (MySqlPacket)buffers[0]; - //MemoryStream ms = stream.InternalBuffer; - Driver.SendQuery(packet); - buffers.RemoveAt(0); - return true; - } - - protected virtual void BindParameters() - { - MySqlParameterCollection parameters = command.Parameters; - int index = 0; - - while (true) - { - InternalBindParameters(ResolvedCommandText, parameters, null); - - // if we are not batching, then we are done. This is only really relevant the - // first time through - if (command.Batch == null) return; - while (index < command.Batch.Count) - { - MySqlCommand batchedCmd = command.Batch[index++]; - MySqlPacket packet = (MySqlPacket)buffers[buffers.Count - 1]; - - // now we make a guess if this statement will fit in our current stream - long estimatedCmdSize = batchedCmd.EstimatedSize(); - if (((packet.Length-4) + estimatedCmdSize) > Connection.driver.MaxPacketSize) - { - // it won't, so we setup to start a new run from here - parameters = batchedCmd.Parameters; - break; - } - - // looks like we might have room for it so we remember the current end of the stream - buffers.RemoveAt(buffers.Count - 1); - //long originalLength = packet.Length - 4; - - // and attempt to stream the next command - string text = batchedCmd.BatchableCommandText; - if (text.StartsWith("(")) - packet.WriteStringNoNull(", "); - else - packet.WriteStringNoNull("; "); - InternalBindParameters(text, batchedCmd.Parameters, packet); - if ((packet.Length-4) > Connection.driver.MaxPacketSize) - { - //TODO - //stream.InternalBuffer.SetLength(originalLength); - parameters = batchedCmd.Parameters; - break; - } - } - if (index == command.Batch.Count) - return; - } - } - - private void InternalBindParameters(string sql, MySqlParameterCollection parameters, - MySqlPacket packet) - { - if (packet == null) - { - packet = new MySqlPacket(Driver.Encoding); - packet.Version = Driver.Version; - packet.WriteByte(0); - } - - int startPos = 0; - MySqlTokenizer tokenizer = new MySqlTokenizer(sql); - tokenizer.ReturnComments = true; - string parameter = tokenizer.NextParameter(); - while (parameter != null) - { - packet.WriteStringNoNull(sql.Substring(startPos, tokenizer.StartIndex - startPos)); - bool serialized = SerializeParameter(parameters, packet, parameter); - startPos = tokenizer.StopIndex; - if (!serialized) - startPos = tokenizer.StartIndex; - parameter = tokenizer.NextParameter(); - } - packet.WriteStringNoNull(sql.Substring(startPos)); - buffers.Add(packet); - } - - protected virtual bool ShouldIgnoreMissingParameter(string parameterName) - { - if (Connection.Settings.AllowUserVariables) - return true; - if (parameterName.StartsWith("@" +StoredProcedure.ParameterPrefix)) - return true; - if (parameterName.Length > 1 && - (parameterName[1] == '`' || parameterName[1] == '\'')) - return true; - return false; - } - - /// - /// Serializes the given parameter to the given memory stream - /// - /// - /// This method is called by PrepareSqlBuffers to convert the given - /// parameter to bytes and write those bytes to the given memory stream. - /// - /// - /// True if the parameter was successfully serialized, false otherwise. - private bool SerializeParameter(MySqlParameterCollection parameters, - MySqlPacket packet, string parmName) - { - MySqlParameter parameter = parameters.GetParameterFlexible(parmName, false); - if (parameter == null) - { - // if we are allowing user variables and the parameter name starts with @ - // then we can't throw an exception - if (parmName.StartsWith("@") && ShouldIgnoreMissingParameter(parmName)) - return false; - throw new MySqlException( - String.Format(Resources.ParameterMustBeDefined, parmName)); - } - parameter.Serialize(packet, false, Connection.Settings); - return true; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/StoredProcedure.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/StoredProcedure.cs deleted file mode 100644 index ea613e6..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/StoredProcedure.cs +++ /dev/null @@ -1,289 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Globalization; -using System.Text; -using MySql.Data.Types; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.MySqlClient -{ - /// - /// Summary description for StoredProcedure. - /// - internal class StoredProcedure : PreparableStatement - { - private string outSelect; - private DataTable parametersTable; - private string resolvedCommandText; - - // Prefix used for to generate inout or output parameters names - internal const string ParameterPrefix = "_cnet_param_"; - - public StoredProcedure(MySqlCommand cmd, string text) - : base(cmd, text) - { - } - - private string GetReturnParameter() - { - if (Parameters != null) - foreach (MySqlParameter p in Parameters) - if (p.Direction == ParameterDirection.ReturnValue) - return p.ParameterName.Substring(1); - return null; - } - - public override string ResolvedCommandText - { - get { return resolvedCommandText; } - } - - private DataSet GetParameters(string procName) - { - // if we can use mysql.proc, then do so - //if (Connection.Settings.UseProcedureBodies) - DataSet ds = Connection.ProcedureCache.GetProcedure(Connection, procName); - - if(ds.Tables.Count == 2) - { - // if we got our parameters and our user says it is ok to use proc bodies - // then just return them - if (Connection.Settings.UseProcedureBodies) return ds; - - // we got the parameters, but ignore them. - if(ds.Tables.Contains("Procedure Parameters")) - ds.Tables.Remove("Procedure Parameters"); - } - - // we were not able to retrieve parameter data so we have to make do by - // adding the parameters from the command object to our table - // we use an internal method to create our procedure parameters table. - ISSchemaProvider sp = new ISSchemaProvider(Connection); - DataTable pTable = sp.CreateParametersTable(); - ds.Tables.Add(pTable); - - // now we run through the parameters that were set and fill in the parameters table - // the best we can - int pos = 1; - foreach (MySqlParameter p in command.Parameters) - { - // in this mode, all parameters must have their type set - if (!p.TypeHasBeenSet) - throw new InvalidOperationException(Resources.NoBodiesAndTypeNotSet); - - DataRow row = pTable.NewRow(); - row["PARAMETER_NAME"] = p.ParameterName; - row["PARAMETER_MODE"] = "IN"; - if (p.Direction == ParameterDirection.InputOutput) - row["PARAMETER_MODE"] = "INOUT"; - else if (p.Direction == ParameterDirection.Output) - row["PARAMETER_MODE"] = "OUT"; - else if (p.Direction == ParameterDirection.ReturnValue) - { - row["PARAMETER_MODE"] = "OUT"; - row["ORDINAL_POSITION"] = 0; - } - else - row["ORDINAL_POSITION"] = pos++; - pTable.Rows.Add(row); - } - return ds; - } - - public static string GetFlags(string dtd) - { - int x = dtd.Length - 1; - while (x > 0 && (Char.IsLetterOrDigit(dtd[x]) || dtd[x] == ' ')) - x--; - return dtd.Substring(x).ToUpper(CultureInfo.InvariantCulture); - } - - private string FixProcedureName(string name) - { - string[] parts = name.Split('.'); - for (int i = 0; i < parts.Length; i++) - if (!parts[i].StartsWith("`")) - parts[i] = String.Format("`{0}`", parts[i]); - if (parts.Length == 1) return parts[0]; - return String.Format("{0}.{1}", parts[0], parts[1]); - } - - private MySqlParameter GetAndFixParameter(DataRow param, bool realAsFloat, string returnParameter) - { - string mode = (string)param["PARAMETER_MODE"]; - string pName = (string)param["PARAMETER_NAME"]; - - if (param["ORDINAL_POSITION"].Equals(0)) - pName = returnParameter; - - if (pName == null) return null; - - // make sure the parameters given to us have an appropriate - // type set if it's not already - MySqlParameter p = command.Parameters.GetParameterFlexible(pName, true); - if (!p.TypeHasBeenSet) - { - string datatype = (string)param["DATA_TYPE"]; - bool unsigned = GetFlags(param["DTD_IDENTIFIER"].ToString()).IndexOf("UNSIGNED") != -1; - p.MySqlDbType = MetaData.NameToType(datatype, unsigned, realAsFloat, Connection); - } - return p; - } - - public override void Resolve(bool preparing) - { - // check to see if we are already resolved - if (resolvedCommandText != null) return; - - // first retrieve the procedure definition from our - // procedure cache - string spName = commandText; - if (spName.IndexOf(".") == -1 && !String.IsNullOrEmpty(Connection.Database)) - spName = Connection.Database + "." + spName; - spName = FixProcedureName(spName); - - DataSet ds = GetParameters(spName); - - DataTable procTable = ds.Tables["procedures"]; - parametersTable = ds.Tables["procedure parameters"]; - - if (procTable.Rows.Count == 0) - throw new InvalidOperationException(String.Format(Resources.RoutineNotFound, spName)); - - bool realAsFloat = procTable.Rows[0]["SQL_MODE"].ToString().IndexOf("REAL_AS_FLOAT") != -1; - StringBuilder sqlStr = new StringBuilder(); - StringBuilder outSql = new StringBuilder(); - string sqlDelimiter = ""; - string outDelimiter = ""; - - string retParm = GetReturnParameter(); - foreach (DataRow param in parametersTable.Rows) - { - MySqlParameter p = GetAndFixParameter(param, realAsFloat, retParm); - if (p == null) continue; - - if (param["ORDINAL_POSITION"].Equals(0)) - continue; - - string baseName = p.ParameterName; - string pName = baseName; - if (baseName.StartsWith("@") || baseName.StartsWith("?")) - baseName = baseName.Substring(1); - else - pName = "@" + pName; - - string inputVar = pName; - if (p.Direction != ParameterDirection.Input && - !(Connection.driver.SupportsOutputParameters || preparing)) - { - // set a user variable to our current value - string sql = String.Format("SET @{0}{1}={2}", ParameterPrefix, baseName, pName); - MySqlCommand cmd = new MySqlCommand(sql, Connection); - - cmd.Parameters.Add(p); - cmd.ExecuteNonQuery(); - - inputVar = String.Format("@{0}{1}", ParameterPrefix, baseName); - - outSql.AppendFormat(CultureInfo.InvariantCulture, "{0}{1}", outDelimiter, inputVar); - outDelimiter = ", "; - } - sqlStr.AppendFormat(CultureInfo.InvariantCulture, "{0}{1}", sqlDelimiter, inputVar); - sqlDelimiter = ", "; - } - - string sqlCmd = sqlStr.ToString().TrimEnd(' ', ','); - outSelect = outSql.ToString().TrimEnd(' ', ','); - - if (procTable.Rows[0]["ROUTINE_TYPE"].Equals("PROCEDURE")) - sqlCmd = String.Format("call {0} ({1})", spName, sqlCmd); - else - { - if (retParm == null) - retParm = ParameterPrefix + "dummy"; - else - outSelect = String.Format("@{0}{1}", ParameterPrefix, retParm); - sqlCmd = String.Format("SET @{0}{1}={2}({3})", ParameterPrefix, retParm, spName, sqlCmd); - } - - resolvedCommandText = sqlCmd; - } - - private MySqlDataReader GetHackedOuputParameters() - { - if (outSelect.Length == 0) return null; - - MySqlCommand cmd = new MySqlCommand("SELECT " + outSelect, Connection); - - MySqlDataReader reader = cmd.ExecuteReader(); - // since MySQL likes to return user variables as strings - // we reset the types of the readers internal value objects - // this will allow those value objects to parse the string based - // return values - ResultSet results = reader.ResultSet; - for (int i = 0; i < reader.FieldCount; i++) - { - string fieldName = reader.GetName(i); - fieldName = fieldName.Remove(0, ParameterPrefix.Length + 1); - MySqlParameter parameter = Parameters.GetParameterFlexible(fieldName, true); - results.SetValueObject(i, MySqlField.GetIMySqlValue(parameter.MySqlDbType)); - } - if (!reader.Read()) - { - reader.Close(); - return null; - } - return reader; - } - - public override void Close(MySqlDataReader reader) - { - base.Close(reader); - - ResultSet rs = reader.ResultSet; - // if our closing reader doesn't have output parameters then we may have to - // use the user variable hack - if (rs == null || !rs.IsOutputParameters) - { - MySqlDataReader rdr = GetHackedOuputParameters(); - if (rdr == null) return; - reader = rdr; - } - - using (reader) - { - string prefix = "@" + ParameterPrefix; - - for (int i = 0; i < reader.FieldCount; i++) - { - string fieldName = reader.GetName(i); - if (fieldName.StartsWith(prefix)) - fieldName = fieldName.Remove(0, prefix.Length); - MySqlParameter parameter = Parameters.GetParameterFlexible(fieldName, true); - parameter.Value = reader.GetValue(i); - } - reader.Close(); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/TimedStream.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/TimedStream.cs deleted file mode 100644 index 171c737..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/TimedStream.cs +++ /dev/null @@ -1,297 +0,0 @@ -// Copyright (c) 2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.IO; -using System.Net.Sockets; -using System.Diagnostics; -using MySql.Data.Common; - -namespace MySql.Data.MySqlClient -{ - /// - /// Stream that supports timeout of IO operations. - /// This class is used is used to support timeouts for SQL command, where a - /// typical operation involves several network reads/writes. - /// Timeout here is defined as the accumulated duration of all IO operations. - /// - - internal class TimedStream : Stream - { - Stream baseStream; - - int timeout; - int lastReadTimeout; - int lastWriteTimeout; - LowResolutionStopwatch stopwatch; - bool isClosed; - - - enum IOKind - { - Read, - Write - }; - - /// - /// Construct a TimedStream - /// - /// Undelying stream - public TimedStream(Stream baseStream) - { - this.baseStream = baseStream; -#if !CF - timeout = baseStream.ReadTimeout; -#else - timeout = System.Threading.Timeout.Infinite; -#endif - isClosed = false; - stopwatch = new LowResolutionStopwatch(); - } - - - /// - /// Figure out whether it is necessary to reset timeout on stream. - /// We track the current value of timeout and try to avoid - /// changing it too often, because setting Read/WriteTimeout property - /// on network stream maybe a slow operation that involves a system call - /// (setsockopt). Therefore, we allow a small difference, and do not - /// reset timeout if current value is slightly greater than the requested - /// one (within 0.1 second). - /// - - private bool ShouldResetStreamTimeout(int currentValue, int newValue) - { - if (newValue == System.Threading.Timeout.Infinite - && currentValue != newValue) - return true; - if (newValue > currentValue) - return true; - if (currentValue>= newValue + 100) - return true; - - return false; - - } - private void StartTimer(IOKind op) - { - - int streamTimeout; - - if (timeout == System.Threading.Timeout.Infinite) - streamTimeout = System.Threading.Timeout.Infinite; - else - streamTimeout = timeout - (int)stopwatch.ElapsedMilliseconds; - - if (op == IOKind.Read) - { - if (ShouldResetStreamTimeout(lastReadTimeout, streamTimeout)) - { -#if !CF - baseStream.ReadTimeout = streamTimeout; -#endif - lastReadTimeout = streamTimeout; - } - } - else - { - if (ShouldResetStreamTimeout(lastWriteTimeout, streamTimeout)) - { -#if !CF - baseStream.WriteTimeout = streamTimeout; -#endif - lastWriteTimeout = streamTimeout; - } - } - - if (timeout == System.Threading.Timeout.Infinite) - return; - - stopwatch.Start(); - } - private void StopTimer() - { - if (timeout == System.Threading.Timeout.Infinite) - return; - - stopwatch.Stop(); - - // Normally, a timeout exception would be thrown by stream itself, - // since we set the read/write timeout for the stream. However - // there is a gap between end of IO operation and stopping the - // stop watch, and it makes it possible for timeout to exceed - // even after IO completed successfully. - if (stopwatch.ElapsedMilliseconds > timeout) - { - ResetTimeout(System.Threading.Timeout.Infinite); - throw new TimeoutException("Timeout in IO operation"); - } - } - public override bool CanRead - { - get { return baseStream.CanRead; } - } - - public override bool CanSeek - { - get { return baseStream.CanSeek; } - } - - public override bool CanWrite - { - get { return baseStream.CanWrite; } - } - - public override void Flush() - { - try - { - StartTimer(IOKind.Write); - baseStream.Flush(); - StopTimer(); - } - catch (Exception e) - { - HandleException(e); - throw; - } - } - - public override long Length - { - get { return baseStream.Length; } - } - - public override long Position - { - get - { - return baseStream.Position; - } - set - { - baseStream.Position = value; - } - } - - public override int Read(byte[] buffer, int offset, int count) - { - try - { - StartTimer(IOKind.Read); - int retval = baseStream.Read(buffer, offset, count); - StopTimer(); - return retval; - } - catch (Exception e) - { - HandleException(e); - throw; - } - } - - public override int ReadByte() - { - try - { - StartTimer(IOKind.Read); - int retval = baseStream.ReadByte(); - StopTimer(); - return retval; - } - catch (Exception e) - { - HandleException(e); - throw; - } - } - - public override long Seek(long offset, SeekOrigin origin) - { - return baseStream.Seek(offset, origin); - } - - public override void SetLength(long value) - { - baseStream.SetLength(value); - } - - public override void Write(byte[] buffer, int offset, int count) - { - try - { - StartTimer(IOKind.Write); - baseStream.Write(buffer, offset, count); - StopTimer(); - } - catch (Exception e) - { - HandleException(e); - throw; - } - } - - public override bool CanTimeout - { - get { return baseStream.CanTimeout; } - } - - public override int ReadTimeout - { - get { return baseStream.ReadTimeout; } - set { baseStream.ReadTimeout = value; } - } - public override int WriteTimeout - { - get { return baseStream.WriteTimeout; } - set { baseStream.WriteTimeout = value; } - } - - public override void Close() - { - if (isClosed) - return; - isClosed = true; - baseStream.Close(); - } - - public void ResetTimeout(int newTimeout) - { - if (newTimeout == System.Threading.Timeout.Infinite || newTimeout == 0) - timeout = System.Threading.Timeout.Infinite; - else - timeout = newTimeout; - stopwatch.Reset(); - } - - - /// - /// Common handler for IO exceptions. - /// Resets timeout to infinity if timeout exception is - /// detected and stops the times. - /// - /// original exception - void HandleException(Exception e) - { - stopwatch.Stop(); - ResetTimeout(-1); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/TracingDriver.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/TracingDriver.cs deleted file mode 100644 index 6ff273c..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/TracingDriver.cs +++ /dev/null @@ -1,248 +0,0 @@ -// Copyright (c) 2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Text; -using MySql.Data.Types; -using System.Diagnostics; -using System.Collections.Generic; -using MySql.Data.MySqlClient.Properties; -using System.Threading; -using MySql.Data.Common; - -namespace MySql.Data.MySqlClient -{ - internal class TracingDriver : Driver - { - private static long driverCounter; - private long driverId; - private ResultSet activeResult; - private int rowSizeInBytes; - - public TracingDriver(MySqlConnectionStringBuilder settings) - : base(settings) - { - driverId = Interlocked.Increment(ref driverCounter); - } - - public override void Open() - { - base.Open(); - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.ConnectionOpened, - Resources.TraceOpenConnection, driverId, Settings.ConnectionString, ThreadID); - } - - public override void Close() - { - base.Close(); - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.ConnectionClosed, - Resources.TraceCloseConnection, driverId); - } - - public override void SendQuery(MySqlPacket p) - { - rowSizeInBytes = 0; - string cmdText = Encoding.GetString(p.Buffer, 5, p.Length - 5); - string normalized_query = null; - - if (cmdText.Length > 300) - { - cmdText = cmdText.Substring(0, 300); - QueryNormalizer normalizer = new QueryNormalizer(); - normalized_query = normalizer.Normalize(cmdText); - } - - base.SendQuery(p); - - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.QueryOpened, - Resources.TraceQueryOpened, driverId, ThreadID, cmdText); - if (normalized_query != null) - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.QueryNormalized, - Resources.TraceQueryNormalized, driverId, ThreadID, normalized_query); - } - - protected override int GetResult(int statementId, ref int affectedRows, ref int insertedId) - { - try - { - int fieldCount = base.GetResult(statementId, ref affectedRows, ref insertedId); - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.ResultOpened, - Resources.TraceResult, driverId, fieldCount, affectedRows, insertedId); - - return fieldCount; - } - catch (MySqlException ex) - { - // we got an error so we report it - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.Error, - Resources.TraceOpenResultError, driverId, ex.Number, ex.Message); - throw ex; - } - } - - public override ResultSet NextResult(int statementId) - { - // first let's see if we already have a resultset on this statementId - if (activeResult != null) - { - //oldRS = activeResults[statementId]; - if (Settings.UseUsageAdvisor) - ReportUsageAdvisorWarnings(statementId, activeResult); - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.ResultClosed, - Resources.TraceResultClosed, driverId, activeResult.TotalRows, activeResult.SkippedRows, - rowSizeInBytes); - rowSizeInBytes = 0; - activeResult = null; - } - - activeResult = base.NextResult(statementId); - return activeResult; - } - - public override int PrepareStatement(string sql, ref MySqlField[] parameters) - { - int statementId = base.PrepareStatement(sql, ref parameters); - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementPrepared, - Resources.TraceStatementPrepared, driverId, sql, statementId); - return statementId; - } - - public override void CloseStatement(int id) - { - base.CloseStatement(id); - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementClosed, - Resources.TraceStatementClosed, driverId, id); - } - - public override void SetDatabase(string dbName) - { - base.SetDatabase(dbName); - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.NonQuery, - Resources.TraceSetDatabase, driverId, dbName); - } - - public override void ExecuteStatement(MySqlPacket packetToExecute) - { - base.ExecuteStatement(packetToExecute); - int pos = packetToExecute.Position; - packetToExecute.Position = 1; - int statementId = packetToExecute.ReadInteger(4); - packetToExecute.Position = pos; - - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementExecuted, - Resources.TraceStatementExecuted, driverId, statementId, ThreadID); - } - - public override bool FetchDataRow(int statementId, int columns) - { - try - { - bool b = base.FetchDataRow(statementId, columns); - if (b) - rowSizeInBytes += (handler as NativeDriver).Packet.Length; - return b; - } - catch (MySqlException ex) - { - MySqlTrace.TraceEvent(TraceEventType.Error, MySqlTraceEventType.Error, - Resources.TraceFetchError, driverId, ex.Number, ex.Message); - throw ex; - } - } - - public override void CloseQuery(MySqlConnection connection, int statementId) - { - base.CloseQuery(connection, statementId); - - MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.QueryClosed, - Resources.TraceQueryDone, driverId); - } - - public override List ReportWarnings(MySqlConnection connection) - { - List warnings = base.ReportWarnings(connection); - foreach (MySqlError warning in warnings) - MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.Warning, - Resources.TraceWarning, driverId, warning.Level, warning.Code, warning.Message); - return warnings; - } - - private bool AllFieldsAccessed(ResultSet rs) - { - if (rs.Fields == null || rs.Fields.Length == 0) return true; - - for (int i = 0; i < rs.Fields.Length; i++) - if (!rs.FieldRead(i)) return false; - return true; - } - - private void ReportUsageAdvisorWarnings(int statementId, ResultSet rs) - { - if (!Settings.UseUsageAdvisor) return; - - if (HasStatus(ServerStatusFlags.NoIndex)) - MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning, - Resources.TraceUAWarningNoIndex, driverId, UsageAdvisorWarningFlags.NoIndex); - else if (HasStatus(ServerStatusFlags.BadIndex)) - MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning, - Resources.TraceUAWarningBadIndex, driverId, UsageAdvisorWarningFlags.BadIndex); - - // report abandoned rows - if (rs.SkippedRows > 0) - MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning, - Resources.TraceUAWarningSkippedRows, driverId, UsageAdvisorWarningFlags.SkippedRows, rs.SkippedRows); - - // report not all fields accessed - if (!AllFieldsAccessed(rs)) - { - StringBuilder notAccessed = new StringBuilder(""); - string delimiter = ""; - for (int i = 0; i < rs.Size; i++) - if (!rs.FieldRead(i)) - { - notAccessed.AppendFormat("{0}{1}", delimiter, rs.Fields[i].ColumnName); - delimiter = ","; - } - MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning, - Resources.TraceUAWarningSkippedColumns, driverId, UsageAdvisorWarningFlags.SkippedColumns, - notAccessed.ToString()); - } - - // report type conversions if any - if (rs.Fields != null) - { - foreach (MySqlField f in rs.Fields) - { - StringBuilder s = new StringBuilder(); - string delimiter = ""; - foreach (Type t in f.TypeConversions) - { - s.AppendFormat("{0}{1}", delimiter, t.Name); - delimiter = ","; - } - if (s.Length > 0) - MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning, - Resources.TraceUAWarningFieldConversion, driverId, UsageAdvisorWarningFlags.FieldConversion, - f.ColumnName, s.ToString()); - } - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MetaData.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MetaData.cs deleted file mode 100644 index 16d659f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MetaData.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using MySql.Data.MySqlClient; -using System.Globalization; - -namespace MySql.Data.Types -{ - internal class MetaData - { - public static bool IsNumericType(string typename) - { - string lowerType = typename.ToLower(CultureInfo.InvariantCulture); - switch (lowerType) - { - case "int": - case "integer": - case "numeric": - case "decimal": - case "dec": - case "fixed": - case "tinyint": - case "mediumint": - case "bigint": - case "real": - case "double": - case "float": - case "serial": - case "smallint": return true; - } - return false; - } - - public static bool SupportScale(string typename) - { - string lowerType = typename.ToLower(CultureInfo.InvariantCulture); - switch (lowerType) - { - case "numeric": - case "decimal": - case "dec": - case "real": return true; - } - return false; - } - - public static MySqlDbType NameToType(string typeName, bool unsigned, - bool realAsFloat, MySqlConnection connection) - { - switch (typeName.ToUpper(CultureInfo.InvariantCulture)) - { - case "CHAR": return MySqlDbType.String; - case "VARCHAR": return MySqlDbType.VarChar; - case "DATE": return MySqlDbType.Date; - case "DATETIME": return MySqlDbType.DateTime; - case "NUMERIC": - case "DECIMAL": - case "DEC": - case "FIXED": - if (connection.driver.Version.isAtLeast(5, 0, 3)) - return MySqlDbType.NewDecimal; - else - return MySqlDbType.Decimal; - case "YEAR": - return MySqlDbType.Year; - case "TIME": - return MySqlDbType.Time; - case "TIMESTAMP": - return MySqlDbType.Timestamp; - case "SET": return MySqlDbType.Set; - case "ENUM": return MySqlDbType.Enum; - case "BIT": return MySqlDbType.Bit; - - case "TINYINT": - return unsigned ? MySqlDbType.UByte : MySqlDbType.Byte; - case "BOOL": - case "BOOLEAN": - return MySqlDbType.Byte; - case "SMALLINT": - return unsigned ? MySqlDbType.UInt16 : MySqlDbType.Int16; - case "MEDIUMINT": - return unsigned ? MySqlDbType.UInt24 : MySqlDbType.Int24; - case "INT": - case "INTEGER": - return unsigned ? MySqlDbType.UInt32 : MySqlDbType.Int32; - case "SERIAL": - return MySqlDbType.UInt64; - case "BIGINT": - return unsigned ? MySqlDbType.UInt64 : MySqlDbType.Int64; - case "FLOAT": return MySqlDbType.Float; - case "DOUBLE": return MySqlDbType.Double; - case "REAL": return - realAsFloat ? MySqlDbType.Float : MySqlDbType.Double; - case "TEXT": - return MySqlDbType.Text; - case "BLOB": - return MySqlDbType.Blob; - case "LONGBLOB": - return MySqlDbType.LongBlob; - case "LONGTEXT": - return MySqlDbType.LongText; - case "MEDIUMBLOB": - return MySqlDbType.MediumBlob; - case "MEDIUMTEXT": - return MySqlDbType.MediumText; - case "TINYBLOB": - return MySqlDbType.TinyBlob; - case "TINYTEXT": - return MySqlDbType.TinyText; - case "BINARY": - return MySqlDbType.Binary; - case "VARBINARY": - return MySqlDbType.VarBinary; - } - throw new MySqlException("Unhandled type encountered"); - } - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlBinary.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlBinary.cs deleted file mode 100644 index 4a8d95f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlBinary.cs +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; - -namespace MySql.Data.Types -{ - - internal struct MySqlBinary : IMySqlValue - { - private MySqlDbType type; - private byte[] mValue; - private bool isNull; - - public MySqlBinary(MySqlDbType type, bool isNull) - { - this.type = type; - this.isNull = isNull; - mValue = null; - } - - public MySqlBinary(MySqlDbType type, byte[] val) - { - this.type = type; - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return type; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.Binary; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public byte[] Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(byte[]); } - } - - string IMySqlValue.MySqlTypeName - { - get - { - switch (type) - { - case MySqlDbType.TinyBlob: return "TINY_BLOB"; - case MySqlDbType.MediumBlob: return "MEDIUM_BLOB"; - case MySqlDbType.LongBlob: return "LONG_BLOB"; - case MySqlDbType.Blob: - default: - return "BLOB"; - } - } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - byte[] buffToWrite = (val as byte[]); - if (buffToWrite == null) - { - char[] valAsChar = (val as Char[]); - if (valAsChar != null) - buffToWrite = packet.Encoding.GetBytes(valAsChar); - else - { - string s = val.ToString(); - if (length == 0) - length = s.Length; - else - s = s.Substring(0, length); - buffToWrite = packet.Encoding.GetBytes(s); - } - } - - // we assume zero length means write all of the value - if (length == 0) - length = buffToWrite.Length; - - if (buffToWrite == null) - throw new MySqlException("Only byte arrays and strings can be serialized by MySqlBinary"); - - if (binary) - { - packet.WriteLength(length); - packet.Write(buffToWrite, 0, length); - } - else - { - if (packet.Version.isAtLeast(4, 1, 0)) - packet.WriteStringNoNull("_binary "); - - packet.WriteByte((byte)'\''); - EscapeByteArray(buffToWrite, length, packet); - packet.WriteByte((byte)'\''); - } - } - - private static void EscapeByteArray(byte[] bytes, int length, MySqlPacket packet) - { - for (int x = 0; x < length; x++) - { - byte b = bytes[x]; - if (b == '\0') - { - packet.WriteByte((byte)'\\'); - packet.WriteByte((byte)'0'); - } - - else if (b == '\\' || b == '\'' || b == '\"') - { - packet.WriteByte((byte)'\\'); - packet.WriteByte(b); - } - else - packet.WriteByte(b); - } - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - MySqlBinary b; - if (nullVal) - b = new MySqlBinary(type, true); - else - { - if (length == -1) - length = (long)packet.ReadFieldLength(); - - byte[] newBuff = new byte[length]; - packet.Read(newBuff, 0, (int)length); - b = new MySqlBinary(type, newBuff); - } - return b; - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - int len = packet.ReadFieldLength(); - packet.Position += len; - } - - #endregion - - public static void SetDSInfo(DataTable dsTable) - { - string[] types = new string[] { "BLOB", "TINYBLOB", "MEDIUMBLOB", "LONGBLOB", "BINARY", "VARBINARY" }; - MySqlDbType[] dbtype = new MySqlDbType[] { MySqlDbType.Blob, - MySqlDbType.TinyBlob, MySqlDbType.MediumBlob, MySqlDbType.LongBlob, MySqlDbType.Binary, MySqlDbType.VarBinary }; - long[] sizes = new long[] { 65535L, 255L, 16777215L, 4294967295L, 255L, 65535L }; - string[] format = new string[] { null, null, null, null, "binary({0})", "varbinary({0})" }; - string[] parms = new string[] { null, null, null, null, "length", "length" }; - - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - for (int x = 0; x < types.Length; x++) - { - DataRow row = dsTable.NewRow(); - row["TypeName"] = types[x]; - row["ProviderDbType"] = dbtype[x]; - row["ColumnSize"] = sizes[x]; - row["CreateFormat"] = format[x]; - row["CreateParameters"] = parms[x]; - row["DataType"] = "System.Byte[]"; - row["IsAutoincrementable"] = false; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = x < 4 ? false : true; - row["IsFixedPrecisionScale"] = false; - row["IsLong"] = sizes[x] > 255; - row["IsNullable"] = true; - row["IsSearchable"] = false; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = DBNull.Value; - row["MaximumScale"] = DBNull.Value; - row["MinimumScale"] = DBNull.Value; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = "0x"; - row["LiteralSuffix"] = DBNull.Value; - row["NativeDataType"] = DBNull.Value; - dsTable.Rows.Add(row); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlBit.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlBit.cs deleted file mode 100644 index 9f904ae..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlBit.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; - -namespace MySql.Data.Types -{ - /// - /// Summary description for MySqlUInt64. - /// - internal struct MySqlBit : IMySqlValue - { - private ulong mValue; - private bool isNull; - - public MySqlBit(bool isnull) - { - mValue = 0; - isNull = isnull; - } - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.Bit; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.UInt64; } - } - - object IMySqlValue.Value - { - get - { - return mValue; - } - } - - Type IMySqlValue.SystemType - { - get - { - return typeof(UInt64); - } - } - - string IMySqlValue.MySqlTypeName - { - get { return "BIT"; } - } - - public void WriteValue(MySqlPacket packet, bool binary, object value, int length) - { - ulong v = (value is UInt64) ? (UInt64)value : Convert.ToUInt64(value); - if (binary) - packet.WriteInteger((long)v, 8); - else - packet.WriteStringNoNull(v.ToString()); - } - - public IMySqlValue ReadValue(MySqlPacket packet, long length, bool isNull) - { - this.isNull = isNull; - if (isNull) - return this; - - if (length == -1) - length = packet.ReadFieldLength(); - - mValue = (UInt64)packet.ReadBitValue((int)length); - return this; - } - - public void SkipValue(MySqlPacket packet) - { - int len = packet.ReadFieldLength(); - packet.Position += len; - } - - public static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "BIT"; - row["ProviderDbType"] = MySqlDbType.Bit; - row["ColumnSize"] = 64; - row["CreateFormat"] = "BIT"; - row["CreateParameters"] = DBNull.Value; ; - row["DataType"] = typeof(UInt64).ToString(); - row["IsAutoincrementable"] = false; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = false; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = DBNull.Value; - row["LiteralSuffix"] = DBNull.Value; - row["NativeDataType"] = DBNull.Value; - dsTable.Rows.Add(row); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlByte.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlByte.cs deleted file mode 100644 index 0f12f00..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlByte.cs +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using System.Globalization; - -namespace MySql.Data.Types -{ - internal struct MySqlByte : IMySqlValue - { - private sbyte mValue; - private bool isNull; - private bool treatAsBool; - - public MySqlByte(bool isNull) - { - this.isNull = isNull; - mValue = 0; - treatAsBool = false; - } - - public MySqlByte(sbyte val) - { - this.isNull = false; - mValue = val; - treatAsBool = false; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.Byte; } - } - - DbType IMySqlValue.DbType - { - get - { - if (TreatAsBoolean) - return DbType.Boolean; - return DbType.SByte; - } - } - - object IMySqlValue.Value - { - get - { - if (TreatAsBoolean) - return Convert.ToBoolean(mValue); - return mValue; - } - } - - public sbyte Value - { - get { return mValue; } - set { mValue = value; } - } - - Type IMySqlValue.SystemType - { - get - { - if (TreatAsBoolean) - return typeof(Boolean); - return typeof(sbyte); - } - } - - string IMySqlValue.MySqlTypeName - { - get { return "TINYINT"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - sbyte v = (val is sbyte) ? (sbyte)val : Convert.ToSByte(val); - if (binary) - packet.WriteByte((byte)v); - else - packet.WriteStringNoNull(v.ToString()); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) - return new MySqlByte(true); - - if (length == -1) - return new MySqlByte((sbyte)packet.ReadByte()); - else - { - string s = packet.ReadString(length); - MySqlByte b = new MySqlByte(SByte.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture)); - b.TreatAsBoolean = TreatAsBoolean; - return b; - } - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - packet.ReadByte(); - } - - #endregion - - internal bool TreatAsBoolean - { - get { return treatAsBool; } - set { treatAsBool = value; } - } - - internal static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "TINYINT"; - row["ProviderDbType"] = MySqlDbType.Byte; - row["ColumnSize"] = 0; - row["CreateFormat"] = "TINYINT"; - row["CreateParameters"] = null; - row["DataType"] = "System.SByte"; - row["IsAutoincrementable"] = true; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlConversionException.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlConversionException.cs deleted file mode 100644 index 0a0b18b..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlConversionException.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; - -namespace MySql.Data.Types -{ - /// - /// Summary description for MySqlConversionException. - /// -#if !CF - [Serializable] -#endif - public class MySqlConversionException : Exception - { - /// Ctor - public MySqlConversionException(string msg) - : base(msg) - { - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDateTime.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDateTime.cs deleted file mode 100644 index 927b629..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDateTime.cs +++ /dev/null @@ -1,646 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using MySql.Data.MySqlClient; -using System.Globalization; - -namespace MySql.Data.Types -{ - - /// - /// - /// - public struct MySqlDateTime : IMySqlValue, IConvertible, IComparable - { - private bool isNull; - private MySqlDbType type; - private int year, month, day, hour, minute, second; - private int millisecond; - - /// - /// Constructs a new MySqlDateTime object by setting the individual time properties to - /// the given values. - /// - /// The year to use. - /// The month to use. - /// The day to use. - /// The hour to use. - /// The minute to use. - /// The second to use. - public MySqlDateTime(int year, int month, int day, int hour, int minute, int second) - : this(MySqlDbType.DateTime, year, month, day, hour, minute, second) - { - } - - /// - /// Constructs a new MySqlDateTime object by using values from the given object. - /// - /// The object to copy. - public MySqlDateTime(DateTime dt) - : this(MySqlDbType.DateTime, dt) - { - } - - /// - /// Constructs a new MySqlDateTime object by copying the current value of the given object. - /// - /// The MySqlDateTime object to copy. - public MySqlDateTime(MySqlDateTime mdt) - { - year = mdt.Year; - month = mdt.Month; - day = mdt.Day; - hour = mdt.Hour; - minute = mdt.Minute; - second = mdt.Second; - millisecond = 0; - type = MySqlDbType.DateTime; - isNull = false; - } - - /// - /// Enables the contruction of a MySqlDateTime object by parsing a string. - /// - public MySqlDateTime(string dateTime) - : this(MySqlDateTime.Parse(dateTime)) - { - } - - internal MySqlDateTime(MySqlDbType type, int year, int month, int day, int hour, int minute, - int second) - { - this.isNull = false; - this.type = type; - this.year = year; - this.month = month; - this.day = day; - this.hour = hour; - this.minute = minute; - this.second = second; - this.millisecond = 0; - } - - internal MySqlDateTime(MySqlDbType type, bool isNull) - : this(type, 0, 0, 0, 0, 0, 0) - { - this.isNull = isNull; - } - - internal MySqlDateTime(MySqlDbType type, DateTime val) - : this(type, 0, 0, 0, 0, 0, 0) - { - this.isNull = false; - year = val.Year; - month = val.Month; - day = val.Day; - hour = val.Hour; - minute = val.Minute; - second = val.Second; - millisecond = val.Millisecond; - } - - #region Properties - - /// - /// Indicates if this object contains a value that can be represented as a DateTime - /// - public bool IsValidDateTime - { - get - { - return year != 0 && month != 0 && day != 0; - } - } - - /// Returns the year portion of this datetime - public int Year - { - get { return year; } - set { year = value; } - } - - /// Returns the month portion of this datetime - public int Month - { - get { return month; } - set { month = value; } - } - - /// Returns the day portion of this datetime - public int Day - { - get { return day; } - set { day = value; } - } - - /// Returns the hour portion of this datetime - public int Hour - { - get { return hour; } - set { hour = value; } - } - - /// Returns the minute portion of this datetime - public int Minute - { - get { return minute; } - set { minute = value; } - } - - /// Returns the second portion of this datetime - public int Second - { - get { return second; } - set { second = value; } - } - - /// - /// Retrieves the millisecond value of this object. - /// - public int Millisecond - { - get { return millisecond; } - set { millisecond = value; } - } - - #endregion - - #region IMySqlValue Members - - /// - /// Returns true if this datetime object has a null value - /// - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return type; } - } - - DbType IMySqlValue.DbType - { - get - { - if (type == MySqlDbType.Date || type == MySqlDbType.Newdate) - return DbType.Date; - return DbType.DateTime; - } - } - - object IMySqlValue.Value - { - get { return GetDateTime(); } - } - - /// - /// Retrieves the value of this as a DateTime object. - /// - public DateTime Value - { - get { return GetDateTime(); } - } - - Type IMySqlValue.SystemType - { - get { return typeof(DateTime); } - } - - string IMySqlValue.MySqlTypeName - { - get - { - switch (type) - { - case MySqlDbType.Date: return "DATE"; - case MySqlDbType.Newdate: return "NEWDATE"; - case MySqlDbType.Timestamp: return "TIMESTAMP"; - } - return "DATETIME"; - } - } - - - private void SerializeText(MySqlPacket packet, MySqlDateTime value) - { - string val = String.Empty; - - if (type == MySqlDbType.Timestamp && !packet.Version.isAtLeast(4, 1, 0)) - val = String.Format("{0:0000}{1:00}{2:00}{3:00}{4:00}{5:00}", - value.Year, value.Month, value.Day, value.Hour, value.Minute, value.Second); - else - { - val = String.Format("{0:0000}-{1:00}-{2:00}", - value.Year, value.Month, value.Day); - if (type != MySqlDbType.Date) - val = String.Format("{0} {1:00}:{2:00}:{3:00}", val, - value.Hour, value.Minute, value.Second); - } - packet.WriteStringNoNull("'" + val + "'"); - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object value, int length) - { - MySqlDateTime dtValue; - - string valueAsString = value as string; - - if (value is DateTime) - dtValue = new MySqlDateTime(type, (DateTime)value); - else if (valueAsString != null) - dtValue = new MySqlDateTime(type, DateTime.Parse(valueAsString, CultureInfo.CurrentCulture)); - else if (value is MySqlDateTime) - dtValue = (MySqlDateTime)value; - else - throw new MySqlException("Unable to serialize date/time value."); - - if (!binary) - { - SerializeText(packet, dtValue); - return; - } - - if (type == MySqlDbType.Timestamp) - packet.WriteByte(11); - else - packet.WriteByte(7); - - packet.WriteInteger(dtValue.Year, 2); - packet.WriteByte((byte)dtValue.Month); - packet.WriteByte((byte)dtValue.Day); - if (type == MySqlDbType.Date) - { - packet.WriteByte(0); - packet.WriteByte(0); - packet.WriteByte(0); - } - else - { - packet.WriteByte((byte)dtValue.Hour); - packet.WriteByte((byte)dtValue.Minute); - packet.WriteByte((byte)dtValue.Second); - } - - if (type == MySqlDbType.Timestamp) - packet.WriteInteger(dtValue.Millisecond, 4); - } - - private MySqlDateTime Parse40Timestamp(string s) - { - int pos = 0; - year = month = day = 1; - hour = minute = second = 0; - - if (s.Length == 14 || s.Length == 8) - { - year = int.Parse(s.Substring(pos, 4)); - pos += 4; - } - else - { - year = int.Parse(s.Substring(pos, 2)); - pos += 2; - if (year >= 70) - year += 1900; - else - year += 2000; - } - - if (s.Length > 2) - { - month = int.Parse(s.Substring(pos, 2)); - pos += 2; - } - if (s.Length > 4) - { - day = int.Parse(s.Substring(pos, 2)); - pos += 2; - } - if (s.Length > 8) - { - hour = int.Parse(s.Substring(pos, 2)); - minute = int.Parse(s.Substring(pos + 2, 2)); - pos += 4; - } - if (s.Length > 10) - second = int.Parse(s.Substring(pos, 2)); - - return new MySqlDateTime(type, year, month, day, hour, - minute, second); - } - - static internal MySqlDateTime Parse(string s) - { - MySqlDateTime dt = new MySqlDateTime(); - return dt.ParseMySql(s, true); - } - - static internal MySqlDateTime Parse(string s, Common.DBVersion version) - { - MySqlDateTime dt = new MySqlDateTime(); - return dt.ParseMySql(s, version.isAtLeast(4, 1, 0)); - } - - private MySqlDateTime ParseMySql(string s, bool is41) - { - if (type == MySqlDbType.Timestamp && !is41) - return Parse40Timestamp(s); - - string[] parts = s.Split('-', ' ', ':', '/'); - - int year = int.Parse(parts[0]); - int month = int.Parse(parts[1]); - int day = int.Parse(parts[2]); - - int hour = 0, minute = 0, second = 0; - if (parts.Length > 3) - { - hour = int.Parse(parts[3]); - minute = int.Parse(parts[4]); - second = int.Parse(parts[5]); - } - - return new MySqlDateTime(type, year, month, day, hour, minute, second); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) return new MySqlDateTime(type, true); - - if (length >= 0) - { - string value = packet.ReadString(length); - return ParseMySql(value, packet.Version.isAtLeast(4, 1, 0)); - } - - long bufLength = packet.ReadByte(); - int year = 0, month = 0, day = 0; - int hour = 0, minute = 0, second = 0; - - if (bufLength >= 4) - { - year = packet.ReadInteger(2); - month = packet.ReadByte(); - day = packet.ReadByte(); - } - - if (bufLength > 4) - { - hour = packet.ReadByte(); - minute = packet.ReadByte(); - second = packet.ReadByte(); - } - - if (bufLength > 7) - packet.ReadInteger(4); - - return new MySqlDateTime(type, year, month, day, hour, minute, second); - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - int len = packet.ReadByte(); - packet.Position += len; - } - - #endregion - - /// Returns this value as a DateTime - public DateTime GetDateTime() - { - if (!IsValidDateTime) - throw new MySqlConversionException("Unable to convert MySQL date/time value to System.DateTime"); - - return new DateTime(year, month, day, hour, minute, second); - } - - private static string FormatDateCustom(string format, int monthVal, int dayVal, int yearVal) - { - format = format.Replace("MM", "{0:00}"); - format = format.Replace("M", "{0}"); - format = format.Replace("dd", "{1:00}"); - format = format.Replace("d", "{1}"); - format = format.Replace("yyyy", "{2:0000}"); - format = format.Replace("yy", "{3:00}"); - format = format.Replace("y", "{4:0}"); - - int year2digit = yearVal - ((yearVal / 1000) * 1000); - year2digit -= ((year2digit / 100) * 100); - int year1digit = year2digit - ((year2digit / 10) * 10); - - return String.Format(format, monthVal, dayVal, yearVal, year2digit, year1digit); - } - - /// Returns a MySQL specific string representation of this value - public override string ToString() - { - if (this.IsValidDateTime) - { - DateTime d = new DateTime(year, month, day, hour, minute, second); - return (type == MySqlDbType.Date) ? d.ToString("d") : d.ToString(); - } - - string dateString = FormatDateCustom( - CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern, month, day, year); - if (type == MySqlDbType.Date) - return dateString; - - DateTime dt = new DateTime(1, 2, 3, hour, minute, second); - dateString = String.Format("{0} {1}", dateString, dt.ToLongTimeString()); - return dateString; - } - - /// - /// - /// - public static explicit operator DateTime(MySqlDateTime val) - { - if (!val.IsValidDateTime) return DateTime.MinValue; - return val.GetDateTime(); - } - - internal static void SetDSInfo(DataTable dsTable) - { - string[] types = new string[] { "DATE", "DATETIME", "TIMESTAMP" }; - MySqlDbType[] dbtype = new MySqlDbType[] { MySqlDbType.Date, - MySqlDbType.DateTime, MySqlDbType.Timestamp }; - - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - for (int x = 0; x < types.Length; x++) - { - DataRow row = dsTable.NewRow(); - row["TypeName"] = types[x]; - row["ProviderDbType"] = dbtype[x]; - row["ColumnSize"] = 0; - row["CreateFormat"] = types[x]; - row["CreateParameters"] = null; - row["DataType"] = "System.DateTime"; - row["IsAutoincrementable"] = false; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } - - #region IConvertible Members - - ulong IConvertible.ToUInt64(IFormatProvider provider) - { - return 0; - } - - sbyte IConvertible.ToSByte(IFormatProvider provider) - { - // TODO: Add MySqlDateTime.ToSByte implementation - return 0; - } - - double IConvertible.ToDouble(IFormatProvider provider) - { - return 0; - } - - DateTime IConvertible.ToDateTime(IFormatProvider provider) - { - return this.GetDateTime(); - } - - float IConvertible.ToSingle(IFormatProvider provider) - { - return 0; - } - - bool IConvertible.ToBoolean(IFormatProvider provider) - { - return false; - } - - int IConvertible.ToInt32(IFormatProvider provider) - { - return 0; - } - - ushort IConvertible.ToUInt16(IFormatProvider provider) - { - return 0; - } - - short IConvertible.ToInt16(IFormatProvider provider) - { - return 0; - } - - string System.IConvertible.ToString(IFormatProvider provider) - { - return null; - } - - byte IConvertible.ToByte(IFormatProvider provider) - { - return 0; - } - - char IConvertible.ToChar(IFormatProvider provider) - { - return '\0'; - } - - long IConvertible.ToInt64(IFormatProvider provider) - { - return 0; - } - - System.TypeCode IConvertible.GetTypeCode() - { - return new System.TypeCode(); - } - - decimal IConvertible.ToDecimal(IFormatProvider provider) - { - return 0; - } - - object IConvertible.ToType(Type conversionType, IFormatProvider provider) - { - return null; - } - - uint IConvertible.ToUInt32(IFormatProvider provider) - { - return 0; - } - - #endregion - - #region IComparable Members - - int IComparable.CompareTo(object obj) - { - MySqlDateTime otherDate = (MySqlDateTime)obj; - - if (Year < otherDate.Year) return -1; - else if (Year > otherDate.Year) return 1; - - if (Month < otherDate.Month) return -1; - else if (Month > otherDate.Month) return 1; - - if (Day < otherDate.Day) return -1; - else if (Day > otherDate.Day) return 1; - - if (Hour < otherDate.Hour) return -1; - else if (Hour > otherDate.Hour) return 1; - - if (Minute < otherDate.Minute) return -1; - else if (Minute > otherDate.Minute) return 1; - - if (Second < otherDate.Second) return -1; - else if (Second > otherDate.Second) return 1; - - if (Millisecond < otherDate.Millisecond) return -1; - else if (Millisecond > otherDate.Millisecond) return 1; - - return 0; - } - - #endregion - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDecimal.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDecimal.cs deleted file mode 100644 index f6baae7..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDecimal.cs +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using System.Globalization; - -namespace MySql.Data.Types -{ - - public struct MySqlDecimal : IMySqlValue - { - private byte precision; - private byte scale; - private string mValue; - private bool isNull; - - internal MySqlDecimal(bool isNull) - { - this.isNull = isNull; - mValue = null; - precision = scale = 0; - } - - internal MySqlDecimal(string val) - { - this.isNull = false; - precision = scale = 0; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.Decimal; } - } - - public byte Precision - { - get { return precision; } - set { precision = value; } - } - - public byte Scale - { - get { return scale; } - set { scale = value; } - } - - - DbType IMySqlValue.DbType - { - get { return DbType.Decimal; } - } - - object IMySqlValue.Value - { - get { return this.Value; } - } - - public decimal Value - { - get { return Convert.ToDecimal(mValue, CultureInfo.InvariantCulture); } - } - - public double ToDouble() - { - return Double.Parse(mValue); - } - - public override string ToString() - { - return mValue; - } - - Type IMySqlValue.SystemType - { - get { return typeof(decimal); } - } - - string IMySqlValue.MySqlTypeName - { - get { return "DECIMAL"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - decimal v = (val is decimal) ? (decimal)val : Convert.ToDecimal(val); - string valStr = v.ToString(CultureInfo.InvariantCulture); - if (binary) - packet.WriteLenString(valStr); - else - packet.WriteStringNoNull(valStr); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) - return new MySqlDecimal(true); - - string s = String.Empty; - if (length == -1) - s = packet.ReadLenString(); - else - s = packet.ReadString(length); - return new MySqlDecimal(s); - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - int len = packet.ReadFieldLength(); - packet.Position += len; - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "DECIMAL"; - row["ProviderDbType"] = MySqlDbType.NewDecimal; - row["ColumnSize"] = 0; - row["CreateFormat"] = "DECIMAL({0},{1})"; - row["CreateParameters"] = "precision,scale"; - row["DataType"] = "System.Decimal"; - row["IsAutoincrementable"] = false; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDouble.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDouble.cs deleted file mode 100644 index fbfd7ef..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlDouble.cs +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Globalization; -using MySql.Data.MySqlClient; - -namespace MySql.Data.Types -{ - - internal struct MySqlDouble : IMySqlValue - { - private double mValue; - private bool isNull; - - public MySqlDouble(bool isNull) - { - this.isNull = isNull; - mValue = 0.0; - } - - public MySqlDouble(double val) - { - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.Double; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.Double; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public double Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(double); } - } - - string IMySqlValue.MySqlTypeName - { - get { return "DOUBLE"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - double v = (val is double) ? (double)val : Convert.ToDouble(val); - if (binary) - packet.Write(BitConverter.GetBytes(v)); - else - packet.WriteStringNoNull(v.ToString("R", CultureInfo.InvariantCulture)); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, - bool nullVal) - { - if (nullVal) - return new MySqlDouble(true); - - if (length == -1) - { - byte[] b = new byte[8]; - packet.Read(b, 0, 8); - return new MySqlDouble(BitConverter.ToDouble(b, 0)); - } - return new MySqlDouble(Double.Parse(packet.ReadString(length), - CultureInfo.InvariantCulture)); - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - packet.Position += 8; - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "DOUBLE"; - row["ProviderDbType"] = MySqlDbType.Double; - row["ColumnSize"] = 0; - row["CreateFormat"] = "DOUBLE"; - row["CreateParameters"] = null; - row["DataType"] = "System.Double"; - row["IsAutoincrementable"] = false; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlGuid.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlGuid.cs deleted file mode 100644 index fcc5df4..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlGuid.cs +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.Types -{ - - internal struct MySqlGuid : IMySqlValue - { - Guid mValue; - private bool isNull; - private byte[] bytes; - private bool oldGuids; - - public MySqlGuid(byte[] buff) - { - oldGuids = false; - mValue = new Guid(buff); - isNull = false; - bytes = buff; - } - - public byte[] Bytes - { - get { return bytes; } - } - - public bool OldGuids - { - get { return oldGuids; } - set { oldGuids = value; } - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.Guid; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.Guid; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public Guid Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(Guid); } - } - - string IMySqlValue.MySqlTypeName - { - get { return OldGuids ? "BINARY(16)" : "CHAR(36)"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - Guid guid = Guid.Empty; - string valAsString = val as string; - byte[] valAsByte = val as byte[]; - - if (val is Guid) - guid = (Guid)val; - else - { - try - { - if (valAsString != null) - guid = new Guid(valAsString); - else if (valAsByte != null) - guid = new Guid(valAsByte); - } - catch (Exception ex) - { - throw new MySqlException(Resources.DataNotInSupportedFormat, ex); - } - } - - if (OldGuids) - WriteOldGuid(packet, guid, binary); - else - { - guid.ToString("D"); - - if (binary) - packet.WriteLenString(guid.ToString("D")); - else - packet.WriteStringNoNull("'" + MySqlHelper.EscapeString(guid.ToString("D")) + "'"); - } - } - - private void WriteOldGuid(MySqlPacket packet, Guid guid, bool binary) - { - byte[] bytes = guid.ToByteArray(); - - if (binary) - { - packet.WriteLength(bytes.Length); - packet.Write(bytes); - } - else - { - if (packet.Version.isAtLeast(4, 1, 0)) - packet.WriteStringNoNull("_binary "); - - packet.WriteByte((byte)'\''); - EscapeByteArray(bytes, bytes.Length, packet); - packet.WriteByte((byte)'\''); - } - } - - private static void EscapeByteArray(byte[] bytes, int length, MySqlPacket packet) - { - for (int x = 0; x < length; x++) - { - byte b = bytes[x]; - if (b == '\0') - { - packet.WriteByte((byte)'\\'); - packet.WriteByte((byte)'0'); - } - - else if (b == '\\' || b == '\'' || b == '\"') - { - packet.WriteByte((byte)'\\'); - packet.WriteByte(b); - } - else - packet.WriteByte(b); - } - } - - private MySqlGuid ReadOldGuid(MySqlPacket packet, long length) - { - if (length == -1) - length = (long)packet.ReadFieldLength(); - - byte[] buff = new byte[length]; - packet.Read(buff, 0, (int)length); - MySqlGuid g = new MySqlGuid(buff); - g.OldGuids = OldGuids; - return g; - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - MySqlGuid g = new MySqlGuid(); - g.isNull = true; - g.OldGuids = OldGuids; - if (!nullVal) - { - if (OldGuids) - return ReadOldGuid(packet, length); - string s = String.Empty; - if (length == -1) - s = packet.ReadLenString(); - else - s = packet.ReadString(length); - g.mValue = new Guid(s); - g.isNull = false; - } - return g; - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - int len = packet.ReadFieldLength(); - packet.Position += len; - } - - #endregion - - public static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "GUID"; - row["ProviderDbType"] = MySqlDbType.Guid; - row["ColumnSize"] = 0; - row["CreateFormat"] = "BINARY(16)"; - row["CreateParameters"] = null; - row["DataType"] = "System.Guid"; - row["IsAutoincrementable"] = false; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = false; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt16.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt16.cs deleted file mode 100644 index 9738969..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt16.cs +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; - -namespace MySql.Data.Types -{ - internal struct MySqlInt16 : IMySqlValue - { - private short mValue; - private bool isNull; - - public MySqlInt16(bool isNull) - { - this.isNull = isNull; - mValue = 0; - } - - public MySqlInt16(short val) - { - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.Int16; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.Int16; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public short Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(short); } - } - - string IMySqlValue.MySqlTypeName - { - get { return "SMALLINT"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - int v = (val is Int32) ? (int)val : Convert.ToInt32(val); - if (binary) - packet.WriteInteger((long)v, 2); - else - packet.WriteStringNoNull(v.ToString()); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) - return new MySqlInt16(true); - - packet.Encoding = System.Text.Encoding.ASCII; - if (length == -1) - return new MySqlInt16((short)packet.ReadInteger(2)); - else - return new MySqlInt16(Int16.Parse(packet.ReadString(length))); - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - packet.Position += 2; - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "SMALLINT"; - row["ProviderDbType"] = MySqlDbType.Int16; - row["ColumnSize"] = 0; - row["CreateFormat"] = "SMALLINT"; - row["CreateParameters"] = null; - row["DataType"] = "System.Int16"; - row["IsAutoincrementable"] = true; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt32.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt32.cs deleted file mode 100644 index 39647a9..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt32.cs +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using System.Globalization; - -namespace MySql.Data.Types -{ - internal struct MySqlInt32 : IMySqlValue - { - private int mValue; - private bool isNull; - private bool is24Bit; - - private MySqlInt32(MySqlDbType type) - { - is24Bit = type == MySqlDbType.Int24 ? true : false; - isNull = true; - mValue = 0; - } - - public MySqlInt32(MySqlDbType type, bool isNull) - : this(type) - { - this.isNull = isNull; - } - - public MySqlInt32(MySqlDbType type, int val) - : this(type) - { - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.Int32; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.Int32; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public int Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(Int32); } - } - - string IMySqlValue.MySqlTypeName - { - get { return is24Bit ? "MEDIUMINT" : "INT"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - int v = (val is Int32) ? (int)val : Convert.ToInt32(val); - if (binary) - packet.WriteInteger((long)v, is24Bit ? 3 : 4); - else - packet.WriteStringNoNull(v.ToString()); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) - return new MySqlInt32((this as IMySqlValue).MySqlDbType, true); - - packet.Encoding = System.Text.Encoding.ASCII; - if (length == -1) - return new MySqlInt32((this as IMySqlValue).MySqlDbType, - packet.ReadInteger(4)); - else - return new MySqlInt32((this as IMySqlValue).MySqlDbType, - Int32.Parse(packet.ReadString(length), - CultureInfo.InvariantCulture)); - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - packet.Position += 4; - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - string[] types = new string[] { "INT", "YEAR", "MEDIUMINT" }; - MySqlDbType[] dbtype = new MySqlDbType[] { MySqlDbType.Int32, - MySqlDbType.Year, MySqlDbType.Int24 }; - - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - for (int x = 0; x < types.Length; x++) - { - DataRow row = dsTable.NewRow(); - row["TypeName"] = types[x]; - row["ProviderDbType"] = dbtype[x]; - row["ColumnSize"] = 0; - row["CreateFormat"] = types[x]; - row["CreateParameters"] = null; - row["DataType"] = "System.Int32"; - row["IsAutoincrementable"] = dbtype[x] == MySqlDbType.Year ? false : true; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt64.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt64.cs deleted file mode 100644 index 07e5914..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlInt64.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; - -namespace MySql.Data.Types -{ - internal struct MySqlInt64 : IMySqlValue - { - private long mValue; - private bool isNull; - - public MySqlInt64(bool isNull) - { - this.isNull = isNull; - mValue = 0; - } - - public MySqlInt64(long val) - { - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.Int64; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.Int64; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public long Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(long); } - } - - string IMySqlValue.MySqlTypeName - { - get { return "BIGINT"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - long v = (val is Int64) ? (Int64)val : Convert.ToInt64(val); - if (binary) - packet.WriteInteger(v, 8); - else - packet.WriteStringNoNull(v.ToString()); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) - return new MySqlInt64(true); - - if (length == -1) - return new MySqlInt64((long)packet.ReadULong(8)); - else - return new MySqlInt64(Int64.Parse(packet.ReadString(length))); - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - packet.Position += 8; - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "BIGINT"; - row["ProviderDbType"] = MySqlDbType.Int64; - row["ColumnSize"] = 0; - row["CreateFormat"] = "BIGINT"; - row["CreateParameters"] = null; - row["DataType"] = "System.Int64"; - row["IsAutoincrementable"] = true; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlSingle.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlSingle.cs deleted file mode 100644 index d3f9fdb..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlSingle.cs +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using System.Globalization; - -namespace MySql.Data.Types -{ - internal struct MySqlSingle : IMySqlValue - { - private float mValue; - private bool isNull; - - public MySqlSingle(bool isNull) - { - this.isNull = isNull; - mValue = 0.0f; - } - - public MySqlSingle(float val) - { - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.Float; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.Single; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public float Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(float); } - } - - string IMySqlValue.MySqlTypeName - { - get { return "FLOAT"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - Single v = (val is Single) ? (Single)val : Convert.ToSingle(val); - if (binary) - packet.Write(BitConverter.GetBytes(v)); - else - packet.WriteStringNoNull(v.ToString("R", - CultureInfo.InvariantCulture)); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) - return new MySqlSingle(true); - - if (length == -1) - { - byte[] b = new byte[4]; - packet.Read(b, 0, 4); - return new MySqlSingle(BitConverter.ToSingle(b, 0)); - } - return new MySqlSingle(Single.Parse(packet.ReadString(length), - CultureInfo.InvariantCulture)); - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - packet.Position += 4; - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "FLOAT"; - row["ProviderDbType"] = MySqlDbType.Float; - row["ColumnSize"] = 0; - row["CreateFormat"] = "FLOAT"; - row["CreateParameters"] = null; - row["DataType"] = "System.Single"; - row["IsAutoincrementable"] = false; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlString.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlString.cs deleted file mode 100644 index e310b7b..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlString.cs +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using MySql.Data.MySqlClient; - -namespace MySql.Data.Types -{ - internal struct MySqlString : IMySqlValue - { - private string mValue; - private bool isNull; - private MySqlDbType type; - - public MySqlString(MySqlDbType type, bool isNull) - { - this.type = type; - this.isNull = isNull; - mValue = String.Empty; - } - - public MySqlString(MySqlDbType type, string val) - { - this.type = type; - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return type; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.String; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public string Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(string); } - } - - string IMySqlValue.MySqlTypeName - { - get { return type == MySqlDbType.Set ? "SET" : type == MySqlDbType.Enum ? "ENUM" : "VARCHAR"; } - } - - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - string v = val.ToString(); - if (length > 0) - { - length = Math.Min(length, v.Length); - v = v.Substring(0, length); - } - - if (binary) - packet.WriteLenString(v); - else - packet.WriteStringNoNull("'" + MySqlHelper.EscapeString(v) + "'"); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) - return new MySqlString(type, true); - - string s = String.Empty; - if (length == -1) - s = packet.ReadLenString(); - else - s = packet.ReadString(length); - MySqlString str = new MySqlString(type, s); - return str; - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - int len = packet.ReadFieldLength(); - packet.Position += len; - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - string[] types = new string[] { "CHAR", "NCHAR", "VARCHAR", "NVARCHAR", "SET", - "ENUM", "TINYTEXT", "TEXT", "MEDIUMTEXT", "LONGTEXT" }; - MySqlDbType[] dbtype = new MySqlDbType[] { MySqlDbType.String, MySqlDbType.String, - MySqlDbType.VarChar, MySqlDbType.VarChar, MySqlDbType.Set, MySqlDbType.Enum, - MySqlDbType.TinyText, MySqlDbType.Text, MySqlDbType.MediumText, - MySqlDbType.LongText }; - - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - for (int x = 0; x < types.Length; x++) - { - DataRow row = dsTable.NewRow(); - row["TypeName"] = types[x]; - row["ProviderDbType"] = dbtype[x]; - row["ColumnSize"] = 0; - row["CreateFormat"] = x < 4 ? types[x] + "({0})" : types[x]; - row["CreateParameters"] = x < 4 ? "size" : null; - row["DataType"] = "System.String"; - row["IsAutoincrementable"] = false; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = false; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = true; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlTime.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlTime.cs deleted file mode 100644 index e1a5cc6..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlTime.cs +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; - -namespace MySql.Data.Types -{ - internal struct MySqlTimeSpan : IMySqlValue - { - private TimeSpan mValue; - private bool isNull; - - public MySqlTimeSpan(bool isNull) - { - this.isNull = isNull; - mValue = TimeSpan.MinValue; - } - - public MySqlTimeSpan(TimeSpan val) - { - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.Time; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.Time; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public TimeSpan Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(TimeSpan); } - } - - string IMySqlValue.MySqlTypeName - { - get { return "TIME"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - if (!(val is TimeSpan)) - throw new MySqlException("Only TimeSpan objects can be serialized by MySqlTimeSpan"); - - TimeSpan ts = (TimeSpan)val; - bool negative = ts.TotalMilliseconds < 0; - ts = ts.Duration(); - - if (binary) - { - packet.WriteByte(8); - packet.WriteByte((byte)(negative ? 1 : 0)); - packet.WriteInteger(ts.Days, 4); - packet.WriteByte((byte)ts.Hours); - packet.WriteByte((byte)ts.Minutes); - packet.WriteByte((byte)ts.Seconds); - } - else - { - String s = String.Format("'{0}{1} {2:00}:{3:00}:{4:00}.{5}'", - negative ? "-" : "", ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds); - - packet.WriteStringNoNull(s); - } - } - - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) return new MySqlTimeSpan(true); - - if (length >= 0) - { - string value = packet.ReadString(length); - ParseMySql(value, packet.Version.isAtLeast(4, 1, 0)); - return this; - } - - long bufLength = packet.ReadByte(); - int negate = 0; - if (bufLength > 0) - negate = packet.ReadByte(); - - isNull = false; - if (bufLength == 0) - isNull = true; - else if (bufLength == 5) - mValue = new TimeSpan(packet.ReadInteger(4), 0, 0, 0); - else if (bufLength == 8) - mValue = new TimeSpan(packet.ReadInteger(4), - packet.ReadByte(), packet.ReadByte(), packet.ReadByte()); - else - mValue = new TimeSpan(packet.ReadInteger(4), - packet.ReadByte(), packet.ReadByte(), packet.ReadByte(), - packet.ReadInteger(4) / 1000000); - - if (negate == 1) - mValue = mValue.Negate(); - return this; - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - int len = packet.ReadByte(); - packet.Position += len; - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "TIME"; - row["ProviderDbType"] = MySqlDbType.Time; - row["ColumnSize"] = 0; - row["CreateFormat"] = "TIME"; - row["CreateParameters"] = null; - row["DataType"] = "System.TimeSpan"; - row["IsAutoincrementable"] = false; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = false; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - - public override string ToString() - { - return String.Format("{0} {1:00}:{2:00}:{3:00}.{4}", - mValue.Days, mValue.Hours, mValue.Minutes, mValue.Seconds, mValue.Milliseconds); - } - - private void ParseMySql(string s, bool is41) - { - string[] parts = s.Split(':'); - int hours = Int32.Parse(parts[0]); - int mins = Int32.Parse(parts[1]); - int secs = Int32.Parse(parts[2]); - if (hours < 0 || parts[0].StartsWith("-")) - { - mins *= -1; - secs *= -1; - } - int days = hours / 24; - hours = hours - (days * 24); - mValue = new TimeSpan(days, hours, mins, secs, 0); - isNull = false; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUByte.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUByte.cs deleted file mode 100644 index 32e700e..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUByte.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; - -namespace MySql.Data.Types -{ - internal struct MySqlUByte : IMySqlValue - { - private byte mValue; - private bool isNull; - - public MySqlUByte(bool isNull) - { - this.isNull = isNull; - mValue = 0; - } - - public MySqlUByte(byte val) - { - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.UByte; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.Byte; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public byte Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(byte); } - } - - string IMySqlValue.MySqlTypeName - { - get { return "TINYINT"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - byte v = (val is byte) ? (byte)val : Convert.ToByte(val); - if (binary) - packet.WriteByte(v); - else - packet.WriteStringNoNull(v.ToString()); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) - return new MySqlUByte(true); - - if (length == -1) - return new MySqlUByte((byte)packet.ReadByte()); - else - return new MySqlUByte(Byte.Parse(packet.ReadString(length))); - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - packet.ReadByte(); - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "TINY INT"; - row["ProviderDbType"] = MySqlDbType.UByte; - row["ColumnSize"] = 0; - row["CreateFormat"] = "TINYINT UNSIGNED"; - row["CreateParameters"] = null; - row["DataType"] = "System.Byte"; - row["IsAutoincrementable"] = true; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = true; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt16.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt16.cs deleted file mode 100644 index aeae97c..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt16.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; - -namespace MySql.Data.Types -{ - internal struct MySqlUInt16 : IMySqlValue - { - private ushort mValue; - private bool isNull; - - public MySqlUInt16(bool isNull) - { - this.isNull = isNull; - mValue = 0; - } - - public MySqlUInt16(ushort val) - { - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.UInt16; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.UInt16; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public ushort Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(ushort); } - } - - string IMySqlValue.MySqlTypeName - { - get { return "SMALLINT"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - int v = (val is UInt16) ? (UInt16)val : Convert.ToUInt16(val); - if (binary) - packet.WriteInteger((long)v, 2); - else - packet.WriteStringNoNull(v.ToString()); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) - return new MySqlUInt16(true); - - if (length == -1) - return new MySqlUInt16((ushort)packet.ReadInteger(2)); - else - return new MySqlUInt16(UInt16.Parse(packet.ReadString(length))); - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - packet.Position += 2; - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "SMALLINT"; - row["ProviderDbType"] = MySqlDbType.UInt16; - row["ColumnSize"] = 0; - row["CreateFormat"] = "SMALLINT UNSIGNED"; - row["CreateParameters"] = null; - row["DataType"] = "System.UInt16"; - row["IsAutoincrementable"] = true; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = true; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt32.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt32.cs deleted file mode 100644 index e0a7483..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt32.cs +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using System.Globalization; - -namespace MySql.Data.Types -{ - internal struct MySqlUInt32 : IMySqlValue - { - private uint mValue; - private bool isNull; - private bool is24Bit; - - private MySqlUInt32(MySqlDbType type) - { - is24Bit = type == MySqlDbType.Int24 ? true : false; - isNull = true; - mValue = 0; - } - - public MySqlUInt32(MySqlDbType type, bool isNull) - : this(type) - { - this.isNull = isNull; - } - - public MySqlUInt32(MySqlDbType type, uint val) - : this(type) - { - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.UInt32; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.UInt32; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public uint Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(UInt32); } - } - - string IMySqlValue.MySqlTypeName - { - get { return is24Bit ? "MEDIUMINT" : "INT"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object v, int length) - { - uint val = (v is uint) ? (uint)v : Convert.ToUInt32(v); - if (binary) - packet.WriteInteger((long)val, is24Bit ? 3 : 4); - else - packet.WriteStringNoNull(val.ToString()); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) - return new MySqlUInt32((this as IMySqlValue).MySqlDbType, true); - - if (length == -1) - return new MySqlUInt32((this as IMySqlValue).MySqlDbType, - (uint)packet.ReadInteger(4)); - else - return new MySqlUInt32((this as IMySqlValue).MySqlDbType, - UInt32.Parse(packet.ReadString(length), NumberStyles.Any, CultureInfo.InvariantCulture)); - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - packet.Position += 4; - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - string[] types = new string[] { "MEDIUMINT", "INT" }; - MySqlDbType[] dbtype = new MySqlDbType[] { MySqlDbType.UInt24, - MySqlDbType.UInt32 }; - - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - for (int x = 0; x < types.Length; x++) - { - DataRow row = dsTable.NewRow(); - row["TypeName"] = types[x]; - row["ProviderDbType"] = dbtype[x]; - row["ColumnSize"] = 0; - row["CreateFormat"] = types[x] + " UNSIGNED"; - row["CreateParameters"] = null; - row["DataType"] = "System.UInt32"; - row["IsAutoincrementable"] = true; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = true; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt64.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt64.cs deleted file mode 100644 index 30bf3df..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlUInt64.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; - -namespace MySql.Data.Types -{ - internal struct MySqlUInt64 : IMySqlValue - { - private ulong mValue; - private bool isNull; - - public MySqlUInt64(bool isNull) - { - this.isNull = isNull; - mValue = 0; - } - - public MySqlUInt64(ulong val) - { - this.isNull = false; - mValue = val; - } - - #region IMySqlValue Members - - public bool IsNull - { - get { return isNull; } - } - - MySqlDbType IMySqlValue.MySqlDbType - { - get { return MySqlDbType.UInt64; } - } - - DbType IMySqlValue.DbType - { - get { return DbType.UInt64; } - } - - object IMySqlValue.Value - { - get { return mValue; } - } - - public ulong Value - { - get { return mValue; } - } - - Type IMySqlValue.SystemType - { - get { return typeof(ulong); } - } - - string IMySqlValue.MySqlTypeName - { - get { return "BIGINT"; } - } - - void IMySqlValue.WriteValue(MySqlPacket packet, bool binary, object val, int length) - { - ulong v = (val is ulong) ? (ulong)val : Convert.ToUInt64(val); - if (binary) - packet.WriteInteger((long)v, 8); - else - packet.WriteStringNoNull(v.ToString()); - } - - IMySqlValue IMySqlValue.ReadValue(MySqlPacket packet, long length, bool nullVal) - { - if (nullVal) - return new MySqlUInt64(true); - - if (length == -1) - return new MySqlUInt64(packet.ReadULong(8)); - else - return new MySqlUInt64(UInt64.Parse(packet.ReadString(length))); - } - - void IMySqlValue.SkipValue(MySqlPacket packet) - { - packet.Position += 8; - } - - #endregion - - internal static void SetDSInfo(DataTable dsTable) - { - // we use name indexing because this method will only be called - // when GetSchema is called for the DataSourceInformation - // collection and then it wil be cached. - DataRow row = dsTable.NewRow(); - row["TypeName"] = "BIGINT"; - row["ProviderDbType"] = MySqlDbType.UInt64; - row["ColumnSize"] = 0; - row["CreateFormat"] = "BIGINT UNSIGNED"; - row["CreateParameters"] = null; - row["DataType"] = "System.UInt64"; - row["IsAutoincrementable"] = true; - row["IsBestMatch"] = true; - row["IsCaseSensitive"] = false; - row["IsFixedLength"] = true; - row["IsFixedPrecisionScale"] = true; - row["IsLong"] = false; - row["IsNullable"] = true; - row["IsSearchable"] = true; - row["IsSearchableWithLike"] = false; - row["IsUnsigned"] = true; - row["MaximumScale"] = 0; - row["MinimumScale"] = 0; - row["IsConcurrencyType"] = DBNull.Value; - row["IsLiteralSupported"] = false; - row["LiteralPrefix"] = null; - row["LiteralSuffix"] = null; - row["NativeDataType"] = null; - dsTable.Rows.Add(row); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlValue.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlValue.cs deleted file mode 100644 index 1c1a35a..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/Types/MySqlValue.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Globalization; -using MySql.Data.MySqlClient; - -namespace MySql.Data.Types -{ - internal interface IMySqlValue - { - bool IsNull { get; } - MySqlDbType MySqlDbType { get; } - DbType DbType { get; } - object Value { get; /*set;*/ } - Type SystemType { get; } - string MySqlTypeName { get; } - - void WriteValue(MySqlPacket packet, bool binary, object value, int length); - IMySqlValue ReadValue(MySqlPacket packet, long length, bool isNull); - void SkipValue(MySqlPacket packet); - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/base/DbConnectionStringBuilder.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/base/DbConnectionStringBuilder.cs deleted file mode 100644 index 1baf7e8..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/base/DbConnectionStringBuilder.cs +++ /dev/null @@ -1,339 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections; -using System.ComponentModel; -using System.Text; - -namespace MySql.Data.MySqlClient -{ - public class DbConnectionStringBuilder : IDictionary, ICollection, IEnumerable, ICustomTypeDescriptor - { - private string connectionString; - private Hashtable hash; - private bool browsable; - - public DbConnectionStringBuilder() - { - hash = new Hashtable(StringComparer.InvariantCultureIgnoreCase); - browsable = false; - } - - #region Properties - - public bool BrowsableConnectionString - { - get { return browsable; } - set { browsable = value; } - } - - public string ConnectionString - { - get { return connectionString; } - set - { - Clear(); - ParseConnectionString(value); - connectionString = value; - } - } - - public virtual object this[string key] - { - get { return hash[key]; } - set { Add(key, value); } - } - - #endregion - - #region IDictionary Members - - public void Add(object key, object value) - { - hash[key] = value; - //TODO: update connection string - } - - public virtual void Clear() - { - connectionString = null; - hash.Clear(); - } - - public bool Contains(object key) - { - return hash.ContainsKey(key); - } - - public IDictionaryEnumerator GetEnumerator() - { - return hash.GetEnumerator(); - } - - public bool IsFixedSize - { - get { return false; } - } - - public bool IsReadOnly - { - get { return false; } - } - - public ICollection Keys - { - get { return hash.Keys; } - } - - public void Remove(object key) - { - hash.Remove(key); - //TODO: update connection string - } - - public ICollection Values - { - get { return hash.Values; } - } - - public object this[object key] - { - get - { - return this[(string)key]; - } - set - { - this[(string)key] = value; - } - } - - #endregion - - #region ICollection Members - - public void CopyTo(Array array, int index) - { - hash.CopyTo(array, index); - } - - public int Count - { - get { return hash.Count; } - } - - public bool IsSynchronized - { - get { return hash.IsSynchronized; } - } - - public object SyncRoot - { - get { return hash.SyncRoot; } - } - - #endregion - - #region IEnumerable Members - - IEnumerator IEnumerable.GetEnumerator() - { - return hash.GetEnumerator(); - } - - #endregion - - #region ICustomTypeDescriptor Members - - public AttributeCollection GetAttributes() - { - throw new Exception("The method or operation is not implemented."); - } - - public string GetClassName() - { - throw new Exception("The method or operation is not implemented."); - } - - public string GetComponentName() - { - throw new Exception("The method or operation is not implemented."); - } - - public TypeConverter GetConverter() - { - throw new Exception("The method or operation is not implemented."); - } - - public EventDescriptor GetDefaultEvent() - { - throw new Exception("The method or operation is not implemented."); - } - - public PropertyDescriptor GetDefaultProperty() - { - throw new Exception("The method or operation is not implemented."); - } - - public object GetEditor(Type editorBaseType) - { - throw new Exception("The method or operation is not implemented."); - } - - public EventDescriptorCollection GetEvents(Attribute[] attributes) - { - throw new Exception("The method or operation is not implemented."); - } - - public EventDescriptorCollection GetEvents() - { - throw new Exception("The method or operation is not implemented."); - } - - public PropertyDescriptorCollection GetProperties(Attribute[] attributes) - { - throw new Exception("The method or operation is not implemented."); - } - - public PropertyDescriptorCollection GetProperties() - { - throw new Exception("The method or operation is not implemented."); - } - - public object GetPropertyOwner(PropertyDescriptor pd) - { - throw new Exception("The method or operation is not implemented."); - } - - #endregion - - public virtual object TryGetValue(string keyword, out object value) - { - if (!hash.ContainsKey(keyword)) - { - value = null; - return false; - } - value = hash[keyword]; - return true; - } - - private void ParseConnectionString(string connectString) - { - if (connectString == null) return; - - StringBuilder key = new StringBuilder(); - StringBuilder value = new StringBuilder(); - bool keyDone = false; - - foreach (char c in connectString) - { - if (c == '=') - keyDone = true; - else if (c == ';') - { - string keyStr = key.ToString().Trim(); - string valueStr = value.ToString().Trim(); - valueStr = CleanValue(valueStr); - if (keyStr.Length > 0) - this[keyStr] = valueStr; - keyDone = false; - key.Remove(0, key.Length); - value.Remove(0, value.Length); - } - else if (keyDone) - value.Append(c); - else - key.Append(c); - } - - if (key.Length == 0) return; - this[key.ToString().Trim()] = CleanValue(value.ToString().Trim()); - } - - private string CleanValue(string value) - { - if ((value.StartsWith("'") && value.EndsWith("'")) || - (value.StartsWith("\"") && value.EndsWith("\""))) - { - value = value.Substring(1); - value = value.Substring(0, value.Length - 1); - } - return value; - } - -/* private void ParseConnectionString(string value) - { - String[] keyvalues = src.Split(';'); - String[] newkeyvalues = new String[keyvalues.Length]; - int x = 0; - - // first run through the array and check for any keys that - // have ; in their value - foreach (String keyvalue in keyvalues) - { - // check for trailing ; at the end of the connection string - if (keyvalue.Length == 0) continue; - - // this value has an '=' sign so we are ok - if (keyvalue.IndexOf('=') >= 0) - { - newkeyvalues[x++] = keyvalue; - } - else - { - newkeyvalues[x - 1] += ";"; - newkeyvalues[x - 1] += keyvalue; - } - } - - Hashtable hash = new Hashtable(); - - // now we run through our normalized key-values, splitting on equals - for (int y = 0; y < x; y++) - { - String[] parts = newkeyvalues[y].Split('='); - - // first trim off any space and lowercase the key - parts[0] = parts[0].Trim().ToLower(); - parts[1] = parts[1].Trim(); - - // we also want to clear off any quotes - if (parts[1].Length >= 2) - { - if ((parts[1][0] == '"' && parts[1][parts[1].Length - 1] == '"') || - (parts[1][0] == '\'' && parts[1][parts[1].Length - 1] == '\'')) - { - parts[1] = parts[1].Substring(1, parts[1].Length - 2); - } - } - else - { - parts[1] = parts[1]; - } - parts[0] = parts[0].Trim('\'', '"'); - - hash[parts[0]] = parts[1]; - } - return hash; - }*/ - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/base/DbException.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/base/DbException.cs deleted file mode 100644 index a44d27f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/base/DbException.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Runtime.InteropServices; - -namespace MySql.Data.MySqlClient -{ - public abstract class DbException : ExternalException - { - private int errorCode; - - public DbException() - : base() - { - } - - public DbException(string message) : base(message) - { - } - - public DbException(string message, Exception innerException) - : base(message, innerException) - { - } - - public DbException(string message, int errorCode) - : base(message) - { - this.errorCode = errorCode; - } - - #region Properties - -// public int ErrorCode - // { - // get { return errorCode; } - // } - - #endregion - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/BufferedStream.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/BufferedStream.cs deleted file mode 100644 index 3b18600..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/BufferedStream.cs +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.IO; -using MySql.Data.MySqlClient; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.Common -{ - internal class BufferedStream : Stream - { - private byte[] writeBuffer; - private byte[] readBuffer; - private int writePos; - private int readLength; - private int readPos; - private int bufferSize; - private Stream baseStream; - - public BufferedStream(Stream stream) - { - baseStream = stream; - bufferSize = 4096; - readBuffer = new byte[bufferSize]; - writeBuffer = new byte[bufferSize]; - } - - #region Stream Implementation - - public override bool CanRead - { - get - { - if (baseStream != null) return baseStream.CanRead; - return false; - } - } - - public override bool CanSeek - { - get - { - if (baseStream != null) return baseStream.CanSeek; - return false; - } - } - - public override bool CanWrite - { - get - { - if (baseStream != null) return baseStream.CanWrite; - return false; - } - } - - public override void Flush() - { - if (baseStream == null) - throw new InvalidOperationException(Resources.ObjectDisposed); - if (writePos == 0) return; - - baseStream.Write(writeBuffer, 0, writePos); - baseStream.Flush(); - writePos = 0; - } - - public override long Length - { - get - { - if (baseStream == null) - throw new InvalidOperationException(Resources.ObjectDisposed); - Flush(); - return baseStream.Length; - } - - } - - public override long Position - { - get - { - throw new Exception("The method or operation is not implemented."); - } - set - { - throw new Exception("The method or operation is not implemented."); - } - } - - public override int Read(byte[] buffer, int offset, int count) - { - if (buffer == null) - throw new ArgumentNullException("buffer", Resources.ParameterCannotBeNull); - if (offset < 0) - throw new ArgumentOutOfRangeException("offset", Resources.OffsetCannotBeNegative); - if (count < 0) - throw new ArgumentOutOfRangeException("count", Resources.CountCannotBeNegative); - if ((buffer.Length - offset) < count) - throw new ArgumentException(Resources.OffsetMustBeValid); - if (baseStream == null) - throw new InvalidOperationException(Resources.ObjectDisposed); - - if ((readLength - readPos) == 0) - { - TryToFillReadBuffer(); - if (readLength == 0) return 0; - } - - int inBuffer = readLength - readPos; - int toRead = count; - if (toRead > inBuffer) - toRead = inBuffer; - Buffer.BlockCopy(readBuffer, readPos, buffer, offset, toRead); - readPos += toRead; - count -= toRead; - if (count > 0) - { - int read = baseStream.Read(buffer, offset + toRead, count); - toRead += read; - readPos = readLength = 0; - } - return toRead; - } - - private void TryToFillReadBuffer() - { - int read = baseStream.Read(readBuffer, 0, bufferSize); - readPos = 0; - readLength = read; - } - - public override long Seek(long offset, SeekOrigin origin) - { - throw new Exception("The method or operation is not implemented."); - } - - public override void SetLength(long value) - { - throw new Exception("The method or operation is not implemented."); - } - - public override void Write(byte[] buffer, int offset, int count) - { - if (buffer == null) - throw new ArgumentNullException("buffer", Resources.ParameterCannotBeNull); - if (offset < 0) - throw new ArgumentOutOfRangeException("offset", Resources.OffsetCannotBeNegative); - if (count < 0) - throw new ArgumentOutOfRangeException("count", Resources.CountCannotBeNegative); - if ((buffer.Length - offset) < count) - throw new ArgumentException(Resources.OffsetMustBeValid); - if (baseStream == null) - throw new InvalidOperationException(Resources.ObjectDisposed); - - // if we don't have enough room in our current write buffer for the data - // then flush the data - int roomLeft = bufferSize - writePos; - if (count > roomLeft) - Flush(); - - // if the data will not fit into a entire buffer, then there is no need to buffer it. - // We just send it down - if (count > bufferSize) - baseStream.Write(buffer, offset, count); - else - { - // if we get here then there is room in our buffer for the data. We store it and - // adjust our internal lengths. - Buffer.BlockCopy(buffer, offset, writeBuffer, writePos, count); - writePos += count; - } - } - - #endregion - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/MissingAttributes.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/MissingAttributes.cs deleted file mode 100644 index 40ae11b..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/MissingAttributes.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; - -namespace MySql.Data.MySqlClient -{ -#if CF - - class CategoryAttribute : Attribute - { - public CategoryAttribute(string cat) { } - } - - class DescriptionAttribute : Attribute - { - public DescriptionAttribute(string desc) { } - } - - class DisplayNameAttribute : Attribute - { - private string displayName; - - public DisplayNameAttribute(string name) - { - displayName = name; - } - - public string DisplayName - { - get { return displayName; } - } - } - - class RefreshPropertiesAttribute : Attribute - { - public RefreshPropertiesAttribute(RefreshProperties prop) { } - } - - class PasswordPropertyTextAttribute : Attribute - { - public PasswordPropertyTextAttribute(bool v) { } - } - - public enum RefreshProperties - { - None = 0, - All = 1, - Repaint = 2, - } - -#endif -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/WinCE.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/WinCE.cs deleted file mode 100644 index e6e2896..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/cf/WinCE.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Runtime.InteropServices; - -namespace MySql.Data.Common -{ - /// - /// Summary description for Win32. - /// - internal class WinCE - { - [DllImport("coredll", SetLastError=true)] - internal static extern Int32 WaitForSingleObject(IntPtr handle, Int32 milliseconds); - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/command.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/command.cs deleted file mode 100644 index 5d03fb4..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/command.cs +++ /dev/null @@ -1,917 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Data.Common; -using System.IO; -using System.Collections; -using System.Text; -using MySql.Data.Common; -using System.ComponentModel; -using System.Threading; -using System.Diagnostics; -using System.Globalization; -using System.Collections.Generic; -using MySql.Data.MySqlClient.Properties; -#if !CF -using System.Transactions; -#endif - -namespace MySql.Data.MySqlClient -{ - /// -#if !CF - [System.Drawing.ToolboxBitmap(typeof(MySqlCommand), "MySqlClient.resources.command.bmp")] - [System.ComponentModel.DesignerCategory("Code")] -#endif - public sealed class MySqlCommand : DbCommand, ICloneable - { - MySqlConnection connection; - MySqlTransaction curTransaction; - string cmdText; - CommandType cmdType; - long updatedRowCount; - UpdateRowSource updatedRowSource; - MySqlParameterCollection parameters; - private IAsyncResult asyncResult; - private bool designTimeVisible; - internal Int64 lastInsertedId; - private PreparableStatement statement; - private int commandTimeout; - private bool resetSqlSelect; - List batch; - private string batchableCommandText; - CommandTimer commandTimer; - - - /// - public MySqlCommand() - { - designTimeVisible = true; - cmdType = CommandType.Text; - parameters = new MySqlParameterCollection(this); - updatedRowSource = UpdateRowSource.Both; - cmdText = String.Empty; - } - - /// - public MySqlCommand(string cmdText) - : this() - { - CommandText = cmdText; - } - - /// - public MySqlCommand(string cmdText, MySqlConnection connection) - : this(cmdText) - { - Connection = connection; - } - - /// - public MySqlCommand(string cmdText, MySqlConnection connection, - MySqlTransaction transaction) - : - this(cmdText, connection) - { - curTransaction = transaction; - } - - #region Properties - - - /// -#if !CF - [Browsable(false)] -#endif - public Int64 LastInsertedId - { - get { return lastInsertedId; } - } - - /// -#if !CF - [Category("Data")] - [Description("Command text to execute")] - [Editor("MySql.Data.Common.Design.SqlCommandTextEditor,MySqlClient.Design", typeof(System.Drawing.Design.UITypeEditor))] -#endif - public override string CommandText - { - get { return cmdText; } - set - { - cmdText = value; - statement = null; - batchableCommandText = null; - if (cmdText != null && cmdText.EndsWith("DEFAULT VALUES")) - { - cmdText = cmdText.Substring(0, cmdText.Length - 14); - cmdText = cmdText + "() VALUES ()"; - } - } - } - - /// -#if !CF - [Category("Misc")] - [Description("Time to wait for command to execute")] - [DefaultValue(30)] -#endif - public override int CommandTimeout - { - get { return commandTimeout == 0 ? 30 : commandTimeout; } - set - { - if (commandTimeout < 0) - throw new ArgumentException("Command timeout must not be negative"); - - // Timeout in milliseconds should not exceed maximum for 32 bit - // signed integer (~24 days), because underlying driver (and streams) - // use milliseconds expressed ints for timeout values. - // Hence, truncate the value. - int timeout = Math.Min(value, Int32.MaxValue / 1000); - if (timeout != value) - { - MySqlTrace.LogWarning(connection.ServerThread, - "Command timeout value too large (" - + value + " seconds). Changed to max. possible value (" - + timeout + " seconds)"); - } - commandTimeout = timeout; - } - } - - /// -#if !CF - [Category("Data")] -#endif - public override CommandType CommandType - { - get { return cmdType; } - set { cmdType = value; } - } - - /// -#if !CF - [Browsable(false)] -#endif - public bool IsPrepared - { - get { return statement != null && statement.IsPrepared; } - } - - /// -#if !CF - [Category("Behavior")] - [Description("Connection used by the command")] -#endif - public new MySqlConnection Connection - { - get { return connection; } - set - { - /* - * The connection is associated with the transaction - * so set the transaction object to return a null reference if the connection - * is reset. - */ - if (connection != value) - Transaction = null; - - connection = value; - - // if the user has not already set the command timeout, then - // take the default from the connection - if (connection != null && commandTimeout == 0) - commandTimeout = (int)connection.Settings.DefaultCommandTimeout; - } - } - - /// -#if !CF - [Category("Data")] - [Description("The parameters collection")] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] -#endif - public new MySqlParameterCollection Parameters - { - get { return parameters; } - } - - - /// -#if !CF - [Browsable(false)] -#endif - public new MySqlTransaction Transaction - { - get { return curTransaction; } - set { curTransaction = value; } - } - - /* /// - #if !CF - [Category("Behavior")] - #endif - public override UpdateRowSource UpdatedRowSource - { - get { return updatedRowSource; } - set { updatedRowSource = value; } - }*/ - - internal List Batch - { - get { return batch; } - } - - internal string BatchableCommandText - { - get { return batchableCommandText; } - } - - #endregion - - #region Methods - - /// - /// Attempts to cancel the execution of a currently active command - /// - /// - /// Cancelling a currently active query only works with MySQL versions 5.0.0 and higher. - /// - public override void Cancel() - { - connection.CancelQuery(connection.ConnectionTimeout); - } - - /// - /// Creates a new instance of a object. - /// - /// - /// This method is a strongly-typed version of . - /// - /// A object. - /// - public new MySqlParameter CreateParameter() - { - return (MySqlParameter)CreateDbParameter(); - } - - /// - /// Check the connection to make sure - /// - it is open - /// - it is not currently being used by a reader - /// - and we have the right version of MySQL for the requested command type - /// - private void CheckState() - { - // There must be a valid and open connection. - if (connection == null) - throw new InvalidOperationException("Connection must be valid and open."); - - if (connection.State != ConnectionState.Open && !connection.SoftClosed) - throw new InvalidOperationException("Connection must be valid and open."); - - // Data readers have to be closed first - if (connection.Reader != null) - throw new MySqlException("There is already an open DataReader associated with this Connection which must be closed first."); - - if (CommandType == CommandType.StoredProcedure && !connection.driver.Version.isAtLeast(5, 0, 0)) - throw new MySqlException("Stored procedures are not supported on this version of MySQL"); - } - - /// - public override int ExecuteNonQuery() - { - MySqlDataReader reader = null; - using (reader = ExecuteReader()) - { - } - - return reader.RecordsAffected; - } - - internal void ClearCommandTimer() - { - if (commandTimer != null) - { - commandTimer.Dispose(); - commandTimer = null; - } - } - - internal void Close(MySqlDataReader reader) - { - if (statement != null) - statement.Close(reader); - ResetSqlSelectLimit(); - connection.driver.CloseQuery(connection, statement.StatementId); - ClearCommandTimer(); - } - - /// - /// Reset SQL_SELECT_LIMIT that could have been modified by CommandBehavior. - /// - internal void ResetSqlSelectLimit() - { - // if we are supposed to reset the sql select limit, do that here - if (resetSqlSelect) - { - resetSqlSelect = false; - new MySqlCommand("SET SQL_SELECT_LIMIT=-1", connection).ExecuteNonQuery(); - } - } - - /// - public new MySqlDataReader ExecuteReader() - { - return ExecuteReader(CommandBehavior.Default); - } - - - /// - public new MySqlDataReader ExecuteReader (CommandBehavior behavior) - { - - CheckState(); - Driver driver = connection.driver; - lock (driver) - { - - // We have to recheck that there is no reader, after we got the lock - if (connection.Reader != null) - { - throw new MySqlException(Resources.DataReaderOpen); - } -#if !CF - System.Transactions.Transaction curTrans = System.Transactions.Transaction.Current; - - if (curTrans != null) - { - TransactionStatus status = TransactionStatus.InDoubt; - try - { - // in some cases (during state transitions) this throws - // an exception. Ignore exceptions, we're only interested - // whether transaction was aborted or not. - status = curTrans.TransactionInformation.Status; - } - catch(TransactionException) - { - } - if (status == TransactionStatus.Aborted) - throw new TransactionAbortedException(); - } -#endif - commandTimer = new CommandTimer(connection, CommandTimeout); - - lastInsertedId = -1; - if (cmdText == null || - cmdText.Trim().Length == 0) - throw new InvalidOperationException(Resources.CommandTextNotInitialized); - - string sql = TrimSemicolons(cmdText); - - if (CommandType == CommandType.TableDirect) - sql = "SELECT * FROM " + sql; - - // now we check to see if we are executing a query that is buggy - // in 4.1 - connection.driver.IsExecutingBuggyQuery = false; - if (!connection.driver.Version.isAtLeast(5, 0, 0) && - connection.driver.Version.isAtLeast(4, 1, 0)) - { - string snippet = sql; - if (snippet.Length > 17) - snippet = sql.Substring(0, 17); - snippet = snippet.ToUpper(CultureInfo.InvariantCulture); - connection.driver.IsExecutingBuggyQuery = - snippet.StartsWith("DESCRIBE") || - snippet.StartsWith("SHOW TABLE STATUS"); - } - - if (statement == null || !statement.IsPrepared) - { - if (CommandType == CommandType.StoredProcedure) - statement = new StoredProcedure(this, sql); - else - statement = new PreparableStatement(this, sql); - } - - // stored procs are the only statement type that need do anything during resolve - statement.Resolve(false); - - // Now that we have completed our resolve step, we can handle our - // command behaviors - HandleCommandBehaviors(behavior); - - updatedRowCount = -1; - try - { - MySqlDataReader reader = new MySqlDataReader(this, statement, behavior); - connection.Reader = reader; - // execute the statement - statement.Execute(); - // wait for data to return - reader.NextResult(); - return reader; - } - catch (TimeoutException tex) - { - connection.HandleTimeout(tex); - return null; - } - catch (MySqlException ex) - { - connection.Reader = null; - if (ex.InnerException is TimeoutException) - throw ex; // already handled - - try - { - ResetSqlSelectLimit(); - } - catch (Exception ex2) - { - // Reset SqlLimit did not work, connection is hosed. - Connection.Abort(); - throw new MySqlException(ex.Message, true, ex); - } - - // if we caught an exception because of a cancel, then just return null - if (ex.Number == 1317) - return null; - - if (ex.IsFatal) - Connection.Close(); - if (ex.Number == 0) - throw new MySqlException(Resources.FatalErrorDuringExecute, ex); - throw; - } - finally - { - if (connection != null && connection.Reader == null) - { - // Comething want seriously wrong, and reader would not be - // able to clear timeout on closing. - // So we clear timeout here. - ClearCommandTimer(); - } - } - } - } - - - - - /// - public override object ExecuteScalar() - { - lastInsertedId = -1; - object val = null; - - using (MySqlDataReader reader = ExecuteReader()) - { - if (reader == null) return null; - - if (reader.Read()) - val = reader.GetValue(0); - } - - return val; - } - - private void HandleCommandBehaviors(CommandBehavior behavior) - { - if ((behavior & CommandBehavior.SchemaOnly) != 0) - { - new MySqlCommand("SET SQL_SELECT_LIMIT=0", connection).ExecuteNonQuery(); - resetSqlSelect = true; - } - else if ((behavior & CommandBehavior.SingleRow) != 0) - { - new MySqlCommand("SET SQL_SELECT_LIMIT=1", connection).ExecuteNonQuery(); - resetSqlSelect = true; - } - } - - /// - private void Prepare(int cursorPageSize) - { - if (!connection.driver.Version.isAtLeast(5, 0, 0) && cursorPageSize > 0) - throw new InvalidOperationException("Nested commands are only supported on MySQL 5.0 and later"); - - using (new CommandTimer(Connection, CommandTimeout)) - { - // if the length of the command text is zero, then just return - string psSQL = CommandText; - if (psSQL == null || - psSQL.Trim().Length == 0) - return; - - if (CommandType == CommandType.StoredProcedure) - statement = new StoredProcedure(this, CommandText); - else - statement = new PreparableStatement(this, CommandText); - - statement.Resolve(true); - statement.Prepare(); - } - } - - /// - public override void Prepare() - { - if (connection == null) - throw new InvalidOperationException("The connection property has not been set."); - if (connection.State != ConnectionState.Open) - throw new InvalidOperationException("The connection is not open."); - if (connection.Settings.IgnorePrepare) - return; - - Prepare(0); - } - #endregion - - #region Async Methods - - internal delegate object AsyncDelegate(int type, CommandBehavior behavior); - internal AsyncDelegate caller = null; - internal Exception thrownException; - - private static string TrimSemicolons(string sql) - { - int start = 0; - while (sql[start] == ';') - start++; - - int end = sql.Length - 1; - while (sql[end] == ';') - end--; - return sql.Substring(start, end-start+1); - } - - internal object AsyncExecuteWrapper(int type, CommandBehavior behavior) - { - thrownException = null; - try - { - if (type == 1) - return ExecuteReader(behavior); - return ExecuteNonQuery(); - } - catch (Exception ex) - { - thrownException = ex; - } - return null; - } - - /// - /// Initiates the asynchronous execution of the SQL statement or stored procedure - /// that is described by this , and retrieves one or more - /// result sets from the server. - /// - /// An that can be used to poll, wait for results, - /// or both; this value is also needed when invoking EndExecuteReader, - /// which returns a instance that can be used to retrieve - /// the returned rows. - public IAsyncResult BeginExecuteReader() - { - return BeginExecuteReader(CommandBehavior.Default); - } - - /// - /// Initiates the asynchronous execution of the SQL statement or stored procedure - /// that is described by this using one of the - /// CommandBehavior values. - /// - /// One of the values, indicating - /// options for statement execution and data retrieval. - /// An that can be used to poll, wait for results, - /// or both; this value is also needed when invoking EndExecuteReader, - /// which returns a instance that can be used to retrieve - /// the returned rows. - public IAsyncResult BeginExecuteReader(CommandBehavior behavior) - { - if (caller != null) - throw new MySqlException(Resources.UnableToStartSecondAsyncOp); - - caller = new AsyncDelegate(AsyncExecuteWrapper); - asyncResult = caller.BeginInvoke(1, behavior, null, null); - return asyncResult; - } - - /// - /// Finishes asynchronous execution of a SQL statement, returning the requested - /// . - /// - /// The returned by the call to - /// . - /// A MySqlDataReader object that can be used to retrieve the requested rows. - public MySqlDataReader EndExecuteReader(IAsyncResult result) - { - result.AsyncWaitHandle.WaitOne(); - AsyncDelegate c = caller; - caller = null; - if (thrownException != null) - throw thrownException; - return (MySqlDataReader)c.EndInvoke(result); - } - - /// - /// Initiates the asynchronous execution of the SQL statement or stored procedure - /// that is described by this . - /// - /// - /// An delegate that is invoked when the command's - /// execution has completed. Pass a null reference (Nothing in Visual Basic) - /// to indicate that no callback is required. - /// A user-defined state object that is passed to the - /// callback procedure. Retrieve this object from within the callback procedure - /// using the property. - /// An that can be used to poll or wait for results, - /// or both; this value is also needed when invoking , - /// which returns the number of affected rows. - public IAsyncResult BeginExecuteNonQuery(AsyncCallback callback, object stateObject) - { - if (caller != null) - throw new MySqlException(Resources.UnableToStartSecondAsyncOp); - - caller = new AsyncDelegate(AsyncExecuteWrapper); - asyncResult = caller.BeginInvoke(2, CommandBehavior.Default, - callback, stateObject); - return asyncResult; - } - - /// - /// Initiates the asynchronous execution of the SQL statement or stored procedure - /// that is described by this . - /// - /// An that can be used to poll or wait for results, - /// or both; this value is also needed when invoking , - /// which returns the number of affected rows. - public IAsyncResult BeginExecuteNonQuery() - { - if (caller != null) - throw new MySqlException(Resources.UnableToStartSecondAsyncOp); - - caller = new AsyncDelegate(AsyncExecuteWrapper); - asyncResult = caller.BeginInvoke(2, CommandBehavior.Default, null, null); - return asyncResult; - } - - /// - /// Finishes asynchronous execution of a SQL statement. - /// - /// The returned by the call - /// to . - /// - public int EndExecuteNonQuery(IAsyncResult asyncResult) - { - asyncResult.AsyncWaitHandle.WaitOne(); - AsyncDelegate c = caller; - caller = null; - if (thrownException != null) - throw thrownException; - return (int)c.EndInvoke(asyncResult); - } - - #endregion - - #region Private Methods - - /* private ArrayList PrepareSqlBuffers(string sql) - { - ArrayList buffers = new ArrayList(); - MySqlStreamWriter writer = new MySqlStreamWriter(new MemoryStream(), connection.Encoding); - writer.Version = connection.driver.Version; - - // if we are executing as a stored procedure, then we need to add the call - // keyword. - if (CommandType == CommandType.StoredProcedure) - { - if (storedProcedure == null) - storedProcedure = new StoredProcedure(this); - sql = storedProcedure.Prepare( CommandText ); - } - - // tokenize the SQL - sql = sql.TrimStart(';').TrimEnd(';'); - ArrayList tokens = TokenizeSql( sql ); - - foreach (string token in tokens) - { - if (token.Trim().Length == 0) continue; - if (token == ";" && ! connection.driver.SupportsBatch) - { - MemoryStream ms = (MemoryStream)writer.Stream; - if (ms.Length > 0) - buffers.Add( ms ); - - writer = new MySqlStreamWriter(new MemoryStream(), connection.Encoding); - writer.Version = connection.driver.Version; - continue; - } - else if (token[0] == parameters.ParameterMarker) - { - if (SerializeParameter(writer, token)) continue; - } - - // our fall through case is to write the token to the byte stream - writer.WriteStringNoNull(token); - } - - // capture any buffer that is left over - MemoryStream mStream = (MemoryStream)writer.Stream; - if (mStream.Length > 0) - buffers.Add( mStream ); - - return buffers; - }*/ - - internal long EstimatedSize() - { - long size = CommandText.Length; - foreach (MySqlParameter parameter in Parameters) - size += parameter.EstimatedSize(); - return size; - } - - #endregion - - #region ICloneable - - /// - /// Creates a clone of this MySqlCommand object. CommandText, Connection, and Transaction properties - /// are included as well as the entire parameter list. - /// - /// The cloned MySqlCommand object - public MySqlCommand Clone() - { - MySqlCommand clone = new MySqlCommand(cmdText, connection, curTransaction); - clone.CommandType = CommandType; - clone.CommandTimeout = CommandTimeout; - clone.batchableCommandText = batchableCommandText; - clone.UpdatedRowSource = UpdatedRowSource; - - foreach (MySqlParameter p in parameters) - { - clone.Parameters.Add(p.Clone()); - } - return clone; - } - - object ICloneable.Clone() - { - return this.Clone(); - } - - #endregion - - #region Batching support - - internal void AddToBatch(MySqlCommand command) - { - if (batch == null) - batch = new List(); - batch.Add(command); - } - - internal string GetCommandTextForBatching() - { - if (batchableCommandText == null) - { - // if the command starts with insert and is "simple" enough, then - // we can use the multi-value form of insert - if (String.Compare(CommandText.Substring(0, 6), "INSERT", true) == 0) - { - MySqlCommand cmd = new MySqlCommand("SELECT @@sql_mode", Connection); - string sql_mode = cmd.ExecuteScalar().ToString().ToUpper(CultureInfo.InvariantCulture); - MySqlTokenizer tokenizer = new MySqlTokenizer(CommandText); - tokenizer.AnsiQuotes = sql_mode.IndexOf("ANSI_QUOTES") != -1; - tokenizer.BackslashEscapes = sql_mode.IndexOf("NO_BACKSLASH_ESCAPES") == -1; - string token = tokenizer.NextToken().ToLower(CultureInfo.InvariantCulture); - while (token != null) - { - if (token.ToUpper(CultureInfo.InvariantCulture) == "VALUES" && - !tokenizer.Quoted) - { - token = tokenizer.NextToken(); - Debug.Assert(token == "("); - while (token != null && token != ")") - { - batchableCommandText += token; - token = tokenizer.NextToken(); - } - if (token != null) - batchableCommandText += token; - token = tokenizer.NextToken(); - if (token != null && (token == "," || - token.ToUpper(CultureInfo.InvariantCulture) == "ON")) - { - batchableCommandText = null; - break; - } - } - token = tokenizer.NextToken(); - } - } - } - - return batchableCommandText; - } - - #endregion - - protected override void Dispose(bool disposing) - { - if (disposing) - { - if (statement != null && statement.IsPrepared) - statement.CloseStatement(); - } - base.Dispose(disposing); - } - - /// - /// Gets or sets a value indicating whether the command object should be visible in a Windows Form Designer control. - /// -#if !CF - [Browsable(false)] -#endif - public override bool DesignTimeVisible - { - get - { - return designTimeVisible; - } - set - { - designTimeVisible = value; - } - } - - /// - /// Gets or sets how command results are applied to the DataRow when used by the - /// Update method of the DbDataAdapter. - /// - public override UpdateRowSource UpdatedRowSource - { - get - { - return updatedRowSource; - } - set - { - updatedRowSource = value; - } - } - - protected override DbParameter CreateDbParameter() - { - return new MySqlParameter(); - } - - protected override DbConnection DbConnection - { - get { return Connection; } - set { Connection = (MySqlConnection)value; } - } - - protected override DbParameterCollection DbParameterCollection - { - get { return Parameters; } - } - - protected override DbTransaction DbTransaction - { - get { return Transaction; } - set { Transaction = (MySqlTransaction)value; } - } - - protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) - { - return ExecuteReader(behavior); - } - } -} - diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Cache.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Cache.cs deleted file mode 100644 index 0ff6234..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Cache.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections.Generic; - -namespace MySql.Data.Common -{ - internal class Cache - { - private int _capacity; - private Queue _keyQ; - private Dictionary _contents; - - public Cache(int initialCapacity, int capacity) - { - _capacity = capacity; - _contents = new Dictionary(initialCapacity); - - if (capacity > 0) - _keyQ = new Queue(initialCapacity); - } - - public ValueType this[KeyType key] - { - get - { - ValueType val; - if (_contents.TryGetValue(key, out val)) - return val; - else - return default(ValueType); - } - set { InternalAdd(key, value); } - } - - public void Add(KeyType key, ValueType value) - { - InternalAdd(key, value); - } - - private void InternalAdd(KeyType key, ValueType value) - { - if (!_contents.ContainsKey(key)) - { - - if (_capacity > 0) - { - _keyQ.Enqueue(key); - - if (_keyQ.Count > _capacity) - _contents.Remove(_keyQ.Dequeue()); - } - } - - _contents[key] = value; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/ContextString.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/ContextString.cs deleted file mode 100644 index 94e0d37..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/ContextString.cs +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections; -using System.Text; - -namespace MySql.Data.Common -{ - internal class ContextString - { - string contextMarkers; - bool escapeBackslash; - - // Create a private ctor so the compiler doesn't give us a default one - public ContextString(string contextMarkers, bool escapeBackslash) - { - this.contextMarkers = contextMarkers; - this.escapeBackslash = escapeBackslash; - } - - public string ContextMarkers - { - get { return contextMarkers; } - set { contextMarkers = value; } - } - - public int IndexOf(string src, string target) - { - return IndexOf(src, target, 0); - } - - public int IndexOf(string src, string target, int startIndex) - { - int index = src.IndexOf(target, startIndex); - while (index != -1) - { - if (!IndexInQuotes(src, index, startIndex)) break; - index = src.IndexOf(target, index + 1); - } - return index; - } - - private bool IndexInQuotes(string src, int index, int startIndex) - { - char contextMarker = Char.MinValue; - bool escaped = false; - - for (int i = startIndex; i < index; i++) - { - char c = src[i]; - - int contextIndex = contextMarkers.IndexOf(c); - - // if we have found the closing marker for our open marker, then close the context - if (contextIndex > -1 && contextMarker == contextMarkers[contextIndex] && !escaped) - contextMarker = Char.MinValue; - - // if we have found a context marker and we are not in a context yet, then start one - else if (contextMarker == Char.MinValue && contextIndex > -1 && !escaped) - contextMarker = c; - - else if (c == '\\' && escapeBackslash) - escaped = !escaped; - } - return contextMarker != Char.MinValue || escaped; - } - - public int IndexOf(string src, char target) - { - char contextMarker = Char.MinValue; - bool escaped = false; - int pos = 0; - - foreach (char c in src) - { - int contextIndex = contextMarkers.IndexOf(c); - - // if we have found the closing marker for our open marker, then close the context - if (contextIndex > -1 && contextMarker == contextMarkers[contextIndex] && !escaped) - contextMarker = Char.MinValue; - - // if we have found a context marker and we are not in a context yet, then start one - else if (contextMarker == Char.MinValue && contextIndex > -1 && !escaped) - contextMarker = c; - - else if (contextMarker == Char.MinValue && c == target) - return pos; - else if (c == '\\' && escapeBackslash) - escaped = !escaped; - pos++; - } - return -1; - } - - public string[] Split(string src, string delimiters) - { - ArrayList parts = new ArrayList(); - StringBuilder sb = new StringBuilder(); - bool escaped = false; - - char contextMarker = Char.MinValue; - - foreach (char c in src) - { - if (delimiters.IndexOf(c) != -1 && !escaped) - { - if (contextMarker != Char.MinValue) - sb.Append(c); - else - { - if (sb.Length > 0) - { - parts.Add( sb.ToString() ); - sb.Remove( 0, sb.Length ); - } - } - } - else if (c == '\\' && escapeBackslash) - escaped = !escaped; - else - { - int contextIndex = contextMarkers.IndexOf(c); - if (!escaped && contextIndex != -1) - { - // if we have found the closing marker for our open - // marker, then close the context - if ((contextIndex % 2) == 1) - { - if (contextMarker == contextMarkers[contextIndex - 1]) - contextMarker = Char.MinValue; - } - else - { - // if the opening and closing context markers are - // the same then we will always find the opening - // marker. - if (contextMarker == contextMarkers[contextIndex + 1]) - contextMarker = Char.MinValue; - else if (contextMarker == Char.MinValue) - contextMarker = c; - } - } - - sb.Append( c ); - } - } - if (sb.Length > 0) - parts.Add( sb.ToString() ); - return (string[])parts.ToArray( typeof(string) ); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/LowResolutionStopwatch.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/LowResolutionStopwatch.cs deleted file mode 100644 index 84040d1..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/LowResolutionStopwatch.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; - -namespace MySql.Data.Common -{ - /// - /// This class is modeled after .NET Stopwatch. It provides better - /// performance (no system calls).It is however less precise than - /// .NET Stopwatch, measuring in milliseconds. It is adequate to use - /// when high-precision is not required (e.g for measuring IO timeouts), - /// but not for other tasks. - /// - class LowResolutionStopwatch - { - long millis; - long startTime; - public static readonly long Frequency = 1000; // measure in milliseconds - public static readonly bool isHighResolution = false; - - public LowResolutionStopwatch() - { - millis = 0; - } - public long ElapsedMilliseconds - { - get { return millis; } - } - public void Start() - { - startTime = Environment.TickCount; - } - - public void Stop() - { - long now = Environment.TickCount; - // Calculate time different, handle possible overflow - long elapsed = (now < startTime)?Int32.MaxValue - startTime + now : now - startTime; - millis += elapsed; - } - - public void Reset() - { - millis = 0; - startTime = 0; - } - - public TimeSpan Elapsed - { - get - { - return new TimeSpan(0, 0, 0, 0, (int)millis); - } - } - - public static LowResolutionStopwatch StartNew() - { - LowResolutionStopwatch sw = new LowResolutionStopwatch(); - sw.Start(); - return sw; - } - - public static long GetTimestamp() - { - return Environment.TickCount; - } - - bool IsRunning() - { - return (startTime != 0); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/MyNetworkStream.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/MyNetworkStream.cs deleted file mode 100644 index d3f7536..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/MyNetworkStream.cs +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (c) 2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Net.Sockets; - -internal class MyNetworkStream : NetworkStream -{ - /// - /// Wrapper around NetworkStream. - /// - /// MyNetworkStream is equivalent to NetworkStream, except - /// 1. It throws TimeoutException if read or write timeout occurs, instead - /// of IOException, to match behavior of other streams (named pipe and - /// shared memory). This property comes handy in TimedStream. - /// - /// 2. It implements workarounds for WSAEWOULDBLOCK errors, that can start - /// occuring after stream has times out. For a discussion about the CLR bug, - /// refer to http://tinyurl.com/lhgpyf. This error should never occur, as - /// we're not using asynchronous operations, but apparerntly it does occur - /// directly after timeout has expired. - /// The workaround is hinted in the URL above and implemented like this: - /// For each IO operation, if it throws WSAEWOULDBLOCK, we explicitely set - /// the socket to Blocking and retry the operation once again. - /// - const int MaxRetryCount = 2; - Socket socket; - - public MyNetworkStream(Socket socket, bool ownsSocket) - : base(socket, ownsSocket) - { - this.socket = socket; - } - - bool IsTimeoutException(SocketException e) - { -#if CF - return (e.NativeErrorCode == 10060); -#else - return (e.SocketErrorCode == SocketError.TimedOut); -#endif - } - - bool IsWouldBlockException(SocketException e) - { -#if CF - return (e.NativeErrorCode == 10035); -#else - return (e.SocketErrorCode == SocketError.WouldBlock); -#endif - } - - - void HandleOrRethrowException(Exception e) - { - Exception currentException = e; - while (currentException != null) - { - if (currentException is SocketException) - { - SocketException socketException = (SocketException)currentException; - if (IsWouldBlockException(socketException)) - { - // Workaround for WSAEWOULDBLOCK - socket.Blocking= true; - // return to give the caller possibility to retry the call - return; - } - else if (IsTimeoutException(socketException)) - { - throw new TimeoutException(socketException.Message, e); - } - - } - currentException = currentException.InnerException; - } - throw (e); - } - - - public override int Read(byte[] buffer, int offset, int count) - { - int retry = 0; - Exception exception = null; - do - { - try - { - return base.Read(buffer, offset, count); - } - catch (Exception e) - { - exception = e; - HandleOrRethrowException(e); - } - } - while (++retry < MaxRetryCount); - throw exception; - } - - public override int ReadByte() - { - int retry = 0; - Exception exception = null; - do - { - try - { - return base.ReadByte(); - } - catch (Exception e) - { - exception = e; - HandleOrRethrowException(e); - } - } - while (++retry < MaxRetryCount); - throw exception; - } - - public override void Write(byte[] buffer, int offset, int count) - { - int retry = 0; - Exception exception = null; - do - { - try - { - base.Write(buffer, offset, count); - return; - } - catch (Exception e) - { - exception = e; - HandleOrRethrowException(e); - } - } - while (++retry < MaxRetryCount); - throw exception; - } - - public override void Flush() - { - int retry = 0; - Exception exception = null; - do - { - try - { - base.Flush(); - return; - } - catch (Exception e) - { - exception = e; - HandleOrRethrowException(e); - } - } - while (++retry < MaxRetryCount); - throw exception; - } - -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/MySqlTokenizer.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/MySqlTokenizer.cs deleted file mode 100644 index 61d8d3b..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/MySqlTokenizer.cs +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright (c) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Text; -using System.IO; -using System.Collections.Generic; -using System.Diagnostics; - -namespace MySql.Data.MySqlClient -{ - internal class MySqlTokenizer - { - private string sql; - - private int startIndex; - private int stopIndex; - - private bool ansiQuotes; - private bool backslashEscapes; - private bool returnComments; - private bool multiLine; - - private bool quoted; - private bool isComment; - - private int pos; - - public MySqlTokenizer() - { - backslashEscapes = true; - multiLine = true; - pos = 0; - } - - public MySqlTokenizer(string input) : this() - { - sql = input; - } - - #region Properties - - public string Text - { - get { return sql; } - set { sql = value; pos = 0; } - } - - public bool AnsiQuotes - { - get { return ansiQuotes; } - set { ansiQuotes = value; } - } - - public bool BackslashEscapes - { - get { return backslashEscapes; } - set { backslashEscapes = value; } - } - - public bool MultiLine - { - get { return multiLine; } - set { multiLine = value; } - } - - public bool Quoted - { - get { return quoted; } - private set { quoted = value; } - } - - public bool IsComment - { - get { return isComment; } - } - - public int StartIndex - { - get { return startIndex; } - set { startIndex = value; } - } - - public int StopIndex - { - get { return stopIndex; } - set { stopIndex = value; } - } - - public int Position - { - get { return pos; } - set { pos = value; } - } - - public bool ReturnComments - { - get { return returnComments; } - set { returnComments = value; } - } - - #endregion - - public List GetAllTokens() - { - List tokens = new List(); - string token = NextToken(); - while (token != null) - { - tokens.Add(token); - token = NextToken(); - } - return tokens; - } - - public string NextToken() - { - while (FindToken()) - { - string token = sql.Substring(startIndex, stopIndex - startIndex).Trim(); - return token; - } - return null; - } - - public string NextParameter() - { - while (FindToken()) - { - if ((stopIndex - startIndex) < 2) continue; - string token = sql.Substring(startIndex, stopIndex - startIndex).Trim(); - char c1 = sql[startIndex]; - char c2 = sql[startIndex+1]; - if (c1 == '?' || - (c1 == '@' && c2 != '@')) - return sql.Substring(startIndex, stopIndex - startIndex); - } - return null; - } - - public bool FindToken() - { - isComment = quoted = false; // reset our flags - startIndex = stopIndex = -1; - - while (pos < sql.Length) - { - char c = sql[pos++]; - if (Char.IsWhiteSpace(c)) continue; - - if (c == '`' || c == '\'' || c == '"') //(c == '"' && AnsiQuotes)) - ReadQuotedToken(c); - else if (c == '#' || c == '-' || c == '/') - { - if (!ReadComment(c)) - ReadSpecialToken(); - } - else - ReadUnquotedToken(); - if (startIndex != -1) return true; - } - return false; - } - - public string ReadParenthesis() - { - StringBuilder sb = new StringBuilder("("); - int start = StartIndex; - string token = NextToken(); - while (true) - { - if (token == null) - throw new InvalidOperationException("Unable to parse SQL"); - sb.Append(token); - if (token == ")" && !Quoted) break; - token = NextToken(); - } - return sb.ToString(); - } - - private bool ReadComment(char c) - { - // make sure the comment starts correctly - if (c == '/' && (pos >= sql.Length || sql[pos] != '*')) return false; - if (c == '-' && ((pos + 1) >= sql.Length || sql[pos] != '-' || sql[pos + 1] != ' ')) return false; - - string endingPattern = "\n"; - if (sql[pos] == '*') - endingPattern = "*/"; - - int startingIndex = pos-1; - - int index = sql.IndexOf(endingPattern, pos); - if (index == -1) - index = sql.Length - 1; - else - index += endingPattern.Length; - - pos = index; - if (ReturnComments) - { - startIndex = startingIndex; - stopIndex = index; - isComment = true; - } - return true; - } - - private void CalculatePosition(int start, int stop) - { - startIndex = start; - stopIndex = stop; - if (!MultiLine) return; - } - - private void ReadUnquotedToken() - { - startIndex = pos-1; - - if (!IsSpecialCharacter(sql[startIndex])) - { - while (pos < sql.Length) - { - char c = sql[pos]; - if (Char.IsWhiteSpace(c)) break; - if (IsSpecialCharacter(c)) break; - pos++; - } - } - - Quoted = false; - stopIndex = pos; - } - - private void ReadSpecialToken() - { - startIndex = pos - 1; - - Debug.Assert(IsSpecialCharacter(sql[startIndex])); - - stopIndex = pos; - Quoted = false; - } - - /// - /// Read a single quoted identifier from the stream - /// - /// - /// - private void ReadQuotedToken(char quoteChar) - { - startIndex = pos-1; - bool escaped = false; - - bool found = false; - while (pos < sql.Length) - { - char c = sql[pos]; - - if (c == quoteChar && !escaped) - { - found = true; - break; - } - - if (escaped) - escaped = false; - else if (c == '\\' && BackslashEscapes) - escaped = true; - pos++; - } - if (found) pos++; - Quoted = found; - stopIndex = pos; - } - - private bool IsQuoteChar(char c) - { - return c == '`' || c == '\'' || c == '\"'; - } - - private bool IsParameterMarker(char c) - { - return c == '@' || c == '?'; - } - - private bool IsSpecialCharacter(char c) - { - if (Char.IsLetterOrDigit(c) || - c == '$' || c == '_' || c == '.') return false; - if (IsParameterMarker(c)) return false; - return true; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/NamedPipeStream.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/NamedPipeStream.cs deleted file mode 100644 index 8fe1384..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/NamedPipeStream.cs +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.IO; -using MySql.Data.MySqlClient; -using MySql.Data.MySqlClient.Properties; -using Microsoft.Win32.SafeHandles; -using System.Threading; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.ComponentModel; - - - -namespace MySql.Data.Common -{ - /// - /// Summary description for API. - /// - internal class NamedPipeStream : Stream - { - SafeFileHandle handle; - Stream fileStream; - int readTimeout = Timeout.Infinite; - int writeTimeout = Timeout.Infinite; - const int ERROR_PIPE_BUSY = 231; - const int ERROR_SEM_TIMEOUT = 121; - - public NamedPipeStream(string path, FileAccess mode, uint timeout) - { - Open(path, mode, timeout); - } - - void CancelIo() - { - bool ok = NativeMethods.CancelIo(handle.DangerousGetHandle()); - if (!ok) - throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error()); - } - public void Open( string path, FileAccess mode ,uint timeout ) - { - IntPtr nativeHandle; - for (; ; ) - { - nativeHandle = NativeMethods.CreateFile(path, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, - 0, null, NativeMethods.OPEN_EXISTING, NativeMethods.FILE_FLAG_OVERLAPPED, 0); - if (nativeHandle != IntPtr.Zero) - break; - - if (Marshal.GetLastWin32Error() != ERROR_PIPE_BUSY) - { - throw new Win32Exception(Marshal.GetLastWin32Error(), - "Error opening pipe"); - } - LowResolutionStopwatch sw = LowResolutionStopwatch.StartNew(); - bool success = NativeMethods.WaitNamedPipe(path, timeout); - sw.Stop(); - if (!success) - { - if (timeout < sw.ElapsedMilliseconds || - Marshal.GetLastWin32Error() == ERROR_SEM_TIMEOUT) - { - throw new TimeoutException("Timeout waiting for named pipe"); - } - else - { - throw new Win32Exception(Marshal.GetLastWin32Error(), - "Error waiting for pipe"); - } - } - timeout -= (uint)sw.ElapsedMilliseconds; - } - handle = new SafeFileHandle(nativeHandle, true); - fileStream = new FileStream(handle, mode, 4096, true); - } - - public override bool CanRead - { - get { return fileStream.CanRead; } - } - - public override bool CanWrite - { - get { return fileStream.CanWrite; } - } - - public override bool CanSeek - { - get { throw new NotSupportedException(Resources.NamedPipeNoSeek); } - } - - public override long Length - { - get { throw new NotSupportedException(Resources.NamedPipeNoSeek); } - } - - public override long Position - { - get { throw new NotSupportedException(Resources.NamedPipeNoSeek); } - set { } - } - - public override void Flush() - { - fileStream.Flush(); - } - - public override int Read(byte[] buffer, int offset, int count) - { - if(readTimeout == Timeout.Infinite) - { - return fileStream.Read(buffer, offset, count); - } - IAsyncResult result = fileStream.BeginRead(buffer, offset, count, null, null); - if (result.CompletedSynchronously) - return fileStream.EndRead(result); - - if (!result.AsyncWaitHandle.WaitOne(readTimeout)) - { - CancelIo(); - throw new TimeoutException("Timeout in named pipe read"); - } - return fileStream.EndRead(result); - } - - - public override void Write(byte[] buffer, int offset, int count) - { - if (writeTimeout == Timeout.Infinite) - { - fileStream.Write(buffer, offset, count); - return; - } - IAsyncResult result = fileStream.BeginWrite(buffer, offset, count, null, null); - if (result.CompletedSynchronously) - { - fileStream.EndWrite(result); - } - - if (!result.AsyncWaitHandle.WaitOne(readTimeout)) - { - CancelIo(); - throw new TimeoutException("Timeout in named pipe write"); - } - fileStream.EndWrite(result); - } - - public override void Close() - { - if (handle != null && !handle.IsInvalid && !handle.IsClosed) - { - fileStream.Close(); - try - { - handle.Close(); - } - catch (Exception) - { - } - } - } - - public override void SetLength(long length) - { - throw new NotSupportedException(Resources.NamedPipeNoSetLength); - } - - - public override bool CanTimeout - { - get - { - return true; - } - } - - public override int ReadTimeout - { - get - { - return readTimeout; - } - set - { - readTimeout = value; - } - } - - public override int WriteTimeout - { - get - { - return writeTimeout; - } - set - { - writeTimeout = value; - } - } - - public override long Seek( long offset, SeekOrigin origin ) - { - throw new NotSupportedException(Resources.NamedPipeNoSeek); - } - - internal static Stream Create(string pipeName, string hostname, uint timeout) - { - string pipePath; - if (0 == String.Compare(hostname, "localhost", true)) - pipePath = @"\\.\pipe\" + pipeName; - else - pipePath = String.Format(@"\\{0}\pipe\{1}", hostname, pipeName); - return new NamedPipeStream(pipePath, FileAccess.ReadWrite, timeout); - } - } -} - - diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/NativeMethods.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/NativeMethods.cs deleted file mode 100644 index e0e3a42..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/NativeMethods.cs +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Runtime.InteropServices; -using System.Threading; - -namespace MySql.Data.Common -{ - internal class NativeMethods - { - // Keep the compiler from generating a default ctor - private NativeMethods() - { - } - - //Constants for dwDesiredAccess: - public const UInt32 GENERIC_READ = 0x80000000; - public const UInt32 GENERIC_WRITE = 0x40000000; - - //Constants for return value: - public const Int32 INVALIDpipeHandle_VALUE = -1; - - //Constants for dwFlagsAndAttributes: - public const UInt32 FILE_FLAG_OVERLAPPED = 0x40000000; - public const UInt32 FILE_FLAG_NO_BUFFERING = 0x20000000; - - //Constants for dwCreationDisposition: - public const UInt32 OPEN_EXISTING = 3; - - [StructLayout(LayoutKind.Sequential)] - public class SecurityAttributes - { - public SecurityAttributes() - { - Length = Marshal.SizeOf(typeof(SecurityAttributes)); - } - public int Length; - public IntPtr securityDescriptor = IntPtr.Zero; - public bool inheritHandle; - } - - [DllImport("Kernel32", CharSet=CharSet.Unicode)] - static extern public IntPtr CreateFile( - String fileName, - uint desiredAccess, - uint shareMode, - SecurityAttributes securityAttributes, - uint creationDisposition, - uint flagsAndAttributes, - uint templateFile); - - [return:MarshalAs(UnmanagedType.Bool)] - [DllImport("kernel32.dll", EntryPoint="PeekNamedPipe", SetLastError=true)] - static extern public bool PeekNamedPipe(IntPtr handle, - byte[] buffer, - uint nBufferSize, - ref uint bytesRead, - ref uint bytesAvail, - ref uint BytesLeftThisMessage); - - [return:MarshalAs(UnmanagedType.Bool)] - [DllImport("kernel32.dll", SetLastError=true)] - static extern public bool ReadFile(IntPtr hFile, [Out] byte[] lpBuffer, uint nNumberOfBytesToRead, - out uint lpNumberOfBytesRead, IntPtr lpOverlapped); - - [return:MarshalAs(UnmanagedType.Bool)] - [DllImport("Kernel32")] - public static extern bool WriteFile(IntPtr hFile, [In]byte[] buffer, - uint numberOfBytesToWrite, out uint numberOfBytesWritten, IntPtr lpOverlapped); - - [return:MarshalAs(UnmanagedType.Bool)] - [DllImport("kernel32.dll", SetLastError=true)] - public static extern bool CloseHandle(IntPtr handle); - - [return: MarshalAs(UnmanagedType.Bool)] - [DllImport("kernel32.dll", SetLastError = true)] - public static extern bool CancelIo(IntPtr handle); - - [return:MarshalAs(UnmanagedType.Bool)] - [DllImport("kernel32.dll", SetLastError=true)] - public static extern bool FlushFileBuffers(IntPtr handle); - - [DllImport("kernel32.dll", CharSet=CharSet.Unicode)] - public static extern IntPtr OpenEvent(uint dwDesiredAccess, - [MarshalAs(UnmanagedType.Bool)]bool bInheritHandle, - string lpName); - - [DllImport("kernel32.dll", CharSet=CharSet.Unicode)] - public static extern IntPtr OpenFileMapping(uint dwDesiredAccess, - [MarshalAs(UnmanagedType.Bool)]bool bInheritHandle, - string lpName); - - [DllImport("kernel32.dll")] - public static extern IntPtr MapViewOfFile(IntPtr hFileMappingObject, uint - dwDesiredAccess, uint dwFileOffsetHigh, uint dwFileOffsetLow, - IntPtr dwNumberOfBytesToMap); - - [DllImport("kernel32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool UnmapViewOfFile(IntPtr lpBaseAddress); - - [DllImport("kernel32.dll", SetLastError = true)] - public static extern int FlushViewOfFile(IntPtr address, uint numBytes); - - [DllImport("kernel32.dll", SetLastError = true)] - public static extern bool WaitNamedPipe(string namedPipeName, uint timeOut); - #region Winsock functions - - // SOcket routines - [DllImport("ws2_32.dll", SetLastError=true)] - static extern public IntPtr socket(int af, int type, int protocol); - - [DllImport("ws2_32.dll", SetLastError=true)] - static extern public int ioctlsocket(IntPtr socket, uint cmd, ref UInt32 arg); - - [DllImport("ws2_32.dll", SetLastError=true)] - public static extern int WSAIoctl(IntPtr s, uint dwIoControlCode, byte[] inBuffer, uint cbInBuffer, - byte[] outBuffer, uint cbOutBuffer, IntPtr lpcbBytesReturned, IntPtr lpOverlapped, - IntPtr lpCompletionRoutine); - - [DllImport("ws2_32.dll", SetLastError=true)] - static extern public int WSAGetLastError(); - - [DllImport("ws2_32.dll", SetLastError=true)] - static extern public int connect(IntPtr socket, byte[] addr, int addrlen); - - [DllImport("ws2_32.dll", SetLastError=true)] - static extern public int recv(IntPtr socket, byte[] buff, int len, int flags); - - [DllImport("ws2_32.Dll", SetLastError=true)] - static extern public int send(IntPtr socket, byte[] buff, int len, int flags); - - #endregion - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Platform.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Platform.cs deleted file mode 100644 index 4aa1b47..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Platform.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; - -namespace MySql.Data.Common -{ - internal class Platform - { - private static bool inited; - private static bool isMono; - - /// - /// By creating a private ctor, we keep the compiler from creating a default ctor - /// - private Platform() - { - } - - public static bool IsWindows() - { - OperatingSystem os = Environment.OSVersion; - switch (os.Platform) - { - case PlatformID.Win32NT: - case PlatformID.Win32S: - case PlatformID.Win32Windows: - return true; - } - return false; - } - - public static bool IsMono() - { - if (!inited) - Init(); - return isMono; - } - - private static void Init() - { - inited = true; - Type t = Type.GetType("Mono.Runtime"); - isMono = t != null; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/QueryNormalizer.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/QueryNormalizer.cs deleted file mode 100644 index 76e82cb..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/QueryNormalizer.cs +++ /dev/null @@ -1,392 +0,0 @@ -// Copyright (c) 2009-2010 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Diagnostics; -using System.Collections; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.Common -{ - internal class QueryNormalizer - { - private static List keywords = new List(); - private List tokens = new List(); - private int pos; - private string fullSql; - private string queryType; - - static QueryNormalizer() - { - StringReader sr = new StringReader(Resources.keywords); - string keyword = sr.ReadLine(); - while (keyword != null) - { - keywords.Add(keyword); - keyword = sr.ReadLine(); - } - } - - public string QueryType - { - get { return queryType; } - } - - public string Normalize(string sql) - { - tokens.Clear(); - StringBuilder newSql = new StringBuilder(); - fullSql = sql; - - TokenizeSql(sql); - DetermineStatementType(tokens); - ProcessMathSymbols(tokens); - CollapseValueLists(tokens); - CollapseInLists(tokens); - CollapseWhitespace(tokens); - - foreach (Token t in tokens) - if (t.Output) - newSql.Append(t.Text); - - return newSql.ToString(); - } - - private void DetermineStatementType(List tok) - { - foreach (Token t in tok) - { - if (t.Type == TokenType.Keyword) - { - queryType = t.Text.ToUpperInvariant(); - //string s = t.Text.ToLowerInvariant(); - //if (s == "select") - // queryType = "SELECT"; - //else if (s == "update" || s == "insert") - // queryType = "UPSERT"; - //else - // queryType = "OTHER"; - break; - } - } - } - - /// - /// Mark - or + signs that are unary ops as no output - /// - /// - private void ProcessMathSymbols(List tok) - { - Token lastToken = null; - - foreach (Token t in tok) - { - if (t.Type == TokenType.Symbol && - (t.Text == "-" || t.Text == "+")) - { - if (lastToken != null && - lastToken.Type != TokenType.Number && - lastToken.Type != TokenType.Identifier && - (lastToken.Type != TokenType.Symbol || lastToken.Text != ")")) - t.Output = false; - } - if (t.IsRealToken) - lastToken = t; - } - } - - private void CollapseWhitespace(List tok) - { - Token lastToken = null; - - foreach (Token t in tok) - { - if (t.Output && - t.Type == TokenType.Whitespace && - lastToken != null && - lastToken.Type == TokenType.Whitespace) - { - t.Output = false; - } - if (t.Output) - lastToken = t; - } - } - - private void CollapseValueLists(List tok) - { - int pos = -1; - while (++pos < tok.Count) - { - Token t = tok[pos]; - if (t.Type != TokenType.Keyword) continue; - if (!t.Text.StartsWith("VALUE")) continue; - CollapseValueList(tok, ref pos); - } - } - - private void CollapseValueList(List tok, ref int pos) - { - List parenIndices = new List(); - - // this while loop will find all closing parens in this value list - while (true) - { - // find the close ')' - while (++pos < tok.Count) - if (tok[pos].Type == TokenType.Symbol && tok[pos].Text == ")") break; - Debug.Assert(pos < tok.Count); - parenIndices.Add(pos); - - // now find the next "real" token - while (++pos < tok.Count) - if (tok[pos].IsRealToken) break; - if (pos == tok.Count) break; - - if (tok[pos].Text != ",") - { - pos--; - break; - } - } - - // if we only have 1 value then we don't collapse - if (parenIndices.Count < 2) return; - int index = parenIndices[0]; - tok[++index] = new Token(TokenType.Whitespace, " "); - tok[++index] = new Token(TokenType.Comment, "/* , ... */"); - index++; - - // now mark all the other tokens as no output - while (index <= parenIndices[parenIndices.Count - 1]) - tok[index++].Output = false; - } - - private void CollapseInLists(List tok) - { - int pos = -1; - while (++pos < tok.Count) - { - Token t = tok[pos]; - if (t.Type != TokenType.Keyword) continue; - if (!(t.Text == "IN")) continue; - CollapseInList(tok, ref pos); - } - } - - private Token GetNextRealToken(List tok, ref int pos) - { - while (++pos < tok.Count) - { - if (tok[pos].IsRealToken) return tok[pos]; - } - return null; - } - - private void CollapseInList(List tok, ref int pos) - { - Token t = GetNextRealToken(tok, ref pos); - Debug.Assert(t.Text == "("); - - // if the first token is a keyword then we likely have a - // SELECT .. IN (SELECT ...) - t = GetNextRealToken(tok, ref pos); - if (t.Type == TokenType.Keyword) return; - - int start = pos; - // first find all the tokens that make up the in list - while (++pos < tok.Count) - { - t = tok[pos]; - if (t.Type == TokenType.CommandComment) return; - if (!t.IsRealToken) continue; - if (t.Text == "(") return; - if (t.Text == ")") break; - } - int stop = pos; - - for (int i = stop; i > start; i--) - tok.RemoveAt(i); - tok.Insert(++start, new Token(TokenType.Whitespace, " ")); - tok.Insert(++start, new Token(TokenType.Comment, "/* , ... */")); - tok.Insert(++start, new Token(TokenType.Whitespace, " ")); - tok.Insert(++start, new Token(TokenType.Symbol, ")")); - } - - private void TokenizeSql(string sql) - { - pos = 0; - - while (pos < sql.Length) - { - char c = sql[pos]; - if (LetterStartsComment(c) && ConsumeComment()) - continue; - if (Char.IsWhiteSpace(c)) - ConsumeWhitespace(); - else if (c == '\'' || c == '\"' || c == '`') - ConsumeQuotedToken(c); - else if (!IsSpecialCharacter(c)) - ConsumeUnquotedToken(); - else - ConsumeSymbol(); - } - } - - private bool LetterStartsComment(char c) - { - return c == '#' || c == '/' || c == '-'; - } - - private bool IsSpecialCharacter(char c) - { - if (Char.IsLetterOrDigit(c) || - c == '$' || c == '_' || c == '.') return false; - return true; - } - - private bool ConsumeComment() - { - char c = fullSql[pos]; - // make sure the comment starts correctly - if (c == '/' && ((pos + 1) >= fullSql.Length || fullSql[pos + 1] != '*')) return false; - if (c == '-' && ((pos + 2) >= fullSql.Length || fullSql[pos + 1] != '-' || fullSql[pos + 2] != ' ')) return false; - - string endingPattern = "\n"; - if (c == '/') - endingPattern = "*/"; - - int startingIndex = pos; - - int index = fullSql.IndexOf(endingPattern, pos); - if (index == -1) - index = fullSql.Length - 1; - else - index += endingPattern.Length; - string comment = fullSql.Substring(pos, index - pos); - if (comment.StartsWith("/*!")) - tokens.Add(new Token(TokenType.CommandComment, comment)); - pos = index; - return true; - } - - private void ConsumeSymbol() - { - char c = fullSql[pos++]; - tokens.Add(new Token(TokenType.Symbol, c.ToString())); - } - - private void ConsumeQuotedToken(char c) - { - bool escaped = false; - int start = pos; - pos++; - while (pos < fullSql.Length) - { - char x = fullSql[pos]; - - if (x == c && !escaped) break; - - if (escaped) - escaped = false; - else if (x == '\\') - escaped = true; - pos++; - } - pos++; - if (c == '\'') - tokens.Add(new Token(TokenType.String, "?")); - else - tokens.Add(new Token(TokenType.Identifier, fullSql.Substring(start, pos - start))); - } - - private void ConsumeUnquotedToken() - { - int startPos = pos; - while (pos < fullSql.Length && !IsSpecialCharacter(fullSql[pos])) - pos++; - string word = fullSql.Substring(startPos, pos - startPos); - double v; - if (Double.TryParse(word, out v)) - tokens.Add(new Token(TokenType.Number, "?")); - else - { - Token t = new Token(TokenType.Identifier, word); - if (IsKeyword(word)) - { - t.Type = TokenType.Keyword; - t.Text = t.Text.ToUpperInvariant(); - } - tokens.Add(t); - } - } - - private void ConsumeWhitespace() - { - tokens.Add(new Token(TokenType.Whitespace, " ")); - while (pos < fullSql.Length && Char.IsWhiteSpace(fullSql[pos])) - pos++; - } - - private bool IsKeyword(string word) - { - return keywords.Contains(word.ToUpperInvariant()); - } - } - - internal class Token - { - public TokenType Type; - public string Text; - public bool Output; - - public Token(TokenType type, string text) - { - Type = type; - Text = text; - Output = true; - } - - public bool IsRealToken - { - get - { - return Type != TokenType.Comment && - Type != TokenType.CommandComment && - Type != TokenType.Whitespace && - Output; } - } - } - - internal enum TokenType - { - Keyword, - String, - Number, - Symbol, - Identifier, - Comment, - CommandComment, - Whitespace - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SHA1.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SHA1.cs deleted file mode 100644 index 0ce093f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SHA1.cs +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; - -namespace MySql.Data.Common -{ - class SHA1Hash - { - private const int SHA1_HASH_SIZE = 20; // Hash size in bytes - - // Constants defined in SHA-1 - private static uint[] K = new uint[4] { - 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 }; - - private static uint[] sha_const_key = new uint[5] { - 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 }; - - private ulong length; // Message length in bits - private uint[] intermediateHash; // Message Digest - private bool computed; // Is the digest computed? -// private bool corrupted; // Is the message digest corrupted? - private short messageBlockIndex; // Index into message block array - private byte[] messageBlock; // 512-bit message blocks - - public SHA1Hash() - { - intermediateHash = new uint[SHA1_HASH_SIZE/4]; - messageBlock = new byte[64]; - Reset(); - } - - public void Reset() - { -/*#ifndef DBUG_OFF - if (!context) - return SHA_NULL; -#endif*/ - - length = 0; - messageBlockIndex = 0; - - intermediateHash[0] = sha_const_key[0]; - intermediateHash[1] = sha_const_key[1]; - intermediateHash[2] = sha_const_key[2]; - intermediateHash[3] = sha_const_key[3]; - intermediateHash[4] = sha_const_key[4]; - - computed = false; -// corrupted = false; - } - - public byte[] ComputeHash(byte[] buffer) - { - Reset(); - Input(buffer, 0, buffer.Length); - return Result(); - } - - public void Input(byte[] buffer, int index, int bufLen) - { - if (buffer == null || bufLen == 0) return; - - if (index < 0 || index > buffer.Length - 1) - throw new ArgumentException("Index must be a value between 0 and buffer.Length-1", "index"); - if (bufLen < 0) - throw new ArgumentException("Length must be a value > 0", "length"); - if ((bufLen+index) > buffer.Length) - throw new ArgumentException("Length + index would extend past the end of buffer", "length"); - -/*#ifndef DBUG_OFF - // We assume client konows what it is doing in non-debug mode - if (!context || !message_array) - return SHA_NULL; - if (context->Computed) - return (context->Corrupted= SHA_STATE_ERROR); - if (context->Corrupted) - return context->Corrupted; -#endif*/ - - while (bufLen-- > 0) - { - messageBlock[messageBlockIndex++] = (byte)(buffer[index++] & 0xFF); - length += 8; /* Length is in bits */ - -/*#ifndef DBUG_OFF - - // Then we're not debugging we assume we never will get message longer - //2^64 bits. - - if (context->Length == 0) - return (context->Corrupted= 1); // Message is too long -#endif*/ - - if (messageBlockIndex == 64) - ProcessMessageBlock(); - } - } - - private void ProcessMessageBlock() - { - uint temp; // Temporary word value - uint[] W; // Word sequence - uint A, B, C, D, E; // Word buffers - - W = new uint[80]; - - //Initialize the first 16 words in the array W - for (int t = 0; t < 16; t++) - { - int index=t*4; - W[t] = (uint)messageBlock[index] << 24; - W[t] |= (uint)messageBlock[index + 1] << 16; - W[t] |= (uint)messageBlock[index + 2] << 8; - W[t] |= (uint)messageBlock[index + 3]; - } - - - for (int t = 16; t < 80; t++) - { - W[t] = CircularShift(1, W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]); - } - - A = intermediateHash[0]; - B = intermediateHash[1]; - C = intermediateHash[2]; - D = intermediateHash[3]; - E = intermediateHash[4]; - - for (int t = 0; t < 20; t++) - { - temp= CircularShift(5, A) + ((B & C) | ((~B) & D)) + E + W[t] + K[0]; - E = D; - D = C; - C = CircularShift(30, B); - B = A; - A = temp; - } - - for (int t = 20; t < 40; t++) - { - temp = CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1]; - E = D; - D = C; - C = CircularShift(30,B); - B = A; - A = temp; - } - - for (int t = 40; t < 60; t++) - { - temp= (CircularShift(5,A) + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2]); - E = D; - D = C; - C = CircularShift(30,B); - B = A; - A = temp; - } - - for (int t = 60; t < 80; t++) - { - temp = CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3]; - E = D; - D = C; - C = CircularShift(30,B); - B = A; - A = temp; - } - - intermediateHash[0] += A; - intermediateHash[1] += B; - intermediateHash[2] += C; - intermediateHash[3] += D; - intermediateHash[4] += E; - - messageBlockIndex = 0; - } - - private static uint CircularShift(int bits, uint word) - { - return (((word) << (bits)) | ((word) >> (32-(bits)))); - } - - private void PadMessage() - { - /* - Check to see if the current message block is too small to hold - the initial padding bits and length. If so, we will pad the - block, process it, and then continue padding into a second - block. - */ - - int i = messageBlockIndex; - - if (i > 55) - { - messageBlock[i++] = 0x80; - Array.Clear(messageBlock, i, 64-i); - //bzero((char*) &context->Message_Block[i], sizeof(messageBlock[0])*(64-i)); - messageBlockIndex = 64; - - /* This function sets messageBlockIndex to zero */ - ProcessMessageBlock(); - - Array.Clear(messageBlock, 0, 56); - //bzero((char*) &context->Message_Block[0], sizeof(messageBlock[0])*56); - messageBlockIndex = 56; - } - else - { - messageBlock[i++] = 0x80; - Array.Clear(messageBlock, i, 56-i); - //bzero((char*) &messageBlock[i], sizeof(messageBlock[0])*(56-i)); - messageBlockIndex = 56; - } - - // Store the message length as the last 8 octets - messageBlock[56] = (byte)(length >> 56); - messageBlock[57] = (byte)(length >> 48); - messageBlock[58] = (byte)(length >> 40); - messageBlock[59] = (byte)(length >> 32); - messageBlock[60] = (byte)(length >> 24); - messageBlock[61] = (byte)(length >> 16); - messageBlock[62] = (byte)(length >> 8); - messageBlock[63] = (byte)length; - - ProcessMessageBlock(); - } - - public byte[] Result() - { -/*#ifndef DBUG_OFF - if (!context || !Message_Digest) - return SHA_NULL; - - if (context->Corrupted) - return context->Corrupted; -#endif*/ - - if (!computed) - { - PadMessage(); - - // message may be sensitive, clear it out - Array.Clear(messageBlock, 0, 64); - //bzero((char*) messageBlock,64); - length = 0; /* and clear length */ - computed = true; - } - - byte[] messageDigest = new byte[SHA1_HASH_SIZE]; - for (int i = 0; i < SHA1_HASH_SIZE; i++) - messageDigest[i] = (byte)((intermediateHash[i>>2] >> 8 * ( 3 - ( i & 0x03 ) ))); - return messageDigest; - } - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SharedMemoryStream.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SharedMemoryStream.cs deleted file mode 100644 index db8d7e3..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SharedMemoryStream.cs +++ /dev/null @@ -1,353 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Runtime.InteropServices; -using System.Threading; -using System.IO; -using MySql.Data.MySqlClient; -using System.Diagnostics; - - -namespace MySql.Data.Common -{ -#if !PocketPC - - /// - /// Helper class to encapsulate shared memory functionality - /// Also cares of proper cleanup of file mapping object and cew - /// - internal class SharedMemory : IDisposable - { - private const uint FILE_MAP_WRITE = 0x0002; - - IntPtr fileMapping; - IntPtr view; - - public SharedMemory(string name, IntPtr size) - { - fileMapping = NativeMethods.OpenFileMapping(FILE_MAP_WRITE, false, - name); - if (fileMapping == IntPtr.Zero) - { - throw new MySqlException("Cannot open file mapping " + name); - } - view = NativeMethods.MapViewOfFile(fileMapping, FILE_MAP_WRITE, 0, 0, size); - } - - public IntPtr View - { - get { return view; } - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - if (view != IntPtr.Zero) - { - NativeMethods.UnmapViewOfFile(view); - view = IntPtr.Zero; - } - if (fileMapping != IntPtr.Zero) - { - // Free the handle - NativeMethods.CloseHandle(fileMapping); - fileMapping = IntPtr.Zero; - } - } - } - - } - /// - /// Summary description for SharedMemoryStream. - /// - internal class SharedMemoryStream : Stream - { - private string memoryName; - private EventWaitHandle serverRead; - private EventWaitHandle serverWrote; - private EventWaitHandle clientRead; - private EventWaitHandle clientWrote; - private EventWaitHandle connectionClosed; - private SharedMemory data; - private int bytesLeft; - private int position; - private int connectNumber; - - private const int BUFFERLENGTH = 16004; - - private int readTimeout = System.Threading.Timeout.Infinite; - private int writeTimeout = System.Threading.Timeout.Infinite; - - public SharedMemoryStream(string memName) - { - memoryName = memName; - } - - public void Open(uint timeOut) - { - if (connectionClosed != null) - { - Debug.Assert(false, "Connection is already open"); - } - GetConnectNumber(timeOut); - SetupEvents(); - } - - public override void Close() - { - if (connectionClosed != null) - { - bool isClosed = connectionClosed.WaitOne(0); - if (!isClosed) - { - connectionClosed.Set(); - connectionClosed.Close(); - } - connectionClosed = null; - EventWaitHandle[] handles = - {serverRead, serverWrote, clientRead, clientWrote}; - - for(int i=0; i< handles.Length; i++) - { - if(handles[i] != null) - handles[i].Close(); - } - if (data != null) - { - data.Dispose(); - data = null; - } - } - } - - private void GetConnectNumber(uint timeOut) - { - EventWaitHandle connectRequest; - try - { - connectRequest = - EventWaitHandle.OpenExisting(memoryName + "_CONNECT_REQUEST"); - - } - catch (Exception) - { - // If server runs as service, its shared memory is global - // And if connector runs in user session, it needs to prefix - // shared memory name with "Global\" - string prefixedMemoryName = @"Global\" + memoryName; - connectRequest = - EventWaitHandle.OpenExisting(prefixedMemoryName + "_CONNECT_REQUEST"); - memoryName = prefixedMemoryName; - } - EventWaitHandle connectAnswer = - EventWaitHandle.OpenExisting(memoryName + "_CONNECT_ANSWER"); - using (SharedMemory connectData = - new SharedMemory(memoryName + "_CONNECT_DATA", (IntPtr)4)) - { - // now start the connection - if (!connectRequest.Set()) - throw new MySqlException("Failed to open shared memory connection"); - if (!connectAnswer.WaitOne((int)(timeOut * 1000), false)) - throw new MySqlException("Timeout during connection"); - connectNumber = Marshal.ReadInt32(connectData.View); - } - } - - - private void SetupEvents() - { - string prefix = memoryName + "_" + connectNumber; - data = new SharedMemory(prefix + "_DATA", (IntPtr)BUFFERLENGTH); - serverWrote = EventWaitHandle.OpenExisting(prefix + "_SERVER_WROTE"); - serverRead = EventWaitHandle.OpenExisting(prefix + "_SERVER_READ"); - clientWrote = EventWaitHandle.OpenExisting(prefix + "_CLIENT_WROTE"); - clientRead = EventWaitHandle.OpenExisting(prefix + "_CLIENT_READ"); - connectionClosed = EventWaitHandle.OpenExisting(prefix + "_CONNECTION_CLOSED"); - - // tell the server we are ready - serverRead.Set(); - } - - #region Properties - public override bool CanRead - { - get { return true; } - } - - public override bool CanSeek - { - get { return false; } - } - - public override bool CanWrite - { - get { return true; } - } - - public override long Length - { - get { throw new NotSupportedException("SharedMemoryStream does not support seeking - length"); } - } - - public override long Position - { - get { throw new NotSupportedException("SharedMemoryStream does not support seeking - position"); } - set { } - } - - #endregion - - public override void Flush() - { - // No need to flush anything to disk ,as our shared memory is backed - // by the page file - } - - public override int Read(byte[] buffer, int offset, int count) - { - int timeLeft = readTimeout; - WaitHandle[] waitHandles = { serverWrote, connectionClosed }; - LowResolutionStopwatch stopwatch = new LowResolutionStopwatch(); - while (bytesLeft == 0) - { - stopwatch.Start(); - int index = WaitHandle.WaitAny(waitHandles, timeLeft); - stopwatch.Stop(); - if (index == WaitHandle.WaitTimeout) - throw new TimeoutException("Timeout when reading from shared memory"); - - if (waitHandles[index] == connectionClosed) - throw new MySqlException("Connection to server lost",true, null); - - if (readTimeout != System.Threading.Timeout.Infinite) - { - timeLeft = readTimeout - (int)stopwatch.ElapsedMilliseconds; - if (timeLeft < 0) - throw new TimeoutException("Timeout when reading from shared memory"); - } - - bytesLeft = Marshal.ReadInt32(data.View); - position = 4; - } - - int len = Math.Min(count, bytesLeft); - long baseMem = data.View.ToInt64() + position; - - for (int i = 0; i < len; i++, position++) - buffer[offset + i] = Marshal.ReadByte((IntPtr)(baseMem + i)); - - bytesLeft -= len; - if (bytesLeft == 0) - clientRead.Set(); - - return len; - } - - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("SharedMemoryStream does not support seeking"); - } - - public override void Write(byte[] buffer, int offset, int count) - { - int leftToDo = count; - int buffPos = offset; - WaitHandle[] waitHandles = { serverRead, connectionClosed }; - LowResolutionStopwatch stopwatch = new LowResolutionStopwatch(); - int timeLeft = writeTimeout; - - while (leftToDo > 0) - { - stopwatch.Start(); - int index = WaitHandle.WaitAny(waitHandles, timeLeft); - stopwatch.Stop(); - - if (waitHandles[index] == connectionClosed) - throw new MySqlException("Connection to server lost",true, null); - - if (index == WaitHandle.WaitTimeout) - throw new TimeoutException("Timeout when reading from shared memory"); - - if (writeTimeout != System.Threading.Timeout.Infinite) - { - timeLeft = writeTimeout - (int)stopwatch.ElapsedMilliseconds; - if (timeLeft < 0) - throw new TimeoutException("Timeout when writing to shared memory"); - } - int bytesToDo = Math.Min(leftToDo, BUFFERLENGTH); - long baseMem = data.View.ToInt64() + 4; - Marshal.WriteInt32(data.View, bytesToDo); - Marshal.Copy(buffer, buffPos, (IntPtr)baseMem, bytesToDo); - buffPos += bytesToDo; - leftToDo -= bytesToDo; - if (!clientWrote.Set()) - throw new MySqlException("Writing to shared memory failed"); - } - } - - public override void SetLength(long value) - { - throw new NotSupportedException("SharedMemoryStream does not support seeking"); - } - - public override bool CanTimeout - { - get - { - return true; - } - } - - public override int ReadTimeout - { - get - { - return readTimeout; - } - set - { - readTimeout = value; - } - } - - public override int WriteTimeout - { - get - { - return writeTimeout; - } - set - { - writeTimeout = value; - } - } - - } -#endif -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SocketStream.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SocketStream.cs deleted file mode 100644 index a355853..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/SocketStream.cs +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Collections; - -namespace MySql.Data.Common -{ - /// - /// Summary description for MySqlSocket. - /// - internal sealed class SocketStream : Stream - { - private Socket socket; - - public SocketStream(AddressFamily addressFamily, SocketType socketType, ProtocolType protocol) - { - socket = new Socket(addressFamily, socketType, protocol); - } - - #region Properties - - public Socket Socket - { - get { return socket; } - } - - public override bool CanRead - { - get { return true; } - } - - public override bool CanSeek - { - get { return false; } - } - - public override bool CanWrite - { - get { return true; } - } - - public override long Length - { - get { return 0; } - } - - public override long Position - { - get { return 0; } - set { throw new NotSupportedException("SocketStream does not support seek"); } - } - - #endregion - - #region Stream Implementation - - public override void Flush() - { - } - - public override int Read(byte[] buffer, int offset, int count) - { - return socket.Receive(buffer, offset, count, SocketFlags.None); - } - - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("SocketStream does not support seek"); - } - - public override void SetLength(long value) - { - } - - public override void Write(byte[] buffer, int offset, int count) - { - socket.Send(buffer, offset, count, SocketFlags.None); - } - - - #endregion - - public bool Connect(EndPoint remoteEP, int timeout) - { - // set the socket to non blocking - socket.Blocking = false; - - // then we star the connect - SocketAddress addr = remoteEP.Serialize(); - byte[] buff = new byte[addr.Size]; - for (int i=0; i - /// Summary description for StreamCreator. - /// - internal class StreamCreator - { - string hostList; - uint port; - string pipeName; - uint timeOut; - uint keepalive; - - public StreamCreator(string hosts, uint port, string pipeName, uint keepalive) - { - hostList = hosts; - if (hostList == null || hostList.Length == 0) - hostList = "localhost"; - this.port = port; - this.pipeName = pipeName; - this.keepalive = keepalive; - } - - public Stream GetStream(uint timeout) - { - timeOut = timeout; - - if (hostList.StartsWith("/", StringComparison.OrdinalIgnoreCase)) - return CreateSocketStream(null, true); - - string[] dnsHosts = hostList.Split('&'); - - Random random = new Random((int)DateTime.Now.Ticks); - int index = random.Next(dnsHosts.Length); - int pos = 0; - bool usePipe = (pipeName != null && pipeName.Length != 0); - Stream stream = null; - - while (pos < dnsHosts.Length) - { - try - { - if (usePipe) - { -#if !CF - stream = NamedPipeStream.Create(pipeName, dnsHosts[index], timeout); -#endif - } - else - { - IPHostEntry ipHE = GetHostEntry(dnsHosts[index]); - foreach (IPAddress address in ipHE.AddressList) - { - // MySQL doesn't currently support IPv6 addresses - if (address.AddressFamily == AddressFamily.InterNetworkV6) - continue; - stream = CreateSocketStream(address, false); - if (stream != null) break; - } - } - if (stream != null) - break; - index++; - if (index == dnsHosts.Length) - index = 0; - pos++; - } - catch (Exception) - { - // if on last host then throw - if (pos >= dnsHosts.Length - 1) throw; - // else continue - } - } - - return stream; - } - - private IPHostEntry ParseIPAddress(string hostname) - { - IPHostEntry ipHE = null; -#if !CF - IPAddress addr; - if (IPAddress.TryParse(hostname, out addr)) - { - ipHE = new IPHostEntry(); - ipHE.AddressList = new IPAddress[1]; - ipHE.AddressList[0] = addr; - } -#endif - return ipHE; - } - -#if CF - IPHostEntry GetDnsHostEntry(string hostname) - { - return Dns.GetHostEntry(hostname); - } -#else - IPHostEntry GetDnsHostEntry(string hostname) - { - LowResolutionStopwatch stopwatch = new LowResolutionStopwatch(); - - try - { - stopwatch.Start(); - return Dns.GetHostEntry(hostname); - } - catch (SocketException ex) - { - string message = String.Format(Resources.GetHostEntryFailed, - stopwatch.Elapsed, hostname, ex.SocketErrorCode, - ex.ErrorCode, ex.NativeErrorCode); - throw new Exception(message, ex); - } - finally - { - stopwatch.Stop(); - } - } -#endif - - private IPHostEntry GetHostEntry(string hostname) - { - IPHostEntry ipHE = ParseIPAddress(hostname); - if (ipHE != null) return ipHE; - return GetDnsHostEntry(hostname); - } - -#if !CF - - private static EndPoint CreateUnixEndPoint(string host) - { - // first we need to load the Mono.posix assembly - Assembly a = Assembly.Load("Mono.Posix"); - - // then we need to construct a UnixEndPoint object - EndPoint ep = (EndPoint)a.CreateInstance("Mono.Posix.UnixEndPoint", - false, BindingFlags.CreateInstance, null, - new object[1] { host }, null, null); - return ep; - } -#endif - - private Stream CreateSocketStream(IPAddress ip, bool unix) - { - EndPoint endPoint; -#if !CF - if (!Platform.IsWindows() && unix) - endPoint = CreateUnixEndPoint(hostList); - else -#endif - endPoint = new IPEndPoint(ip, (int)port); - - Socket socket = unix ? - new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP) : - new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - if (keepalive > 0) - { - SetKeepAlive(socket, keepalive); - } - IAsyncResult ias = socket.BeginConnect(endPoint, null, null); - if (!ias.AsyncWaitHandle.WaitOne((int)timeOut * 1000, false)) - { - socket.Close(); - return null; - } - try - { - socket.EndConnect(ias); - } - catch (Exception) - { - socket.Close(); - throw; - } - MyNetworkStream stream = new MyNetworkStream(socket, true); - GC.SuppressFinalize(socket); - GC.SuppressFinalize(stream); - return stream; - } - - - - /// - /// Set keepalive + timeout on socket. - /// - /// socket - /// keepalive timeout, in seconds - private static void SetKeepAlive(Socket s, uint time) - { - -#if !CF - uint on = 1; - uint interval = 1000; // default interval = 1 sec - - uint timeMilliseconds; - if (time > UInt32.MaxValue / 1000) - timeMilliseconds = UInt32.MaxValue; - else - timeMilliseconds = time * 1000; - - // Use Socket.IOControl to implement equivalent of - // WSAIoctl with SOL_KEEPALIVE_VALS - - // the native structure passed to WSAIoctl is - //struct tcp_keepalive { - // ULONG onoff; - // ULONG keepalivetime; - // ULONG keepaliveinterval; - //}; - // marshal the equivalent of the native structure into a byte array - - byte[] inOptionValues = new byte[12]; - BitConverter.GetBytes(on).CopyTo(inOptionValues, 0); - BitConverter.GetBytes(time).CopyTo(inOptionValues, 4); - BitConverter.GetBytes(interval).CopyTo(inOptionValues, 8); - try - { - // call WSAIoctl via IOControl - s.IOControl(IOControlCode.KeepAliveValues, inOptionValues, null); - return; - } - catch (NotImplementedException) - { - // Mono throws not implemented currently - } -#endif - // Fallback if Socket.IOControl is not available ( Compact Framework ) - // or not implemented ( Mono ). Keepalive option will still be set, but - // with timeout is kept default. - s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Version.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Version.cs deleted file mode 100644 index b4ad08e..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/common/Version.cs +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using MySql.Data.MySqlClient; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.Common -{ - /// - /// Summary description for Version. - /// - internal struct DBVersion - { - private int major; - private int minor; - private int build; - private string srcString; - - public DBVersion( string s, int major, int minor, int build) - { - this.major = major; - this.minor = minor; - this.build = build; - srcString = s; - } - - public int Major - { - get { return major; } - } - - public int Minor - { - get { return minor; } - } - - public int Build - { - get { return build; } - } - - public static DBVersion Parse( string versionString ) - { - int start = 0; - int index = versionString.IndexOf('.', start); - if (index == -1) - throw new MySqlException(Resources.BadVersionFormat); - string val = versionString.Substring(start, index-start).Trim(); - int major = Convert.ToInt32(val, System.Globalization.NumberFormatInfo.InvariantInfo); - - start = index+1; - index = versionString.IndexOf('.', start); - if (index == -1) - throw new MySqlException(Resources.BadVersionFormat); - val = versionString.Substring(start, index-start).Trim(); - int minor = Convert.ToInt32(val, System.Globalization.NumberFormatInfo.InvariantInfo); - - start = index+1; - int i = start; - while (i < versionString.Length && Char.IsDigit(versionString, i)) - i++; - val = versionString.Substring(start, i-start).Trim(); - int build = Convert.ToInt32(val, System.Globalization.NumberFormatInfo.InvariantInfo); - - return new DBVersion(versionString, major, minor, build); - } - - public bool isAtLeast(int majorNum, int minorNum, int buildNum) - { - if (major > majorNum) return true; - if (major == majorNum && minor > minorNum) return true; - if (major == majorNum && minor == minorNum && build >= buildNum) return true; - return false; - } - - public override string ToString() - { - return srcString; - } - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/dataadapter.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/dataadapter.cs deleted file mode 100644 index 12a2e6a..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/dataadapter.cs +++ /dev/null @@ -1,309 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Data.Common; -using System.ComponentModel; -using System.Collections.Generic; - -namespace MySql.Data.MySqlClient -{ - /// -#if !CF - [System.Drawing.ToolboxBitmap( typeof(MySqlDataAdapter), "MySqlClient.resources.dataadapter.bmp")] - [System.ComponentModel.DesignerCategory("Code")] - [Designer("MySql.Data.MySqlClient.Design.MySqlDataAdapterDesigner,MySqlClient.Design")] -#endif - public sealed class MySqlDataAdapter : DbDataAdapter, IDbDataAdapter, IDataAdapter, ICloneable - { - private bool loadingDefaults; - private int updateBatchSize; - List commandBatch; - - /// - /// Occurs during Update before a command is executed against the data source. The attempt to update is made, so the event fires. - /// - public event MySqlRowUpdatingEventHandler RowUpdating; - - /// - /// Occurs during Update after a command is executed against the data source. The attempt to update is made, so the event fires. - /// - public event MySqlRowUpdatedEventHandler RowUpdated; - - /// - public MySqlDataAdapter() - { - loadingDefaults = true; - updateBatchSize = 1; - } - - /// - public MySqlDataAdapter(MySqlCommand selectCommand) : this() - { - SelectCommand = selectCommand; - } - - /// - public MySqlDataAdapter(string selectCommandText, MySqlConnection connection) : this() - { - SelectCommand = new MySqlCommand(selectCommandText, connection); - } - - /// - public MySqlDataAdapter(string selectCommandText, string selectConnString) : this() - { - SelectCommand = new MySqlCommand(selectCommandText, - new MySqlConnection(selectConnString) ); - } - - #region Properties - - /// -#if !CF - [Description("Used during Update for deleted rows in Dataset.")] -#endif - public new MySqlCommand DeleteCommand - { - get { return (MySqlCommand)base.DeleteCommand; } - set { base.DeleteCommand = value; } - } - - /// -#if !CF - [Description("Used during Update for new rows in Dataset.")] -#endif - public new MySqlCommand InsertCommand - { - get { return (MySqlCommand)base.InsertCommand; } - set { base.InsertCommand = value; } - } - - /// -#if !CF - [Description("Used during Fill/FillSchema")] - [Category("Fill")] -#endif - public new MySqlCommand SelectCommand - { - get { return (MySqlCommand)base.SelectCommand; } - set { base.SelectCommand = value; } - } - - /// -#if !CF - [Description("Used during Update for modified rows in Dataset.")] -#endif - public new MySqlCommand UpdateCommand - { - get { return (MySqlCommand)base.UpdateCommand; } - set { base.UpdateCommand = value; } - } - - internal bool LoadDefaults - { - get { return loadingDefaults; } - set { loadingDefaults = value; } - } - - #endregion - - #region Batching Support - - public override int UpdateBatchSize - { - get { return updateBatchSize; } - set { updateBatchSize = value; } - } - - protected override void InitializeBatching() - { - commandBatch = new List(); - } - - protected override int AddToBatch(IDbCommand command) - { - // the first time each command is asked to be batched, we ask - // that command to prepare its batchable command text. We only want - // to do this one time for each command - MySqlCommand commandToBatch = (MySqlCommand)command; - if (commandToBatch.BatchableCommandText == null) - commandToBatch.GetCommandTextForBatching(); - - IDbCommand cloneCommand = (IDbCommand)((ICloneable)command).Clone(); - commandBatch.Add(cloneCommand); - - return commandBatch.Count - 1; - } - - protected override int ExecuteBatch() - { - int recordsAffected = 0; - int index = 0; - while (index < commandBatch.Count) - { - MySqlCommand cmd = (MySqlCommand)commandBatch[index++]; - for (int index2 = index; index2 < commandBatch.Count; index2++,index++) - { - MySqlCommand cmd2 = (MySqlCommand)commandBatch[index2]; - if (cmd2.BatchableCommandText == null || - cmd2.CommandText != cmd.CommandText) break; - cmd.AddToBatch(cmd2); - } - recordsAffected += cmd.ExecuteNonQuery(); - } - return recordsAffected; - } - - protected override void ClearBatch() - { - if (commandBatch.Count > 0) - { - MySqlCommand cmd = (MySqlCommand)commandBatch[0]; - if (cmd.Batch != null) - cmd.Batch.Clear(); - } - commandBatch.Clear(); - } - - protected override void TerminateBatching() - { - ClearBatch(); - commandBatch = null; - } - - protected override IDataParameter GetBatchedParameter(int commandIdentifier, int parameterIndex) - { - return (IDataParameter)commandBatch[commandIdentifier].Parameters[parameterIndex]; - } - - #endregion - - /// - /// Overridden. See . - /// - /// - /// - /// - /// - /// - override protected RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) - { - return new MySqlRowUpdatedEventArgs(dataRow, command, statementType, tableMapping); - } - - /// - /// Overridden. See . - /// - /// - /// - /// - /// - /// - override protected RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) - { - return new MySqlRowUpdatingEventArgs(dataRow, command, statementType, tableMapping); - } - - /// - /// Overridden. Raises the RowUpdating event. - /// - /// A MySqlRowUpdatingEventArgs that contains the event data. - override protected void OnRowUpdating(RowUpdatingEventArgs value) - { - if (RowUpdating != null) - RowUpdating(this, (value as MySqlRowUpdatingEventArgs)); - } - - /// - /// Overridden. Raises the RowUpdated event. - /// - /// A MySqlRowUpdatedEventArgs that contains the event data. - override protected void OnRowUpdated(RowUpdatedEventArgs value) - { - if (RowUpdated != null) - RowUpdated(this, (value as MySqlRowUpdatedEventArgs)); - } - } - - /// - /// Represents the method that will handle the event of a . - /// - public delegate void MySqlRowUpdatingEventHandler(object sender, MySqlRowUpdatingEventArgs e); - - /// - /// Represents the method that will handle the event of a . - /// - public delegate void MySqlRowUpdatedEventHandler(object sender, MySqlRowUpdatedEventArgs e); - - /// - /// Provides data for the RowUpdating event. This class cannot be inherited. - /// - public sealed class MySqlRowUpdatingEventArgs : RowUpdatingEventArgs - { - /// - /// Initializes a new instance of the MySqlRowUpdatingEventArgs class. - /// - /// The to - /// . - /// The to execute during . - /// One of the values that specifies the type of query executed. - /// The sent through an . - public MySqlRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) - : base(row, command, statementType, tableMapping) - { - } - - /// - /// Gets or sets the MySqlCommand to execute when performing the Update. - /// - new public MySqlCommand Command - { - get { return (MySqlCommand)base.Command; } - set { base.Command = value; } - } - } - - /// - /// Provides data for the RowUpdated event. This class cannot be inherited. - /// - public sealed class MySqlRowUpdatedEventArgs : RowUpdatedEventArgs - { - /// - /// Initializes a new instance of the MySqlRowUpdatedEventArgs class. - /// - /// The sent through an . - /// The executed when is called. - /// One of the values that specifies the type of query executed. - /// The sent through an . - public MySqlRowUpdatedEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) - : base(row, command, statementType, tableMapping) - { - } - - /// - /// Gets or sets the MySqlCommand executed when Update is called. - /// - new public MySqlCommand Command - { - get { return (MySqlCommand)base.Command; } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/datareader.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/datareader.cs deleted file mode 100644 index 803e533..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/datareader.cs +++ /dev/null @@ -1,924 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Data.Common; -using System.Collections; -using MySql.Data.Types; -using System.Data.SqlTypes; -using System.Collections.Generic; -using System.Globalization; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.MySqlClient -{ - /// - public sealed class MySqlDataReader : DbDataReader, IDataReader, IDataRecord - { - // The DataReader should always be open when returned to the user. - private bool isOpen = true; - - private CommandBehavior commandBehavior; - private MySqlCommand command; - internal long affectedRows; - internal Driver driver; - private PreparableStatement statement; - private ResultSet resultSet; - - /* - * Keep track of the connection in order to implement the - * CommandBehavior.CloseConnection flag. A null reference means - * normal behavior (do not automatically close). - */ - private MySqlConnection connection; - - /* - * Because the user should not be able to directly create a - * DataReader object, the constructors are - * marked as internal. - */ - internal MySqlDataReader(MySqlCommand cmd, PreparableStatement statement, CommandBehavior behavior) - { - this.command = cmd; - connection = (MySqlConnection)command.Connection; - commandBehavior = behavior; - driver = connection.driver; - affectedRows = -1; - this.statement = statement; - } - - #region Properties - - internal PreparableStatement Statement - { - get { return statement; } - } - - internal MySqlCommand Command - { - get { return command; } - } - - internal ResultSet ResultSet - { - get { return resultSet; } - } - - /// - /// Gets a value indicating the depth of nesting for the current row. This method is not - /// supported currently and always returns 0. - /// - public override int Depth - { - get { return 0; } - } - - /// - /// Gets the number of columns in the current row. - /// - public override int FieldCount - { - get { return resultSet == null ? 0 : resultSet.Size; } - } - - /// - /// Gets a value indicating whether the MySqlDataReader contains one or more rows. - /// - public override bool HasRows - { - get { return resultSet == null ? false : resultSet.HasRows; } - } - - /// - /// Gets a value indicating whether the data reader is closed. - /// - public override bool IsClosed - { - get { return !isOpen; } - } - - /// - /// Gets the number of rows changed, inserted, or deleted by execution of the SQL statement. - /// - public override int RecordsAffected - { - // RecordsAffected returns the number of rows affected in batch - // statments from insert/delete/update statments. This property - // is not completely accurate until .Close() has been called. - get { return (int)affectedRows; } - } - - /// - /// Overloaded. Gets the value of a column in its native format. - /// In C#, this property is the indexer for the MySqlDataReader class. - /// - public override object this[int i] - { - get { return GetValue(i); } - } - - /// - /// Gets the value of a column in its native format. - /// [C#] In C#, this property is the indexer for the MySqlDataReader class. - /// - public override object this[String name] - { - // Look up the ordinal and return - // the value at that position. - get { return this[GetOrdinal(name)]; } - } - - #endregion - - /// - /// Closes the MySqlDataReader object. - /// - public override void Close() - { - if (!isOpen) return; - - bool shouldCloseConnection = (commandBehavior & CommandBehavior.CloseConnection) != 0; - commandBehavior = CommandBehavior.Default; - - // clear all remaining resultsets - try - { - while (NextResult()) { } - } - catch (MySqlException ex) - { - if (ex.Number != 1317) - throw; - } - - connection.Reader = null; - // we now give the command a chance to terminate. In the case of - // stored procedures it needs to update out and inout parameters - command.Close(this); - - if (shouldCloseConnection) - connection.Close(); - - command = null; - connection = null; - isOpen = false; - } - - #region TypeSafe Accessors - - /// - /// Gets the value of the specified column as a Boolean. - /// - /// - /// - public bool GetBoolean(string name) - { - return GetBoolean(GetOrdinal(name)); - } - - /// - /// Gets the value of the specified column as a Boolean. - /// - /// - /// - public override bool GetBoolean(int i) - { - return Convert.ToBoolean(GetValue(i)); - } - - /// - /// Gets the value of the specified column as a byte. - /// - /// - /// - public byte GetByte(string name) - { - return GetByte(GetOrdinal(name)); - } - - /// - /// Gets the value of the specified column as a byte. - /// - /// - /// - public override byte GetByte(int i) - { - IMySqlValue v = GetFieldValue(i, false); - if (v is MySqlUByte) - return ((MySqlUByte)v).Value; - else - return (byte)((MySqlByte)v).Value; - } - - /// - /// Gets the value of the specified column as a sbyte. - /// - /// - /// - public sbyte GetSByte(string name) - { - return GetSByte(GetOrdinal(name)); - } - - /// - /// Gets the value of the specified column as a sbyte. - /// - /// - /// - public sbyte GetSByte(int i) - { - IMySqlValue v = GetFieldValue(i, false); - if (v is MySqlByte) - return ((MySqlByte)v).Value; - else - return (sbyte)((MySqlByte)v).Value; - } - - /// - /// Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset. - /// - /// The zero-based column ordinal. - /// The index within the field from which to begin the read operation. - /// The buffer into which to read the stream of bytes. - /// The index for buffer to begin the read operation. - /// The maximum length to copy into the buffer. - /// The actual number of bytes read. - /// - public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) - { - if (i >= FieldCount) - throw new IndexOutOfRangeException(); - - IMySqlValue val = GetFieldValue(i, false); - - if (!(val is MySqlBinary) && !(val is MySqlGuid)) - throw new MySqlException("GetBytes can only be called on binary or guid columns"); - - byte[] bytes = null; - if (val is MySqlBinary) - bytes = ((MySqlBinary)val).Value; - else - bytes = ((MySqlGuid)val).Bytes; - - if (buffer == null) - return bytes.Length; - - if (bufferoffset >= buffer.Length || bufferoffset < 0) - throw new IndexOutOfRangeException("Buffer index must be a valid index in buffer"); - if (buffer.Length < (bufferoffset + length)) - throw new ArgumentException("Buffer is not large enough to hold the requested data"); - if (fieldOffset < 0 || - ((ulong)fieldOffset >= (ulong)bytes.Length && (ulong)bytes.Length > 0)) - throw new IndexOutOfRangeException("Data index must be a valid index in the field"); - - // adjust the length so we don't run off the end - if ((ulong)bytes.Length < (ulong)(fieldOffset + length)) - { - length = (int)((ulong)bytes.Length - (ulong)fieldOffset); - } - - Buffer.BlockCopy(bytes, (int)fieldOffset, buffer, (int)bufferoffset, (int)length); - - return length; - } - - private object ChangeType(IMySqlValue value, int fieldIndex, Type newType) - { -#if !CF - resultSet.Fields[fieldIndex].AddTypeConversion(newType); -#endif - return Convert.ChangeType(value.Value, newType, CultureInfo.InvariantCulture); - } - - /// - /// Gets the value of the specified column as a single character. - /// - /// - /// - public char GetChar(string name) - { - return GetChar(GetOrdinal(name)); - } - - /// - /// Gets the value of the specified column as a single character. - /// - /// - /// - public override char GetChar(int i) - { - string s = GetString(i); - return s[0]; - } - - /// - /// Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset. - /// - /// - /// - /// - /// - /// - /// - public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) - { - if (i >= FieldCount) - throw new IndexOutOfRangeException(); - - string valAsString = GetString(i); - - if (buffer == null) return valAsString.Length; - - if (bufferoffset >= buffer.Length || bufferoffset < 0) - throw new IndexOutOfRangeException("Buffer index must be a valid index in buffer"); - if (buffer.Length < (bufferoffset + length)) - throw new ArgumentException("Buffer is not large enough to hold the requested data"); - if (fieldoffset < 0 || fieldoffset >= valAsString.Length) - throw new IndexOutOfRangeException("Field offset must be a valid index in the field"); - - if (valAsString.Length < length) - length = valAsString.Length; - valAsString.CopyTo((int)fieldoffset, buffer, bufferoffset, length); - return length; - } - - /// - /// Gets the name of the source data type. - /// - /// - /// - public override String GetDataTypeName(int i) - { - if (!isOpen) throw new Exception("No current query in data reader"); - if (i >= FieldCount) throw new IndexOutOfRangeException(); - - // return the name of the type used on the backend - IMySqlValue v = resultSet.Values[i]; - return v.MySqlTypeName; - } - - /// - public MySqlDateTime GetMySqlDateTime(string column) - { - return GetMySqlDateTime(GetOrdinal(column)); - } - - /// - public MySqlDateTime GetMySqlDateTime(int column) - { - return (MySqlDateTime)GetFieldValue(column, true); - } - - /// - public DateTime GetDateTime(string column) - { - return GetDateTime(GetOrdinal(column)); - } - - /// - public override DateTime GetDateTime(int i) - { - IMySqlValue val = GetFieldValue(i, true); - MySqlDateTime dt; - - if (val is MySqlDateTime) - dt = (MySqlDateTime)val; - else - { - // we need to do this because functions like date_add return string - string s = GetString(i); - dt = MySqlDateTime.Parse(s); - } - - if (connection.Settings.ConvertZeroDateTime && !dt.IsValidDateTime) - return DateTime.MinValue; - else - return dt.GetDateTime(); - } - - public MySqlDecimal GetMySqlDecimal(string column) - { - return GetMySqlDecimal(GetOrdinal(column)); - } - - public MySqlDecimal GetMySqlDecimal(int i) - { - return (MySqlDecimal)GetFieldValue(i, false); - } - - /// - public Decimal GetDecimal(string column) - { - return GetDecimal(GetOrdinal(column)); - } - - /// - public override Decimal GetDecimal(int i) - { - IMySqlValue v = GetFieldValue(i, true); - if (v is MySqlDecimal) - return ((MySqlDecimal)v).Value; - return Convert.ToDecimal(v.Value); - } - - /// - public double GetDouble(string column) - { - return GetDouble(GetOrdinal(column)); - } - - /// - public override double GetDouble(int i) - { - IMySqlValue v = GetFieldValue(i, true); - if (v is MySqlDouble) - return ((MySqlDouble)v).Value; - return Convert.ToDouble(v.Value); - } - - public Type GetFieldType(string column) - { - return GetFieldType(GetOrdinal(column)); - } - - /// - /// Gets the Type that is the data type of the object. - /// - /// - /// - public override Type GetFieldType(int i) - { - if (!isOpen) throw new Exception("No current query in data reader"); - if (i >= FieldCount) throw new IndexOutOfRangeException(); - - // we have to use the values array directly because we can't go through - // GetValue - IMySqlValue v = resultSet.Values[i]; - if (v is MySqlDateTime) - { - if (!connection.Settings.AllowZeroDateTime) - return typeof(DateTime); - return typeof(MySqlDateTime); - } - return v.SystemType; - } - - /// - public float GetFloat(string column) - { - return GetFloat(GetOrdinal(column)); - } - - /// - public override float GetFloat(int i) - { - IMySqlValue v = GetFieldValue(i, true); - if (v is MySqlSingle) - return ((MySqlSingle)v).Value; - return Convert.ToSingle(v.Value); - } - - /// - public Guid GetGuid(string column) - { - return GetGuid(GetOrdinal(column)); - } - - /// - public override Guid GetGuid(int i) - { - object v = GetValue(i); - if (v is Guid) - return (Guid)v; - if (v is string) - return new Guid(v as string); - if (v is byte[]) - { - byte[] bytes = (byte[])v; - if (bytes.Length == 16) - return new Guid(bytes); - } - throw new MySqlException(Resources.ValueNotSupportedForGuid); - } - - /// - public Int16 GetInt16(string column) - { - return GetInt16(GetOrdinal(column)); - } - - /// - public override Int16 GetInt16(int i) - { - IMySqlValue v = GetFieldValue(i, true); - if (v is MySqlInt16) - return ((MySqlInt16)v).Value; - - return (short)ChangeType(v, i, typeof(short)); - } - - /// - public Int32 GetInt32(string column) - { - return GetInt32(GetOrdinal(column)); - } - - /// - public override Int32 GetInt32(int i) - { - IMySqlValue v = GetFieldValue(i, true); - if (v is MySqlInt32) - return ((MySqlInt32)v).Value; - - return (Int32)ChangeType(v, i, typeof(Int32)); - } - - /// - public Int64 GetInt64(string column) - { - return GetInt64(GetOrdinal(column)); - } - - /// - public override Int64 GetInt64(int i) - { - IMySqlValue v = GetFieldValue(i, true); - if (v is MySqlInt64) - return ((MySqlInt64)v).Value; - - return (Int64)ChangeType(v, i, typeof(Int64)); - } - - /// - /// Gets the name of the specified column. - /// - /// - /// - public override String GetName(int i) - { - if (!isOpen) throw new Exception("No current query in data reader"); - if (i >= FieldCount) throw new IndexOutOfRangeException(); - - return resultSet.Fields[i].ColumnName; - } - - /// - /// Gets the column ordinal, given the name of the column. - /// - /// - /// - public override int GetOrdinal(string name) - { - if (!isOpen || resultSet == null) - throw new Exception("No current query in data reader"); - - return resultSet.GetOrdinal(name); - } - - /// - /// Returns a DataTable that describes the column metadata of the MySqlDataReader. - /// - /// - public override DataTable GetSchemaTable() - { - // Only Results from SQL SELECT Queries - // get a DataTable for schema of the result - // otherwise, DataTable is null reference - if (FieldCount == 0) return null; - - DataTable dataTableSchema = new DataTable("SchemaTable"); - - dataTableSchema.Columns.Add("ColumnName", typeof(string)); - dataTableSchema.Columns.Add("ColumnOrdinal", typeof(int)); - dataTableSchema.Columns.Add("ColumnSize", typeof(int)); - dataTableSchema.Columns.Add("NumericPrecision", typeof(int)); - dataTableSchema.Columns.Add("NumericScale", typeof(int)); - dataTableSchema.Columns.Add("IsUnique", typeof(bool)); - dataTableSchema.Columns.Add("IsKey", typeof(bool)); - DataColumn dc = dataTableSchema.Columns["IsKey"]; - dc.AllowDBNull = true; // IsKey can have a DBNull - dataTableSchema.Columns.Add("BaseCatalogName", typeof(string)); - dataTableSchema.Columns.Add("BaseColumnName", typeof(string)); - dataTableSchema.Columns.Add("BaseSchemaName", typeof(string)); - dataTableSchema.Columns.Add("BaseTableName", typeof(string)); - dataTableSchema.Columns.Add("DataType", typeof(Type)); - dataTableSchema.Columns.Add("AllowDBNull", typeof(bool)); - dataTableSchema.Columns.Add("ProviderType", typeof(int)); - dataTableSchema.Columns.Add("IsAliased", typeof(bool)); - dataTableSchema.Columns.Add("IsExpression", typeof(bool)); - dataTableSchema.Columns.Add("IsIdentity", typeof(bool)); - dataTableSchema.Columns.Add("IsAutoIncrement", typeof(bool)); - dataTableSchema.Columns.Add("IsRowVersion", typeof(bool)); - dataTableSchema.Columns.Add("IsHidden", typeof(bool)); - dataTableSchema.Columns.Add("IsLong", typeof(bool)); - dataTableSchema.Columns.Add("IsReadOnly", typeof(bool)); - - int ord = 1; - for (int i = 0; i < FieldCount; i++) - { - MySqlField f = resultSet.Fields[i]; - DataRow r = dataTableSchema.NewRow(); - r["ColumnName"] = f.ColumnName; - r["ColumnOrdinal"] = ord++; - r["ColumnSize"] = f.IsTextField ? f.ColumnLength / f.MaxLength : f.ColumnLength; - int prec = f.Precision; - int pscale = f.Scale; - if (prec != -1) - r["NumericPrecision"] = (short)prec; - if (pscale != -1) - r["NumericScale"] = (short)pscale; - r["DataType"] = GetFieldType(i); - r["ProviderType"] = (int)f.Type; - r["IsLong"] = f.IsBlob && f.ColumnLength > 255; - r["AllowDBNull"] = f.AllowsNull; - r["IsReadOnly"] = false; - r["IsRowVersion"] = false; - r["IsUnique"] = f.IsUnique; - r["IsKey"] = f.IsPrimaryKey; - r["IsAutoIncrement"] = f.IsAutoIncrement; - r["BaseSchemaName"] = f.DatabaseName; - r["BaseCatalogName"] = null; - r["BaseTableName"] = f.RealTableName; - r["BaseColumnName"] = f.OriginalColumnName; - - dataTableSchema.Rows.Add(r); - } - - return dataTableSchema; - } - - /// - public string GetString(string column) - { - return GetString(GetOrdinal(column)); - } - - /// - public override String GetString(int i) - { - IMySqlValue val = GetFieldValue(i, true); - - if (val is MySqlBinary) - { - byte[] v = ((MySqlBinary)val).Value; - return resultSet.Fields[i].Encoding.GetString(v, 0, v.Length); - } - - return val.Value.ToString(); - } - - /// - public TimeSpan GetTimeSpan(string column) - { - return GetTimeSpan(GetOrdinal(column)); - } - - /// - public TimeSpan GetTimeSpan(int column) - { - IMySqlValue val = GetFieldValue(column, true); - - MySqlTimeSpan ts = (MySqlTimeSpan)val; - return ts.Value; - } - - /// - /// Gets the value of the specified column in its native format. - /// - /// - /// - public override object GetValue(int i) - { - if (!isOpen) throw new Exception("No current query in data reader"); - if (i >= FieldCount) throw new IndexOutOfRangeException(); - - IMySqlValue val = GetFieldValue(i, false); - if (val.IsNull) - return DBNull.Value; - - // if the column is a date/time, then we return a MySqlDateTime - // so .ToString() will print '0000-00-00' correctly - if (val is MySqlDateTime) - { - MySqlDateTime dt = (MySqlDateTime)val; - if (!dt.IsValidDateTime && connection.Settings.ConvertZeroDateTime) - return DateTime.MinValue; - else if (connection.Settings.AllowZeroDateTime) - return val; - else - return dt.GetDateTime(); - } - - return val.Value; - } - - /// - /// Gets all attribute columns in the collection for the current row. - /// - /// - /// - public override int GetValues(object[] values) - { - int numCols = Math.Min(values.Length, FieldCount); - for (int i = 0; i < numCols; i++) - values[i] = GetValue(i); - - return numCols; - } - - /// - public UInt16 GetUInt16(string column) - { - return GetUInt16(GetOrdinal(column)); - } - - /// - public UInt16 GetUInt16(int column) - { - IMySqlValue v = GetFieldValue(column, true); - if (v is MySqlUInt16) - return ((MySqlUInt16)v).Value; - - return (UInt16)ChangeType(v, column, typeof(UInt16)); - } - - /// - public UInt32 GetUInt32(string column) - { - return GetUInt32(GetOrdinal(column)); - } - - /// - public UInt32 GetUInt32(int column) - { - IMySqlValue v = GetFieldValue(column, true); - if (v is MySqlUInt32) - return ((MySqlUInt32)v).Value; - return (uint)ChangeType(v, column, typeof(UInt32)); - } - - /// - public UInt64 GetUInt64(string column) - { - return GetUInt64(GetOrdinal(column)); - } - - /// - public UInt64 GetUInt64(int column) - { - IMySqlValue v = GetFieldValue(column, true); - if (v is MySqlUInt64) - return ((MySqlUInt64)v).Value; - - return (UInt64)ChangeType(v, column, typeof(UInt64)); - } - - - #endregion - - IDataReader IDataRecord.GetData(int i) - { - return base.GetData(i); - } - - /// - /// Gets a value indicating whether the column contains non-existent or missing values. - /// - /// - /// - public override bool IsDBNull(int i) - { - return DBNull.Value == GetValue(i); - } - - /// - /// Advances the data reader to the next result, when reading the results of batch SQL statements. - /// - /// - public override bool NextResult() - { - if (!isOpen) - throw new MySqlException(Resources.NextResultIsClosed); - - // this will clear out any unread data - if (resultSet != null) - resultSet.Close(); - - // single result means we only return a single resultset. If we have already - // returned one, then we return false; - if (resultSet != null && (commandBehavior & CommandBehavior.SingleResult) != 0) - return false; - - // next load up the next resultset if any - try - { - do - { - resultSet = null; - resultSet = driver.NextResult(Statement.StatementId); - if (resultSet == null) return false; - if (resultSet.IsOutputParameters) return false; - - if (resultSet.Size == 0) - { - Command.lastInsertedId = resultSet.InsertedId; - if (affectedRows == -1) - affectedRows = resultSet.AffectedRows; - else - affectedRows += resultSet.AffectedRows; - } - } while (resultSet.Size == 0); - - return true; - } - catch (MySqlException ex) - { - if (ex.IsFatal) - connection.Abort(); - if (ex.Number == 0) - throw new MySqlException(Resources.FatalErrorReadingResult, ex); - throw; - } - } - - /// - /// Advances the MySqlDataReader to the next record. - /// - /// - public override bool Read() - { - if (!isOpen) - throw new MySqlException("Invalid attempt to Read when reader is closed."); - if (resultSet == null) - return false; - - try - { - return resultSet.NextRow(commandBehavior); - } - catch (TimeoutException tex) - { - connection.HandleTimeout(tex); - return false; // unreached - } - catch (MySqlException ex) - { - if (ex.IsFatal) - connection.Abort(); - - // if we get a query interrupted then our resultset is done - if (ex.Number == 1317) - { - return false; - } - - throw new MySqlException(Resources.FatalErrorDuringRead, ex); - } - } - - - private IMySqlValue GetFieldValue(int index, bool checkNull) - { - if (index < 0 || index >= FieldCount) - throw new ArgumentException(Resources.InvalidColumnOrdinal); - - IMySqlValue v = resultSet[index]; - - if (checkNull && v.IsNull) - throw new SqlNullValueException(); - - return v; - } - - #region IEnumerator - - /// - /// Returns an that iterates through the . - /// - /// - public override IEnumerator GetEnumerator() - { - return new DbEnumerator(this, (commandBehavior & CommandBehavior.CloseConnection) != 0); - } - - #endregion - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlCommand.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlCommand.xml deleted file mode 100644 index 4d89152..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlCommand.xml +++ /dev/null @@ -1,934 +0,0 @@ - - - Represents a SQL statement to execute against a MySQL database. This class cannot be inherited. - - MySqlCommand features the following methods for executing commands at a MySQL database: - - - Item - Description - - - - ExecuteReader - - Executes commands that return rows. - - - - ExecuteNonQuery - - Executes commands such as SQL INSERT, DELETE, and UPDATE statements. - - - - ExecuteScalar - - Retrieves a single value (for example, an aggregate value) from a database. - - - - You can reset the CommandText property and reuse the MySqlCommand - object. However, you must close the MySqlDataReader - before you can execute a new or previous command. - - If a MySqlException is - generated by the method executing a MySqlCommand, the MySqlConnection - remains open. It is the responsibility of the programmer to close the connection. - - - Using the '@' symbol for paramters is now the preferred approach although the old pattern of using - '?' is still supported. Please be aware though that using '@' can cause conflicts when user variables - are also used. To help with this situation please see the documentation on the 'allow user variables' - connection string option. The 'old syntax' connection string option has now been deprecated. - - - - - The following example creates a MySqlCommand and - a MySqlConnection. The MySqlConnection is opened and set as the Connection - for the MySqlCommand. The example then calls ExecuteNonQuery, - and closes the connection. To accomplish this, the ExecuteNonQuery is - passed a connection string and a query string that is a SQL INSERT - statement. - - Public Sub InsertRow(myConnectionString As String) - " If the connection string is null, use a default. - If myConnectionString = "" Then - myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass" - End If - Dim myConnection As New MySqlConnection(myConnectionString) - Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)" - Dim myCommand As New MySqlCommand(myInsertQuery) - myCommand.Connection = myConnection - myConnection.Open() - myCommand.ExecuteNonQuery() - myCommand.Connection.Close() - End Sub - - - public void InsertRow(string myConnectionString) - { - // If the connection string is null, use a default. - if(myConnectionString == "") - { - myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"; - } - MySqlConnection myConnection = new MySqlConnection(myConnectionString); - string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"; - MySqlCommand myCommand = new MySqlCommand(myInsertQuery); - myCommand.Connection = myConnection; - myConnection.Open(); - myCommand.ExecuteNonQuery(); - myCommand.Connection.Close(); - } - - - - - - - - - - Initializes a new instance of the MySqlCommand class. - - - The following example creates a MySqlCommand and sets some of its properties. - - - This example shows how to use one of the overloaded - versions of the MySqlCommand constructor. For other examples that might be available, - see the individual overload topics. - - - - Public Sub CreateMySqlCommand() - Dim myConnection As New MySqlConnection _ - ("Persist Security Info=False;database=test;server=myServer") - myConnection.Open() - Dim myTrans As MySqlTransaction = myConnection.BeginTransaction() - Dim mySelectQuery As String = "SELECT * FROM MyTable" - Dim myCommand As New MySqlCommand(mySelectQuery, myConnection, myTrans) - myCommand.CommandTimeout = 20 - End Sub - - - public void CreateMySqlCommand() - { - MySqlConnection myConnection = new MySqlConnection("Persist Security Info=False; - database=test;server=myServer"); - myConnection.Open(); - MySqlTransaction myTrans = myConnection.BeginTransaction(); - string mySelectQuery = "SELECT * FROM myTable"; - MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection,myTrans); - myCommand.CommandTimeout = 20; - } - - - public: - void CreateMySqlCommand() - { - MySqlConnection* myConnection = new MySqlConnection(S"Persist Security Info=False; - database=test;server=myServer"); - myConnection->Open(); - MySqlTransaction* myTrans = myConnection->BeginTransaction(); - String* mySelectQuery = S"SELECT * FROM myTable"; - MySqlCommand* myCommand = new MySqlCommand(mySelectQuery, myConnection, myTrans); - myCommand->CommandTimeout = 20; - }; - - - - - - - Initializes a new instance of the MySqlCommand class. - - - The base constructor initializes all fields to their default values. The - following table shows initial property values for an instance of . - - - Properties - Initial Value - - - - - - empty string ("") - - - - - - 0 - - - - - - CommandType.Text - - - - - - Null - - - - You can change the value for any of these properties through a separate call to - the property. - - - - The following example creates a and - sets some of its properties. - - - Public Sub CreateMySqlCommand() - Dim myCommand As New MySqlCommand() - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - MySqlCommand myCommand = new MySqlCommand(); - myCommand.CommandType = CommandType.Text; - } - - - - - - - Initializes a new instance of the class with the text of the query. - - The text of the query. - - When an instance of is created, - the following read/write properties are set to initial values. - - - - Properties - Initial Value - - - - - - - cmdText - - - - - - - 0 - - - - - - CommandType.Text - - - - - - Null - - - - You can change the value for any of these properties through a separate call to - the property. - - - - The following example creates a and - sets some of its properties. - - - Public Sub CreateMySqlCommand() - Dim sql as String = "SELECT * FROM mytable" - Dim myCommand As New MySqlCommand(sql) - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - string sql = "SELECT * FROM mytable"; - MySqlCommand myCommand = new MySqlCommand(sql); - myCommand.CommandType = CommandType.Text; - } - - - - - - - Initializes a new instance of the class - with the text of the query and a . - - The text of the query. - - A that represents the - connection to an instance of SQL Server. - - - When an instance of is created, - the following read/write properties are set to initial values. - - - - Properties - Initial Value - - - - - - - cmdText - - - - - - - 0 - - - - - - CommandType.Text - - - - - - - connection - - - - - You can change the value for any of these properties through a separate call to - the property. - - - - The following example creates a and - sets some of its properties. - - - Public Sub CreateMySqlCommand() - Dim conn as new MySqlConnection("server=myServer") - Dim sql as String = "SELECT * FROM mytable" - Dim myCommand As New MySqlCommand(sql, conn) - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - MySqlConnection conn = new MySqlConnection("server=myserver") - string sql = "SELECT * FROM mytable"; - MySqlCommand myCommand = new MySqlCommand(sql, conn); - myCommand.CommandType = CommandType.Text; - } - - - - - - - - - Initializes a new instance of the class - with the text of the query, a , and the - . - - - The text of the query. - - A that represents the - connection to an instance of SQL Server. - - - The in which the executes. - - - When an instance of is created, - the following read/write properties are set to initial values. - - - - Properties - Initial Value - - - - - - - cmdText - - - - - - - 0 - - - - - - CommandType.Text - - - - - - - connection - - - - - You can change the value for any of these properties through a separate call to - the property. - - - - The following example creates a and - sets some of its properties. - - - Public Sub CreateMySqlCommand() - Dim conn as new MySqlConnection("server=myServer") - conn.Open(); - Dim txn as MySqlTransaction = conn.BeginTransaction() - Dim sql as String = "SELECT * FROM mytable" - Dim myCommand As New MySqlCommand(sql, conn, txn) - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - MySqlConnection conn = new MySqlConnection("server=myserver") - conn.Open(); - MySqlTransaction txn = conn.BeginTransaction(); - string sql = "SELECT * FROM mytable"; - MySqlCommand myCommand = new MySqlCommand(sql, conn, txn); - myCommand.CommandType = CommandType.Text; - } - - - - - - - - - - - Executes a SQL statement against the connection and returns the number of rows affected. - - Number of rows affected - - You can use ExecuteNonQuery to perform any type of database operation, - however any resultsets returned will not be available. Any output parameters - used in calling a stored procedure will be populated with data and can be - retrieved after execution is complete. - For UPDATE, INSERT, and DELETE statements, the return value is the number - of rows affected by the command. For all other types of statements, the return - value is -1. - - - The following example creates a MySqlCommand and then - executes it using ExecuteNonQuery. The example is passed a string that is a - SQL statement (such as UPDATE, INSERT, or DELETE) and a string to use to - connect to the data source. - - Public Sub CreateMySqlCommand(myExecuteQuery As String, myConnection As MySqlConnection) - Dim myCommand As New MySqlCommand(myExecuteQuery, myConnection) - myCommand.Connection.Open() - myCommand.ExecuteNonQuery() - myConnection.Close() - End Sub - - - public void CreateMySqlCommand(string myExecuteQuery, MySqlConnection myConnection) - { - MySqlCommand myCommand = new MySqlCommand(myExecuteQuery, myConnection); - myCommand.Connection.Open(); - myCommand.ExecuteNonQuery(); - myConnection.Close(); - } - - - - - - - Sends the to the Connection, - and builds a using one of the values. - - - One of the values. - - - - When the property is set to StoredProcedure, - the property should be set to the name of the stored - procedure. The command executes this stored procedure when you call - ExecuteReader. - - - The supports a special mode that enables large binary - values to be read efficiently. For more information, see the SequentialAccess - setting for . - - - While the is in use, the associated - is busy serving the MySqlDataReader. - While in this state, no other operations can be performed on the - MySqlConnection other than closing it. This is the case until the - method of the MySqlDataReader is called. - If the MySqlDataReader is created with CommandBehavior set to - CloseConnection, closing the MySqlDataReader closes the connection - automatically. - - - When calling ExecuteReader with the SingleRow behavior, you should be aware that using a limit - clause in your SQL will cause all rows (up to the limit given) to be retrieved by the client. The - method will still return false after the first row but pulling all rows of data - into the client will have a performance impact. If the limit clause is not necessary, it should - be avoided. - - - - A object. - - - - - - - Sends the to the Connection - and builds a . - - - A object. - - - - When the property is set to StoredProcedure, - the property should be set to the name of the stored - procedure. The command executes this stored procedure when you call - ExecuteReader. - - - While the is in use, the associated - is busy serving the MySqlDataReader. - While in this state, no other operations can be performed on the - MySqlConnection other than closing it. This is the case until the - method of the MySqlDataReader is called. - - - - The following example creates a , then executes it by - passing a string that is a SQL SELECT statement, and a string to use to connect to the - data source. - - Public Sub CreateMySqlDataReader(mySelectQuery As String, myConnection As MySqlConnection) - Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) - myConnection.Open() - Dim myReader As MySqlDataReader - myReader = myCommand.ExecuteReader() - Try - While myReader.Read() - Console.WriteLine(myReader.GetString(0)) - End While - Finally - myReader.Close - myConnection.Close - End Try - End Sub - - - public void CreateMySqlDataReader(string mySelectQuery, MySqlConnection myConnection) - { - MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection); - myConnection.Open(); - MMySqlDataReader myReader; - myReader = myCommand.ExecuteReader(); - try - { - while(myReader.Read()) - { - Console.WriteLine(myReader.GetString(0)); - } - } - finally - { - myReader.Close(); - myConnection.Close(); - } - } - - - - - - - - Creates a prepared version of the command on an instance of MySQL Server. - - - - Prepared statements are only supported on MySQL version 4.1 and higher. Calling - prepare while connected to earlier versions of MySQL will succeed but will execute - the statement in the same way as unprepared. - - - - The following example demonstrates the use of the Prepare method. - - public sub PrepareExample() - Dim cmd as New MySqlCommand("INSERT INTO mytable VALUES (@val)", myConnection) - cmd.Parameters.Add( "@val", 10 ) - cmd.Prepare() - cmd.ExecuteNonQuery() - - cmd.Parameters(0).Value = 20 - cmd.ExecuteNonQuery() - end sub - - - private void PrepareExample() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO mytable VALUES (@val)", myConnection); - cmd.Parameters.Add( "@val", 10 ); - cmd.Prepare(); - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = 20; - cmd.ExecuteNonQuery(); - } - - - - - - - Executes the query, and returns the first column of the first row in the - result set returned by the query. Extra columns or rows are ignored. - - - The first column of the first row in the result set, or a null reference if the - result set is empty - - - - Use the ExecuteScalar method to retrieve a single value (for example, - an aggregate value) from a database. This requires less code than using the - method, and then performing the operations necessary - to generate the single value using the data returned by a - - - - The following example creates a and then - executes it using ExecuteScalar. The example is passed a string that is a - SQL statement that returns an aggregate result, and a string to use to - connect to the data source. - - - Public Sub CreateMySqlCommand(myScalarQuery As String, myConnection As MySqlConnection) - Dim myCommand As New MySqlCommand(myScalarQuery, myConnection) - myCommand.Connection.Open() - myCommand.ExecuteScalar() - myConnection.Close() - End Sub - - - public void CreateMySqlCommand(string myScalarQuery, MySqlConnection myConnection) - { - MySqlCommand myCommand = new MySqlCommand(myScalarQuery, myConnection); - myCommand.Connection.Open(); - myCommand.ExecuteScalar(); - myConnection.Close(); - } - - - public: - void CreateMySqlCommand(String* myScalarQuery, MySqlConnection* myConnection) - { - MySqlCommand* myCommand = new MySqlCommand(myScalarQuery, myConnection); - myCommand->Connection->Open(); - myCommand->ExecuteScalar(); - myConnection->Close(); - } - - - - - - - - Gets or sets the SQL statement to execute at the data source. - - - The SQL statement or stored procedure to execute. The default is an empty string. - - - - When the property is set to StoredProcedure, - the CommandText property should be set to the name of the stored procedure. - The user may be required to use escape character syntax if the stored procedure name - contains any special characters. The command executes this stored procedure when - you call one of the Execute methods. Starting with Connector/Net 5.0, having both a stored function - and stored procedure with the same name in the same database is not supported. It is - suggested that you provide unqiue names for your stored routines. - - - - The following example creates a and sets some of its properties. - - Public Sub CreateMySqlCommand() - Dim myCommand As New MySqlCommand() - myCommand.CommandText = "SELECT * FROM Mytable ORDER BY id" - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - MySqlCommand myCommand = new MySqlCommand(); - myCommand.CommandText = "SELECT * FROM mytable ORDER BY id"; - myCommand.CommandType = CommandType.Text; - } - - - - - - - Gets or sets the wait time before terminating the attempt to execute a command - and generating an error. - - - The time (in seconds) to wait for the command to execute. The default is 30 - seconds. - - - CommandTimeout is dependent on the ability of MySQL to cancel an executing query. - Because of this, CommandTimeout is only supported when connected to MySQL - version 5.0.0 or higher. - - - - - - Gets or sets a value indicating how the property is to be interpreted. - - - One of the values. The default is Text. - - - - When you set the CommandType property to StoredProcedure, you - should set the property to the name of the stored - procedure. The command executes this stored procedure when you call one of the - Execute methods. - - - - The following example creates a and sets some of its properties. - - Public Sub CreateMySqlCommand() - Dim myCommand As New MySqlCommand() - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - MySqlCommand myCommand = new MySqlCommand(); - myCommand.CommandType = CommandType.Text; - } - - - - - - - - - - - Gets or sets the used by this instance of the - . - - - The connection to a data source. The default value is a null reference - (Nothing in Visual Basic). - - - - If you set Connection while a transaction is in progress and the - property is not null, an - is generated. If the Transaction property is not null and the transaction - has already been committed or rolled back, Transaction is set to - null. - - - - The following example creates a and sets some of its properties. - - Public Sub CreateMySqlCommand() - Dim mySelectQuery As String = "SELECT * FROM mytable ORDER BY id" - Dim myConnectString As String = "Persist Security Info=False;database=test;server=myServer" - Dim myCommand As New MySqlCommand(mySelectQuery) - myCommand.Connection = New MySqlConnection(myConnectString) - myCommand.CommandType = CommandType.Text - End Sub - - - public void CreateMySqlCommand() - { - string mySelectQuery = "SELECT * FROM mytable ORDER BY id"; - string myConnectString = "Persist Security Info=False;database=test;server=myServer"; - MySqlCommand myCommand = new MySqlCommand(mySelectQuery); - myCommand.Connection = new MySqlConnection(myConnectString); - myCommand.CommandType = CommandType.Text; - } - - - - - - - - - Provides the id of the last inserted row. - - Id of the last inserted row. -1 if none exists. - - - An important point to remember is that this property can be used - in batch SQL scenarios but it's important to remember that it will - only reflect the insert id from the last insert statement in the batch. - - This property can also be used when the batch includes select statements - and ExecuteReader is used. This property can be consulted during result set - processing. - - - - - - Get the - - - The parameters of the SQL statement or stored procedure. The default is - an empty collection. - - - Connector/Net does not support unnamed parameters. Every parameter added to the collection must - have an associated name. - - - The following example creates a and displays its parameters. - To accomplish this, the method is passed a , a query string - that is a SQL SELECT statement, and an array of objects. - - Public Sub CreateMySqlCommand(myConnection As MySqlConnection, _ - mySelectQuery As String, myParamArray() As MySqlParameter) - Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) - myCommand.CommandText = "SELECT id, name FROM mytable WHERE age=@age" - myCommand.UpdatedRowSource = UpdateRowSource.Both - myCommand.Parameters.Add(myParamArray) - Dim j As Integer - For j = 0 To myCommand.Parameters.Count - 1 - myCommand.Parameters.Add(myParamArray(j)) - Next j - Dim myMessage As String = "" - Dim i As Integer - For i = 0 To myCommand.Parameters.Count - 1 - myMessage += myCommand.Parameters(i).ToString() & ControlChars.Cr - Next i - Console.WriteLine(myMessage) - End Sub - - - public void CreateMySqlCommand(MySqlConnection myConnection, string mySelectQuery, - MySqlParameter[] myParamArray) - { - MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection); - myCommand.CommandText = "SELECT id, name FROM mytable WHERE age=@age"; - myCommand.Parameters.Add(myParamArray); - for (int j=0; j<myParamArray.Length; j++) - { - myCommand.Parameters.Add(myParamArray[j]) ; - } - string myMessage = ""; - for (int i = 0; i < myCommand.Parameters.Count; i++) - { - myMessage += myCommand.Parameters[i].ToString() + "\n"; - } - MessageBox.Show(myMessage); - } - - - - - - - Gets or sets the within which the executes. - - - The . The default value is a null reference (Nothing in Visual Basic). - - - You cannot set the Transaction property if it is already set to a - specific value, and the command is in the process of executing. If you set the - transaction property to a object that is not connected - to the same as the object, - an exception will be thrown the next time you attempt to execute a statement. - - - - - - Gets or sets how command results are applied to the - when used by the method - of the . - - - One of the values. - - - - The default value is - Both unless the command is automatically generated (as in the case of the - ), in which case the default is None. - - - - - diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlCommandBuilder.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlCommandBuilder.xml deleted file mode 100644 index 8b3731f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlCommandBuilder.xml +++ /dev/null @@ -1,321 +0,0 @@ - - - - Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated MySQL database. This class cannot be inherited. - - - - The does not automatically generate the SQL statements required to - reconcile changes made to a DataSet with the associated instance of MySQL. - However, you can create a MySqlCommandBuilder object to automatically generate SQL statements for - single-table updates if you set the SelectCommand property - of the MySqlDataAdapter. Then, any additional SQL statements that you do not set are generated by the - MySqlCommandBuilder. - - - - The MySqlCommandBuilder registers itself as a listener for RowUpdating - events whenever you set the property. You can only associate one - MySqlDataAdapter or MySqlCommandBuilder object with each other at one time. - - - - To generate INSERT, UPDATE, or DELETE statements, the MySqlCommandBuilder uses the - SelectCommand property to retrieve a required set of metadata automatically. If you change - the SelectCommand after the metadata has is retrieved (for example, after the first update), you - should call the method to update the metadata. - - - - The SelectCommand must also return at least one primary key or unique - column. If none are present, an InvalidOperation exception is generated, - and the commands are not generated. - - - - The MySqlCommandBuilder also uses the Connection, - CommandTimeout, and Transaction - properties referenced by the SelectCommand. The user should call - RefreshSchema if any of these properties are modified, or if the - SelectCommand itself is replaced. Otherwise the InsertCommand, - UpdateCommand, and - DeleteCommand properties retain - their previous values. - - - - If you call Dispose, the MySqlCommandBuilder is disassociated - from the MySqlDataAdapter, and the generated commands are no longer used. - - - - Caution must be used when using MySqlCOmmandBuilder on MySql 4.0 systems. With MySql 4.0, - database/schema information is not provided to the connector for a query. This means that - a query that pulls columns from two identically named tables in two or more different databases - will not cause an exception to be thrown but will not work correctly. Even more dangerous - is the situation where your select statement references database X but is executed in - database Y and both databases have tables with similar layouts. This situation can cause - unwanted changes or deletes. - This note does not apply to MySQL versions 4.1 and later. - - - - - - The following example uses the , along - and , to - select rows from a data source. The example is passed an initialized - , a connection string, a - query string that is a SQL SELECT statement, and a string that is the - name of the database table. The example then creates a MySqlCommandBuilder. - - - Public Shared Function SelectRows(myConnection As String, mySelectQuery As String, myTableName As String) As DataSet - Dim myConn As New MySqlConnection(myConnection) - Dim myDataAdapter As New MySqlDataAdapter() - myDataAdapter.SelectCommand = New MySqlCommand(mySelectQuery, myConn) - Dim cb As SqlCommandBuilder = New MySqlCommandBuilder(myDataAdapter) - - myConn.Open() - - Dim ds As DataSet = New DataSet - myDataAdapter.Fill(ds, myTableName) - - ' Code to modify data in DataSet here - - ' Without the MySqlCommandBuilder this line would fail. - myDataAdapter.Update(ds, myTableName) - - myConn.Close() - End Function 'SelectRows - - - public static DataSet SelectRows(string myConnection, string mySelectQuery, string myTableName) - { - MySqlConnection myConn = new MySqlConnection(myConnection); - MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(); - myDataAdapter.SelectCommand = new MySqlCommand(mySelectQuery, myConn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(myDataAdapter); - - myConn.Open(); - - DataSet ds = new DataSet(); - myDataAdapter.Fill(ds, myTableName); - - //code to modify data in DataSet here - - //Without the MySqlCommandBuilder this line would fail - myDataAdapter.Update(ds, myTableName); - - myConn.Close(); - - return ds; - } - - - - - - - - Initializes a new instance of the class. - - - - - - Initializes a new instance of the class - with the associated object. - - - The to use. - - - - The registers itself as a listener for - events that are generated by the - specified in this property. - - - When you create a new instance MySqlCommandBuilder, any existing - MySqlCommandBuilder associated with this MySqlDataAdapter - is released. - - - - - - - - Gets or sets a object for which SQL statements are automatically generated. - - - A object. - - - - The registers itself as a listener for - events that are generated by the - specified in this property. - - - When you create a new instance MySqlCommandBuilder, any existing - MySqlCommandBuilder associated with this MySqlDataAdapter - is released. - - - - - - - Gets or sets the beginning character or characters to use when specifying MySQL - database objects (for example, tables or columns) whose names contain - characters such as spaces or reserved tokens. - - - The beginning character or characters to use. The default value is `. - - - Database objects in MySQL can contain special characters such as spaces that would - make normal SQL strings impossible to correctly parse. Use of the QuotePrefix - and the properties allows the - to build SQL commands that handle this situation. - - - - - - Gets or sets the beginning character or characters to use when specifying MySQL - database objects (for example, tables or columns) whose names contain - characters such as spaces or reserved tokens. - - - The beginning character or characters to use. The default value is `. - - - Database objects in MySQL can contain special characters such as spaces that would - make normal SQL strings impossible to correctly parse. Use of the - and the QuoteSuffix properties allows the - to build SQL commands that handle this situation. - - - - - - - - - - - - - - Gets the automatically generated object - required to perform deletions on the database. - - - The object generated to handle delete operations. - - - - An application can use the GetDeleteCommand method for informational - or troubleshooting purposes because it returns the - object to be executed. - - - You can also use GetDeleteCommand as the basis of a modified command. - For example, you might call GetDeleteCommand and modify the - value, and then explicitly set that on the - . - - - After the SQL statement is first generated, the application must explicitly - call if it changes the statement in any way. - Otherwise, the GetDeleteCommand will be still be using information - from the previous statement, which might not be correct. The SQL statements - are first generated either when the application calls - or GetDeleteCommand. - - - - - - - Gets the automatically generated object - required to perform insertions on the database. - - - The object generated to handle insert operations. - - - - An application can use the GetInsertCommand method for informational - or troubleshooting purposes because it returns the - object to be executed. - - - You can also use the GetInsertCommand as the basis of a modified command. - For example, you might call GetInsertCommand and modify the - value, and then explicitly set that on the - . - - - After the SQL statement is first generated, the application must explicitly - call if it changes the statement in any way. - Otherwise, the GetInsertCommand will be still be using information - from the previous statement, which might not be correct. The SQL statements - are first generated either when the application calls - or GetInsertCommand. - - - - - - - Gets the automatically generated object - required to perform updates on the database. - - - The object generated to handle update operations. - - - - An application can use the GetUpdateCommand method for informational - or troubleshooting purposes because it returns the - object to be executed. - - - You can also use GetUpdateCommand as the basis of a modified command. - For example, you might call GetUpdateCommand and modify the - value, and then explicitly set that on the - . - - - After the SQL statement is first generated, the application must explicitly - call if it changes the statement in any way. - Otherwise, the GetUpdateCommand will be still be using information - from the previous statement, which might not be correct. The SQL statements - are first generated either when the application calls - or GetUpdateCommand. - - - - - - - Refreshes the database schema information used to generate INSERT, UPDATE, or - DELETE statements. - - - - An application should call RefreshSchema whenever the SELECT statement - associated with the changes. - - - An application should call RefreshSchema whenever the - value of the changes. - - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlConnection.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlConnection.xml deleted file mode 100644 index 06bf770..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlConnection.xml +++ /dev/null @@ -1,1239 +0,0 @@ - - - - Initializes a new instance of the class. - - - When a new instance of is created, the read/write - properties are set to the following initial values unless they are specifically - set using their associated keywords in the property. - - - - Properties - Initial Value - - - - - - empty string ("") - - - - - - 15 - - - - - - empty string ("") - - - - - - empty string ("") - - - - - - empty string ("") - - - - You can change the value for these properties only by using the ConnectionString property. - - - - - - Initializes a new instance of the class. - - - - - - - Initializes a new instance of the class when given a string containing the connection string. - - - When a new instance of is created, the read/write - properties are set to the following initial values unless they are specifically - set using their associated keywords in the property. - - - - Properties - Initial Value - - - - - - empty string ("") - - - - - - 15 - - - - - - empty string ("") - - - - - - empty string ("") - - - - - - empty string ("") - - - - You can change the value for these properties only by using the ConnectionString property. - - - - The connection properties used to open the MySQL database. - - - - Opens a database connection with the property settings specified by the ConnectionString. - Cannot open a connection without specifying a data source or server. - A connection-level error occurred while opening the connection. - - - The draws an open connection from the connection pool if one is available. - Otherwise, it establishes a new connection to an instance of MySQL. - - - - The following example creates a , opens it, - displays some of its properties, then closes the connection. - - - Public Sub CreateMySqlConnection(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.Cr + "State: " + myConnection.State.ToString()) - myConnection.Close() - End Sub - - - public void CreateMySqlConnection(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + - "\nState: " + myConnection.State.ToString()); - myConnection.Close(); - } - - - - - - Gets the name of the current database or the database to be used after a connection is opened. - The name of the current database or the name of the database to be used after a connection is opened. The default value is an empty string. - - - The Database property does not update dynamically. - If you change the current database using a SQL statement, then this property - may reflect the wrong value. If you change the current database using the - method, this property is updated to reflect the new database. - - - - The following example creates a and displays - some of its read-only properties. - - - Public Sub CreateMySqlConnection() - Dim myConnString As String = _ - "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass" - Dim myConnection As New MySqlConnection( myConnString ) - myConnection.Open() - MessageBox.Show( "Server Version: " + myConnection.ServerVersion _ - + ControlChars.NewLine + "Database: " + myConnection.Database ) - myConnection.ChangeDatabase( "test2" ) - MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.NewLine + "Database: " + myConnection.Database ) - myConnection.Close() - End Sub - - - - public void CreateMySqlConnection() - { - string myConnString = - "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"; - MySqlConnection myConnection = new MySqlConnection( myConnString ); - myConnection.Open(); - MessageBox.Show( "Server Version: " + myConnection.ServerVersion - + "\nDatabase: " + myConnection.Database ); - myConnection.ChangeDatabase( "test2" ); - MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion - + "\nDatabase: " + myConnection.Database ); - myConnection.Close(); - } - - - - - - Gets the current state of the connection. - - A bitwise combination of the values. The default is Closed. - - - The allowed state changes are: - - - From Closed to Open, using the Open method of the connection object. - - - From Open to Closed, using either the Close method or the Dispose method of the connection object. - - - - - The following example creates a , opens it, - displays some of its properties, then closes the connection. - - - Public Sub CreateMySqlConnection(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.Cr + "State: " + myConnection.State.ToString()) - myConnection.Close() - End Sub - - - public void CreateMySqlConnection(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + - "\nState: " + myConnection.State.ToString()); - myConnection.Close(); - } - - - - - - Gets a string containing the version of the MySQL server to which the client is connected. - The version of the instance of MySQL. - The connection is closed. - - The following example creates a , opens it, - displays some of its properties, then closes the connection. - - - Public Sub CreateMySqlConnection(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.Cr + "State: " + myConnection.State.ToString()) - myConnection.Close() - End Sub - - - public void CreateMySqlConnection(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + - "\nState: " + myConnection.State.ToString()); - myConnection.Close(); - } - - - - - - Closes the connection to the database. This is the preferred method of closing any open connection. - - - The Close method rolls back any pending transactions. It then releases - the connection to the connection pool, or closes the connection if connection - pooling is disabled. - - - An application can call Close more than one time. No exception is - generated. - - - - The following example creates a , opens it, - displays some of its properties, then closes the connection. - - - Public Sub CreateMySqlConnection(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.Cr + "State: " + myConnection.State.ToString()) - myConnection.Close() - End Sub - - - public void CreateMySqlConnection(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + - "\nState: " + myConnection.State.ToString()); - myConnection.Close(); - } - - - - - - - Creates and returns a object associated with the . - - - A object. - - - - - Begins a database transaction. - An object representing the new transaction. - Parallel transactions are not supported. - - This command is equivalent to the MySQL BEGIN TRANSACTION command. - - You must explicitly commit or roll back the transaction using the or - method. - - If you do not specify an isolation level, the default isolation level is used. To specify an isolation - level with the method, use the overload that takes the iso parameter. Also - note that any attempt to begin a transaction while a transaction is in progress will throw an exception on MySQL 4.1 and higher. - On MySQL 4.0, an exception will not be thrown because servers 4.0 and earlier did not report their transacation status. - - - - - The following example creates a and a - . It also demonstrates how to use the BeginTransaction, a - , and methods. - - Public Sub RunTransaction(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - - Dim myCommand As MySqlCommand = myConnection.CreateCommand() - Dim myTrans As MySqlTransaction - - ' Start a local transaction - myTrans = myConnection.BeginTransaction() - ' Must assign both transaction object and connection - ' to Command object for a pending local transaction - myCommand.Connection = myConnection - myCommand.Transaction = myTrans - - Try - myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')" - myCommand.ExecuteNonQuery() - myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')" - myCommand.ExecuteNonQuery() - myTrans.Commit() - Console.WriteLine("Both records are written to database.") - Catch e As Exception - Try - myTrans.Rollback() - Catch ex As MySqlException - If Not myTrans.Connection Is Nothing Then - Console.WriteLine("An exception of type " + ex.GetType().ToString() + _ - " was encountered while attempting to roll back the transaction.") - End If - End Try - - Console.WriteLine("An exception of type " + e.GetType().ToString() + _ - "was encountered while inserting the data.") - Console.WriteLine("Neither record was written to database.") - Finally - myConnection.Close() - End Try - End Sub - - - public void RunTransaction(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - - MySqlCommand myCommand = myConnection.CreateCommand(); - MySqlTransaction myTrans; - - // Start a local transaction - myTrans = myConnection.BeginTransaction(); - // Must assign both transaction object and connection - // to Command object for a pending local transaction - myCommand.Connection = myConnection; - myCommand.Transaction = myTrans; - - try - { - myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')"; - myCommand.ExecuteNonQuery(); - myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')"; - myCommand.ExecuteNonQuery(); - myTrans.Commit(); - Console.WriteLine("Both records are written to database."); - } - catch(Exception e) - { - try - { - myTrans.Rollback(); - } - catch (SqlException ex) - { - if (myTrans.Connection != null) - { - Console.WriteLine("An exception of type " + ex.GetType() + - " was encountered while attempting to roll back the transaction."); - } - } - - Console.WriteLine("An exception of type " + e.GetType() + - " was encountered while inserting the data."); - Console.WriteLine("Neither record was written to database."); - } - finally - { - myConnection.Close(); - } - } - - - - - - Begins a database transaction with the specified isolation level. - The isolation level under which the transaction should run. - An object representing the new transaction. - Parallel exceptions are not supported. - - This command is equivalent to the MySQL BEGIN TRANSACTION command. - - You must explicitly commit or roll back the transaction using the or - method. - - If you do not specify an isolation level, the default isolation level is used. To specify an isolation - level with the method, use the overload that takes the iso parameter. - Also note that any attempt to begin a transaction while a transaction is in progress will throw an exception on MySQL 4.1 and higher. - On MySQL 4.0, an exception will not be thrown because servers 4.0 and earlier did not report their transacation status. - - - - - The following example creates a and a - . It also demonstrates how to use the BeginTransaction, a - , and methods. - - Public Sub RunTransaction(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - - Dim myCommand As MySqlCommand = myConnection.CreateCommand() - Dim myTrans As MySqlTransaction - - ' Start a local transaction - myTrans = myConnection.BeginTransaction() - ' Must assign both transaction object and connection - ' to Command object for a pending local transaction - myCommand.Connection = myConnection - myCommand.Transaction = myTrans - - Try - myCommand.CommandText = "Insert into Test (id, desc) VALUES (100, 'Description')" - myCommand.ExecuteNonQuery() - myCommand.CommandText = "Insert into Test (id, desc) VALUES (101, 'Description')" - myCommand.ExecuteNonQuery() - myTrans.Commit() - Console.WriteLine("Both records are written to database.") - Catch e As Exception - Try - myTrans.Rollback() - Catch ex As MySqlException - If Not myTrans.Connection Is Nothing Then - Console.WriteLine("An exception of type " + ex.GetType().ToString() + _ - " was encountered while attempting to roll back the transaction.") - End If - End Try - - Console.WriteLine("An exception of type " + e.GetType().ToString() + _ - "was encountered while inserting the data.") - Console.WriteLine("Neither record was written to database.") - Finally - myConnection.Close() - End Try - End Sub - - - public void RunTransaction(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - - MySqlCommand myCommand = myConnection.CreateCommand(); - MySqlTransaction myTrans; - - // Start a local transaction - myTrans = myConnection.BeginTransaction(); - // Must assign both transaction object and connection - // to Command object for a pending local transaction - myCommand.Connection = myConnection; - myCommand.Transaction = myTrans; - - try - { - myCommand.CommandText = "insert into Test (id, desc) VALUES (100, 'Description')"; - myCommand.ExecuteNonQuery(); - myCommand.CommandText = "insert into Test (id, desc) VALUES (101, 'Description')"; - myCommand.ExecuteNonQuery(); - myTrans.Commit(); - Console.WriteLine("Both records are written to database."); - } - catch(Exception e) - { - try - { - myTrans.Rollback(); - } - catch (SqlException ex) - { - if (myTrans.Connection != null) - { - Console.WriteLine("An exception of type " + ex.GetType() + - " was encountered while attempting to roll back the transaction."); - } - } - - Console.WriteLine("An exception of type " + e.GetType() + - " was encountered while inserting the data."); - Console.WriteLine("Neither record was written to database."); - } - finally - { - myConnection.Close(); - } - } - - - - - - Changes the current database for an open MySqlConnection. - The name of the database to use. - - - The value supplied in the database parameter must be a valid database - name. The database parameter cannot contain a null value, an empty - string, or a string with only blank characters. - - - - When you are using connection pooling against MySQL, and you close - the connection, it is returned to the connection pool. The next time the - connection is retrieved from the pool, the reset connection request - executes before the user performs any operations. - - - The database name is not valid. - The connection is not open. - Cannot change the database. - - The following example creates a and displays - some of its read-only properties. - - - Public Sub CreateMySqlConnection() - Dim myConnString As String = _ - "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass" - Dim myConnection As New MySqlConnection( myConnString ) - myConnection.Open() - MessageBox.Show( "Server Version: " + myConnection.ServerVersion _ - + ControlChars.NewLine + "Database: " + myConnection.Database ) - myConnection.ChangeDatabase( "test2" ) - MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion _ - + ControlChars.NewLine + "Database: " + myConnection.Database ) - myConnection.Close() - End Sub - - - - public void CreateMySqlConnection() - { - string myConnString = - "Persist Security Info=False;database=test;server=localhost;user id=joeuser;pwd=pass"; - MySqlConnection myConnection = new MySqlConnection( myConnString ); - myConnection.Open(); - MessageBox.Show( "Server Version: " + myConnection.ServerVersion - + "\nDatabase: " + myConnection.Database ); - myConnection.ChangeDatabase( "test2" ); - MessageBox.Show( "ServerVersion: " + myConnection.ServerVersion - + "\nDatabase: " + myConnection.Database ); - myConnection.Close(); - } - - - - - - Occurs when the state of the connection changes. - - - The StateChange event fires whenever the changes from - closed to opened, or from opened to closed. StateChange fires immediately - after the transitions. - - - - If an event handler throws an exception from within the StateChange - event, the exception propagates to the caller of the or - method. - - - - The StateChange event is not raised unless you explicitly call - Close or Dispose. - - - - Raised. - - - The event handler receives an argument of type - containing data related to this event. The following StateChangeEventArgs - properties provide information specific to this event. - - - - Property - Description - - - - - - - Gets the new state of the connection. The connection object will - be in the new state already when the event is fired. - - - - - - - Gets the original state of the connection. - - - - - - - - Occurs when MySQL returns warnings as a result of executing a command or query. - - - - - - - Represents an open connection to a MySQL Server database. This class cannot be inherited. - - - - A MySqlConnection object represents a session to a MySQL Server - data source. When you create an instance of MySqlConnection, all - properties are set to their initial values. For a list of these values, see the - MySqlConnection constructor. - - - - If the MySqlConnection goes out of scope, it is not closed. Therefore, - you must explicitly close the connection by calling - or . - - - - - The following example creates a and - a MySqlConnection. The MySqlConnection is opened and set as the - for the MySqlCommand. The example then calls - , and closes the connection. To accomplish this, the ExecuteNonQuery is - passed a connection string and a query string that is a SQL INSERT - statement. - - - Public Sub InsertRow(myConnectionString As String) - ' If the connection string is null, use a default. - If myConnectionString = "" Then - myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass" - End If - Dim myConnection As New MySqlConnection(myConnectionString) - Dim myInsertQuery As String = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)" - Dim myCommand As New MySqlCommand(myInsertQuery) - myCommand.Connection = myConnection - myConnection.Open() - myCommand.ExecuteNonQuery() - myCommand.Connection.Close() - End Sub - - - - - public void InsertRow(string myConnectionString) - { - // If the connection string is null, use a default. - if(myConnectionString == "") - { - myConnectionString = "Database=Test;Data Source=localhost;User Id=username;Password=pass"; - } - MySqlConnection myConnection = new MySqlConnection(myConnectionString); - string myInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"; - MySqlCommand myCommand = new MySqlCommand(myInsertQuery); - myCommand.Connection = myConnection; - myConnection.Open(); - myCommand.ExecuteNonQuery(); - myCommand.Connection.Close(); - } - - - - - - - - Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error. - - The value set is less than 0. - - A value of 0 indicates no limit, and should be avoided in a - because an attempt to connect - will wait indefinitely. - - - The following example creates a MySqlConnection - and sets some of its properties in the connection string. - - Public Sub CreateSqlConnection() - Dim myConnection As New MySqlConnection() - myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30" - myConnection.Open() - End Sub - - - public void CreateSqlConnection() - { - MySqlConnection myConnection = new MySqlConnection(); - myConnection.ConnectionString = "Persist Security Info=False;Username=user;Password=pass;database=test1;server=localhost;Connect Timeout=30"; - myConnection.Open(); - } - - - - - - - - Gets or sets the string used to connect to a MySQL Server database. - - - - The ConnectionString returned may not be exactly like what was originally - set but will be indentical in terms of keyword/value pairs. Security information - will not be included unless the Persist Security Info value is set to true. - - - You can use the ConnectionString property to connect to a database. - The following example illustrates a typical connection string. - - "Persist Security Info=False;database=MyDB;server=MySqlServer;user id=myUser;Password=myPass" - - The ConnectionString property can be set only when the connection is - closed. Many of the connection string values have corresponding read-only - properties. When the connection string is set, all of these properties are - updated, except when an error is detected. In this case, none of the properties - are updated. properties return only those settings contained in the - ConnectionString. - - - To connect to a local machine, specify "localhost" for the server. If you do not - specify a server, localhost is assumed. - - - Resetting the ConnectionString on a closed connection resets all - connection string values (and related properties) including the password. For - example, if you set a connection string that includes "Database= MyDb", and - then reset the connection string to "Data Source=myserver;User Id=myUser;Password=myPass", - the property is no longer set to MyDb. - - - The connection string is parsed immediately after being set. If errors in - syntax are found when parsing, a runtime exception, such as , - is generated. Other errors can be found only when an attempt is made to open the - connection. - - - The basic format of a connection string consists of a series of keyword/value - pairs separated by semicolons. The equal sign (=) connects each keyword and its - value. To include values that contain a semicolon, single-quote character, or - double-quote character, the value must be enclosed in double quotes. If the - value contains both a semicolon and a double-quote character, the value can be - enclosed in single quotes. The single quote is also useful if the value begins - with a double-quote character. Conversely, the double quote can be used if the - value begins with a single quote. If the value contains both single-quote and - double-quote characters, the quote character used to enclose the value must be - doubled each time it occurs within the value. - - - To include preceding or trailing spaces in the string value, the value must - be enclosed in either single quotes or double quotes. Any leading or trailing - spaces around integer, Boolean, or enumerated values are ignored, even if - enclosed in quotes. However, spaces within a string literal keyword or value are - preserved. Using .NET Framework version 1.1, single or double quotes may be used - within a connection string without using delimiters (for example, Data Source= - my'Server or Data Source= my"Server), unless a quote character is the first or - last character in the value. - - - To include an equal sign (=) in a keyword or value, it must be preceded by - another equal sign. For example, in the hypothetical connection string - - "key==word=value" - - the keyword is "key=word" and the value is "value". - - If a specific keyword in a keyword= value pair occurs multiple times in a - connection string, the last occurrence listed is used in the value set. - - Keywords are not case sensitive. - - The following table lists the valid names for keyword values within the - ConnectionString. - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameDefaultDescription
- Connect Timeout -or- Connection Timeout - 15 - The length of time (in seconds) to wait for a connection to the server before - terminating the attempt and generating an error. -
- Host -or- Server -or- Data Source -or- - DataSource -or- Address -or- Addr -or- - Network Address - localhost - - The name or network address of the instance of MySQL to which to connect. Multiple hosts can be - specified separated by &. This can be useful where multiple MySQL servers are configured for replication - and you are not concerned about the precise server you are connecting to. No attempt is made by the provider to - synchronize writes to the database so care should be taken when using this option. - - - In Unix environment with Mono, this can be a fully qualified path to MySQL socket filename. With this configuration, the Unix socket will be used instead of TCP/IP socket. - Currently only a single socket name can be given so accessing MySQL in a replicated environment using Unix sockets is not currently supported. - -
Port3306 - The port MySQL is using to listen for connections. This value is ignored if the connection protocol - is anything but socket. -
Protocolsocket - Specifies the type of connection to make to the server.Values can be: - socket or tcp for a socket connection
- pipe for a named pipe connection
- unix for a Unix socket connection
- memory to use MySQL shared memory -
- CharSet -or Character Set - - Specifies the character set that should be used to encode all queries sent to the server. - Resultsets are still returned in the character set of the data returned. -
LoggingfalseWhen true, various pieces of information is output to any configured TraceListeners.
Allow Batchtrue - When true, multiple SQL statements can be sent with one command execution.

- -Note-
- Starting with MySQL 4.1.1, batch statements should be separated by the server-defined seperator character.
- Commands sent to earlier versions of MySQL should be seperated with ';'. -
Encryptfalse - When true, SSL/TLS encryption is used for all data sent between the - client and server if the server has a certificate installed. Recognized values - are true, false, yes, and no. -
- Initial Catalog -or- Database - mysqlThe name of the database to use intially
- Password -or- pwd - The password for the MySQL account being used.
Persist Security Infofalse - When set to false or no (strongly recommended), security-sensitive - information, such as the password, is not returned as part of the connection if - the connection is open or has ever been in an open state. Resetting the - connection string resets all connection string values including the password. - Recognized values are true, false, yes, and no. -
- User Id -or- Username -or- Uid -or- User name - The MySQL login account being used.
Shared Memory NameMYSQLThe name of the shared memory object to use for communication if the connection protocol is set to memory.
Allow Zero Datetimefalse - True to have MySqlDataReader.GetValue() return a MySqlDateTime for date or datetime columns that have illegal values. - False will cause a DateTime object to be returned for legal values and an exception will be thrown for illegal values. -
Convert Zero Datetimefalse - True to have MySqlDataReader.GetValue() and MySqlDataReader.GetDateTime() - return DateTime.MinValue for date or datetime columns that have illegal values. -
- Pipe Name -or- Pipe - mysql - When set to the name of a named pipe, the MySqlConnection will attempt to connect to MySQL - on that named pipe.

This settings only applies to the Windows platform. -
- Use Performance Monitor -or- UsePerformanceMonitor - false - Posts performance data that can be tracked using perfmon -
- Procedure Cache Size - 25 - How many stored procedure definitions can be held in the cache -
- Ignore Prepare - true - Instructs the provider to ignore any attempts to prepare commands. This option - was added to allow a user to disable prepared statements in an entire application - without modifying the code. A user might want to do this if errors or bugs are - encountered with MySQL prepared statements. -
Use Procedure Bodiestrue - Instructs the provider to attempt to call the procedure without first resolving the metadata. This - is useful in situations where the calling user does not have access to the mysql.proc table. To - use this mode, the parameters for the procedure must be added to the command in the same order - as they appear in the procedure definition and their types must be explicitly set. -
Auto Enlisttrue - Indicates whether the connection should automatically enlist in the current transaction, - if there is one. -
Respect Binary Flagstrue - Indicates whether the connection should respect all binary flags sent to the client - as part of column metadata. False will cause the connector to behave like - Connector/Net 5.0 and earlier. -
BlobAsUTF8IncludePatternnull - Pattern that should be used to indicate which blob columns should be treated as UTF-8. -
BlobAsUTF8ExcludePatternnull - Pattern that should be used to indicate which blob columns should not be treated as UTF-8. -
Default Command Timeout30 - The default timeout that new MySqlCommand objects will use unless changed. -
Allow User Variablesfalse - Should the provider expect user variables in the SQL. -
Interactive -or- Interactive Sessionfalse - Should this session be considered interactive? -
Functions Return Stringfalse - Set this option to true to force the return value of SQL functions to be string. -
Use Affected Rowsfalse - 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. -
-
- - The following table lists the valid names for connection pooling values within - the ConnectionString. For more information about connection pooling, see - Connection Pooling for the MySql Data Provider. - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameDefaultDescription
Connection Lifetime0 - When a connection is returned to the pool, its creation time is compared with - the current time, and the connection is destroyed if that time span (in seconds) - exceeds the value specified by Connection Lifetime. This is useful in - clustered configurations to force load balancing between a running server and a - server just brought online. - - A value of zero (0) causes pooled connections to have the maximum connection - timeout. - -
Max Pool Size100The maximum number of connections allowed in the pool.
Min Pool Size0The minimum number of connections allowed in the pool.
Poolingtrue - When true, the MySqlConnection object is drawn from the appropriate - pool, or if necessary, is created and added to the appropriate pool. Recognized - values are true, false, yes, and no. -
Connection Resetfalse - Specifies whether the database connection should be reset when being - drawn from the pool. Leaving this as false will yeild much faster - connection opens but the user should understand the side effects - of doing this such as temporary tables and user variables from the previous - session not being cleared out. -
-
- - When setting keyword or connection pooling values that require a Boolean - value, you can use 'yes' instead of 'true', and 'no' instead of 'false'. - - - Note The MySql Data Provider uses the native socket protocol to - communicate with MySQL. Therefore, it does not support the use of an ODBC data source name (DSN) when - connecting to MySQL because it does not add an ODBC layer. - - - CAUTION In this release, the application should use caution when constructing a - connection string based on user input (for example when retrieving user ID and password information from a - dialog box, and appending it to the connection string). The application should - ensure that a user cannot embed extra connection string parameters in these - values (for example, entering a password as "validpassword;database=somedb" in - an attempt to attach to a different database). - -
- - The following example creates a and sets some of its properties - - Public Sub CreateConnection() - Dim myConnection As New MySqlConnection() - myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass" - myConnection.Open() - End Sub 'CreateConnection - - - public void CreateConnection() - { - MySqlConnection myConnection = new MySqlConnection(); - myConnection.ConnectionString = "Persist Security Info=False;database=myDB;server=myHost;Connect Timeout=30;user id=myUser; pwd=myPass"; - myConnection.Open(); - } - - - - The following example creates a in Unix environment with Mono installed. MySQL socket filename used in this example is "/var/lib/mysql/mysql.sock". The actual filename depends on your MySQL configuration. - - Public Sub CreateConnection() - Dim myConnection As New MySqlConnection() - myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass" - myConnection.Open() - End Sub 'CreateConnection - - - public void CreateConnection() - { - MySqlConnection myConnection = new MySqlConnection(); - myConnection.ConnectionString = "database=myDB;server=/var/lib/mysql/mysql.sock;user id=myUser; pwd=myPass"; - myConnection.Open(); - } - - -
- - Empties the connection pool associated with the specified connection. - - The associated with the pool to be cleared. - - - - ClearPool clears the connection pool that is associated with the connection. - If additional connections associated with connection are in use at the time of the call, - they are marked appropriately and are discarded (instead of being returned to the pool) - when Close is called on them. - - - - - - Clears all connection pools. - - - ClearAllPools essentially performs a on all current connection - pools. - - - - -
diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlConnectionStringBuilder.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlConnectionStringBuilder.xml deleted file mode 100644 index 3955bfa..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlConnectionStringBuilder.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - Gets or sets the name or address of the MySQL instance to connect to. - - - If this property is not set, then the provider will attempt to - connect to localhost even though this property will return - String.Empty. - - - - - - - - Gets or sets the name of the database that should be selected - when the connection is first opened. - - - There is no default for this property and, if not set, the - connection will not have a current database until one is set - using the method. - - - - - - - - Gets or sets the connection protocol that is being used for this - connection. - - - - - - - - - - - Gets or sets the name of the named pipe object that the provider - should use. - - - This property has no effect unless the - property has been set to NamedPipe. - - - - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlDataAdapter.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlDataAdapter.xml deleted file mode 100644 index f499ca6..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlDataAdapter.xml +++ /dev/null @@ -1,801 +0,0 @@ - - - - Represents a set of data commands and a database connection that are used to fill a dataset and update a MySQL database. This class cannot be inherited. - - - - The MySQLDataAdapter, serves as a bridge between a - and MySQL for retrieving and saving data. The MySQLDataAdapter provides this - bridge by mapping , which changes the data in the - DataSet to match the data in the data source, and , - which changes the data in the data source to match the data in the DataSet, - using the appropriate SQL statements against the data source. - - - When the MySQLDataAdapter fills a DataSet, it will create the necessary - tables and columns for the returned data if they do not already exist. However, primary - key information will not be included in the implicitly created schema unless the - property is set to . - You may also have the MySQLDataAdapter create the schema of the DataSet, - including primary key information, before filling it with data using . - - - MySQLDataAdapter is used in conjunction with - and to increase performance when connecting to a MySQL database. - - - The MySQLDataAdapter also includes the , - , , - , and - properties to facilitate the loading and updating of data. - - - When an instance of MySQLDataAdapter is created, the read/write properties - are set to initial values. For a list of these values, see the MySQLDataAdapter - constructor. - - - Please be aware that the class allows only - Int16, Int32, and Int64 to have the AutoIncrement property set. - If you plan to use autoincremement columns with MySQL, you should consider - using signed integer columns. - - - - - The following example creates a and a . - The MySqlConnection is opened and set as the for the - MySqlCommand. The example then calls , and closes - the connection. To accomplish this, the ExecuteNonQuery is - passed a connection string and a query string that is a SQL INSERT - statement. - - Public Function SelectRows(dataSet As DataSet, connection As String, query As String) As DataSet - Dim conn As New MySqlConnection(connection) - Dim adapter As New MySqlDataAdapter() - adapter.SelectCommand = new MySqlCommand(query, conn) - adapter.Fill(dataset) - Return dataset - End Function - - - public DataSet SelectRows(DataSet dataset,string connection,string query) - { - MySqlConnection conn = new MySqlConnection(connection); - MySqlDataAdapter adapter = new MySqlDataAdapter(); - adapter.SelectCommand = new MySqlCommand(query, conn); - adapter.Fill(dataset); - return dataset; - } - - - - - - - - Initializes a new instance of the MySqlDataAdapter class. - - - - When an instance of is created, - the following read/write properties are set to the following initial - values. - - - - Properties - Initial Value - - - - - - - MissingMappingAction.Passthrough - - - - - - - - MissingSchemaAction.Add - - - - - You can change the value of any of these properties through a separate call - to the property. - - - - The following example creates a and sets some of - its properties. - - Public Sub CreateSqlDataAdapter() - Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _ - "database=test") - Dim da As MySqlDataAdapter = New MySqlDataAdapter - da.MissingSchemaAction = MissingSchemaAction.AddWithKey - - da.SelectCommand = New MySqlCommand("SELECT id, name FROM mytable", conn) - da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ - "VALUES (@id, @name)", conn) - da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ - "WHERE id=@oldId", conn) - da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - End Sub - - - public static void CreateSqlDataAdapter() - { - MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test"); - MySqlDataAdapter da = new MySqlDataAdapter(); - da.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - da.SelectCommand = new MySqlCommand("SELECT id, name FROM mytable", conn); - da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + - "VALUES (@id, @name)", conn); - da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + - "WHERE id=@oldId", conn); - da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - } - - - - - - - Initializes a new instance of the class with - the specified as the - property. - - - that is a SQL SELECT statement or stored procedure and is set - as the property of the . - - - - When an instance of is created, - the following read/write properties are set to the following initial - values. - - - - Properties - Initial Value - - - - - - - MissingMappingAction.Passthrough - - - - - - - - MissingSchemaAction.Add - - - - - You can change the value of any of these properties through a separate call - to the property. - - - When SelectCommand (or any of the other command properties) is assigned - to a previously created , the MySqlCommand is not cloned. - The SelectCommand maintains a reference to the previously created MySqlCommand - object. - - - - The following example creates a and sets some of - its properties. - - Public Sub CreateSqlDataAdapter() - Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _ - "database=test") - Dim cmd as new MySqlCommand("SELECT id, name FROM mytable", conn) - Dim da As MySqlDataAdapter = New MySqlDataAdapter(cmd) - da.MissingSchemaAction = MissingSchemaAction.AddWithKey - - da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ - "VALUES (@id, @name)", conn) - da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ - "WHERE id=@oldId", conn) - da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - End Sub - - - public static void CreateSqlDataAdapter() - { - MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test"); - MySqlCommand cmd = new MySqlCommand("SELECT id, name FROM mytable", conn); - MySqlDataAdapter da = new MySqlDataAdapter(cmd); - da.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + - "VALUES (@id, @name)", conn); - da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + - "WHERE id=@oldId", conn); - da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - } - - - - - - - Initializes a new instance of the class with - a and a object. - - - A String that is a SQL SELECT statement or stored procedure to be used by - the property of the . - - - A that represents the connection. - - - - This implementation of the opens and closes a - if it is not already open. This can be useful in a an application that must call the - method for two or more MySqlDataAdapter objects. - If the MySqlConnection is already open, you must explicitly call - or to close it. - - - When an instance of is created, - the following read/write properties are set to the following initial - values. - - - - Properties - Initial Value - - - - - - - MissingMappingAction.Passthrough - - - - - - - - MissingSchemaAction.Add - - - - - You can change the value of any of these properties through a separate call - to the property. - - - - The following example creates a and sets some of - its properties. - - Public Sub CreateSqlDataAdapter() - Dim conn As MySqlConnection = New MySqlConnection("Data Source=localhost;" & _ - "database=test") - Dim da As MySqlDataAdapter = New MySqlDataAdapter("SELECT id, name FROM mytable", conn) - da.MissingSchemaAction = MissingSchemaAction.AddWithKey - - da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ - "VALUES (@id, @name)", conn) - da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ - "WHERE id=@oldId", conn) - da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - End Sub - - - public static void CreateSqlDataAdapter() - { - MySqlConnection conn = new MySqlConnection("Data Source=localhost;database=test"); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, name FROM mytable", conn); - da.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + - "VALUES (@id, @name)", conn); - da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + - "WHERE id=@oldId", conn); - da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - } - - - - - - - Initializes a new instance of the class with - a and a connection string. - - - A that is a SQL SELECT statement or stored procedure to - be used by the property of the . - - The connection string - - - When an instance of is created, - the following read/write properties are set to the following initial - values. - - - - Properties - Initial Value - - - - - - - MissingMappingAction.Passthrough - - - - - - - - MissingSchemaAction.Add - - - - - You can change the value of any of these properties through a separate call - to the property. - - - - The following example creates a and sets some of - its properties. - - Public Sub CreateSqlDataAdapter() - Dim da As MySqlDataAdapter = New MySqlDataAdapter("SELECT id, name FROM mytable", "Data Source=localhost;database=test") - Dim conn As MySqlConnection = da.SelectCommand.Connection - da.MissingSchemaAction = MissingSchemaAction.AddWithKey - - da.InsertCommand = New MySqlCommand("INSERT INTO mytable (id, name) " & _ - "VALUES (@id, @name)", conn) - da.UpdateCommand = New MySqlCommand("UPDATE mytable SET id=@id, name=@name " & _ - "WHERE id=@oldId", conn) - da.DeleteCommand = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name") - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original - End Sub - - - public static void CreateSqlDataAdapter() - { - MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, name FROM mytable", "Data Source=localhost;database=test"); - MySqlConnection conn = da.SelectCommand.Connection; - da.MissingSchemaAction = MissingSchemaAction.AddWithKey; - - da.InsertCommand = new MySqlCommand("INSERT INTO mytable (id, name) " + - "VALUES (@id, @name)", conn); - da.UpdateCommand = new MySqlCommand("UPDATE mytable SET id=@id, name=@name " + - "WHERE id=@oldId", conn); - da.DeleteCommand = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); - - da.InsertCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.InsertCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - - da.UpdateCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - da.UpdateCommand.Parameters.Add("@name", MySqlDbType.VarChar, 40, "name"); - da.UpdateCommand.Parameters.Add("@oldId", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - - da.DeleteCommand.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id").SourceVersion = DataRowVersion.Original; - } - - - - - - - Gets or sets a SQL statement or stored procedure used to delete records from the data set. - - - A used during to delete records in the - database that correspond to deleted rows in the . - - - - During , if this property is not set and primary key information - is present in the , the DeleteCommand can be generated - automatically if you set the property and use the - . Then, any additional commands that you do not set are - generated by the MySqlCommandBuilder. This generation logic requires key column - information to be present in the DataSet. - - - When DeleteCommand is assigned to a previously created , - the MySqlCommand is not cloned. The DeleteCommand maintains a reference - to the previously created MySqlCommand object. - - - - The following example creates a and sets the - and DeleteCommand properties. It assumes you have already - created a object. - - Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter - - Dim da As MySqlDataAdapter = New MySqlDataAdapter() - Dim cmd As MySqlCommand - Dim parm As MySqlParameter - - ' Create the SelectCommand. - cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) - - da.SelectCommand = cmd - - ' Create the DeleteCommand. - cmd = New MySqlCommand("DELETE FROM mytable WHERE id=@id", conn) - - parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id") - parm.SourceVersion = DataRowVersion.Original - - da.DeleteCommand = cmd - - Return da - End Function - - - public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) - { - MySqlDataAdapter da = new MySqlDataAdapter(); - MySqlCommand cmd; - MySqlParameter parm; - - // Create the SelectCommand. - cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); - - da.SelectCommand = cmd; - - // Create the DeleteCommand. - cmd = new MySqlCommand("DELETE FROM mytable WHERE id=@id", conn); - - parm = cmd.Parameters.Add("@id", MySqlDbType.VarChar, 5, "id"); - parm.SourceVersion = DataRowVersion.Original; - - da.DeleteCommand = cmd; - - return da; - } - - - - - - - Gets or sets a SQL statement or stored procedure used to insert records into the data set. - - - A used during to insert records into the - database that correspond to new rows in the . - - - - During , if this property is not set and primary key information - is present in the , the InsertCommand can be generated - automatically if you set the property and use the - . Then, any additional commands that you do not set are - generated by the MySqlCommandBuilder. This generation logic requires key column - information to be present in the DataSet. - - - When InsertCommand is assigned to a previously created , - the MySqlCommand is not cloned. The InsertCommand maintains a reference - to the previously created MySqlCommand object. - - - If execution of this command returns rows, these rows may be added to the DataSet - depending on how you set the property of the MySqlCommand object. - - - - The following example creates a and sets the - and InsertCommand properties. It assumes you have already - created a object. - - Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter - - Dim da As MySqlDataAdapter = New MySqlDataAdapter() - Dim cmd As MySqlCommand - Dim parm As MySqlParameter - - ' Create the SelectCommand. - cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) - - da.SelectCommand = cmd - - ' Create the InsertCommand. - cmd = New MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id, @name)", conn) - - cmd.Parameters.Add( "@id", MySqlDbType.VarChar, 15, "id" ) - cmd.Parameters.Add( "@name", MySqlDbType.VarChar, 15, "name" ) - da.InsertCommand = cmd - - Return da - End Function - - - public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) - { - MySqlDataAdapter da = new MySqlDataAdapter(); - MySqlCommand cmd; - MySqlParameter parm; - - // Create the SelectCommand. - cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); - - da.SelectCommand = cmd; - - // Create the InsertCommand. - cmd = new MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id,@name)", conn); - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15, "id" ); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15, "name" ); - - da.InsertCommand = cmd; - - return da; - } - - - - - - - Gets or sets a SQL statement or stored procedure used to updated records in the data source. - - - A used during to update records in the - database with data from the . - - - - During , if this property is not set and primary key information - is present in the , the UpdateCommand can be generated - automatically if you set the property and use the - . Then, any additional commands that you do not set are - generated by the MySqlCommandBuilder. This generation logic requires key column - information to be present in the DataSet. - - - When UpdateCommand is assigned to a previously created , - the MySqlCommand is not cloned. The UpdateCommand maintains a reference - to the previously created MySqlCommand object. - - - If execution of this command returns rows, these rows may be merged with the DataSet - depending on how you set the property of the MySqlCommand object. - - - - The following example creates a and sets the - and UpdateCommand properties. It assumes you have already - created a object. - - Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter - - Dim da As MySqlDataAdapter = New MySqlDataAdapter() - Dim cmd As MySqlCommand - Dim parm As MySqlParameter - - ' Create the SelectCommand. - cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) - - da.SelectCommand = cmd - - ' Create the UpdateCommand. - cmd = New MySqlCommand("UPDATE mytable SET id=@id, name=@name WHERE id=@oldId", conn) - - cmd.Parameters.Add( "@id", MySqlDbType.VarChar, 15, "id" ) - cmd.Parameters.Add( "@name", MySqlDbType.VarChar, 15, "name" ) - - parm = cmd.Parameters.Add("@oldId", MySqlDbType.VarChar, 15, "id") - parm.SourceVersion = DataRowVersion.Original - - da.UpdateCommand = cmd - - Return da - End Function - - - public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) - { - MySqlDataAdapter da = new MySqlDataAdapter(); - MySqlCommand cmd; - MySqlParameter parm; - - // Create the SelectCommand. - cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); - - da.SelectCommand = cmd; - - // Create the UpdateCommand. - cmd = new MySqlCommand("UPDATE mytable SET id=@id, name=@name WHERE id=@oldId", conn); - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15, "id" ); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15, "name" ); - - parm = cmd.Parameters.Add( "@oldId", MySqlDbType.VarChar, 15, "id" ); - parm.SourceVersion = DataRowVersion.Original; - - da.UpdateCommand = cmd; - - return da; - } - - - - - - - Gets or sets a SQL statement or stored procedure used to select records in the data source. - - - A used during to select records from the - database for placement in the . - - - - When SelectCommand is assigned to a previously created , - the MySqlCommand is not cloned. The SelectCommand maintains a reference to the - previously created MySqlCommand object. - - - If the SelectCommand does not return any rows, no tables are added to the - , and no exception is raised. - - - - The following example creates a and sets the - and InsertCommand properties. It assumes you have already - created a object. - - Public Shared Function CreateCustomerAdapter(conn As MySqlConnection) As MySqlDataAdapter - - Dim da As MySqlDataAdapter = New MySqlDataAdapter() - Dim cmd As MySqlCommand - Dim parm As MySqlParameter - - ' Create the SelectCommand. - cmd = New MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn) - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15) - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15) - - da.SelectCommand = cmd - - ' Create the InsertCommand. - cmd = New MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id, @name)", conn) - - cmd.Parameters.Add( "@id", MySqlDbType.VarChar, 15, "id" ) - cmd.Parameters.Add( "@name", MySqlDbType.VarChar, 15, "name" ) - da.InsertCommand = cmd - - Return da - End Function - - - public static MySqlDataAdapter CreateCustomerAdapter(MySqlConnection conn) - { - MySqlDataAdapter da = new MySqlDataAdapter(); - MySqlCommand cmd; - MySqlParameter parm; - - // Create the SelectCommand. - cmd = new MySqlCommand("SELECT * FROM mytable WHERE id=@id AND name=@name", conn); - - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15); - - da.SelectCommand = cmd; - - // Create the InsertCommand. - cmd = new MySqlCommand("INSERT INTO mytable (id,name) VALUES (@id,@name)", conn); - cmd.Parameters.Add("@id", MySqlDbType.VarChar, 15, "id" ); - cmd.Parameters.Add("@name", MySqlDbType.VarChar, 15, "name" ); - - da.InsertCommand = cmd; - - return da; - } - - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlDataReader.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlDataReader.xml deleted file mode 100644 index c0f861f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlDataReader.xml +++ /dev/null @@ -1,452 +0,0 @@ - - - - Provides a means of reading a forward-only stream of rows from a MySQL database. This class cannot be inherited. - - - - To create a MySQLDataReader, you must call the - method of the object, rather than directly using a constructor. - - - While the MySqlDataReader is in use, the associated - is busy serving the MySqlDataReader, and no other operations can be performed - on the MySqlConnection other than closing it. This is the case until the - method of the MySqlDataReader is called. - - - and - are the only properties that you can call after the MySqlDataReader is - closed. Though the RecordsAffected property may be accessed at any time - while the MySqlDataReader exists, always call Close before returning - the value of RecordsAffected to ensure an accurate return value. - - - For optimal performance, MySqlDataReader avoids creating - unnecessary objects or making unnecessary copies of data. As a result, multiple calls - to methods such as return a reference to the - same object. Use caution if you are modifying the underlying value of the objects - returned by methods such as GetValue. - - - - - The following example creates a , - a , and a MySqlDataReader. The example reads through - the data, writing it out to the console. Finally, the example closes the MySqlDataReader, then the - MySqlConnection. - - Public Sub ReadMyData(myConnString As String) - Dim mySelectQuery As String = "SELECT OrderID, CustomerID FROM Orders" - Dim myConnection As New MySqlConnection(myConnString) - Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) - myConnection.Open() - Dim myReader As MySqlDataReader - myReader = myCommand.ExecuteReader() - ' Always call Read before accessing data. - While myReader.Read() - Console.WriteLine((myReader.GetInt32(0) & ", " & myReader.GetString(1))) - End While - ' always call Close when done reading. - myReader.Close() - ' Close the connection when done with it. - myConnection.Close() - End Sub 'ReadMyData - - - public void ReadMyData(string myConnString) { - string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders"; - MySqlConnection myConnection = new MySqlConnection(myConnString); - MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection); - myConnection.Open(); - MySqlDataReader myReader; - myReader = myCommand.ExecuteReader(); - // Always call Read before accessing data. - while (myReader.Read()) { - Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1)); - } - // always call Close when done reading. - myReader.Close(); - // Close the connection when done with it. - myConnection.Close(); - } - - - - - - - - GetBytes returns the number of available bytes in the field. In most - cases this is the exact length of the field. However, the number returned may be - less than the true length of the field if GetBytes has already been used - to obtain bytes from the field. This may be the case, for example, if the - is reading a large data structure into a buffer. - For more information, see the SequentialAccess setting for - . - - - If you pass a buffer that is a null reference (Nothing in Visual - Basic), GetBytes returns the length of the field in bytes. - - - No conversions are performed; therefore the data retrieved must already be a - byte array. - - - - - - - - Gets the value of the specified column as a object. - - - - No conversions are performed; therefore, the data retrieved must already be a Time value. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal or column name. - The value of the specified column. - - - - - Gets the value of the specified column as a object. - - - - No conversions are performed; therefore, the data retrieved must already be a DateTime object. - - - Call IsDBNull to check for null values before calling this method. - - - - MySql allows date columns to contain the value '0000-00-00' and datetime - columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain - or represent these values. To read a datetime value from a column that might - contain zero values, use . - - - The behavior of reading a zero datetime column using this method is defined by the - ZeroDateTimeBehavior connection string option. For more information on this option, - please refer to . - - - - The zero-based column ordinal. - The value of the specified column. - - - - - Gets the value of the specified column as a object. - - - - No conversions are performed; therefore, the data retrieved must already be a DateTime object. - - - Call IsDBNull to check for null values before calling this method. - - - - MySql allows date columns to contain the value '0000-00-00' and datetime - columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain - or represent these values. To read a datetime value from a column that might - contain zero values, use . - - - The behavior of reading a zero datetime column using this method is defined by the - ZeroDateTimeBehavior connection string option. For more information on this option, - please refer to . - - - - The column name. - The value of the specified column. - - - - - Gets the value of the specified column as a object. - - - - No conversions are performed; therefore, the data retrieved must already be a DateTime object. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal or column name. - The value of the specified column. - - - - - Gets the value of the specified column as a object. - - - - No conversions are performed; therefore, the data retrieved must already be a String object. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal. - The value of the specified column. - - - - - Gets the value of the specified column as a object. - - - - No conversions are performed; therefore, the data retrieved must already be a String object. - - - Call IsDBNull to check for null values before calling this method. - - - The column name. - The value of the specified column. - - - - - Gets the value of the specified column as a object. - - - - No conversions are performed; therefore, the data retrieved must already be a Decimal object. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal - The value of the specified column. - - - - - Gets the value of the specified column as a object. - - - - No conversions are performed; therefore, the data retrieved must already be a Decimal object. - - - Call IsDBNull to check for null values before calling this method. - - - The column name - The value of the specified column. - - - - Gets the value of the specified column as a double-precision floating point number. - - - No conversions are performed; therefore, the data retrieved must already be a Double object. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal. - The value of the specified column. - - - - Gets the value of the specified column as a double-precision floating point number. - - - No conversions are performed; therefore, the data retrieved must already be a Double object. - - - Call IsDBNull to check for null values before calling this method. - - - The column name - The value of the specified column. - - - - - Gets the value of the specified column as a single-precision floating point number. - - - - No conversions are performed; therefore, the data retrieved must already be a Float object. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal. - The value of the specified column. - - - - - Gets the value of the specified column as a single-precision floating point number. - - - - No conversions are performed; therefore, the data retrieved must already be a Float object. - - - Call IsDBNull to check for null values before calling this method. - - - The column name - The value of the specified column. - - - - Gets the value of the specified column as a globally-unique identifier (GUID). - The zero-based column ordinal. - The value of the specified column. - - - - Gets the value of the specified column as a globally-unique identifier (GUID). - The column name - The value of the specified column. - - - - Gets the value of the specified column as a 16-bit signed integer. - - - No conversions are performed; therefore, the data retrieved must already be a 16 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal. - The value of the specified column. - - - - Gets the value of the specified column as a 16-bit signed integer. - - - No conversions are performed; threfore, the data retrieved must already be a 16 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - - The column name - The value of the specified column. - - - - Gets the value of the specified column as a 32-bit signed integer. - - - No conversions are performed; therefore, the data retrieved must already be a 32 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal. - The value of the specified column. - - - - Gets the value of the specified column as a 32-bit signed integer. - - - No conversions are performed; therefore, the data retrieved must already be a 32 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - - The column name. - The value of the specified column. - - - - Gets the value of the specified column as a 64-bit signed integer. - - - No conversions are performed; therefore, the data retrieved must already be a 64 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal. - The value of the specified column. - - - - Gets the value of the specified column as a 64-bit signed integer. - - - No conversions are performed; therefore, the data retrieved must already be a 64 bit integer value. - - - Call IsDBNull to check for null values before calling this method. - - - The column name. - The value of the specified column. - - - - Gets the value of the specified column as a 16-bit unsigned integer. - - - No conversions are performed; therefore, the data retrieved must already be a 16 bit unsigned integer value. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal or column name. - The value of the specified column. - - - - Gets the value of the specified column as a 32-bit unsigned integer. - - - No conversions are performed; therefore, the data retrieved must already be a 32 bit unsigned integer value. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal or column name. - The value of the specified column. - - - - Gets the value of the specified column as a 64-bit unsigned integer. - - - No conversions are performed; therefore, the data retrieved must already be a 64 bit unsigned integer value. - - - Call IsDBNull to check for null values before calling this method. - - - The zero-based column ordinal or column name. - The value of the specified column. - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlException.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlException.xml deleted file mode 100644 index 4830805..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlException.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - This class is created whenever the MySql Data Provider encounters an error generated from the server. - - - Any open connections are not automatically closed when an exception is thrown. If - the client application determines that the exception is fatal, it should close any open - objects or objects. - - - - - The following example generates a MySqlException due to a missing server, - and then displays the exception. - - - Public Sub ShowException() - Dim mySelectQuery As String = "SELECT column1 FROM table1" - Dim myConnection As New MySqlConnection ("Data Source=localhost;Database=Sample;") - Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) - - Try - myCommand.Connection.Open() - Catch e As MySqlException - MessageBox.Show( e.Message ) - End Try - End Sub - - - public void ShowException() - { - string mySelectQuery = "SELECT column1 FROM table1"; - MySqlConnection myConnection = - new MySqlConnection("Data Source=localhost;Database=Sample;"); - MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection); - - try - { - myCommand.Connection.Open(); - } - catch (MySqlException e) - { - MessageBox.Show( e.Message ); - } - } - - - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlHelper.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlHelper.xml deleted file mode 100644 index 4830805..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlHelper.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - This class is created whenever the MySql Data Provider encounters an error generated from the server. - - - Any open connections are not automatically closed when an exception is thrown. If - the client application determines that the exception is fatal, it should close any open - objects or objects. - - - - - The following example generates a MySqlException due to a missing server, - and then displays the exception. - - - Public Sub ShowException() - Dim mySelectQuery As String = "SELECT column1 FROM table1" - Dim myConnection As New MySqlConnection ("Data Source=localhost;Database=Sample;") - Dim myCommand As New MySqlCommand(mySelectQuery, myConnection) - - Try - myCommand.Connection.Open() - Catch e As MySqlException - MessageBox.Show( e.Message ) - End Try - End Sub - - - public void ShowException() - { - string mySelectQuery = "SELECT column1 FROM table1"; - MySqlConnection myConnection = - new MySqlConnection("Data Source=localhost;Database=Sample;"); - MySqlCommand myCommand = new MySqlCommand(mySelectQuery,myConnection); - - try - { - myCommand.Connection.Open(); - } - catch (MySqlException e) - { - MessageBox.Show( e.Message ); - } - } - - - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlParameter.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlParameter.xml deleted file mode 100644 index c3cc263..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlParameter.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - Parameter names are not case sensitive. - - - - The following example creates multiple instances of MySqlParameter through the - collection within the . - These parameters are used to select data from the data source and place the data - in the . This example assumes that a DataSet and a - MySqlDataAdapter have already been created with the appropriate schema, commands, - and connection. - - Public Sub AddSqlParameters() - ' ... - ' create myDataSet and myDataAdapter - ' ... - myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters" - myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239 - - myDataAdapter.Fill(myDataSet) - End Sub 'AddSqlParameters - - - public void AddSqlParameters() - { - // ... - // create myDataSet and myDataAdapter - // ... - - myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters"; - myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239; - myDataAdapter.Fill(myDataSet); - - } - - - - - - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlParameterCollection.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlParameterCollection.xml deleted file mode 100644 index 19c0ca5..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlParameterCollection.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - The number of the parameters in the collection must be equal to the number of - parameter placeholders within the command text, or an exception will be generated. - - - - The following example creates multiple instances of - through the MySqlParameterCollection collection within the . - These parameters are used to select data within the data source and place the data in - the . This code assumes that a DataSet and a MySqlDataAdapter - have already been created with the appropriate schema, commands, and connection. - - Public Sub AddParameters() - ' ... - ' create myDataSet and myDataAdapter - ' ... - myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters" - myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239 - - myDataAdapter.Fill(myDataSet) - End Sub 'AddSqlParameters - - - public void AddSqlParameters() - { - // ... - // create myDataSet and myDataAdapter - // ... - - myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters"; - myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239; - myDataAdapter.Fill(myDataSet); - - } - - - - - - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlTransaction.xml b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlTransaction.xml deleted file mode 100644 index a8544ed..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/docs/MySqlTransaction.xml +++ /dev/null @@ -1,329 +0,0 @@ - - - - Represents a SQL transaction to be made in a MySQL database. This class cannot be inherited. - - - - The application creates a MySqlTransaction object by calling - on the object. All subsequent operations associated with the - transaction (for example, committing or aborting the transaction), are performed on the - MySqlTransaction object. - - - - The following example creates a and a MySqlTransaction. - It also demonstrates how to use the , - , and methods. - - Public Sub RunTransaction(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - - Dim myCommand As MySqlCommand = myConnection.CreateCommand() - Dim myTrans As MySqlTransaction - - ' Start a local transaction - myTrans = myConnection.BeginTransaction() - ' Must assign both transaction object and connection - ' to Command object for a pending local transaction - myCommand.Connection = myConnection - myCommand.Transaction = myTrans - - Try - myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')" - myCommand.ExecuteNonQuery() - myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')" - myCommand.ExecuteNonQuery() - myTrans.Commit() - Console.WriteLine("Both records are written to database.") - Catch e As Exception - Try - myTrans.Rollback() - Catch ex As MySqlException - If Not myTrans.Connection Is Nothing Then - Console.WriteLine("An exception of type " & ex.GetType().ToString() & _ - " was encountered while attempting to roll back the transaction.") - End If - End Try - - Console.WriteLine("An exception of type " & e.GetType().ToString() & _ - "was encountered while inserting the data.") - Console.WriteLine("Neither record was written to database.") - Finally - myConnection.Close() - End Try - End Sub 'RunTransaction - - - public void RunTransaction(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - - MySqlCommand myCommand = myConnection.CreateCommand(); - MySqlTransaction myTrans; - - // Start a local transaction - myTrans = myConnection.BeginTransaction(); - // Must assign both transaction object and connection - // to Command object for a pending local transaction - myCommand.Connection = myConnection; - myCommand.Transaction = myTrans; - - try - { - myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')"; - myCommand.ExecuteNonQuery(); - myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')"; - myCommand.ExecuteNonQuery(); - myTrans.Commit(); - Console.WriteLine("Both records are written to database."); - } - catch(Exception e) - { - try - { - myTrans.Rollback(); - } - catch (MySqlException ex) - { - if (myTrans.Connection != null) - { - Console.WriteLine("An exception of type " + ex.GetType() + - " was encountered while attempting to roll back the transaction."); - } - } - - Console.WriteLine("An exception of type " + e.GetType() + - " was encountered while inserting the data."); - Console.WriteLine("Neither record was written to database."); - } - finally - { - myConnection.Close(); - } - } - - - - - - - - - Rolls back a transaction from a pending state. - - - The Rollback method is equivalent to the MySQL statement ROLLBACK. - The transaction can only be rolled back from a pending state - (after BeginTransaction has been called, but before Commit is - called). - - - The following example creates a and a - . It also demonstrates how to use the - , , and Rollback - methods. - - Public Sub RunSqlTransaction(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - - Dim myCommand As MySqlCommand = myConnection.CreateCommand() - Dim myTrans As MySqlTransaction - - ' Start a local transaction - myTrans = myConnection.BeginTransaction() - - ' Must assign both transaction object and connection - ' to Command object for a pending local transaction - myCommand.Connection = myConnection - myCommand.Transaction = myTrans - - Try - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')" - myCommand.ExecuteNonQuery() - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')" - myCommand.ExecuteNonQuery() - myTrans.Commit() - Console.WriteLine("Success.") - Catch e As Exception - Try - myTrans.Rollback() - Catch ex As MySqlException - If Not myTrans.Connection Is Nothing Then - Console.WriteLine("An exception of type " & ex.GetType().ToString() & _ - " was encountered while attempting to roll back the transaction.") - End If - End Try - - Console.WriteLine("An exception of type " & e.GetType().ToString() & _ - "was encountered while inserting the data.") - Console.WriteLine("Neither record was written to database.") - Finally - myConnection.Close() - End Try - End Sub - - - public void RunSqlTransaction(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - - MySqlCommand myCommand = myConnection.CreateCommand(); - MySqlTransaction myTrans; - - // Start a local transaction - myTrans = myConnection.BeginTransaction(); - // Must assign both transaction object and connection - // to Command object for a pending local transaction - myCommand.Connection = myConnection; - myCommand.Transaction = myTrans; - - try - { - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')"; - myCommand.ExecuteNonQuery(); - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')"; - myCommand.ExecuteNonQuery(); - myTrans.Commit(); - Console.WriteLine("Both records are written to database."); - } - catch(Exception e) - { - try - { - myTrans.Rollback(); - } - catch (MySqlException ex) - { - if (myTrans.Connection != null) - { - Console.WriteLine("An exception of type " + ex.GetType() + - " was encountered while attempting to roll back the transaction."); - } - } - - Console.WriteLine("An exception of type " + e.GetType() + - " was encountered while inserting the data."); - Console.WriteLine("Neither record was written to database."); - } - finally - { - myConnection.Close(); - } - } - - - - - - - Commits the database transaction. - - - The Commit method is equivalent to the MySQL SQL statement - COMMIT. - - - The following example creates a and a - . It also demonstrates how to use the - , , and Rollback - methods. - - Public Sub RunSqlTransaction(myConnString As String) - Dim myConnection As New MySqlConnection(myConnString) - myConnection.Open() - - Dim myCommand As MySqlCommand = myConnection.CreateCommand() - Dim myTrans As MySqlTransaction - - ' Start a local transaction - myTrans = myConnection.BeginTransaction() - - ' Must assign both transaction object and connection - ' to Command object for a pending local transaction - myCommand.Connection = myConnection - myCommand.Transaction = myTrans - - Try - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')" - myCommand.ExecuteNonQuery() - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')" - myCommand.ExecuteNonQuery() - myTrans.Commit() - Console.WriteLine("Success.") - Catch e As Exception - Try - myTrans.Rollback() - Catch ex As MySqlException - If Not myTrans.Connection Is Nothing Then - Console.WriteLine("An exception of type " & ex.GetType().ToString() & _ - " was encountered while attempting to roll back the transaction.") - End If - End Try - - Console.WriteLine("An exception of type " & e.GetType().ToString() & _ - "was encountered while inserting the data.") - Console.WriteLine("Neither record was written to database.") - Finally - myConnection.Close() - End Try - End Sub - - - public void RunSqlTransaction(string myConnString) - { - MySqlConnection myConnection = new MySqlConnection(myConnString); - myConnection.Open(); - - MySqlCommand myCommand = myConnection.CreateCommand(); - MySqlTransaction myTrans; - - // Start a local transaction - myTrans = myConnection.BeginTransaction(); - // Must assign both transaction object and connection - // to Command object for a pending local transaction - myCommand.Connection = myConnection; - myCommand.Transaction = myTrans; - - try - { - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (100, 'Description')"; - myCommand.ExecuteNonQuery(); - myCommand.CommandText = "Insert into mytable (id, desc) VALUES (101, 'Description')"; - myCommand.ExecuteNonQuery(); - myTrans.Commit(); - Console.WriteLine("Both records are written to database."); - } - catch(Exception e) - { - try - { - myTrans.Rollback(); - } - catch (MySqlException ex) - { - if (myTrans.Connection != null) - { - Console.WriteLine("An exception of type " + ex.GetType() + - " was encountered while attempting to roll back the transaction."); - } - } - - Console.WriteLine("An exception of type " + e.GetType() + - " was encountered while inserting the data."); - Console.WriteLine("Neither record was written to database."); - } - finally - { - myConnection.Close(); - } - } - - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/parameter.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/parameter.cs deleted file mode 100644 index 774913f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/parameter.cs +++ /dev/null @@ -1,714 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Data.Common; -using MySql.Data.Types; -using System.ComponentModel; -using System.Globalization; -using System.Reflection; -using System.Text; -using System.Collections; -#if !CF -using System.ComponentModel.Design.Serialization; -#endif - -namespace MySql.Data.MySqlClient -{ - /// - /// Represents a parameter to a , and optionally, its mapping to columns. This class cannot be inherited. - /// -#if !CF - [TypeConverter(typeof(MySqlParameterConverter))] -#endif - public sealed class MySqlParameter : DbParameter, IDataParameter, IDbDataParameter, ICloneable - { - private const int UNSIGNED_MASK = 0x8000; - private object paramValue; - private ParameterDirection direction = ParameterDirection.Input; - private bool isNullable; - private string paramName; - private string sourceColumn; - private DataRowVersion sourceVersion = DataRowVersion.Current; - private int size; - private byte precision; - private byte scale; - private MySqlDbType mySqlDbType; - private DbType dbType; - private bool inferType; - private bool sourceColumnNullMapping; - private MySqlParameterCollection collection; - IMySqlValue valueObject; - private Encoding encoding; - private IList possibleValues; - - #region Constructors - - /// - /// Initializes a new instance of the MySqlParameter class. - /// - public MySqlParameter() - { - inferType = true; - } - - /// - /// Initializes a new instance of the class with the parameter name and a value of the new MySqlParameter. - /// - /// The name of the parameter to map. - /// An that is the value of the . - public MySqlParameter(string parameterName, object value) - : this() - { - ParameterName = parameterName; - Value = value; - } - - /// - /// Initializes a new instance of the class with the parameter name and the data type. - /// - /// The name of the parameter to map. - /// One of the values. - public MySqlParameter(string parameterName, MySqlDbType dbType) - : this(parameterName, null) - { - MySqlDbType = dbType; - } - - /// - /// Initializes a new instance of the class with the parameter name, the , and the size. - /// - /// The name of the parameter to map. - /// One of the values. - /// The length of the parameter. - public MySqlParameter(string parameterName, MySqlDbType dbType, int size) - : this(parameterName, dbType) - { - this.size = size; - } - - /// - /// Initializes a new instance of the class with the parameter name, the , the size, and the source column name. - /// - /// The name of the parameter to map. - /// One of the values. - /// The length of the parameter. - /// The name of the source column. - public MySqlParameter(string parameterName, MySqlDbType dbType, int size, string sourceColumn) - : - this(parameterName, dbType) - { - this.size = size; - direction = ParameterDirection.Input; - this.sourceColumn = sourceColumn; - sourceVersion = DataRowVersion.Current; - } - - internal MySqlParameter(string name, MySqlDbType type, ParameterDirection dir, string col, - DataRowVersion ver, object val) - : this(name, type) - { - direction = dir; - sourceColumn = col; - sourceVersion = ver; - Value = val; - } - - /// - /// Initializes a new instance of the class with the parameter name, the type of the parameter, the size of the parameter, a , the precision of the parameter, the scale of the parameter, the source column, a to use, and the value of the parameter. - /// - /// The name of the parameter to map. - /// One of the values. - /// The length of the parameter. - /// One of the values. - /// true if the value of the field can be null, otherwise false. - /// The total number of digits to the left and right of the decimal point to which is resolved. - /// The total number of decimal places to which is resolved. - /// The name of the source column. - /// One of the values. - /// An that is the value of the . - /// - public MySqlParameter(string parameterName, MySqlDbType dbType, int size, ParameterDirection direction, - bool isNullable, byte precision, byte scale, string sourceColumn, - DataRowVersion sourceVersion, - object value) - : this(parameterName, dbType, size, sourceColumn) - { - this.direction = direction; - this.sourceVersion = sourceVersion; - Value = value; - } - - #endregion - - #region Properties - - internal MySqlParameterCollection Collection - { - get { return collection; } - set { collection = value; } - } - - internal bool TypeHasBeenSet - { - get { return inferType == false; } - } - - internal Encoding Encoding - { - get { return encoding; } - set { encoding = value; } - } - - /// - /// Gets or sets the of the parameter. - /// - public override DbType DbType - { - get { return dbType; } - set - { - SetDbType(value); - inferType = false; - } - } - - /// - /// Gets or sets a value indicating whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter. - /// As of MySql version 4.1 and earlier, input-only is the only valid choice. - /// -#if !CF - [Category("Data")] -#endif - public override ParameterDirection Direction - { - get { return direction; } - set { direction = value; } - } - - /// - /// Gets or sets a value indicating whether the parameter accepts null values. - /// -#if !CF - [Browsable(false)] -#endif - public override Boolean IsNullable - { - get { return isNullable; } - set { isNullable = value; } - } - - /// - /// Gets or sets the MySqlDbType of the parameter. - /// -#if !CF - [Category("Data")] - [DbProviderSpecificTypeProperty(true)] -#endif - public MySqlDbType MySqlDbType - { - get { return mySqlDbType; } - set - { - SetMySqlDbType(value); - inferType = false; - } - } - - /// - /// Gets or sets the name of the MySqlParameter. - /// -#if !CF - [Category("Misc")] -#endif - public override String ParameterName - { - get { return paramName; } - set - { - if (collection != null) - collection.ParameterNameChanged(this, paramName, value); - paramName = value; - } - } - - /// - /// Gets or sets the maximum number of digits used to represent the property. - /// -#if !CF - [Category("Data")] -#endif - public byte Precision - { - get { return precision; } - set { precision = value; } - } - - /// - /// Gets or sets the number of decimal places to which is resolved. - /// -#if !CF - [Category("Data")] -#endif - public byte Scale - { - get { return scale; } - set { scale = value; } - } - - /// - /// Gets or sets the maximum size, in bytes, of the data within the column. - /// -#if !CF - [Category("Data")] -#endif - public override int Size - { - get { return size; } - set { size = value; } - } - - /// - /// Gets or sets the name of the source column that is mapped to the and used for loading or returning the . - /// -#if !CF - [Category("Data")] -#endif - public override String SourceColumn - { - get { return sourceColumn; } - set { sourceColumn = value; } - } - - /// - /// Gets or sets the to use when loading . - /// -#if !CF - [Category("Data")] -#endif - public override DataRowVersion SourceVersion - { - get { return sourceVersion; } - set { sourceVersion = value; } - } - - /// - /// Gets or sets the value of the parameter. - /// -#if !CF - [TypeConverter(typeof (StringConverter))] - [Category("Data")] -#endif - public override object Value - { - get { return paramValue; } - set - { - paramValue = value; - byte[] valueAsByte = value as byte[]; - string valueAsString = value as string; - - if (valueAsByte != null) - size = valueAsByte.Length; - else if (valueAsString != null) - size = valueAsString.Length; - if (inferType) - SetTypeFromValue(); - } - } - - private IMySqlValue ValueObject - { - get { return valueObject; } - } - - /// - /// Returns the possible values for this parameter if this parameter is of type - /// SET or ENUM. Returns null otherwise. - /// - public IList PossibleValues - { - get { return possibleValues; } - internal set { possibleValues = value; } - } - - #endregion - - /// - /// Overridden. Gets a string containing the . - /// - /// - public override string ToString() - { - return paramName; - } - - internal int GetPSType() - { - switch (mySqlDbType) - { - case MySqlDbType.Bit: - return (int) MySqlDbType.Int64 | UNSIGNED_MASK; - case MySqlDbType.UByte: - return (int) MySqlDbType.Byte | UNSIGNED_MASK; - case MySqlDbType.UInt64: - return (int) MySqlDbType.Int64 | UNSIGNED_MASK; - case MySqlDbType.UInt32: - return (int) MySqlDbType.Int32 | UNSIGNED_MASK; - case MySqlDbType.UInt24: - return (int) MySqlDbType.Int32 | UNSIGNED_MASK; - case MySqlDbType.UInt16: - return (int) MySqlDbType.Int16 | UNSIGNED_MASK; - default: - return (int) mySqlDbType; - } - } - - internal void Serialize(MySqlPacket packet, bool binary, MySqlConnectionStringBuilder settings) - { - if (!binary && (paramValue == null || paramValue == DBNull.Value)) - packet.WriteStringNoNull("NULL"); - else - { - if (ValueObject.MySqlDbType == MySqlDbType.Guid) - { - MySqlGuid g = (MySqlGuid)ValueObject; - g.OldGuids = settings.OldGuids; - valueObject = g; - } - ValueObject.WriteValue(packet, binary, paramValue, size); - } - } - - private void SetMySqlDbType(MySqlDbType mysql_dbtype) - { - mySqlDbType = mysql_dbtype; - valueObject = MySqlField.GetIMySqlValue(mySqlDbType); - - switch (mySqlDbType) - { - case MySqlDbType.Decimal: - dbType = DbType.Decimal; - break; - case MySqlDbType.Byte: - dbType = DbType.SByte; - break; - case MySqlDbType.UByte: - dbType = DbType.Byte; - break; - case MySqlDbType.Int16: - dbType = DbType.Int16; - break; - case MySqlDbType.UInt16: - dbType = DbType.UInt16; - break; - case MySqlDbType.Int24: - case MySqlDbType.Int32: - dbType = DbType.Int32; - break; - case MySqlDbType.UInt24: - case MySqlDbType.UInt32: - dbType = DbType.UInt32; - break; - case MySqlDbType.Int64: - dbType = DbType.Int64; - break; - case MySqlDbType.UInt64: - dbType = DbType.UInt64; - break; - case MySqlDbType.Bit: - dbType = DbType.UInt64; - break; - case MySqlDbType.Float: - dbType = DbType.Single; - break; - case MySqlDbType.Double: - dbType = DbType.Double; - break; - case MySqlDbType.Timestamp: - case MySqlDbType.DateTime: - dbType = DbType.DateTime; - break; - case MySqlDbType.Date: - case MySqlDbType.Newdate: - case MySqlDbType.Year: - dbType = DbType.Date; - break; - case MySqlDbType.Time: - dbType = DbType.Time; - break; - case MySqlDbType.Enum: - case MySqlDbType.Set: - case MySqlDbType.VarChar: - dbType = DbType.String; - break; - case MySqlDbType.TinyBlob: - case MySqlDbType.MediumBlob: - case MySqlDbType.LongBlob: - case MySqlDbType.Blob: - dbType = DbType.Object; - break; - case MySqlDbType.String: - dbType = DbType.StringFixedLength; - break; - case MySqlDbType.Guid: - dbType = DbType.Guid; - break; - } - } - - private void SetDbType(DbType db_type) - { - dbType = db_type; - switch (dbType) - { - case DbType.Guid: - mySqlDbType = MySqlDbType.Guid; - break; - - case DbType.AnsiString: - case DbType.String: - mySqlDbType = MySqlDbType.VarChar; - break; - - case DbType.AnsiStringFixedLength: - case DbType.StringFixedLength: - mySqlDbType = MySqlDbType.String; - break; - - case DbType.Boolean: - case DbType.Byte: - mySqlDbType = MySqlDbType.UByte; - break; - - case DbType.SByte: - mySqlDbType = MySqlDbType.Byte; - break; - - case DbType.Date: - mySqlDbType = MySqlDbType.Date; - break; - case DbType.DateTime: - mySqlDbType = MySqlDbType.DateTime; - break; - - case DbType.Time: - mySqlDbType = MySqlDbType.Time; - break; - case DbType.Single: - mySqlDbType = MySqlDbType.Float; - break; - case DbType.Double: - mySqlDbType = MySqlDbType.Double; - break; - - case DbType.Int16: - mySqlDbType = MySqlDbType.Int16; - break; - case DbType.UInt16: - mySqlDbType = MySqlDbType.UInt16; - break; - - case DbType.Int32: - mySqlDbType = MySqlDbType.Int32; - break; - case DbType.UInt32: - mySqlDbType = MySqlDbType.UInt32; - break; - - case DbType.Int64: - mySqlDbType = MySqlDbType.Int64; - break; - case DbType.UInt64: - mySqlDbType = MySqlDbType.UInt64; - break; - - case DbType.Decimal: - case DbType.Currency: - mySqlDbType = MySqlDbType.Decimal; - break; - - case DbType.Object: - case DbType.VarNumeric: - case DbType.Binary: - default: - mySqlDbType = MySqlDbType.Blob; - break; - } - valueObject = MySqlField.GetIMySqlValue(mySqlDbType); - } - - private void SetTypeFromValue() - { - if (paramValue == null || paramValue == DBNull.Value) return; - - if (paramValue is Guid) - DbType = DbType.Guid; - else if (paramValue is TimeSpan) - DbType = DbType.Time; - else if (paramValue is bool) - DbType = DbType.Byte; - else - { - TypeCode tc = Type.GetTypeCode(paramValue.GetType()); - switch (tc) - { - case TypeCode.SByte: - DbType = DbType.SByte; - break; - case TypeCode.Byte: - DbType = DbType.Byte; - break; - case TypeCode.Int16: - DbType = DbType.Int16; - break; - case TypeCode.UInt16: - DbType = DbType.UInt16; - break; - case TypeCode.Int32: - DbType = DbType.Int32; - break; - case TypeCode.UInt32: - DbType = DbType.UInt32; - break; - case TypeCode.Int64: - DbType = DbType.Int64; - break; - case TypeCode.UInt64: - DbType = DbType.UInt64; - break; - case TypeCode.DateTime: - DbType = DbType.DateTime; - break; - case TypeCode.String: - DbType = DbType.String; - break; - case TypeCode.Single: - DbType = DbType.Single; - break; - case TypeCode.Double: - DbType = DbType.Double; - break; - case TypeCode.Decimal: - DbType = DbType.Decimal; - break; - case TypeCode.Object: - default: - DbType = DbType.Object; - break; - } - } - } - - #region ICloneable - - public MySqlParameter Clone() - { - MySqlParameter clone = new MySqlParameter(paramName, mySqlDbType, direction, - sourceColumn, sourceVersion, paramValue); - // if we have not had our type set yet then our clone should not either - clone.inferType = inferType; - return clone; - } - - object ICloneable.Clone() - { - return this.Clone(); - } - - #endregion - - /// - /// Resets the DbType property to its original settings. - /// - public override void ResetDbType() - { - inferType = true; - } - - /// - /// Sets or gets a value which indicates whether the source column is nullable. - /// This allows to correctly generate Update statements - /// for nullable columns. - /// - public override bool SourceColumnNullMapping - { - get { return sourceColumnNullMapping; } - set { sourceColumnNullMapping = value; } - } - - // this method is pretty dumb but we want it to be fast. it doesn't return size based - // on value and type but just on the value. - internal long EstimatedSize() - { - if (Value == null || Value == DBNull.Value) - return 4; // size of NULL - if (Value is byte[]) - return (Value as byte[]).Length; - if (Value is string) - return (Value as string).Length * 4; // account for UTF-8 (yeah I know) - if (Value is decimal || Value is float) - return 64; - return 32; - } - } - -#if !CF - internal class MySqlParameterConverter : TypeConverter - { - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - { - if (destinationType == typeof(InstanceDescriptor)) - { - return true; - } - - // Always call the base to see if it can perform the conversion. - return base.CanConvertTo(context, destinationType); - } - - public override object ConvertTo(ITypeDescriptorContext context, - CultureInfo culture, object value, Type destinationType) - { - if (destinationType == typeof(InstanceDescriptor)) - { - ConstructorInfo ci = typeof(MySqlParameter).GetConstructor( - new Type[] - { - typeof (string), typeof (MySqlDbType), typeof (int), typeof (ParameterDirection), - typeof (bool), typeof (byte), typeof (byte), typeof (string), typeof (DataRowVersion), - typeof (object) - }); - MySqlParameter p = (MySqlParameter)value; - return new InstanceDescriptor(ci, new object[] - { - p.ParameterName, p.DbType, p.Size, p.Direction, - p.IsNullable, p.Precision, - p.Scale, p.SourceColumn, p.SourceVersion, p.Value - }); - } - - // Always call base, even if you can't convert. - return base.ConvertTo(context, culture, value, destinationType); - } - } -#endif -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/parameter_collection.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/parameter_collection.cs deleted file mode 100644 index 044d688..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/parameter_collection.cs +++ /dev/null @@ -1,501 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data.Common; -using System.Collections; -using System.ComponentModel; -using System.Collections.Generic; -using MySql.Data.MySqlClient.Properties; - -namespace MySql.Data.MySqlClient -{ - /// - /// Represents a collection of parameters relevant to a as well as their respective mappings to columns in a . This class cannot be inherited. - /// - /// -#if !CF - [Editor("MySql.Data.MySqlClient.Design.DBParametersEditor,MySql.Design", typeof(System.Drawing.Design.UITypeEditor))] - [ListBindable(true)] -#endif - public sealed class MySqlParameterCollection : DbParameterCollection - { - List items = new List(); - //private ArrayList items = new ArrayList(); - private Hashtable indexHashCS; - private Hashtable indexHashCI; - - internal MySqlParameterCollection(MySqlCommand cmd) - { - indexHashCS = new Hashtable(); - indexHashCI = new Hashtable(StringComparer.CurrentCultureIgnoreCase); - Clear(); - } - - #region Public Methods - - /// - /// Gets the at the specified index. - /// - /// Gets the with a specified attribute. - /// [C#] In C#, this property is the indexer for the class. - /// - public new MySqlParameter this[int index] - { - get { return (MySqlParameter)GetParameter(index); } - set { SetParameter(index, value); } - } - - /// - /// Gets the with the specified name. - /// - public new MySqlParameter this[string name] - { - get { return (MySqlParameter)GetParameter(name); } - set { SetParameter(name, value); } - } - - /// - /// Adds the specified object to the . - /// - /// The to add to the collection. - /// The newly added object. - public MySqlParameter Add(MySqlParameter value) - { - return InternalAdd(value, -1); - } - - /// - /// Adds a to the given the specified parameter name and value. - /// - /// The name of the parameter. - /// The of the to add to the collection. - /// The newly added object. - [Obsolete("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value)")] - public MySqlParameter Add(string parameterName, object value) - { - return Add(new MySqlParameter(parameterName, value)); - } - - public MySqlParameter AddWithValue(string parameterName, object value) - { - return Add(new MySqlParameter(parameterName, value)); - } - - /// - /// Adds a to the given the parameter name and the data type. - /// - /// The name of the parameter. - /// One of the values. - /// The newly added object. - public MySqlParameter Add(string parameterName, MySqlDbType dbType) - { - return Add(new MySqlParameter(parameterName, dbType)); - } - - /// - /// Adds a to the with the parameter name, the data type, and the column length. - /// - /// The name of the parameter. - /// One of the values. - /// The length of the column. - /// The newly added object. - public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size) - { - return Add(new MySqlParameter(parameterName, dbType, size)); - } - - /// - /// Adds a to the with the parameter name, the data type, the column length, and the source column name. - /// - /// The name of the parameter. - /// One of the values. - /// The length of the column. - /// The name of the source column. - /// The newly added object. - public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size, string sourceColumn) - { - return Add(new MySqlParameter(parameterName, dbType, size, sourceColumn)); - } - - #endregion - - #region DbParameterCollection Implementation - - /// - /// Adds an array of values to the end of the . - /// - /// - public override void AddRange(Array values) - { - foreach (DbParameter p in values) - Add(p); - } - - void CheckIndex(int index) - { - if (index < 0 || index >= Count) - throw new IndexOutOfRangeException("Parameter index is out of range."); - } - - /// - /// Retrieve the parameter with the given name. - /// - /// - /// - protected override DbParameter GetParameter(string parameterName) - { - int index = IndexOf(parameterName); - if (index < 0) - { - // check to see if the user has added the parameter without a - // parameter marker. If so, kindly tell them what they did. - if (parameterName.StartsWith("@") || - parameterName.StartsWith("?")) - { - string newParameterName = parameterName.Substring(1); - index = IndexOf(newParameterName); - if (index != -1) - return (DbParameter)items[index]; - } - throw new ArgumentException("Parameter '" + parameterName + "' not found in the collection."); - } - return (DbParameter)items[index]; - } - - protected override DbParameter GetParameter(int index) - { - CheckIndex(index); - return (DbParameter)items[index]; - } - - protected override void SetParameter(string parameterName, DbParameter value) - { - int index = IndexOf(parameterName); - if (index < 0) - throw new ArgumentException("Parameter '" + parameterName + "' not found in the collection."); - SetParameter(index, value); - } - - protected override void SetParameter(int index, DbParameter value) - { - CheckIndex(index); - MySqlParameter p = (MySqlParameter)items[index]; - - // first we remove the old parameter from our hashes - indexHashCS.Remove(p.ParameterName); - indexHashCI.Remove(p.ParameterName); - - // then we add in the new parameter - items[index] = value; - indexHashCS.Add(value.ParameterName, index); - indexHashCI.Add(value.ParameterName, index); - } - - /// - /// Adds the specified object to the . - /// - /// The to add to the collection. - /// The index of the new object. - public override int Add(object value) - { - MySqlParameter parameter = value as MySqlParameter; - if (parameter == null) - throw new MySqlException("Only MySqlParameter objects may be stored"); - - if (parameter.ParameterName == null || parameter.ParameterName == String.Empty) - throw new MySqlException("Parameters must be named"); - - parameter = Add(parameter); - return IndexOf(parameter); - } - - /// - /// Removes all items from the collection. - /// - public override void Clear() - { - foreach (MySqlParameter p in items) - p.Collection = null; - items.Clear(); - indexHashCS.Clear(); - indexHashCI.Clear(); - } - - /// - /// Gets a value indicating whether a with the specified parameter name exists in the collection. - /// - /// The name of the object to find. - /// true if the collection contains the parameter; otherwise, false. - public override bool Contains(string parameterName) - { - return IndexOf(parameterName) != -1; - } - - /// - /// Gets a value indicating whether a MySqlParameter exists in the collection. - /// - /// The value of the object to find. - /// true if the collection contains the object; otherwise, false. - /// Gets a value indicating whether a exists in the collection. - public override bool Contains(object value) - { - DbParameter parameter = value as DbParameter; - if (null == parameter) - throw new ArgumentException("Argument must be of type DbParameter", "value"); - return items.Contains(parameter); - } - - /// - /// Copies MySqlParameter objects from the MySqlParameterCollection to the specified array. - /// - /// - /// - public override void CopyTo(Array array, int index) - { - items.ToArray().CopyTo(array, index); - } - - /// - /// Gets the number of MySqlParameter objects in the collection. - /// - public override int Count - { - get { return items.Count; } - } - - /// - /// Returns an enumerator that iterates through the . - /// - /// - public override IEnumerator GetEnumerator() - { - return items.GetEnumerator(); - } - - /// - /// Gets the location of the in the collection with a specific parameter name. - /// - /// The name of the object to retrieve. - /// The zero-based location of the in the collection. - public override int IndexOf(string parameterName) - { - object o = indexHashCS[parameterName]; - if (o == null) - o = indexHashCI[parameterName]; - if (o == null) - return -1; - return (int)o; - } - - /// - /// Gets the location of a in the collection. - /// - /// The object to locate. - /// The zero-based location of the in the collection. - /// Gets the location of a in the collection. - public override int IndexOf(object value) - { - DbParameter parameter = value as DbParameter; - if (null == parameter) - throw new ArgumentException("Argument must be of type DbParameter", "value"); - return items.IndexOf(parameter); - } - - /// - /// Inserts a MySqlParameter into the collection at the specified index. - /// - /// - /// - public override void Insert(int index, object value) - { - MySqlParameter parameter = value as MySqlParameter; - if (parameter == null) - throw new MySqlException("Only MySqlParameter objects may be stored"); - InternalAdd(parameter, index); - } - - /// - /// Gets a value that indicates whether the - /// has a fixed size. - /// - public override bool IsFixedSize - { - get { return (items as IList).IsFixedSize; } - } - - /// - /// Gets a value that indicates whether the - /// is read-only. - /// - public override bool IsReadOnly - { - get { return (items as IList).IsReadOnly; } - } - - /// - /// Gets a value that indicates whether the - /// is synchronized. - /// - public override bool IsSynchronized - { - get { return (items as IList).IsSynchronized; } - } - - /// - /// Removes the specified MySqlParameter from the collection. - /// - /// - public override void Remove(object value) - { - MySqlParameter p = (value as MySqlParameter); - p.Collection = null; - int index = IndexOf(p); - items.Remove(p); - - indexHashCS.Remove(p.ParameterName); - indexHashCI.Remove(p.ParameterName); - AdjustHashes(index, false); - } - - /// - /// Removes the specified from the collection using the parameter name. - /// - /// The name of the object to retrieve. - public override void RemoveAt(string parameterName) - { - DbParameter p = GetParameter(parameterName); - Remove(p); - } - - /// - /// Removes the specified from the collection using a specific index. - /// - /// The zero-based index of the parameter. - /// Removes the specified from the collection. - public override void RemoveAt(int index) - { - object o = items[index]; - Remove(o); - } - - /// - /// Gets an object that can be used to synchronize access to the - /// . - /// - public override object SyncRoot - { - get { return (items as IList).SyncRoot; } - } - - #endregion - - internal void ParameterNameChanged(MySqlParameter p, string oldName, string newName) - { - int index = IndexOf(oldName); - indexHashCS.Remove(oldName); - indexHashCI.Remove(oldName); - - indexHashCS.Add(newName, index); - indexHashCI.Add(newName, index); - } - - private MySqlParameter InternalAdd(MySqlParameter value, int index) - { - if (value == null) - throw new ArgumentException("The MySqlParameterCollection only accepts non-null MySqlParameter type objects.", "value"); - - // make sure we don't already have a parameter with this name - if (IndexOf(value.ParameterName) >= 0) - { - throw new MySqlException( - String.Format(Resources.ParameterAlreadyDefined, value.ParameterName)); - } - else - { - string inComingName = value.ParameterName; - if (inComingName[0] == '@' || inComingName[0] == '?') - inComingName = inComingName.Substring(1, inComingName.Length - 1); - if (IndexOf(inComingName) >= 0) - throw new MySqlException( - String.Format(Resources.ParameterAlreadyDefined, value.ParameterName)); - } - - if (index == -1) - { - items.Add(value); - index = items.IndexOf(value); - } - else - { - items.Insert(index, value); - AdjustHashes(index, true); - } - - indexHashCS.Add(value.ParameterName, index); - indexHashCI.Add(value.ParameterName, index); - - value.Collection = this; - return value; - } - - private static void AdjustHash(Hashtable hash, string parameterName, int keyIndex, bool addEntry) - { - if (!hash.ContainsKey(parameterName)) return; - int index = (int)hash[parameterName]; - if (index < keyIndex) return; - hash[parameterName] = addEntry ? ++index : --index; - } - - /// - /// This method will update all the items in the index hashes when - /// we insert a parameter somewhere in the middle - /// - /// - /// - private void AdjustHashes(int keyIndex, bool addEntry) - { - for (int i = 0; i < Count; i++) - { - string name = (items[i] as MySqlParameter).ParameterName; - AdjustHash(indexHashCI, name, keyIndex, addEntry); - AdjustHash(indexHashCS, name, keyIndex, addEntry); - } - } - - internal MySqlParameter GetParameterFlexible(string parameterName, bool throwOnNotFound) - { - int index = IndexOf(parameterName); - if (-1 == index) - index = IndexOf("?" + parameterName); - if (-1 == index) - index = IndexOf("@" + parameterName); - if (-1 == index) - { if (parameterName.StartsWith("@") || parameterName.StartsWith("?")) - index = IndexOf(parameterName.Substring(1)); - } - if (-1 != index) - return this[index]; - if (throwOnNotFound) - throw new ArgumentException("Parameter '" + parameterName + "' not found in the collection."); - return null; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/transaction.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/transaction.cs deleted file mode 100644 index f781dbe..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/transaction.cs +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Data.Common; - -namespace MySql.Data.MySqlClient -{ - /// - public sealed class MySqlTransaction : DbTransaction - { - private IsolationLevel level; - private MySqlConnection conn; - private bool open; - - internal MySqlTransaction(MySqlConnection c, IsolationLevel il) - { - conn = c; - level = il; - open = true; - } - - #region Properties - - /// - /// Gets the object associated with the transaction, or a null reference (Nothing in Visual Basic) if the transaction is no longer valid. - /// - /// The object associated with this transaction. - /// - /// A single application may have multiple database connections, each - /// with zero or more transactions. This property enables you to - /// determine the connection object associated with a particular - /// transaction created by . - /// - public new MySqlConnection Connection - { - get { return conn; } - } - - /// - /// Specifies the for this transaction. - /// - /// - /// The for this transaction. The default is ReadCommitted. - /// - /// - /// Parallel transactions are not supported. Therefore, the IsolationLevel - /// applies to the entire transaction. - /// - public override IsolationLevel IsolationLevel - { - get { return level; } - } - - protected override DbConnection DbConnection - { - get { return conn; } - } - - #endregion - - protected override void Dispose(bool disposing) - { - if ((conn != null && conn.State == ConnectionState.Open || conn.SoftClosed) && open) - Rollback(); - base.Dispose(disposing); - } - - /// - public override void Commit() - { - if (conn == null || (conn.State != ConnectionState.Open && !conn.SoftClosed)) - throw new InvalidOperationException("Connection must be valid and open to commit transaction"); - if (!open) - throw new InvalidOperationException("Transaction has already been committed or is not pending"); - MySqlCommand cmd = new MySqlCommand("COMMIT", conn); - cmd.ExecuteNonQuery(); - open = false; - } - - /// - public override void Rollback() - { - if (conn == null || (conn.State != ConnectionState.Open && !conn.SoftClosed)) - throw new InvalidOperationException("Connection must be valid and open to rollback transaction"); - if (!open) - throw new InvalidOperationException("Transaction has already been rolled back or is not pending"); - MySqlCommand cmd = new MySqlCommand("ROLLBACK", conn); - cmd.ExecuteNonQuery(); - open = false; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Adler32.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Adler32.cs deleted file mode 100644 index 4367c04..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Adler32.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -/* -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - sealed class Adler32 - { - - // largest prime smaller than 65536 - private const int BASE = 65521; - // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 - private const int NMAX = 5552; - - internal long adler32(long adler, byte[] buf, int index, int len) - { - if (buf == null) - { - return 1L; - } - - long s1 = adler & 0xffff; - long s2 = (adler >> 16) & 0xffff; - int k; - - while (len > 0) - { - k = len < NMAX?len:NMAX; - len -= k; - while (k >= 16) - { - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - s1 += (buf[index++] & 0xff); s2 += s1; - k -= 16; - } - if (k != 0) - { - do - { - s1 += (buf[index++] & 0xff); s2 += s1; - } - while (--k != 0); - } - s1 %= BASE; - s2 %= BASE; - } - return (s2 << 16) | s1; - } - - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Deflate.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Deflate.cs deleted file mode 100644 index cd6fd2d..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Deflate.cs +++ /dev/null @@ -1,1799 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - sealed class Deflate - { - - private const int MAX_MEM_LEVEL = 9; - - private const int Z_DEFAULT_COMPRESSION = - 1; - - private const int MAX_WBITS = 15; // 32K LZ77 window - private const int DEF_MEM_LEVEL = 8; - - internal class Config - { - internal int good_length; // reduce lazy search above this match length - internal int max_lazy; // do not perform lazy search above this match length - internal int nice_length; // quit search above this match length - internal int max_chain; - internal int func; - internal Config(int good_length, int max_lazy, int nice_length, int max_chain, int func) - { - this.good_length = good_length; - this.max_lazy = max_lazy; - this.nice_length = nice_length; - this.max_chain = max_chain; - this.func = func; - } - } - - private const int STORED = 0; - private const int FAST = 1; - private const int SLOW = 2; - private static Config[] config_table; - - private static readonly System.String[] z_errmsg = new System.String[]{"need dictionary", "stream end", "", "file error", "stream error", "data error", "insufficient memory", "buffer error", "incompatible version", ""}; - - // block not completed, need more input or more output - private const int NeedMore = 0; - - // block flush performed - private const int BlockDone = 1; - - // finish started, need only more output at next deflate - private const int FinishStarted = 2; - - // finish done, accept no more input or output - private const int FinishDone = 3; - - // preset dictionary flag in zlib header - private const int PRESET_DICT = 0x20; - - private const int Z_FILTERED = 1; - private const int Z_HUFFMAN_ONLY = 2; - private const int Z_DEFAULT_STRATEGY = 0; - - private const int Z_NO_FLUSH = 0; - private const int Z_PARTIAL_FLUSH = 1; - private const int Z_SYNC_FLUSH = 2; - private const int Z_FULL_FLUSH = 3; - private const int Z_FINISH = 4; - - private const int Z_OK = 0; - private const int Z_STREAM_END = 1; - private const int Z_NEED_DICT = 2; - private const int Z_ERRNO = - 1; - private const int Z_STREAM_ERROR = - 2; - private const int Z_DATA_ERROR = - 3; - private const int Z_MEM_ERROR = - 4; - private const int Z_BUF_ERROR = - 5; - private const int Z_VERSION_ERROR = - 6; - - private const int INIT_STATE = 42; - private const int BUSY_STATE = 113; - private const int FINISH_STATE = 666; - - // The deflate compression method - private const int Z_DEFLATED = 8; - - private const int STORED_BLOCK = 0; - private const int STATIC_TREES = 1; - private const int DYN_TREES = 2; - - // The three kinds of block type - private const int Z_BINARY = 0; - private const int Z_ASCII = 1; - private const int Z_UNKNOWN = 2; - - private const int Buf_size = 8 * 2; - - // repeat previous bit length 3-6 times (2 bits of repeat count) - private const int REP_3_6 = 16; - - // repeat a zero length 3-10 times (3 bits of repeat count) - private const int REPZ_3_10 = 17; - - // repeat a zero length 11-138 times (7 bits of repeat count) - private const int REPZ_11_138 = 18; - - private const int MIN_MATCH = 3; - private const int MAX_MATCH = 258; - private static readonly int MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1); - - private const int MAX_BITS = 15; - private const int D_CODES = 30; - private const int BL_CODES = 19; - private const int LENGTH_CODES = 29; - private const int LITERALS = 256; - private static readonly int L_CODES = (LITERALS + 1 + LENGTH_CODES); - private static readonly int HEAP_SIZE = (2 * L_CODES + 1); - - private const int END_BLOCK = 256; - - internal ZStream strm; // pointer back to this zlib stream - internal int status; // as the name implies - internal byte[] pending_buf; // output still pending - internal int pending_buf_size; // size of pending_buf - internal int pending_out; // next pending byte to output to the stream - internal int pending; // nb of bytes in the pending buffer - internal int noheader; // suppress zlib header and adler32 - internal byte data_type; // UNKNOWN, BINARY or ASCII - internal byte method; // STORED (for zip only) or DEFLATED - internal int last_flush; // value of flush param for previous deflate call - - internal int w_size; // LZ77 window size (32K by default) - internal int w_bits; // log2(w_size) (8..16) - internal int w_mask; // w_size - 1 - - internal byte[] window; - // Sliding window. Input bytes are read into the second half of the window, - // and move to the first half later to keep a dictionary of at least wSize - // bytes. With this organization, matches are limited to a distance of - // wSize-MAX_MATCH bytes, but this ensures that IO is always - // performed with a length multiple of the block size. Also, it limits - // the window size to 64K, which is quite useful on MSDOS. - // To do: use the user input buffer as sliding window. - - internal int window_size; - // Actual size of window: 2*wSize, except when the user input buffer - // is directly used as sliding window. - - internal short[] prev; - // Link to older string with same hash index. To limit the size of this - // array to 64K, this link is maintained only for the last 32K strings. - // An index in this array is thus a window index modulo 32K. - - internal short[] head; // Heads of the hash chains or NIL. - - internal int ins_h; // hash index of string to be inserted - internal int hash_size; // number of elements in hash table - internal int hash_bits; // log2(hash_size) - internal int hash_mask; // hash_size-1 - - // Number of bits by which ins_h must be shifted at each input - // step. It must be such that after MIN_MATCH steps, the oldest - // byte no longer takes part in the hash key, that is: - // hash_shift * MIN_MATCH >= hash_bits - internal int hash_shift; - - // Window position at the beginning of the current output block. Gets - // negative when the window is moved backwards. - - internal int block_start; - - internal int match_length; // length of best match - internal int prev_match; // previous match - internal int match_available; // set if previous match exists - internal int strstart; // start of string to insert - internal int match_start; // start of matching string - internal int lookahead; // number of valid bytes ahead in window - - // Length of the best match at previous step. Matches not greater than this - // are discarded. This is used in the lazy match evaluation. - internal int prev_length; - - // To speed up deflation, hash chains are never searched beyond this - // length. A higher limit improves compression ratio but degrades the speed. - internal int max_chain_length; - - // Attempt to find a better match only when the current match is strictly - // smaller than this value. This mechanism is used only for compression - // levels >= 4. - internal int max_lazy_match; - - // Insert new strings in the hash table only if the match length is not - // greater than this length. This saves time but degrades compression. - // max_insert_length is used only for compression levels <= 3. - - internal int level; // compression level (1..9) - internal int strategy; // favor or force Huffman coding - - // Use a faster search when the previous match is longer than this - internal int good_match; - - // Stop searching when current match exceeds this - internal int nice_match; - - internal short[] dyn_ltree; // literal and length tree - internal short[] dyn_dtree; // distance tree - internal short[] bl_tree; // Huffman tree for bit lengths - - internal Tree l_desc = new Tree(); // desc for literal tree - internal Tree d_desc = new Tree(); // desc for distance tree - internal Tree bl_desc = new Tree(); // desc for bit length tree - - // number of codes at each bit length for an optimal tree - internal short[] bl_count = new short[MAX_BITS + 1]; - - // heap used to build the Huffman trees - internal int[] heap = new int[2 * L_CODES + 1]; - - internal int heap_len; // number of elements in the heap - internal int heap_max; // element of largest frequency - // The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - // The same heap array is used to build all trees. - - // Depth of each subtree used as tie breaker for trees of equal frequency - internal byte[] depth = new byte[2 * L_CODES + 1]; - - internal int l_buf; // index for literals or lengths */ - - // Size of match buffer for literals/lengths. There are 4 reasons for - // limiting lit_bufsize to 64K: - // - frequencies can be kept in 16 bit counters - // - if compression is not successful for the first block, all input - // data is still in the window so we can still emit a stored block even - // when input comes from standard input. (This can also be done for - // all blocks if lit_bufsize is not greater than 32K.) - // - if compression is not successful for a file smaller than 64K, we can - // even emit a stored file instead of a stored block (saving 5 bytes). - // This is applicable only for zip (not gzip or zlib). - // - creating new Huffman trees less frequently may not provide fast - // adaptation to changes in the input data statistics. (Take for - // example a binary file with poorly compressible code followed by - // a highly compressible string table.) Smaller buffer sizes give - // fast adaptation but have of course the overhead of transmitting - // trees more frequently. - // - I can't count above 4 - internal int lit_bufsize; - - internal int last_lit; // running index in l_buf - - // Buffer for distances. To simplify the code, d_buf and l_buf have - // the same number of elements. To use different lengths, an extra flag - // array would be necessary. - - internal int d_buf; // index of pendig_buf - - internal int opt_len; // bit length of current block with optimal trees - internal int static_len; // bit length of current block with static trees - internal int matches; // number of string matches in current block - internal int last_eob_len; // bit length of EOB code for last block - - // Output buffer. bits are inserted starting at the bottom (least - // significant bits). - internal short bi_buf; - - // Number of valid bits in bi_buf. All bits above the last valid bit - // are always zero. - internal int bi_valid; - - internal Deflate() - { - dyn_ltree = new short[HEAP_SIZE * 2]; - dyn_dtree = new short[(2 * D_CODES + 1) * 2]; // distance tree - bl_tree = new short[(2 * BL_CODES + 1) * 2]; // Huffman tree for bit lengths - } - - internal void lm_init() - { - window_size = 2 * w_size; - - head[hash_size - 1] = 0; - for (int i = 0; i < hash_size - 1; i++) - { - head[i] = 0; - } - - // Set the default configuration parameters: - max_lazy_match = Deflate.config_table[level].max_lazy; - good_match = Deflate.config_table[level].good_length; - nice_match = Deflate.config_table[level].nice_length; - max_chain_length = Deflate.config_table[level].max_chain; - - strstart = 0; - block_start = 0; - lookahead = 0; - match_length = prev_length = MIN_MATCH - 1; - match_available = 0; - ins_h = 0; - } - - // Initialize the tree data structures for a new zlib stream. - internal void tr_init() - { - - l_desc.dyn_tree = dyn_ltree; - l_desc.stat_desc = StaticTree.static_l_desc; - - d_desc.dyn_tree = dyn_dtree; - d_desc.stat_desc = StaticTree.static_d_desc; - - bl_desc.dyn_tree = bl_tree; - bl_desc.stat_desc = StaticTree.static_bl_desc; - - bi_buf = 0; - bi_valid = 0; - last_eob_len = 8; // enough lookahead for inflate - - // Initialize the first block of the first file: - init_block(); - } - - internal void init_block() - { - // Initialize the trees. - for (int i = 0; i < L_CODES; i++) - dyn_ltree[i * 2] = 0; - for (int i = 0; i < D_CODES; i++) - dyn_dtree[i * 2] = 0; - for (int i = 0; i < BL_CODES; i++) - bl_tree[i * 2] = 0; - - dyn_ltree[END_BLOCK * 2] = 1; - opt_len = static_len = 0; - last_lit = matches = 0; - } - - // Restore the heap property by moving down the tree starting at node k, - // exchanging a node with the smallest of its two sons if necessary, stopping - // when the heap property is re-established (each father smaller than its - // two sons). - internal void pqdownheap(short[] tree, int k) - { - int v = heap[k]; - int j = k << 1; // left son of k - while (j <= heap_len) - { - // Set j to the smallest of the two sons: - if (j < heap_len && smaller(tree, heap[j + 1], heap[j], depth)) - { - j++; - } - // Exit if v is smaller than both sons - if (smaller(tree, v, heap[j], depth)) - break; - - // Exchange v with the smallest son - heap[k] = heap[j]; k = j; - // And continue down the tree, setting j to the left son of k - j <<= 1; - } - heap[k] = v; - } - - internal static bool smaller(short[] tree, int n, int m, byte[] depth) - { - return (tree[n * 2] < tree[m * 2] || (tree[n * 2] == tree[m * 2] && depth[n] <= depth[m])); - } - - // Scan a literal or distance tree to determine the frequencies of the codes - // in the bit length tree. - internal void scan_tree(short[] tree, int max_code) - { - int n; // iterates over all tree elements - int prevlen = - 1; // last emitted length - int curlen; // length of current code - int nextlen = tree[0 * 2 + 1]; // length of next code - int count = 0; // repeat count of the current code - int max_count = 7; // max repeat count - int min_count = 4; // min repeat count - - if (nextlen == 0) - { - max_count = 138; min_count = 3; - } - tree[(max_code + 1) * 2 + 1] = (short) SupportClass.Identity(0xffff); // guard - - for (n = 0; n <= max_code; n++) - { - curlen = nextlen; nextlen = tree[(n + 1) * 2 + 1]; - if (++count < max_count && curlen == nextlen) - { - continue; - } - else if (count < min_count) - { - bl_tree[curlen * 2] = (short) (bl_tree[curlen * 2] + count); - } - else if (curlen != 0) - { - if (curlen != prevlen) - bl_tree[curlen * 2]++; - bl_tree[REP_3_6 * 2]++; - } - else if (count <= 10) - { - bl_tree[REPZ_3_10 * 2]++; - } - else - { - bl_tree[REPZ_11_138 * 2]++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) - { - max_count = 138; min_count = 3; - } - else if (curlen == nextlen) - { - max_count = 6; min_count = 3; - } - else - { - max_count = 7; min_count = 4; - } - } - } - - // Construct the Huffman tree for the bit lengths and return the index in - // bl_order of the last bit length code to send. - internal int build_bl_tree() - { - int max_blindex; // index of last bit length code of non zero freq - - // Determine the bit length frequencies for literal and distance trees - scan_tree(dyn_ltree, l_desc.max_code); - scan_tree(dyn_dtree, d_desc.max_code); - - // Build the bit length tree: - bl_desc.build_tree(this); - // opt_len now includes the length of the tree representations, except - // the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - - // Determine the number of bit length codes to send. The pkzip format - // requires that at least 4 bit length codes be sent. (appnote.txt says - // 3 but the actual value used is 4.) - for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) - { - if (bl_tree[Tree.bl_order[max_blindex] * 2 + 1] != 0) - break; - } - // Update opt_len to include the bit length tree and counts - opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; - - return max_blindex; - } - - - // Send the header for a block using dynamic Huffman trees: the counts, the - // lengths of the bit length codes, the literal tree and the distance tree. - // IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - internal void send_all_trees(int lcodes, int dcodes, int blcodes) - { - int rank; // index in bl_order - - send_bits(lcodes - 257, 5); // not +255 as stated in appnote.txt - send_bits(dcodes - 1, 5); - send_bits(blcodes - 4, 4); // not -3 as stated in appnote.txt - for (rank = 0; rank < blcodes; rank++) - { - send_bits(bl_tree[Tree.bl_order[rank] * 2 + 1], 3); - } - send_tree(dyn_ltree, lcodes - 1); // literal tree - send_tree(dyn_dtree, dcodes - 1); // distance tree - } - - // Send a literal or distance tree in compressed form, using the codes in - // bl_tree. - internal void send_tree(short[] tree, int max_code) - { - int n; // iterates over all tree elements - int prevlen = - 1; // last emitted length - int curlen; // length of current code - int nextlen = tree[0 * 2 + 1]; // length of next code - int count = 0; // repeat count of the current code - int max_count = 7; // max repeat count - int min_count = 4; // min repeat count - - if (nextlen == 0) - { - max_count = 138; min_count = 3; - } - - for (n = 0; n <= max_code; n++) - { - curlen = nextlen; nextlen = tree[(n + 1) * 2 + 1]; - if (++count < max_count && curlen == nextlen) - { - continue; - } - else if (count < min_count) - { - do - { - send_code(curlen, bl_tree); - } - while (--count != 0); - } - else if (curlen != 0) - { - if (curlen != prevlen) - { - send_code(curlen, bl_tree); count--; - } - send_code(REP_3_6, bl_tree); - send_bits(count - 3, 2); - } - else if (count <= 10) - { - send_code(REPZ_3_10, bl_tree); - send_bits(count - 3, 3); - } - else - { - send_code(REPZ_11_138, bl_tree); - send_bits(count - 11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) - { - max_count = 138; min_count = 3; - } - else if (curlen == nextlen) - { - max_count = 6; min_count = 3; - } - else - { - max_count = 7; min_count = 4; - } - } - } - - // Output a byte on the stream. - // IN assertion: there is enough room in pending_buf. - internal void put_byte(byte[] p, int start, int len) - { - Array.Copy(p, start, pending_buf, pending, len); - pending += len; - } - - internal void put_byte(byte c) - { - pending_buf[pending++] = c; - } - internal void put_short(int w) - { - put_byte((byte) (w)); - put_byte((byte) (SupportClass.URShift(w, 8))); - } - internal void putShortMSB(int b) - { - put_byte((byte) (b >> 8)); - put_byte((byte) (b)); - } - - internal void send_code(int c, short[] tree) - { - send_bits((tree[c * 2] & 0xffff), (tree[c * 2 + 1] & 0xffff)); - } - - internal void send_bits(int value_Renamed, int length) - { - int len = length; - if (bi_valid > (int) Buf_size - len) - { - int val = value_Renamed; - // bi_buf |= (val << bi_valid); - bi_buf = (short) ((ushort) bi_buf | (ushort) (((val << bi_valid) & 0xffff))); - put_short(bi_buf); - bi_buf = (short) (SupportClass.URShift(val, (Buf_size - bi_valid))); - bi_valid += len - Buf_size; - } - else - { - // bi_buf |= (value) << bi_valid; - bi_buf = (short)((ushort)bi_buf | (ushort)((((value_Renamed) << bi_valid) & 0xffff))); - bi_valid += len; - } - } - - // Send one empty static block to give enough lookahead for inflate. - // This takes 10 bits, of which 7 may remain in the bit buffer. - // The current inflate code requires 9 bits of lookahead. If the - // last two codes for the previous block (real code plus EOB) were coded - // on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode - // the last real code. In this case we send two empty static blocks instead - // of one. (There are no problems if the previous block is stored or fixed.) - // To simplify the code, we assume the worst case of last real code encoded - // on one bit only. - internal void _tr_align() - { - send_bits(STATIC_TREES << 1, 3); - send_code(END_BLOCK, StaticTree.static_ltree); - - bi_flush(); - - // Of the 10 bits for the empty block, we have already sent - // (10 - bi_valid) bits. The lookahead for the last real code (before - // the EOB of the previous block) was thus at least one plus the length - // of the EOB plus what we have just sent of the empty static block. - if (1 + last_eob_len + 10 - bi_valid < 9) - { - send_bits(STATIC_TREES << 1, 3); - send_code(END_BLOCK, StaticTree.static_ltree); - bi_flush(); - } - last_eob_len = 7; - } - - - // Save the match info and tally the frequency counts. Return true if - // the current block must be flushed. - internal bool _tr_tally(int dist, int lc) - { - - pending_buf[d_buf + last_lit * 2] = (byte) (SupportClass.URShift(dist, 8)); - pending_buf[d_buf + last_lit * 2 + 1] = (byte) dist; - - pending_buf[l_buf + last_lit] = (byte) lc; last_lit++; - - if (dist == 0) - { - // lc is the unmatched char - dyn_ltree[lc * 2]++; - } - else - { - matches++; - // Here, lc is the match length - MIN_MATCH - dist--; // dist = match distance - 1 - dyn_ltree[(Tree._length_code[lc] + LITERALS + 1) * 2]++; - dyn_dtree[Tree.d_code(dist) * 2]++; - } - - if ((last_lit & 0x1fff) == 0 && level > 2) - { - // Compute an upper bound for the compressed length - int out_length = last_lit * 8; - int in_length = strstart - block_start; - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) - { - out_length = (int) (out_length + (int) dyn_dtree[dcode * 2] * (5L + Tree.extra_dbits[dcode])); - } - out_length = SupportClass.URShift(out_length, 3); - if ((matches < (last_lit / 2)) && out_length < in_length / 2) - return true; - } - - return (last_lit == lit_bufsize - 1); - // We avoid equality with lit_bufsize because of wraparound at 64K - // on 16 bit machines and because stored blocks are restricted to - // 64K-1 bytes. - } - - // Send the block data compressed using the given Huffman trees - internal void compress_block(short[] ltree, short[] dtree) - { - int dist; // distance of matched string - int lc; // match length or unmatched char (if dist == 0) - int lx = 0; // running index in l_buf - int code; // the code to send - int extra; // number of extra bits to send - - if (last_lit != 0) - { - do - { - dist = ((pending_buf[d_buf + lx * 2] << 8) & 0xff00) | (pending_buf[d_buf + lx * 2 + 1] & 0xff); - lc = (pending_buf[l_buf + lx]) & 0xff; lx++; - - if (dist == 0) - { - send_code(lc, ltree); // send a literal byte - } - else - { - // Here, lc is the match length - MIN_MATCH - code = Tree._length_code[lc]; - - send_code(code + LITERALS + 1, ltree); // send the length code - extra = Tree.extra_lbits[code]; - if (extra != 0) - { - lc -= Tree.base_length[code]; - send_bits(lc, extra); // send the extra length bits - } - dist--; // dist is now the match distance - 1 - code = Tree.d_code(dist); - - send_code(code, dtree); // send the distance code - extra = Tree.extra_dbits[code]; - if (extra != 0) - { - dist -= Tree.base_dist[code]; - send_bits(dist, extra); // send the extra distance bits - } - } // literal or match pair ? - - // Check that the overlay between pending_buf and d_buf+l_buf is ok: - } - while (lx < last_lit); - } - - send_code(END_BLOCK, ltree); - last_eob_len = ltree[END_BLOCK * 2 + 1]; - } - - // Set the data type to ASCII or BINARY, using a crude approximation: - // binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. - // IN assertion: the fields freq of dyn_ltree are set and the total of all - // frequencies does not exceed 64K (to fit in an int on 16 bit machines). - internal void set_data_type() - { - int n = 0; - int ascii_freq = 0; - int bin_freq = 0; - while (n < 7) - { - bin_freq += dyn_ltree[n * 2]; n++; - } - while (n < 128) - { - ascii_freq += dyn_ltree[n * 2]; n++; - } - while (n < LITERALS) - { - bin_freq += dyn_ltree[n * 2]; n++; - } - data_type = (byte) (bin_freq > (SupportClass.URShift(ascii_freq, 2))?Z_BINARY:Z_ASCII); - } - - // Flush the bit buffer, keeping at most 7 bits in it. - internal void bi_flush() - { - if (bi_valid == 16) - { - put_short(bi_buf); - bi_buf = 0; - bi_valid = 0; - } - else if (bi_valid >= 8) - { - put_byte((byte) bi_buf); - bi_buf = (short) (SupportClass.URShift(bi_buf, 8)); - bi_valid -= 8; - } - } - - // Flush the bit buffer and align the output on a byte boundary - internal void bi_windup() - { - if (bi_valid > 8) - { - put_short(bi_buf); - } - else if (bi_valid > 0) - { - put_byte((byte) bi_buf); - } - bi_buf = 0; - bi_valid = 0; - } - - // Copy a stored block, storing first the length and its - // one's complement if requested. - internal void copy_block(int buf, int len, bool header) - { - - bi_windup(); // align on byte boundary - last_eob_len = 8; // enough lookahead for inflate - - if (header) - { - put_short((short) len); - put_short((short) ~ len); - } - - // while(len--!=0) { - // put_byte(window[buf+index]); - // index++; - // } - put_byte(window, buf, len); - } - - internal void flush_block_only(bool eof) - { - _tr_flush_block(block_start >= 0?block_start:- 1, strstart - block_start, eof); - block_start = strstart; - strm.flush_pending(); - } - - // Copy without compression as much as possible from the input stream, return - // the current block state. - // This function does not insert new strings in the dictionary since - // uncompressible data is probably not useful. This function is used - // only for the level=0 compression option. - // NOTE: this function should be optimized to avoid extra copying from - // window to pending_buf. - internal int deflate_stored(int flush) - { - // Stored blocks are limited to 0xffff bytes, pending_buf is limited - // to pending_buf_size, and each stored block has a 5 byte header: - - int max_block_size = 0xffff; - int max_start; - - if (max_block_size > pending_buf_size - 5) - { - max_block_size = pending_buf_size - 5; - } - - // Copy as much as possible from input to output: - while (true) - { - // Fill the window as much as possible: - if (lookahead <= 1) - { - fill_window(); - if (lookahead == 0 && flush == Z_NO_FLUSH) - return NeedMore; - if (lookahead == 0) - break; // flush the current block - } - - strstart += lookahead; - lookahead = 0; - - // Emit a stored block if pending_buf will be full: - max_start = block_start + max_block_size; - if (strstart == 0 || strstart >= max_start) - { - // strstart == 0 is possible when wraparound on 16-bit machine - lookahead = (int) (strstart - max_start); - strstart = (int) max_start; - - flush_block_only(false); - if (strm.avail_out == 0) - return NeedMore; - } - - // Flush if we may have to slide, otherwise block_start may become - // negative and the data will be gone: - if (strstart - block_start >= w_size - MIN_LOOKAHEAD) - { - flush_block_only(false); - if (strm.avail_out == 0) - return NeedMore; - } - } - - flush_block_only(flush == Z_FINISH); - if (strm.avail_out == 0) - return (flush == Z_FINISH)?FinishStarted:NeedMore; - - return flush == Z_FINISH?FinishDone:BlockDone; - } - - // Send a stored block - internal void _tr_stored_block(int buf, int stored_len, bool eof) - { - send_bits((STORED_BLOCK << 1) + (eof?1:0), 3); // send block type - copy_block(buf, stored_len, true); // with header - } - - // Determine the best encoding for the current block: dynamic trees, static - // trees or store, and output the encoded block to the zip file. - internal void _tr_flush_block(int buf, int stored_len, bool eof) - { - int opt_lenb, static_lenb; // opt_len and static_len in bytes - int max_blindex = 0; // index of last bit length code of non zero freq - - // Build the Huffman trees unless a stored block is forced - if (level > 0) - { - // Check if the file is ascii or binary - if (data_type == Z_UNKNOWN) - set_data_type(); - - // Construct the literal and distance trees - l_desc.build_tree(this); - - d_desc.build_tree(this); - - // At this point, opt_len and static_len are the total bit lengths of - // the compressed block data, excluding the tree representations. - - // Build the bit length tree for the above two trees, and get the index - // in bl_order of the last bit length code to send. - max_blindex = build_bl_tree(); - - // Determine the best encoding. Compute first the block length in bytes - opt_lenb = SupportClass.URShift((opt_len + 3 + 7), 3); - static_lenb = SupportClass.URShift((static_len + 3 + 7), 3); - - if (static_lenb <= opt_lenb) - opt_lenb = static_lenb; - } - else - { - opt_lenb = static_lenb = stored_len + 5; // force a stored block - } - - if (stored_len + 4 <= opt_lenb && buf != - 1) - { - // 4: two words for the lengths - // The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - // Otherwise we can't have processed more than WSIZE input bytes since - // the last block flush, because compression would have been - // successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - // transform a block into a stored block. - _tr_stored_block(buf, stored_len, eof); - } - else if (static_lenb == opt_lenb) - { - send_bits((STATIC_TREES << 1) + (eof?1:0), 3); - compress_block(StaticTree.static_ltree, StaticTree.static_dtree); - } - else - { - send_bits((DYN_TREES << 1) + (eof?1:0), 3); - send_all_trees(l_desc.max_code + 1, d_desc.max_code + 1, max_blindex + 1); - compress_block(dyn_ltree, dyn_dtree); - } - - // The above check is made mod 2^32, for files larger than 512 MB - // and uLong implemented on 32 bits. - - init_block(); - - if (eof) - { - bi_windup(); - } - } - - // Fill the window when the lookahead becomes insufficient. - // Updates strstart and lookahead. - // - // IN assertion: lookahead < MIN_LOOKAHEAD - // OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - // At least one byte has been read, or avail_in == 0; reads are - // performed for at least two bytes (required for the zip translate_eol - // option -- not supported here). - internal void fill_window() - { - int n, m; - int p; - int more; // Amount of free space at the end of the window. - - do - { - more = (window_size - lookahead - strstart); - - // Deal with !@#$% 64K limit: - if (more == 0 && strstart == 0 && lookahead == 0) - { - more = w_size; - } - else if (more == - 1) - { - // Very unlikely, but possible on 16 bit machine if strstart == 0 - // and lookahead == 1 (input done one byte at time) - more--; - - // If the window is almost full and there is insufficient lookahead, - // move the upper half to the lower one to make room in the upper half. - } - else if (strstart >= w_size + w_size - MIN_LOOKAHEAD) - { - Array.Copy(window, w_size, window, 0, w_size); - match_start -= w_size; - strstart -= w_size; // we now have strstart >= MAX_DIST - block_start -= w_size; - - // Slide the hash table (could be avoided with 32 bit values - // at the expense of memory usage). We slide even when level == 0 - // to keep the hash table consistent if we switch back to level > 0 - // later. (Using level 0 permanently is not an optimal usage of - // zlib, so we don't care about this pathological case.) - - n = hash_size; - p = n; - do - { - m = (head[--p] & 0xffff); - head[p] = (short)(m >= w_size?(m - w_size):0); - //head[p] = (m >= w_size?(short) (m - w_size):0); - } - while (--n != 0); - - n = w_size; - p = n; - do - { - m = (prev[--p] & 0xffff); - prev[p] = (short)(m >= w_size?(m - w_size):0); - //prev[p] = (m >= w_size?(short) (m - w_size):0); - // If n is not on any hash chain, prev[n] is garbage but - // its value will never be used. - } - while (--n != 0); - more += w_size; - } - - if (strm.avail_in == 0) - return ; - - // If there was no sliding: - // strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - // more == window_size - lookahead - strstart - // => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - // => more >= window_size - 2*WSIZE + 2 - // In the BIG_MEM or MMAP case (not yet supported), - // window_size == input_size + MIN_LOOKAHEAD && - // strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - // Otherwise, window_size == 2*WSIZE so more >= 2. - // If there was sliding, more >= WSIZE. So in all cases, more >= 2. - - n = strm.read_buf(window, strstart + lookahead, more); - lookahead += n; - - // Initialize the hash value now that we have some input: - if (lookahead >= MIN_MATCH) - { - ins_h = window[strstart] & 0xff; - ins_h = (((ins_h) << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask; - } - // If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - // but this is not important since only literal bytes will be emitted. - } - while (lookahead < MIN_LOOKAHEAD && strm.avail_in != 0); - } - - // Compress as much as possible from the input stream, return the current - // block state. - // This function does not perform lazy evaluation of matches and inserts - // new strings in the dictionary only for unmatched strings or for short - // matches. It is used only for the fast compression options. - internal int deflate_fast(int flush) - { - // short hash_head = 0; // head of the hash chain - int hash_head = 0; // head of the hash chain - bool bflush; // set if current block must be flushed - - while (true) - { - // Make sure that we always have enough lookahead, except - // at the end of the input file. We need MAX_MATCH bytes - // for the next match, plus MIN_MATCH bytes to insert the - // string following the next match. - if (lookahead < MIN_LOOKAHEAD) - { - fill_window(); - if (lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) - { - return NeedMore; - } - if (lookahead == 0) - break; // flush the current block - } - - // Insert the string window[strstart .. strstart+2] in the - // dictionary, and set hash_head to the head of the hash chain: - if (lookahead >= MIN_MATCH) - { - ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; - - // prev[strstart&w_mask]=hash_head=head[ins_h]; - hash_head = (head[ins_h] & 0xffff); - prev[strstart & w_mask] = head[ins_h]; - head[ins_h] = (short) strstart; - } - - // Find the longest match, discarding those <= prev_length. - // At this point we have always match_length < MIN_MATCH - - if (hash_head != 0L && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) - { - // To simplify the code, we prevent matches with the string - // of window index 0 (in particular we have to avoid a match - // of the string with itself at the start of the input file). - if (strategy != Z_HUFFMAN_ONLY) - { - match_length = longest_match(hash_head); - } - // longest_match() sets match_start - } - if (match_length >= MIN_MATCH) - { - // check_match(strstart, match_start, match_length); - - bflush = _tr_tally(strstart - match_start, match_length - MIN_MATCH); - - lookahead -= match_length; - - // Insert new strings in the hash table only if the match length - // is not too large. This saves time but degrades compression. - if (match_length <= max_lazy_match && lookahead >= MIN_MATCH) - { - match_length--; // string at strstart already in hash table - do - { - strstart++; - - ins_h = ((ins_h << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; - // prev[strstart&w_mask]=hash_head=head[ins_h]; - hash_head = (head[ins_h] & 0xffff); - prev[strstart & w_mask] = head[ins_h]; - head[ins_h] = (short) strstart; - - // strstart never exceeds WSIZE-MAX_MATCH, so there are - // always MIN_MATCH bytes ahead. - } - while (--match_length != 0); - strstart++; - } - else - { - strstart += match_length; - match_length = 0; - ins_h = window[strstart] & 0xff; - - ins_h = (((ins_h) << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask; - // If lookahead < MIN_MATCH, ins_h is garbage, but it does not - // matter since it will be recomputed at next deflate call. - } - } - else - { - // No match, output a literal byte - - bflush = _tr_tally(0, window[strstart] & 0xff); - lookahead--; - strstart++; - } - if (bflush) - { - - flush_block_only(false); - if (strm.avail_out == 0) - return NeedMore; - } - } - - flush_block_only(flush == Z_FINISH); - if (strm.avail_out == 0) - { - if (flush == Z_FINISH) - return FinishStarted; - else - return NeedMore; - } - return flush == Z_FINISH?FinishDone:BlockDone; - } - - // Same as above, but achieves better compression. We use a lazy - // evaluation for matches: a match is finally adopted only if there is - // no better match at the next window position. - internal int deflate_slow(int flush) - { - // short hash_head = 0; // head of hash chain - int hash_head = 0; // head of hash chain - bool bflush; // set if current block must be flushed - - // Process the input block. - while (true) - { - // Make sure that we always have enough lookahead, except - // at the end of the input file. We need MAX_MATCH bytes - // for the next match, plus MIN_MATCH bytes to insert the - // string following the next match. - - if (lookahead < MIN_LOOKAHEAD) - { - fill_window(); - if (lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) - { - return NeedMore; - } - if (lookahead == 0) - break; // flush the current block - } - - // Insert the string window[strstart .. strstart+2] in the - // dictionary, and set hash_head to the head of the hash chain: - - if (lookahead >= MIN_MATCH) - { - ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; - // prev[strstart&w_mask]=hash_head=head[ins_h]; - hash_head = (head[ins_h] & 0xffff); - prev[strstart & w_mask] = head[ins_h]; - head[ins_h] = (short) strstart; - } - - // Find the longest match, discarding those <= prev_length. - prev_length = match_length; prev_match = match_start; - match_length = MIN_MATCH - 1; - - if (hash_head != 0 && prev_length < max_lazy_match && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) - { - // To simplify the code, we prevent matches with the string - // of window index 0 (in particular we have to avoid a match - // of the string with itself at the start of the input file). - - if (strategy != Z_HUFFMAN_ONLY) - { - match_length = longest_match(hash_head); - } - // longest_match() sets match_start - - if (match_length <= 5 && (strategy == Z_FILTERED || (match_length == MIN_MATCH && strstart - match_start > 4096))) - { - - // If prev_match is also MIN_MATCH, match_start is garbage - // but we will ignore the current match anyway. - match_length = MIN_MATCH - 1; - } - } - - // If there was a match at the previous step and the current - // match is not better, output the previous match: - if (prev_length >= MIN_MATCH && match_length <= prev_length) - { - int max_insert = strstart + lookahead - MIN_MATCH; - // Do not insert strings in hash table beyond this. - - // check_match(strstart-1, prev_match, prev_length); - - bflush = _tr_tally(strstart - 1 - prev_match, prev_length - MIN_MATCH); - - // Insert in hash table all strings up to the end of the match. - // strstart-1 and strstart are already inserted. If there is not - // enough lookahead, the last two strings are not inserted in - // the hash table. - lookahead -= (prev_length - 1); - prev_length -= 2; - do - { - if (++strstart <= max_insert) - { - ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; - //prev[strstart&w_mask]=hash_head=head[ins_h]; - hash_head = (head[ins_h] & 0xffff); - prev[strstart & w_mask] = head[ins_h]; - head[ins_h] = (short) strstart; - } - } - while (--prev_length != 0); - match_available = 0; - match_length = MIN_MATCH - 1; - strstart++; - - if (bflush) - { - flush_block_only(false); - if (strm.avail_out == 0) - return NeedMore; - } - } - else if (match_available != 0) - { - - // If there was no match at the previous position, output a - // single literal. If there was a match but the current match - // is longer, truncate the previous match to a single literal. - - bflush = _tr_tally(0, window[strstart - 1] & 0xff); - - if (bflush) - { - flush_block_only(false); - } - strstart++; - lookahead--; - if (strm.avail_out == 0) - return NeedMore; - } - else - { - // There is no previous match to compare with, wait for - // the next step to decide. - - match_available = 1; - strstart++; - lookahead--; - } - } - - if (match_available != 0) - { - bflush = _tr_tally(0, window[strstart - 1] & 0xff); - match_available = 0; - } - flush_block_only(flush == Z_FINISH); - - if (strm.avail_out == 0) - { - if (flush == Z_FINISH) - return FinishStarted; - else - return NeedMore; - } - - return flush == Z_FINISH?FinishDone:BlockDone; - } - - internal int longest_match(int cur_match) - { - int chain_length = max_chain_length; // max hash chain length - int scan = strstart; // current string - int match; // matched string - int len; // length of current match - int best_len = prev_length; // best match length so far - int limit = strstart > (w_size - MIN_LOOKAHEAD)?strstart - (w_size - MIN_LOOKAHEAD):0; - int nice_match = this.nice_match; - - // Stop when cur_match becomes <= limit. To simplify the code, - // we prevent matches with the string of window index 0. - - int wmask = w_mask; - - int strend = strstart + MAX_MATCH; - byte scan_end1 = window[scan + best_len - 1]; - byte scan_end = window[scan + best_len]; - - // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - // It is easy to get rid of this optimization if necessary. - - // Do not waste too much time if we already have a good match: - if (prev_length >= good_match) - { - chain_length >>= 2; - } - - // Do not look for matches beyond the end of the input. This is necessary - // to make deflate deterministic. - if (nice_match > lookahead) - nice_match = lookahead; - - do - { - match = cur_match; - - // Skip to next match if the match length cannot increase - // or if the match length is less than 2: - if (window[match + best_len] != scan_end || window[match + best_len - 1] != scan_end1 || window[match] != window[scan] || window[++match] != window[scan + 1]) - continue; - - // The check at best_len-1 can be removed because it will be made - // again later. (This heuristic is not always a win.) - // It is not necessary to compare scan[2] and match[2] since they - // are always equal when the other bytes match, given that - // the hash keys are equal and that HASH_BITS >= 8. - scan += 2; match++; - - // We check for insufficient lookahead only every 8th comparison; - // the 256th check will be made at strstart+258. - do - { - } - while (window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && scan < strend); - - len = MAX_MATCH - (int) (strend - scan); - scan = strend - MAX_MATCH; - - if (len > best_len) - { - match_start = cur_match; - best_len = len; - if (len >= nice_match) - break; - scan_end1 = window[scan + best_len - 1]; - scan_end = window[scan + best_len]; - } - } - while ((cur_match = (prev[cur_match & wmask] & 0xffff)) > limit && --chain_length != 0); - - if (best_len <= lookahead) - return best_len; - return lookahead; - } - - internal int deflateInit(ZStream strm, int level, int bits) - { - return deflateInit2(strm, level, Z_DEFLATED, bits, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); - } - internal int deflateInit(ZStream strm, int level) - { - return deflateInit(strm, level, MAX_WBITS); - } - internal int deflateInit2(ZStream strm, int level, int method, int windowBits, int memLevel, int strategy) - { - int noheader = 0; - // byte[] my_version=ZLIB_VERSION; - - // - // if (version == null || version[0] != my_version[0] - // || stream_size != sizeof(z_stream)) { - // return Z_VERSION_ERROR; - // } - - strm.msg = null; - - if (level == Z_DEFAULT_COMPRESSION) - level = 6; - - if (windowBits < 0) - { - // undocumented feature: suppress zlib header - noheader = 1; - windowBits = - windowBits; - } - - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) - { - return Z_STREAM_ERROR; - } - - strm.dstate = (Deflate) this; - - this.noheader = noheader; - w_bits = windowBits; - w_size = 1 << w_bits; - w_mask = w_size - 1; - - hash_bits = memLevel + 7; - hash_size = 1 << hash_bits; - hash_mask = hash_size - 1; - hash_shift = ((hash_bits + MIN_MATCH - 1) / MIN_MATCH); - - window = new byte[w_size * 2]; - prev = new short[w_size]; - head = new short[hash_size]; - - lit_bufsize = 1 << (memLevel + 6); // 16K elements by default - - // We overlay pending_buf and d_buf+l_buf. This works since the average - // output size for (length,distance) codes is <= 24 bits. - pending_buf = new byte[lit_bufsize * 4]; - pending_buf_size = lit_bufsize * 4; - - d_buf = lit_bufsize / 2; - l_buf = (1 + 2) * lit_bufsize; - - this.level = level; - - //System.out.println("level="+level); - - this.strategy = strategy; - this.method = (byte) method; - - return deflateReset(strm); - } - - internal int deflateReset(ZStream strm) - { - strm.total_in = strm.total_out = 0; - strm.msg = null; // - strm.data_type = Z_UNKNOWN; - - pending = 0; - pending_out = 0; - - if (noheader < 0) - { - noheader = 0; // was set to -1 by deflate(..., Z_FINISH); - } - status = (noheader != 0)?BUSY_STATE:INIT_STATE; - strm.adler = strm._adler.adler32(0, null, 0, 0); - - last_flush = Z_NO_FLUSH; - - tr_init(); - lm_init(); - return Z_OK; - } - - internal int deflateEnd() - { - if (status != INIT_STATE && status != BUSY_STATE && status != FINISH_STATE) - { - return Z_STREAM_ERROR; - } - // Deallocate in reverse order of allocations: - pending_buf = null; - head = null; - prev = null; - window = null; - // free - // dstate=null; - return status == BUSY_STATE?Z_DATA_ERROR:Z_OK; - } - - internal int deflateParams(ZStream strm, int _level, int _strategy) - { - int err = Z_OK; - - if (_level == Z_DEFAULT_COMPRESSION) - { - _level = 6; - } - if (_level < 0 || _level > 9 || _strategy < 0 || _strategy > Z_HUFFMAN_ONLY) - { - return Z_STREAM_ERROR; - } - - if (config_table[level].func != config_table[_level].func && strm.total_in != 0) - { - // Flush the last buffer: - err = strm.deflate(Z_PARTIAL_FLUSH); - } - - if (level != _level) - { - level = _level; - max_lazy_match = config_table[level].max_lazy; - good_match = config_table[level].good_length; - nice_match = config_table[level].nice_length; - max_chain_length = config_table[level].max_chain; - } - strategy = _strategy; - return err; - } - - internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLength) - { - int length = dictLength; - int index = 0; - - if (dictionary == null || status != INIT_STATE) - return Z_STREAM_ERROR; - - strm.adler = strm._adler.adler32(strm.adler, dictionary, 0, dictLength); - - if (length < MIN_MATCH) - return Z_OK; - if (length > w_size - MIN_LOOKAHEAD) - { - length = w_size - MIN_LOOKAHEAD; - index = dictLength - length; // use the tail of the dictionary - } - Array.Copy(dictionary, index, window, 0, length); - strstart = length; - block_start = length; - - // Insert all strings in the hash table (except for the last two bytes). - // s->lookahead stays null, so s->ins_h will be recomputed at the next - // call of fill_window. - - ins_h = window[0] & 0xff; - ins_h = (((ins_h) << hash_shift) ^ (window[1] & 0xff)) & hash_mask; - - for (int n = 0; n <= length - MIN_MATCH; n++) - { - ins_h = (((ins_h) << hash_shift) ^ (window[(n) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; - prev[n & w_mask] = head[ins_h]; - head[ins_h] = (short) n; - } - return Z_OK; - } - - internal int deflate(ZStream strm, int flush) - { - int old_flush; - - if (flush > Z_FINISH || flush < 0) - { - return Z_STREAM_ERROR; - } - - if (strm.next_out == null || (strm.next_in == null && strm.avail_in != 0) || (status == FINISH_STATE && flush != Z_FINISH)) - { - strm.msg = z_errmsg[Z_NEED_DICT - (Z_STREAM_ERROR)]; - return Z_STREAM_ERROR; - } - if (strm.avail_out == 0) - { - strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)]; - return Z_BUF_ERROR; - } - - this.strm = strm; // just in case - old_flush = last_flush; - last_flush = flush; - - // Write the zlib header - if (status == INIT_STATE) - { - int header = (Z_DEFLATED + ((w_bits - 8) << 4)) << 8; - int level_flags = ((level - 1) & 0xff) >> 1; - - if (level_flags > 3) - level_flags = 3; - header |= (level_flags << 6); - if (strstart != 0) - header |= PRESET_DICT; - header += 31 - (header % 31); - - status = BUSY_STATE; - putShortMSB(header); - - - // Save the adler32 of the preset dictionary: - if (strstart != 0) - { - putShortMSB((int) (SupportClass.URShift(strm.adler, 16))); - putShortMSB((int) (strm.adler & 0xffff)); - } - strm.adler = strm._adler.adler32(0, null, 0, 0); - } - - // Flush as much pending output as possible - if (pending != 0) - { - strm.flush_pending(); - if (strm.avail_out == 0) - { - //System.out.println(" avail_out==0"); - // Since avail_out is 0, deflate will be called again with - // more output space, but possibly with both pending and - // avail_in equal to zero. There won't be anything to do, - // but this is not an error situation so make sure we - // return OK instead of BUF_ERROR at next call of deflate: - last_flush = - 1; - return Z_OK; - } - - // Make sure there is something to do and avoid duplicate consecutive - // flushes. For repeated and useless calls with Z_FINISH, we keep - // returning Z_STREAM_END instead of Z_BUFF_ERROR. - } - else if (strm.avail_in == 0 && flush <= old_flush && flush != Z_FINISH) - { - strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)]; - return Z_BUF_ERROR; - } - - // User must not provide more input after the first FINISH: - if (status == FINISH_STATE && strm.avail_in != 0) - { - strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)]; - return Z_BUF_ERROR; - } - - // Start a new block or continue the current one. - if (strm.avail_in != 0 || lookahead != 0 || (flush != Z_NO_FLUSH && status != FINISH_STATE)) - { - int bstate = - 1; - switch (config_table[level].func) - { - - case STORED: - bstate = deflate_stored(flush); - break; - - case FAST: - bstate = deflate_fast(flush); - break; - - case SLOW: - bstate = deflate_slow(flush); - break; - - default: - break; - - } - - if (bstate == FinishStarted || bstate == FinishDone) - { - status = FINISH_STATE; - } - if (bstate == NeedMore || bstate == FinishStarted) - { - if (strm.avail_out == 0) - { - last_flush = - 1; // avoid BUF_ERROR next call, see above - } - return Z_OK; - // If flush != Z_NO_FLUSH && avail_out == 0, the next call - // of deflate should use the same flush parameter to make sure - // that the flush is complete. So we don't have to output an - // empty block here, this will be done at next call. This also - // ensures that for a very small output buffer, we emit at most - // one empty block. - } - - if (bstate == BlockDone) - { - if (flush == Z_PARTIAL_FLUSH) - { - _tr_align(); - } - else - { - // FULL_FLUSH or SYNC_FLUSH - _tr_stored_block(0, 0, false); - // For a full flush, this empty block will be recognized - // as a special marker by inflate_sync(). - if (flush == Z_FULL_FLUSH) - { - //state.head[s.hash_size-1]=0; - for (int i = 0; i < hash_size; i++) - // forget history - head[i] = 0; - } - } - strm.flush_pending(); - if (strm.avail_out == 0) - { - last_flush = - 1; // avoid BUF_ERROR at next call, see above - return Z_OK; - } - } - } - - if (flush != Z_FINISH) - return Z_OK; - if (noheader != 0) - return Z_STREAM_END; - - // Write the zlib trailer (adler32) - putShortMSB((int) (SupportClass.URShift(strm.adler, 16))); - putShortMSB((int) (strm.adler & 0xffff)); - strm.flush_pending(); - - // If avail_out is zero, the application will call deflate again - // to flush the rest. - noheader = - 1; // write the trailer only once! - return pending != 0?Z_OK:Z_STREAM_END; - } - static Deflate() - { - { - config_table = new Config[10]; - // good lazy nice chain - config_table[0] = new Config(0, 0, 0, 0, STORED); - config_table[1] = new Config(4, 4, 8, 4, FAST); - config_table[2] = new Config(4, 5, 16, 8, FAST); - config_table[3] = new Config(4, 6, 32, 32, FAST); - - config_table[4] = new Config(4, 4, 16, 16, SLOW); - config_table[5] = new Config(8, 16, 32, 32, SLOW); - config_table[6] = new Config(8, 16, 128, 128, SLOW); - config_table[7] = new Config(8, 32, 128, 256, SLOW); - config_table[8] = new Config(32, 128, 258, 1024, SLOW); - config_table[9] = new Config(32, 258, 258, 4096, SLOW); - } - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfBlocks.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfBlocks.cs deleted file mode 100644 index 251589f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfBlocks.cs +++ /dev/null @@ -1,720 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - sealed class InfBlocks - { - private const int MANY = 1440; - - // And'ing with mask[n] masks the lower n bits - private static readonly int[] inflate_mask = new int[]{0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff}; - - // Table for deflate from PKZIP's appnote.txt. - internal static readonly int[] border = new int[]{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - private const int Z_OK = 0; - private const int Z_STREAM_END = 1; - private const int Z_NEED_DICT = 2; - private const int Z_ERRNO = - 1; - private const int Z_STREAM_ERROR = - 2; - private const int Z_DATA_ERROR = - 3; - private const int Z_MEM_ERROR = - 4; - private const int Z_BUF_ERROR = - 5; - private const int Z_VERSION_ERROR = - 6; - - private const int TYPE = 0; // get type bits (3, including end bit) - private const int LENS = 1; // get lengths for stored - private const int STORED = 2; // processing stored block - private const int TABLE = 3; // get table lengths - private const int BTREE = 4; // get bit lengths tree for a dynamic block - private const int DTREE = 5; // get length, distance trees for a dynamic block - private const int CODES = 6; // processing fixed or dynamic block - private const int DRY = 7; // output remaining window bytes - private const int DONE = 8; // finished last block, done - private const int BAD = 9; // ot a data error--stuck here - - internal int mode; // current inflate_block mode - - internal int left; // if STORED, bytes left to copy - - internal int table; // table lengths (14 bits) - internal int index; // index into blens (or border) - internal int[] blens; // bit lengths of codes - internal int[] bb = new int[1]; // bit length tree depth - internal int[] tb = new int[1]; // bit length decoding tree - - internal InfCodes codes; // if CODES, current state - - internal int last; // true if this block is the last block - - // mode independent information - internal int bitk; // bits in bit buffer - internal int bitb; // bit buffer - internal int[] hufts; // single malloc for tree space - internal byte[] window; // sliding window - internal int end; // one byte after sliding window - internal int read; // window read pointer - internal int write; // window write pointer - internal System.Object checkfn; // check function - internal long check; // check on output - - internal InfBlocks(ZStream z, System.Object checkfn, int w) - { - hufts = new int[MANY * 3]; - window = new byte[w]; - end = w; - this.checkfn = checkfn; - mode = TYPE; - reset(z, null); - } - - internal void reset(ZStream z, long[] c) - { - if (c != null) - c[0] = check; - if (mode == BTREE || mode == DTREE) - { - blens = null; - } - if (mode == CODES) - { - codes.free(z); - } - mode = TYPE; - bitk = 0; - bitb = 0; - read = write = 0; - - if (checkfn != null) - z.adler = check = z._adler.adler32(0L, null, 0, 0); - } - - internal int proc(ZStream z, int r) - { - int t; // temporary storage - int b; // bit buffer - int k; // bits in bit buffer - int p; // input data pointer - int n; // bytes available there - int q; // output window write pointer - int m; // bytes to end of window or read pointer - - // copy input/output information to locals (UPDATE macro restores) - { - p = z.next_in_index; n = z.avail_in; b = bitb; k = bitk; - } - { - q = write; m = (int) (q < read?read - q - 1:end - q); - } - - // process input based on current state - while (true) - { - switch (mode) - { - - case TYPE: - - while (k < (3)) - { - if (n != 0) - { - r = Z_OK; - } - else - { - bitb = b; bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - ; - n--; - b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - t = (int) (b & 7); - last = t & 1; - - switch (SupportClass.URShift(t, 1)) - { - - case 0: // stored - { - b = SupportClass.URShift(b, (3)); k -= (3); - } - t = k & 7; // go to byte boundary - - { - b = SupportClass.URShift(b, (t)); k -= (t); - } - mode = LENS; // get length of stored block - break; - - case 1: // fixed - { - int[] bl = new int[1]; - int[] bd = new int[1]; - int[][] tl = new int[1][]; - int[][] td = new int[1][]; - - InfTree.inflate_trees_fixed(bl, bd, tl, td, z); - codes = new InfCodes(bl[0], bd[0], tl[0], td[0], z); - } - - { - b = SupportClass.URShift(b, (3)); k -= (3); - } - - mode = CODES; - break; - - case 2: // dynamic - - { - b = SupportClass.URShift(b, (3)); k -= (3); - } - - mode = TABLE; - break; - - case 3: // illegal - - { - b = SupportClass.URShift(b, (3)); k -= (3); - } - mode = BAD; - z.msg = "invalid block type"; - r = Z_DATA_ERROR; - - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - break; - - case LENS: - - while (k < (32)) - { - if (n != 0) - { - r = Z_OK; - } - else - { - bitb = b; bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - ; - n--; - b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - if (((SupportClass.URShift((~ b), 16)) & 0xffff) != (b & 0xffff)) - { - mode = BAD; - z.msg = "invalid stored block lengths"; - r = Z_DATA_ERROR; - - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - left = (b & 0xffff); - b = k = 0; // dump bits - mode = left != 0?STORED:(last != 0?DRY:TYPE); - break; - - case STORED: - if (n == 0) - { - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - - if (m == 0) - { - if (q == end && read != 0) - { - q = 0; m = (int) (q < read?read - q - 1:end - q); - } - if (m == 0) - { - write = q; - r = inflate_flush(z, r); - q = write; m = (int) (q < read?read - q - 1:end - q); - if (q == end && read != 0) - { - q = 0; m = (int) (q < read?read - q - 1:end - q); - } - if (m == 0) - { - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - } - } - r = Z_OK; - - t = left; - if (t > n) - t = n; - if (t > m) - t = m; - Array.Copy(z.next_in, p, window, q, t); - p += t; n -= t; - q += t; m -= t; - if ((left -= t) != 0) - break; - mode = last != 0?DRY:TYPE; - break; - - case TABLE: - - while (k < (14)) - { - if (n != 0) - { - r = Z_OK; - } - else - { - bitb = b; bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - ; - n--; - b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - table = t = (b & 0x3fff); - if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) - { - mode = BAD; - z.msg = "too many length or distance symbols"; - r = Z_DATA_ERROR; - - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); - blens = new int[t]; - - { - b = SupportClass.URShift(b, (14)); k -= (14); - } - - index = 0; - mode = BTREE; - goto case BTREE; - - case BTREE: - while (index < 4 + (SupportClass.URShift(table, 10))) - { - while (k < (3)) - { - if (n != 0) - { - r = Z_OK; - } - else - { - bitb = b; bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - ; - n--; - b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - blens[border[index++]] = b & 7; - - { - b = SupportClass.URShift(b, (3)); k -= (3); - } - } - - while (index < 19) - { - blens[border[index++]] = 0; - } - - bb[0] = 7; - t = InfTree.inflate_trees_bits(blens, bb, tb, hufts, z); - if (t != Z_OK) - { - r = t; - if (r == Z_DATA_ERROR) - { - blens = null; - mode = BAD; - } - - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - - index = 0; - mode = DTREE; - goto case DTREE; - - case DTREE: - while (true) - { - t = table; - if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))) - { - break; - } - - - int i, j, c; - - t = bb[0]; - - while (k < (t)) - { - if (n != 0) - { - r = Z_OK; - } - else - { - bitb = b; bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - ; - n--; - b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - if (tb[0] == - 1) - { - //System.err.println("null..."); - } - - t = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 1]; - c = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 2]; - - if (c < 16) - { - b = SupportClass.URShift(b, (t)); k -= (t); - blens[index++] = c; - } - else - { - // c == 16..18 - i = c == 18?7:c - 14; - j = c == 18?11:3; - - while (k < (t + i)) - { - if (n != 0) - { - r = Z_OK; - } - else - { - bitb = b; bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - ; - n--; - b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - b = SupportClass.URShift(b, (t)); k -= (t); - - j += (b & inflate_mask[i]); - - b = SupportClass.URShift(b, (i)); k -= (i); - - i = index; - t = table; - if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) - { - blens = null; - mode = BAD; - z.msg = "invalid bit length repeat"; - r = Z_DATA_ERROR; - - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - - c = c == 16?blens[i - 1]:0; - do - { - blens[i++] = c; - } - while (--j != 0); - index = i; - } - } - - tb[0] = - 1; - { - int[] bl = new int[1]; - int[] bd = new int[1]; - int[] tl = new int[1]; - int[] td = new int[1]; - - - bl[0] = 9; // must be <= 9 for lookahead assumptions - bd[0] = 6; // must be <= 9 for lookahead assumptions - t = table; - t = InfTree.inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), blens, bl, bd, tl, td, hufts, z); - if (t != Z_OK) - { - if (t == Z_DATA_ERROR) - { - blens = null; - mode = BAD; - } - r = t; - - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - - codes = new InfCodes(bl[0], bd[0], hufts, tl[0], hufts, td[0], z); - } - blens = null; - mode = CODES; - goto case CODES; - - case CODES: - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - - if ((r = codes.proc(this, z, r)) != Z_STREAM_END) - { - return inflate_flush(z, r); - } - r = Z_OK; - codes.free(z); - - p = z.next_in_index; n = z.avail_in; b = bitb; k = bitk; - q = write; m = (int) (q < read?read - q - 1:end - q); - - if (last == 0) - { - mode = TYPE; - break; - } - mode = DRY; - goto case DRY; - - case DRY: - write = q; - r = inflate_flush(z, r); - q = write; m = (int) (q < read?read - q - 1:end - q); - if (read != write) - { - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - } - mode = DONE; - goto case DONE; - - case DONE: - r = Z_STREAM_END; - - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - - case BAD: - r = Z_DATA_ERROR; - - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - - - default: - r = Z_STREAM_ERROR; - - bitb = b; bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - write = q; - return inflate_flush(z, r); - - } - } - } - - internal void free(ZStream z) - { - reset(z, null); - window = null; - hufts = null; - //ZFREE(z, s); - } - - internal void set_dictionary(byte[] d, int start, int n) - { - Array.Copy(d, start, window, 0, n); - read = write = n; - } - - // Returns true if inflate is currently at the end of a block generated - // by Z_SYNC_FLUSH or Z_FULL_FLUSH. - internal int sync_point() - { - return mode == LENS?1:0; - } - - // copy as much as possible from the sliding window to the output area - internal int inflate_flush(ZStream z, int r) - { - int n; - int p; - int q; - - // local copies of source and destination pointers - p = z.next_out_index; - q = read; - - // compute number of bytes to copy as far as end of window - n = (int) ((q <= write?write:end) - q); - if (n > z.avail_out) - n = z.avail_out; - if (n != 0 && r == Z_BUF_ERROR) - r = Z_OK; - - // update counters - z.avail_out -= n; - z.total_out += n; - - // update check information - if (checkfn != null) - z.adler = check = z._adler.adler32(check, window, q, n); - - // copy as far as end of window - Array.Copy(window, q, z.next_out, p, n); - p += n; - q += n; - - // see if more to copy at beginning of window - if (q == end) - { - // wrap pointers - q = 0; - if (write == end) - write = 0; - - // compute bytes to copy - n = write - q; - if (n > z.avail_out) - n = z.avail_out; - if (n != 0 && r == Z_BUF_ERROR) - r = Z_OK; - - // update counters - z.avail_out -= n; - z.total_out += n; - - // update check information - if (checkfn != null) - z.adler = check = z._adler.adler32(check, window, q, n); - - // copy - Array.Copy(window, q, z.next_out, p, n); - p += n; - q += n; - } - - // update pointers - z.next_out_index = p; - read = q; - - // done - return r; - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfCodes.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfCodes.cs deleted file mode 100644 index d8124ba..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfCodes.cs +++ /dev/null @@ -1,716 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - sealed class InfCodes - { - - private static readonly int[] inflate_mask = new int[]{0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff}; - - private const int Z_OK = 0; - private const int Z_STREAM_END = 1; - private const int Z_NEED_DICT = 2; - private const int Z_ERRNO = - 1; - private const int Z_STREAM_ERROR = - 2; - private const int Z_DATA_ERROR = - 3; - private const int Z_MEM_ERROR = - 4; - private const int Z_BUF_ERROR = - 5; - private const int Z_VERSION_ERROR = - 6; - - // waiting for "i:"=input, - // "o:"=output, - // "x:"=nothing - private const int START = 0; // x: set up for LEN - private const int LEN = 1; // i: get length/literal/eob next - private const int LENEXT = 2; // i: getting length extra (have base) - private const int DIST = 3; // i: get distance next - private const int DISTEXT = 4; // i: getting distance extra - private const int COPY = 5; // o: copying bytes in window, waiting for space - private const int LIT = 6; // o: got literal, waiting for output space - private const int WASH = 7; // o: got eob, possibly still output waiting - private const int END = 8; // x: got eob and all data flushed - private const int BADCODE = 9; // x: got error - - internal int mode; // current inflate_codes mode - - // mode dependent information - internal int len; - - internal int[] tree; // pointer into tree - internal int tree_index = 0; - internal int need; // bits needed - - internal int lit; - - // if EXT or COPY, where and how much - internal int get_Renamed; // bits to get for extra - internal int dist; // distance back to copy from - - internal byte lbits; // ltree bits decoded per branch - internal byte dbits; // dtree bits decoder per branch - internal int[] ltree; // literal/length/eob tree - internal int ltree_index; // literal/length/eob tree - internal int[] dtree; // distance tree - internal int dtree_index; // distance tree - - internal InfCodes(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, ZStream z) - { - mode = START; - lbits = (byte) bl; - dbits = (byte) bd; - ltree = tl; - ltree_index = tl_index; - dtree = td; - dtree_index = td_index; - } - - internal InfCodes(int bl, int bd, int[] tl, int[] td, ZStream z) - { - mode = START; - lbits = (byte) bl; - dbits = (byte) bd; - ltree = tl; - ltree_index = 0; - dtree = td; - dtree_index = 0; - } - - internal int proc(InfBlocks s, ZStream z, int r) - { - int j; // temporary storage - //int[] t; // temporary pointer - int tindex; // temporary pointer - int e; // extra bits or operation - int b = 0; // bit buffer - int k = 0; // bits in bit buffer - int p = 0; // input data pointer - int n; // bytes available there - int q; // output window write pointer - int m; // bytes to end of window or read pointer - int f; // pointer to copy strings from - - // copy input/output information to locals (UPDATE macro restores) - p = z.next_in_index; n = z.avail_in; b = s.bitb; k = s.bitk; - q = s.write; m = q < s.read?s.read - q - 1:s.end - q; - - // process input and output based on current state - while (true) - { - switch (mode) - { - - // waiting for "i:"=input, "o:"=output, "x:"=nothing - case START: // x: set up for LEN - if (m >= 258 && n >= 10) - { - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z); - - p = z.next_in_index; n = z.avail_in; b = s.bitb; k = s.bitk; - q = s.write; m = q < s.read?s.read - q - 1:s.end - q; - - if (r != Z_OK) - { - mode = r == Z_STREAM_END?WASH:BADCODE; - break; - } - } - need = lbits; - tree = ltree; - tree_index = ltree_index; - - mode = LEN; - goto case LEN; - - case LEN: // i: get length/literal/eob next - j = need; - - while (k < (j)) - { - if (n != 0) - r = Z_OK; - else - { - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - n--; - b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - tindex = (tree_index + (b & inflate_mask[j])) * 3; - - b = SupportClass.URShift(b, (tree[tindex + 1])); - k -= (tree[tindex + 1]); - - e = tree[tindex]; - - if (e == 0) - { - // literal - lit = tree[tindex + 2]; - mode = LIT; - break; - } - if ((e & 16) != 0) - { - // length - get_Renamed = e & 15; - len = tree[tindex + 2]; - mode = LENEXT; - break; - } - if ((e & 64) == 0) - { - // next table - need = e; - tree_index = tindex / 3 + tree[tindex + 2]; - break; - } - if ((e & 32) != 0) - { - // end of block - mode = WASH; - break; - } - mode = BADCODE; // invalid code - z.msg = "invalid literal/length code"; - r = Z_DATA_ERROR; - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - - - case LENEXT: // i: getting length extra (have base) - j = get_Renamed; - - while (k < (j)) - { - if (n != 0) - r = Z_OK; - else - { - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - n--; b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - len += (b & inflate_mask[j]); - - b >>= j; - k -= j; - - need = dbits; - tree = dtree; - tree_index = dtree_index; - mode = DIST; - goto case DIST; - - case DIST: // i: get distance next - j = need; - - while (k < (j)) - { - if (n != 0) - r = Z_OK; - else - { - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - n--; b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - tindex = (tree_index + (b & inflate_mask[j])) * 3; - - b >>= tree[tindex + 1]; - k -= tree[tindex + 1]; - - e = (tree[tindex]); - if ((e & 16) != 0) - { - // distance - get_Renamed = e & 15; - dist = tree[tindex + 2]; - mode = DISTEXT; - break; - } - if ((e & 64) == 0) - { - // next table - need = e; - tree_index = tindex / 3 + tree[tindex + 2]; - break; - } - mode = BADCODE; // invalid code - z.msg = "invalid distance code"; - r = Z_DATA_ERROR; - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - - - case DISTEXT: // i: getting distance extra - j = get_Renamed; - - while (k < (j)) - { - if (n != 0) - r = Z_OK; - else - { - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - n--; b |= (z.next_in[p++] & 0xff) << k; - k += 8; - } - - dist += (b & inflate_mask[j]); - - b >>= j; - k -= j; - - mode = COPY; - goto case COPY; - - case COPY: // o: copying bytes in window, waiting for space - f = q - dist; - while (f < 0) - { - // modulo window size-"while" instead - f += s.end; // of "if" handles invalid distances - } - while (len != 0) - { - - if (m == 0) - { - if (q == s.end && s.read != 0) - { - q = 0; m = q < s.read?s.read - q - 1:s.end - q; - } - if (m == 0) - { - s.write = q; r = s.inflate_flush(z, r); - q = s.write; m = q < s.read?s.read - q - 1:s.end - q; - - if (q == s.end && s.read != 0) - { - q = 0; m = q < s.read?s.read - q - 1:s.end - q; - } - - if (m == 0) - { - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - } - } - - s.window[q++] = s.window[f++]; m--; - - if (f == s.end) - f = 0; - len--; - } - mode = START; - break; - - case LIT: // o: got literal, waiting for output space - if (m == 0) - { - if (q == s.end && s.read != 0) - { - q = 0; m = q < s.read?s.read - q - 1:s.end - q; - } - if (m == 0) - { - s.write = q; r = s.inflate_flush(z, r); - q = s.write; m = q < s.read?s.read - q - 1:s.end - q; - - if (q == s.end && s.read != 0) - { - q = 0; m = q < s.read?s.read - q - 1:s.end - q; - } - if (m == 0) - { - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - } - } - r = Z_OK; - - s.window[q++] = (byte) lit; m--; - - mode = START; - break; - - case WASH: // o: got eob, possibly more output - if (k > 7) - { - // return unused byte, if any - k -= 8; - n++; - p--; // can always return one - } - - s.write = q; r = s.inflate_flush(z, r); - q = s.write; m = q < s.read?s.read - q - 1:s.end - q; - - if (s.read != s.write) - { - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - mode = END; - goto case END; - - case END: - r = Z_STREAM_END; - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - - - case BADCODE: // x: got error - - r = Z_DATA_ERROR; - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - - - default: - r = Z_STREAM_ERROR; - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - - } - } - } - - internal void free(ZStream z) - { - // ZFREE(z, c); - } - - // Called with number of bytes left to write in window at least 258 - // (the maximum string length) and number of input bytes available - // at least ten. The ten bytes are six bytes for the longest length/ - // distance pair plus four bytes for overloading the bit buffer. - - internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z) - { - int t; // temporary pointer - int[] tp; // temporary pointer - int tp_index; // temporary pointer - int e; // extra bits or operation - int b; // bit buffer - int k; // bits in bit buffer - int p; // input data pointer - int n; // bytes available there - int q; // output window write pointer - int m; // bytes to end of window or read pointer - int ml; // mask for literal/length tree - int md; // mask for distance tree - int c; // bytes to copy - int d; // distance back to copy from - int r; // copy source pointer - - // load input, output, bit values - p = z.next_in_index; n = z.avail_in; b = s.bitb; k = s.bitk; - q = s.write; m = q < s.read?s.read - q - 1:s.end - q; - - // initialize masks - ml = inflate_mask[bl]; - md = inflate_mask[bd]; - - // do until not enough input or output space for fast loop - do - { - // assume called with m >= 258 && n >= 10 - // get literal/length code - while (k < (20)) - { - // max bits for literal/length code - n--; - b |= (z.next_in[p++] & 0xff) << k; k += 8; - } - - t = b & ml; - tp = tl; - tp_index = tl_index; - if ((e = tp[(tp_index + t) * 3]) == 0) - { - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - s.window[q++] = (byte) tp[(tp_index + t) * 3 + 2]; - m--; - continue; - } - do - { - - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - if ((e & 16) != 0) - { - e &= 15; - c = tp[(tp_index + t) * 3 + 2] + ((int) b & inflate_mask[e]); - - b >>= e; k -= e; - - // decode distance base of block to copy - while (k < (15)) - { - // max bits for distance code - n--; - b |= (z.next_in[p++] & 0xff) << k; k += 8; - } - - t = b & md; - tp = td; - tp_index = td_index; - e = tp[(tp_index + t) * 3]; - - do - { - - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - if ((e & 16) != 0) - { - // get extra bits to add to distance base - e &= 15; - while (k < (e)) - { - // get extra bits (up to 13) - n--; - b |= (z.next_in[p++] & 0xff) << k; k += 8; - } - - d = tp[(tp_index + t) * 3 + 2] + (b & inflate_mask[e]); - - b >>= (e); k -= (e); - - // do the copy - m -= c; - if (q >= d) - { - // offset before dest - // just copy - r = q - d; - if (q - r > 0 && 2 > (q - r)) - { - s.window[q++] = s.window[r++]; c--; // minimum count is three, - s.window[q++] = s.window[r++]; c--; // so unroll loop a little - } - else - { - Array.Copy(s.window, r, s.window, q, 2); - q += 2; r += 2; c -= 2; - } - } - else - { - // else offset after destination - r = q - d; - do - { - r += s.end; // force pointer in window - } - while (r < 0); // covers invalid distances - e = s.end - r; - if (c > e) - { - // if source crosses, - c -= e; // wrapped copy - if (q - r > 0 && e > (q - r)) - { - do - { - s.window[q++] = s.window[r++]; - } - while (--e != 0); - } - else - { - Array.Copy(s.window, r, s.window, q, e); - q += e; r += e; e = 0; - } - r = 0; // copy rest from start of window - } - } - - // copy all or what's left - if (q - r > 0 && c > (q - r)) - { - do - { - s.window[q++] = s.window[r++]; - } - while (--c != 0); - } - else - { - Array.Copy(s.window, r, s.window, q, c); - q += c; r += c; c = 0; - } - break; - } - else if ((e & 64) == 0) - { - t += tp[(tp_index + t) * 3 + 2]; - t += (b & inflate_mask[e]); - e = tp[(tp_index + t) * 3]; - } - else - { - z.msg = "invalid distance code"; - - c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - - return Z_DATA_ERROR; - } - } - while (true); - break; - } - - if ((e & 64) == 0) - { - t += tp[(tp_index + t) * 3 + 2]; - t += (b & inflate_mask[e]); - if ((e = tp[(tp_index + t) * 3]) == 0) - { - - b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]); - - s.window[q++] = (byte) tp[(tp_index + t) * 3 + 2]; - m--; - break; - } - } - else if ((e & 32) != 0) - { - - c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - - return Z_STREAM_END; - } - else - { - z.msg = "invalid literal/length code"; - - c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - - return Z_DATA_ERROR; - } - } - while (true); - } - while (m >= 258 && n >= 10); - - // not enough input or output--restore pointers and return - c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3); - - s.bitb = b; s.bitk = k; - z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p; - s.write = q; - - return Z_OK; - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfTree.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfTree.cs deleted file mode 100644 index a15c4fa..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/InfTree.cs +++ /dev/null @@ -1,377 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - sealed class InfTree - { - - private const int MANY = 1440; - - private const int Z_OK = 0; - private const int Z_STREAM_END = 1; - private const int Z_NEED_DICT = 2; - private const int Z_ERRNO = - 1; - private const int Z_STREAM_ERROR = - 2; - private const int Z_DATA_ERROR = - 3; - private const int Z_MEM_ERROR = - 4; - private const int Z_BUF_ERROR = - 5; - private const int Z_VERSION_ERROR = - 6; - - internal const int fixed_bl = 9; - internal const int fixed_bd = 5; - - - internal static readonly int[] fixed_tl = new int[]{96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186, - 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8, - 14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255}; - - internal static readonly int[] fixed_td = new int[]{80, 5, 1, 87, 5, 257, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5, 8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5, 24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577}; - - // Tables for deflate from PKZIP's appnote.txt. - internal static readonly int[] cplens = new int[]{3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - - internal static readonly int[] cplext = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; - - internal static readonly int[] cpdist = new int[]{1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; - - internal static readonly int[] cpdext = new int[]{0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; - - // If BMAX needs to be larger than 16, then h and x[] should be uLong. - internal const int BMAX = 15; // maximum bit length of any code - - internal static int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v) - { - // Given a list of code lengths and a maximum table size, make a set of - // tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR - // if the given code set is incomplete (the tables are still built in this - // case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of - // lengths), or Z_MEM_ERROR if not enough memory. - - int a; // counter for codes of length k - int[] c = new int[BMAX + 1]; // bit length count table - int f; // i repeats in table every f entries - int g; // maximum code length - int h; // table level - int i; // counter, current code - int j; // counter - int k; // number of bits in current code - int l; // bits per table (returned in m) - int mask; // (1 << w) - 1, to avoid cc -O bug on HP - int p; // pointer into c[], b[], or v[] - int q; // points to current table - int[] r = new int[3]; // table entry for structure assignment - int[] u = new int[BMAX]; // table stack - int w; // bits before this table == (l * h) - int[] x = new int[BMAX + 1]; // bit offsets, then code stack - int xp; // pointer into x - int y; // number of dummy codes added - int z; // number of entries in current table - - // Generate counts for each bit length - - p = 0; i = n; - do - { - c[b[bindex + p]]++; p++; i--; // assume all entries <= BMAX - } - while (i != 0); - - if (c[0] == n) - { - // null input--all zero length codes - t[0] = - 1; - m[0] = 0; - return Z_OK; - } - - // Find minimum and maximum length, bound *m by those - l = m[0]; - for (j = 1; j <= BMAX; j++) - if (c[j] != 0) - break; - k = j; // minimum code length - if (l < j) - { - l = j; - } - for (i = BMAX; i != 0; i--) - { - if (c[i] != 0) - break; - } - g = i; // maximum code length - if (l > i) - { - l = i; - } - m[0] = l; - - // Adjust last length count to fill out codes, if needed - for (y = 1 << j; j < i; j++, y <<= 1) - { - if ((y -= c[j]) < 0) - { - return Z_DATA_ERROR; - } - } - if ((y -= c[i]) < 0) - { - return Z_DATA_ERROR; - } - c[i] += y; - - // Generate starting offsets into the value table for each length - x[1] = j = 0; - p = 1; xp = 2; - while (--i != 0) - { - // note that i == g from above - x[xp] = (j += c[p]); - xp++; - p++; - } - - // Make a table of values in order of bit lengths - i = 0; p = 0; - do - { - if ((j = b[bindex + p]) != 0) - { - v[x[j]++] = i; - } - p++; - } - while (++i < n); - n = x[g]; // set n to length of v - - // Generate the Huffman codes and for each, make the table entries - x[0] = i = 0; // first Huffman code is zero - p = 0; // grab values in bit order - h = - 1; // no tables yet--level -1 - w = - l; // bits decoded == (l * h) - u[0] = 0; // just to keep compilers happy - q = 0; // ditto - z = 0; // ditto - - // go through the bit lengths (k already is bits in shortest code) - for (; k <= g; k++) - { - a = c[k]; - while (a-- != 0) - { - // here i is the Huffman code of length k bits for value *p - // make tables up to required level - while (k > w + l) - { - h++; - w += l; // previous table always l bits - // compute minimum size table less than or equal to l bits - z = g - w; - z = (z > l)?l:z; // table size upper limit - if ((f = 1 << (j = k - w)) > a + 1) - { - // try a k-w bit table - // too few codes for k-w bit table - f -= (a + 1); // deduct codes from patterns left - xp = k; - if (j < z) - { - while (++j < z) - { - // try smaller tables up to z bits - if ((f <<= 1) <= c[++xp]) - break; // enough codes to use up j bits - f -= c[xp]; // else deduct codes from patterns - } - } - } - z = 1 << j; // table entries for j-bit table - - // allocate new table - if (hn[0] + z > MANY) - // (note: doesn't matter for fixed) - return Z_DATA_ERROR; // overflow of MANY - u[h] = q = hn[0]; // DEBUG - hn[0] += z; - - // connect to last table, if there is one - if (h != 0) - { - x[h] = i; // save pattern for backing up - r[0] = (byte) j; // bits in this table - r[1] = (byte) l; // bits to dump before this table - j = SupportClass.URShift(i, (w - l)); - r[2] = (int) (q - u[h - 1] - j); // offset to this table - Array.Copy(r, 0, hp, (u[h - 1] + j) * 3, 3); // connect to last table - } - else - { - t[0] = q; // first table is returned result - } - } - - // set up table entry in r - r[1] = (byte) (k - w); - if (p >= n) - { - r[0] = 128 + 64; // out of values--invalid code - } - else if (v[p] < s) - { - r[0] = (byte) (v[p] < 256?0:32 + 64); // 256 is end-of-block - r[2] = v[p++]; // simple code is just the value - } - else - { - r[0] = (byte) (e[v[p] - s] + 16 + 64); // non-simple--look up in lists - r[2] = d[v[p++] - s]; - } - - // fill code-like entries with r - f = 1 << (k - w); - for (j = SupportClass.URShift(i, w); j < z; j += f) - { - Array.Copy(r, 0, hp, (q + j) * 3, 3); - } - - // backwards increment the k-bit code i - for (j = 1 << (k - 1); (i & j) != 0; j = SupportClass.URShift(j, 1)) - { - i ^= j; - } - i ^= j; - - // backup over finished tables - mask = (1 << w) - 1; // needed on HP, cc -O bug - while ((i & mask) != x[h]) - { - h--; // don't need to update q - w -= l; - mask = (1 << w) - 1; - } - } - } - // Return Z_BUF_ERROR if we were given an incomplete table - return y != 0 && g != 1?Z_BUF_ERROR:Z_OK; - } - - internal static int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZStream z) - { - int r; - int[] hn = new int[1]; // hufts used in space - int[] v = new int[19]; // work area for huft_build - - r = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v); - - if (r == Z_DATA_ERROR) - { - z.msg = "oversubscribed dynamic bit lengths tree"; - } - else if (r == Z_BUF_ERROR || bb[0] == 0) - { - z.msg = "incomplete dynamic bit lengths tree"; - r = Z_DATA_ERROR; - } - return r; - } - - internal static int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZStream z) - { - int r; - int[] hn = new int[1]; // hufts used in space - int[] v = new int[288]; // work area for huft_build - - // build literal/length tree - r = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v); - if (r != Z_OK || bl[0] == 0) - { - if (r == Z_DATA_ERROR) - { - z.msg = "oversubscribed literal/length tree"; - } - else if (r != Z_MEM_ERROR) - { - z.msg = "incomplete literal/length tree"; - r = Z_DATA_ERROR; - } - return r; - } - - // build distance tree - r = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v); - - if (r != Z_OK || (bd[0] == 0 && nl > 257)) - { - if (r == Z_DATA_ERROR) - { - z.msg = "oversubscribed distance tree"; - } - else if (r == Z_BUF_ERROR) - { - z.msg = "incomplete distance tree"; - r = Z_DATA_ERROR; - } - else if (r != Z_MEM_ERROR) - { - z.msg = "empty distance tree with lengths"; - r = Z_DATA_ERROR; - } - return r; - } - - return Z_OK; - } - - internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZStream z) - { - bl[0] = fixed_bl; - bd[0] = fixed_bd; - tl[0] = fixed_tl; - td[0] = fixed_td; - return Z_OK; - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Inflate.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Inflate.cs deleted file mode 100644 index 25b2019..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Inflate.cs +++ /dev/null @@ -1,450 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - sealed class Inflate - { - - private const int MAX_WBITS = 15; // 32K LZ77 window - - // preset dictionary flag in zlib header - private const int PRESET_DICT = 0x20; - - internal const int Z_NO_FLUSH = 0; - internal const int Z_PARTIAL_FLUSH = 1; - internal const int Z_SYNC_FLUSH = 2; - internal const int Z_FULL_FLUSH = 3; - internal const int Z_FINISH = 4; - - private const int Z_DEFLATED = 8; - - private const int Z_OK = 0; - private const int Z_STREAM_END = 1; - private const int Z_NEED_DICT = 2; - private const int Z_ERRNO = - 1; - private const int Z_STREAM_ERROR = - 2; - private const int Z_DATA_ERROR = - 3; - private const int Z_MEM_ERROR = - 4; - private const int Z_BUF_ERROR = - 5; - private const int Z_VERSION_ERROR = - 6; - - private const int METHOD = 0; // waiting for method byte - private const int FLAG = 1; // waiting for flag byte - private const int DICT4 = 2; // four dictionary check bytes to go - private const int DICT3 = 3; // three dictionary check bytes to go - private const int DICT2 = 4; // two dictionary check bytes to go - private const int DICT1 = 5; // one dictionary check byte to go - private const int DICT0 = 6; // waiting for inflateSetDictionary - private const int BLOCKS = 7; // decompressing blocks - private const int CHECK4 = 8; // four check bytes to go - private const int CHECK3 = 9; // three check bytes to go - private const int CHECK2 = 10; // two check bytes to go - private const int CHECK1 = 11; // one check byte to go - private const int DONE = 12; // finished check, done - private const int BAD = 13; // got an error--stay here - - internal int mode; // current inflate mode - - // mode dependent information - internal int method; // if FLAGS, method byte - - // if CHECK, check values to compare - internal long[] was = new long[1]; // computed check value - internal long need; // stream check value - - // if BAD, inflateSync's marker bytes count - internal int marker; - - // mode independent information - internal int nowrap; // flag for no wrapper - internal int wbits; // log2(window size) (8..15, defaults to 15) - - internal InfBlocks blocks; // current inflate_blocks state - - internal int inflateReset(ZStream z) - { - if (z == null || z.istate == null) - return Z_STREAM_ERROR; - - z.total_in = z.total_out = 0; - z.msg = null; - z.istate.mode = z.istate.nowrap != 0?BLOCKS:METHOD; - z.istate.blocks.reset(z, null); - return Z_OK; - } - - internal int inflateEnd(ZStream z) - { - if (blocks != null) - blocks.free(z); - blocks = null; - // ZFREE(z, z->state); - return Z_OK; - } - - internal int inflateInit(ZStream z, int w) - { - z.msg = null; - blocks = null; - - // handle undocumented nowrap option (no zlib header or check) - nowrap = 0; - if (w < 0) - { - w = - w; - nowrap = 1; - } - - // set window size - if (w < 8 || w > 15) - { - inflateEnd(z); - return Z_STREAM_ERROR; - } - wbits = w; - - z.istate.blocks = new InfBlocks(z, z.istate.nowrap != 0?null:this, 1 << w); - - // reset state - inflateReset(z); - return Z_OK; - } - - internal int inflate(ZStream z, int f) - { - int r; - int b; - - if (z == null || z.istate == null || z.next_in == null) - return Z_STREAM_ERROR; - f = f == Z_FINISH?Z_BUF_ERROR:Z_OK; - r = Z_BUF_ERROR; - while (true) - { - //System.out.println("mode: "+z.istate.mode); - switch (z.istate.mode) - { - - case METHOD: - - if (z.avail_in == 0) - return r; r = f; - - z.avail_in--; z.total_in++; - if (((z.istate.method = z.next_in[z.next_in_index++]) & 0xf) != Z_DEFLATED) - { - z.istate.mode = BAD; - z.msg = "unknown compression method"; - z.istate.marker = 5; // can't try inflateSync - break; - } - if ((z.istate.method >> 4) + 8 > z.istate.wbits) - { - z.istate.mode = BAD; - z.msg = "invalid window size"; - z.istate.marker = 5; // can't try inflateSync - break; - } - z.istate.mode = FLAG; - goto case FLAG; - - case FLAG: - - if (z.avail_in == 0) - return r; r = f; - - z.avail_in--; z.total_in++; - b = (z.next_in[z.next_in_index++]) & 0xff; - - if ((((z.istate.method << 8) + b) % 31) != 0) - { - z.istate.mode = BAD; - z.msg = "incorrect header check"; - z.istate.marker = 5; // can't try inflateSync - break; - } - - if ((b & PRESET_DICT) == 0) - { - z.istate.mode = BLOCKS; - break; - } - z.istate.mode = DICT4; - goto case DICT4; - - case DICT4: - - if (z.avail_in == 0) - return r; r = f; - - z.avail_in--; z.total_in++; - z.istate.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int) 0xff000000L); - z.istate.mode = DICT3; - goto case DICT3; - - case DICT3: - - if (z.avail_in == 0) - return r; r = f; - - z.avail_in--; z.total_in++; - z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L); - z.istate.mode = DICT2; - goto case DICT2; - - case DICT2: - - if (z.avail_in == 0) - return r; r = f; - - z.avail_in--; z.total_in++; - z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L); - z.istate.mode = DICT1; - goto case DICT1; - - case DICT1: - - if (z.avail_in == 0) - return r; r = f; - - z.avail_in--; z.total_in++; - z.istate.need += (z.next_in[z.next_in_index++] & 0xffL); - z.adler = z.istate.need; - z.istate.mode = DICT0; - return Z_NEED_DICT; - - case DICT0: - z.istate.mode = BAD; - z.msg = "need dictionary"; - z.istate.marker = 0; // can try inflateSync - return Z_STREAM_ERROR; - - case BLOCKS: - - r = z.istate.blocks.proc(z, r); - if (r == Z_DATA_ERROR) - { - z.istate.mode = BAD; - z.istate.marker = 0; // can try inflateSync - break; - } - if (r == Z_OK) - { - r = f; - } - if (r != Z_STREAM_END) - { - return r; - } - r = f; - z.istate.blocks.reset(z, z.istate.was); - if (z.istate.nowrap != 0) - { - z.istate.mode = DONE; - break; - } - z.istate.mode = CHECK4; - goto case CHECK4; - - case CHECK4: - - if (z.avail_in == 0) - return r; r = f; - - z.avail_in--; z.total_in++; - z.istate.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int) 0xff000000L); - z.istate.mode = CHECK3; - goto case CHECK3; - - case CHECK3: - - if (z.avail_in == 0) - return r; r = f; - - z.avail_in--; z.total_in++; - z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L); - z.istate.mode = CHECK2; - goto case CHECK2; - - case CHECK2: - - if (z.avail_in == 0) - return r; r = f; - - z.avail_in--; z.total_in++; - z.istate.need += (((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L); - z.istate.mode = CHECK1; - goto case CHECK1; - - case CHECK1: - - if (z.avail_in == 0) - return r; r = f; - - z.avail_in--; z.total_in++; - z.istate.need += (z.next_in[z.next_in_index++] & 0xffL); - - if (((int) (z.istate.was[0])) != ((int) (z.istate.need))) - { - z.istate.mode = BAD; - z.msg = "incorrect data check"; - z.istate.marker = 5; // can't try inflateSync - break; - } - - z.istate.mode = DONE; - goto case DONE; - - case DONE: - return Z_STREAM_END; - - case BAD: - return Z_DATA_ERROR; - - default: - return Z_STREAM_ERROR; - - } - } - } - - - internal int inflateSetDictionary(ZStream z, byte[] dictionary, int dictLength) - { - int index = 0; - int length = dictLength; - if (z == null || z.istate == null || z.istate.mode != DICT0) - return Z_STREAM_ERROR; - - if (z._adler.adler32(1L, dictionary, 0, dictLength) != z.adler) - { - return Z_DATA_ERROR; - } - - z.adler = z._adler.adler32(0, null, 0, 0); - - if (length >= (1 << z.istate.wbits)) - { - length = (1 << z.istate.wbits) - 1; - index = dictLength - length; - } - z.istate.blocks.set_dictionary(dictionary, index, length); - z.istate.mode = BLOCKS; - return Z_OK; - } - - private static byte[] mark = new byte[]{(byte) 0, (byte) 0, (byte) SupportClass.Identity(0xff), (byte) SupportClass.Identity(0xff)}; - - internal int inflateSync(ZStream z) - { - int n; // number of bytes to look at - int p; // pointer to bytes - int m; // number of marker bytes found in a row - long r, w; // temporaries to save total_in and total_out - - // set up - if (z == null || z.istate == null) - return Z_STREAM_ERROR; - if (z.istate.mode != BAD) - { - z.istate.mode = BAD; - z.istate.marker = 0; - } - if ((n = z.avail_in) == 0) - return Z_BUF_ERROR; - p = z.next_in_index; - m = z.istate.marker; - - // search - while (n != 0 && m < 4) - { - if (z.next_in[p] == mark[m]) - { - m++; - } - else if (z.next_in[p] != 0) - { - m = 0; - } - else - { - m = 4 - m; - } - p++; n--; - } - - // restore - z.total_in += p - z.next_in_index; - z.next_in_index = p; - z.avail_in = n; - z.istate.marker = m; - - // return no joy or set up to restart on a new block - if (m != 4) - { - return Z_DATA_ERROR; - } - r = z.total_in; w = z.total_out; - inflateReset(z); - z.total_in = r; z.total_out = w; - z.istate.mode = BLOCKS; - return Z_OK; - } - - // Returns true if inflate is currently at the end of a block generated - // by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - // implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH - // but removes the length bytes of the resulting empty stored block. When - // decompressing, PPP checks that at the end of input packet, inflate is - // waiting for these length bytes. - internal int inflateSyncPoint(ZStream z) - { - if (z == null || z.istate == null || z.istate.blocks == null) - return Z_STREAM_ERROR; - return z.istate.blocks.sync_point(); - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/StaticTree.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/StaticTree.cs deleted file mode 100644 index b1db3cf..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/StaticTree.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - sealed class StaticTree - { - private const int MAX_BITS = 15; - - private const int BL_CODES = 19; - private const int D_CODES = 30; - private const int LITERALS = 256; - private const int LENGTH_CODES = 29; - private static readonly int L_CODES = (LITERALS + 1 + LENGTH_CODES); - - // Bit length codes must not exceed MAX_BL_BITS bits - internal const int MAX_BL_BITS = 7; - - internal static readonly short[] static_ltree = new short[]{12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8, 2, 8, 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8, 18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8, 10, 8, 138, 8, 74, 8, 202, 8, 42, 8, 170, 8, 106, 8, 234, 8, 26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8, 6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8, 22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8, 14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8, 30, 8, 158, 8, 94, 8, 222, 8, 62, 8, 190, 8, 126, 8, 254, 8, 1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8, 17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, 8, 241, 8, 9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8, 25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8, 5, 8, 133, 8, 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8, 21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8, 13, 8, 141, 8, 77, 8, 205, 8, 45, 8, 173, 8, 109, 8, 237, 8, 29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8, 19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9, 51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9, 11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9, 43, 9, 299, 9, 171, 9, 427, 9, 107, 9, 363, 9, 235, 9, 491, 9, 27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9, 59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, 9, 251, 9, 507, 9, 7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9, 39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9, 23, 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9, 55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9, 15, 9, 271, 9, 143, 9, 399, 9, 79, 9, 335, 9, 207, 9, 463, 9, 47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9, 31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, 223, 9, 479, 9, 63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, 511, 9, 0, 7, 64, 7 - , 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7, 8, 7, 72, 7, 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7, 4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7, 3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, 99, 8, 227, 8}; - - internal static readonly short[] static_dtree = new short[]{0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5, 2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5, 1, 5, 17, 5, 9, 5, 25, 5, 5, 5, 21, 5, 13, 5, 29, 5, 3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5}; - - internal static StaticTree static_l_desc; - - internal static StaticTree static_d_desc; - - internal static StaticTree static_bl_desc; - - internal short[] static_tree; // static tree or null - internal int[] extra_bits; // extra bits for each code or null - internal int extra_base; // base index for extra_bits - internal int elems; // max number of elements in the tree - internal int max_length; // max bit length for the codes - - internal StaticTree(short[] static_tree, int[] extra_bits, int extra_base, int elems, int max_length) - { - this.static_tree = static_tree; - this.extra_bits = extra_bits; - this.extra_base = extra_base; - this.elems = elems; - this.max_length = max_length; - } - static StaticTree() - { - static_l_desc = new StaticTree(static_ltree, Tree.extra_lbits, LITERALS + 1, L_CODES, MAX_BITS); - static_d_desc = new StaticTree(static_dtree, Tree.extra_dbits, 0, D_CODES, MAX_BITS); - static_bl_desc = new StaticTree(null, Tree.extra_blbits, 0, BL_CODES, MAX_BL_BITS); - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/SupportClass.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/SupportClass.cs deleted file mode 100644 index 533fd8e..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/SupportClass.cs +++ /dev/null @@ -1,219 +0,0 @@ -using System; - -/* Contains conversion support elements such as classes, interfaces and static methods. */ -namespace zlib -{ - class SupportClass - { - /// - /// This method returns the literal value received - /// - /// The literal to return - /// The received value - public static long Identity(long literal) - { - return literal; - } - - /// - /// This method returns the literal value received - /// - /// The literal to return - /// The received value - public static ulong Identity(ulong literal) - { - return literal; - } - - /// - /// This method returns the literal value received - /// - /// The literal to return - /// The received value - public static float Identity(float literal) - { - return literal; - } - - /// - /// This method returns the literal value received - /// - /// The literal to return - /// The received value - public static double Identity(double literal) - { - return literal; - } - - /*******************************/ - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - public static int URShift(int number, int bits) - { - if ( number >= 0) - return number >> bits; - else - return (number >> bits) + (2 << ~bits); - } - - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - public static int URShift(int number, long bits) - { - return URShift(number, (int)bits); - } - - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - public static long URShift(long number, int bits) - { - if ( number >= 0) - return number >> bits; - else - return (number >> bits) + (2L << ~bits); - } - - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - public static long URShift(long number, long bits) - { - return URShift(number, (int)bits); - } - - /*******************************/ - /// Reads a number of characters from the current source Stream and writes the data to the target array at the specified index. - /// The source Stream to read from. - /// Contains the array of characteres read from the source Stream. - /// The starting index of the target array. - /// The maximum number of characters to read from the source Stream. - /// The number of characters read. The number will be less than or equal to count depending on the data available in the source Stream. Returns -1 if the end of the stream is reached. - public static System.Int32 ReadInput(System.IO.Stream sourceStream, byte[] target, int start, int count) - { - // Returns 0 bytes if not enough space in target - if (target.Length == 0) - return 0; - - byte[] receiver = new byte[target.Length]; - int bytesRead = sourceStream.Read(receiver, start, count); - - // Returns -1 if EOF - if (bytesRead == 0) - return -1; - - for(int i = start; i < start + bytesRead; i++) - target[i] = (byte)receiver[i]; - - return bytesRead; - } - - /// Reads a number of characters from the current source TextReader and writes the data to the target array at the specified index. - /// The source TextReader to read from - /// Contains the array of characteres read from the source TextReader. - /// The starting index of the target array. - /// The maximum number of characters to read from the source TextReader. - /// The number of characters read. The number will be less than or equal to count depending on the data available in the source TextReader. Returns -1 if the end of the stream is reached. - public static System.Int32 ReadInput(System.IO.TextReader sourceTextReader, byte[] target, int start, int count) - { - // Returns 0 bytes if not enough space in target - if (target.Length == 0) return 0; - - char[] charArray = new char[target.Length]; - int bytesRead = sourceTextReader.Read(charArray, start, count); - - // Returns -1 if EOF - if (bytesRead == 0) return -1; - - for(int index=start; index - /// Converts a string to an array of bytes - /// - /// The string to be converted - /// The new array of bytes - public static byte[] ToByteArray(System.String sourceString) - { - return System.Text.UTF8Encoding.UTF8.GetBytes(sourceString); - } - - /// - /// Converts an array of bytes to an array of chars - /// - /// The array of bytes to convert - /// The new array of chars - public static char[] ToCharArray(byte[] byteArray) - { - return System.Text.UTF8Encoding.UTF8.GetChars(byteArray); - } - -#if !CF - /*******************************/ - /// - /// Writes an object to the specified Stream - /// - /// The target Stream - /// The object to be sent - public static void Serialize(System.IO.Stream stream, System.Object objectToSend) - { - System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); - formatter.Serialize(stream, objectToSend); - } - - /// - /// Writes an object to the specified BinaryWriter - /// - /// The target BinaryWriter - /// The object to be sent - public static void Serialize(System.IO.BinaryWriter binaryWriter, System.Object objectToSend) - { - System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); - formatter.Serialize(binaryWriter.BaseStream, objectToSend); - } - - /*******************************/ - /// - /// Deserializes an object, or an entire graph of connected objects, and returns the object intance - /// - /// Reader instance used to read the object - /// The object instance - public static System.Object Deserialize(System.IO.BinaryReader binaryReader) - { - System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); - return formatter.Deserialize(binaryReader.BaseStream); - } - -#endif - - /*******************************/ - /// - /// Writes the exception stack trace to the received stream - /// - /// Exception to obtain information from - /// Output sream used to write to - public static void WriteStackTrace(System.Exception throwable, System.IO.TextWriter stream) - { - stream.Write(throwable.StackTrace); - stream.Flush(); - } - - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Tree.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Tree.cs deleted file mode 100644 index 73bcce0..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Tree.cs +++ /dev/null @@ -1,349 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - sealed class Tree - { - private const int MAX_BITS = 15; - private const int BL_CODES = 19; - private const int D_CODES = 30; - private const int LITERALS = 256; - private const int LENGTH_CODES = 29; - private static readonly int L_CODES = (LITERALS + 1 + LENGTH_CODES); - private static readonly int HEAP_SIZE = (2 * L_CODES + 1); - - // Bit length codes must not exceed MAX_BL_BITS bits - internal const int MAX_BL_BITS = 7; - - // end of block literal code - internal const int END_BLOCK = 256; - - // repeat previous bit length 3-6 times (2 bits of repeat count) - internal const int REP_3_6 = 16; - - // repeat a zero length 3-10 times (3 bits of repeat count) - internal const int REPZ_3_10 = 17; - - // repeat a zero length 11-138 times (7 bits of repeat count) - internal const int REPZ_11_138 = 18; - - // extra bits for each length code - internal static readonly int[] extra_lbits = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; - - // extra bits for each distance code - internal static readonly int[] extra_dbits = new int[]{0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; - - // extra bits for each bit length code - internal static readonly int[] extra_blbits = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7}; - - internal static readonly byte[] bl_order = new byte[]{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - - // The lengths of the bit length codes are sent in order of decreasing - // probability, to avoid transmitting the lengths for unused bit - // length codes. - - internal const int Buf_size = 8 * 2; - - // see definition of array dist_code below - internal const int DIST_CODE_LEN = 512; - - internal static readonly byte[] _dist_code = new byte[]{0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, 29}; - - internal static readonly byte[] _length_code = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28}; - - internal static readonly int[] base_length = new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0}; - - internal static readonly int[] base_dist = new int[]{0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576}; - - // Mapping from a distance to a distance code. dist is the distance - 1 and - // must not have side effects. _dist_code[256] and _dist_code[257] are never - // used. - internal static int d_code(int dist) - { - return ((dist) < 256?_dist_code[dist]:_dist_code[256 + (SupportClass.URShift((dist), 7))]); - } - - internal short[] dyn_tree; // the dynamic tree - internal int max_code; // largest code with non zero frequency - internal StaticTree stat_desc; // the corresponding static tree - - // Compute the optimal bit lengths for a tree and update the total bit length - // for the current block. - // IN assertion: the fields freq and dad are set, heap[heap_max] and - // above are the tree nodes sorted by increasing frequency. - // OUT assertions: the field len is set to the optimal bit length, the - // array bl_count contains the frequencies for each bit length. - // The length opt_len is updated; static_len is also updated if stree is - // not null. - internal void gen_bitlen(Deflate s) - { - short[] tree = dyn_tree; - short[] stree = stat_desc.static_tree; - int[] extra = stat_desc.extra_bits; - int base_Renamed = stat_desc.extra_base; - int max_length = stat_desc.max_length; - int h; // heap index - int n, m; // iterate over the tree elements - int bits; // bit length - int xbits; // extra bits - short f; // frequency - int overflow = 0; // number of elements with bit length too large - - for (bits = 0; bits <= MAX_BITS; bits++) - s.bl_count[bits] = 0; - - // In a first pass, compute the optimal bit lengths (which may - // overflow in the case of the bit length tree). - tree[s.heap[s.heap_max] * 2 + 1] = 0; // root of the heap - - for (h = s.heap_max + 1; h < HEAP_SIZE; h++) - { - n = s.heap[h]; - bits = tree[tree[n * 2 + 1] * 2 + 1] + 1; - if (bits > max_length) - { - bits = max_length; overflow++; - } - tree[n * 2 + 1] = (short) bits; - // We overwrite tree[n*2+1] which is no longer needed - - if (n > max_code) - continue; // not a leaf node - - s.bl_count[bits]++; - xbits = 0; - if (n >= base_Renamed) - xbits = extra[n - base_Renamed]; - f = tree[n * 2]; - s.opt_len += f * (bits + xbits); - if (stree != null) - s.static_len += f * (stree[n * 2 + 1] + xbits); - } - if (overflow == 0) - return ; - - // This happens for example on obj2 and pic of the Calgary corpus - // Find the first bit length which could increase: - do - { - bits = max_length - 1; - while (s.bl_count[bits] == 0) - bits--; - s.bl_count[bits]--; // move one leaf down the tree - s.bl_count[bits + 1] = (short) (s.bl_count[bits + 1] + 2); // move one overflow item as its brother - s.bl_count[max_length]--; - // The brother of the overflow item also moves one step up, - // but this does not affect bl_count[max_length] - overflow -= 2; - } - while (overflow > 0); - - for (bits = max_length; bits != 0; bits--) - { - n = s.bl_count[bits]; - while (n != 0) - { - m = s.heap[--h]; - if (m > max_code) - continue; - if (tree[m * 2 + 1] != bits) - { - s.opt_len = (int) (s.opt_len + ((long) bits - (long) tree[m * 2 + 1]) * (long) tree[m * 2]); - tree[m * 2 + 1] = (short) bits; - } - n--; - } - } - } - - // Construct one Huffman tree and assigns the code bit strings and lengths. - // Update the total bit length for the current block. - // IN assertion: the field freq is set for all tree elements. - // OUT assertions: the fields len and code are set to the optimal bit length - // and corresponding code. The length opt_len is updated; static_len is - // also updated if stree is not null. The field max_code is set. - internal void build_tree(Deflate s) - { - short[] tree = dyn_tree; - short[] stree = stat_desc.static_tree; - int elems = stat_desc.elems; - int n, m; // iterate over heap elements - int max_code = - 1; // largest code with non zero frequency - int node; // new node being created - - // Construct the initial heap, with least frequent element in - // heap[1]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - // heap[0] is not used. - s.heap_len = 0; - s.heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) - { - if (tree[n * 2] != 0) - { - s.heap[++s.heap_len] = max_code = n; - s.depth[n] = 0; - } - else - { - tree[n * 2 + 1] = 0; - } - } - - // The pkzip format requires that at least one distance code exists, - // and that at least one bit should be sent even if there is only one - // possible code. So to avoid special checks later on we force at least - // two codes of non zero frequency. - while (s.heap_len < 2) - { - node = s.heap[++s.heap_len] = (max_code < 2?++max_code:0); - tree[node * 2] = 1; - s.depth[node] = 0; - s.opt_len--; - if (stree != null) - s.static_len -= stree[node * 2 + 1]; - // node is 0 or 1 so it does not have extra bits - } - this.max_code = max_code; - - // The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - // establish sub-heaps of increasing lengths: - - for (n = s.heap_len / 2; n >= 1; n--) - s.pqdownheap(tree, n); - - // Construct the Huffman tree by repeatedly combining the least two - // frequent nodes. - - node = elems; // next internal node of the tree - do - { - // n = node of least frequency - n = s.heap[1]; - s.heap[1] = s.heap[s.heap_len--]; - s.pqdownheap(tree, 1); - m = s.heap[1]; // m = node of next least frequency - - s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency - s.heap[--s.heap_max] = m; - - // Create a new node father of n and m - tree[node * 2] = (short) (tree[n * 2] + tree[m * 2]); - s.depth[node] = (byte) (System.Math.Max((byte) s.depth[n], (byte) s.depth[m]) + 1); - tree[n * 2 + 1] = tree[m * 2 + 1] = (short) node; - - // and insert the new node in the heap - s.heap[1] = node++; - s.pqdownheap(tree, 1); - } - while (s.heap_len >= 2); - - s.heap[--s.heap_max] = s.heap[1]; - - // At this point, the fields freq and dad are set. We can now - // generate the bit lengths. - - gen_bitlen(s); - - // The field len is now set, we can generate the bit codes - gen_codes(tree, max_code, s.bl_count); - } - - // Generate the codes for a given tree and bit counts (which need not be - // optimal). - // IN assertion: the array bl_count contains the bit length statistics for - // the given tree and the field len is set for all tree elements. - // OUT assertion: the field code is set for all tree elements of non - // zero code length. - internal static void gen_codes(short[] tree, int max_code, short[] bl_count) - { - short[] next_code = new short[MAX_BITS + 1]; // next code value for each bit length - short code = 0; // running code value - int bits; // bit index - int n; // code index - - // The distribution counts are first used to generate the code values - // without bit reversal. - for (bits = 1; bits <= MAX_BITS; bits++) - { - next_code[bits] = code = (short) ((code + bl_count[bits - 1]) << 1); - } - - // Check that the bit counts in bl_count are consistent. The last code - // must be all ones. - //Assert (code + bl_count[MAX_BITS]-1 == (1< 0); - return SupportClass.URShift(res, 1); - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZInputStream.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZInputStream.cs deleted file mode 100644 index 4799e09..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZInputStream.cs +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Copyright (c) 2001 Lapo Luchini. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - class ZInputStream : System.IO.BinaryReader - { - public long maxInput; - - private void InitBlock() - { - flush = zlibConst.Z_NO_FLUSH; - buf = new byte[bufsize]; - } - virtual public int FlushMode - { - get - { - return (flush); - } - - set - { - this.flush = value; - } - - } - /// Returns the total number of bytes input so far. - virtual public long TotalIn - { - get - { - return z.total_in; - } - - } - /// Returns the total number of bytes output so far. - virtual public long TotalOut - { - get - { - return z.total_out; - } - - } - - protected internal ZStream z = new ZStream(); - protected internal int bufsize = 512; - protected internal int flush; - protected internal byte[] buf, buf1 = new byte[1]; - protected internal bool compress; - - private System.IO.Stream in_Renamed = null; - - public ZInputStream(System.IO.Stream in_Renamed) - : base(in_Renamed) - { - InitBlock(); - this.in_Renamed = in_Renamed; - z.inflateInit(); - compress = false; - z.next_in = buf; - z.next_in_index = 0; - z.avail_in = 0; - } - - public ZInputStream(System.IO.Stream in_Renamed, int level) - : base(in_Renamed) - { - InitBlock(); - this.in_Renamed = in_Renamed; - z.deflateInit(level); - compress = true; - z.next_in = buf; - z.next_in_index = 0; - z.avail_in = 0; - } - - /*public int available() throws IOException { - return inf.finished() ? 0 : 1; - }*/ - - public override int Read() - { - if (read(buf1, 0, 1) == -1) - return (-1); - return (buf1[0] & 0xFF); - } - - private bool nomoreinput = false; - - public int read(byte[] b, int off, int len) - { - if (len == 0) - return (0); - int err; - z.next_out = b; - z.next_out_index = off; - z.avail_out = len; - do - { - if ((z.avail_in == 0) && (!nomoreinput)) - { - // if buffer is empty and more input is avaiable, refill it - z.next_in_index = 0; - - int inToRead = bufsize; - if (maxInput > 0) - { - if (TotalIn < maxInput) - inToRead = (int)(Math.Min(maxInput - TotalIn, (long)bufsize)); - else - z.avail_in = -1; - } - if (z.avail_in != -1) - z.avail_in = SupportClass.ReadInput(in_Renamed, buf, 0, inToRead); //(bufsize 0 && err == zlibConst.Z_OK); - //while (z.avail_out == len && err == zlibConst.Z_OK); - //System.err.print("("+(len-z.avail_out)+")"); - return (len - z.avail_out); - } - - public long skip(long n) - { - int len = 512; - if (n < len) - len = (int)n; - byte[] tmp = new byte[len]; - return ((long)SupportClass.ReadInput(BaseStream, tmp, 0, tmp.Length)); - } - - public override void Close() - { - in_Renamed.Close(); - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZOutputStream.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZOutputStream.cs deleted file mode 100644 index 070be30..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZOutputStream.cs +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -/* -Copyright (c) 2001 Lapo Luchini. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - class ZOutputStream:System.IO.Stream - { - private void InitBlock() - { - flush_Renamed_Field = zlibConst.Z_NO_FLUSH; - buf = new byte[bufsize]; - } - virtual public int FlushMode - { - get - { - return (flush_Renamed_Field); - } - - set - { - this.flush_Renamed_Field = value; - } - - } - /// Returns the total number of bytes input so far. - virtual public long TotalIn - { - get - { - return z.total_in; - } - - } - /// Returns the total number of bytes output so far. - virtual public long TotalOut - { - get - { - return z.total_out; - } - - } - - protected internal ZStream z = new ZStream(); - protected internal int bufsize = 512; - protected internal int flush_Renamed_Field; - protected internal byte[] buf, buf1 = new byte[1]; - protected internal bool compress; - - private System.IO.Stream out_Renamed; - - public ZOutputStream(System.IO.Stream out_Renamed):base() - { - InitBlock(); - this.out_Renamed = out_Renamed; - z.inflateInit(); - compress = false; - } - - public ZOutputStream(System.IO.Stream out_Renamed, int level):base() - { - InitBlock(); - this.out_Renamed = out_Renamed; - z.deflateInit(level); - compress = true; - } - - public void WriteByte(int b) - { - buf1[0] = (byte) b; - Write(buf1, 0, 1); - } - //UPGRADE_TODO: The differences in the Expected value of parameters for method 'WriteByte' may cause compilation errors. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1092_3"' - public override void WriteByte(byte b) - { - WriteByte((int) b); - } - - public override void Write(System.Byte[] b1, int off, int len) - { - if (len == 0) - return ; - int err; - byte[] b = new byte[b1.Length]; - System.Array.Copy(b1,b,b1.Length); - z.next_in = b; - z.next_in_index = off; - z.avail_in = len; - do - { - z.next_out = buf; - z.next_out_index = 0; - z.avail_out = bufsize; - if (compress) - err = z.deflate(flush_Renamed_Field); - else - err = z.inflate(flush_Renamed_Field); - if (err != zlibConst.Z_OK) - throw new ZStreamException((compress?"de":"in") + "flating: " + z.msg); - out_Renamed.Write(buf, 0, bufsize - z.avail_out); - } - while (z.avail_in > 0 || z.avail_out == 0); - } - - public virtual void finish() - { - int err; - do - { - z.next_out = buf; - z.next_out_index = 0; - z.avail_out = bufsize; - if (compress) - { - err = z.deflate(zlibConst.Z_FINISH); - } - else - { - err = z.inflate(zlibConst.Z_FINISH); - } - if (err != zlibConst.Z_STREAM_END && err != zlibConst.Z_OK) - throw new ZStreamException((compress?"de":"in") + "flating: " + z.msg); - if (bufsize - z.avail_out > 0) - { - out_Renamed.Write(buf, 0, bufsize - z.avail_out); - } - } - while (z.avail_in > 0 || z.avail_out == 0); - try - { - Flush(); - } - catch - { - } - } - public virtual void end() - { - if (compress) - { - z.deflateEnd(); - } - else - { - z.inflateEnd(); - } - z.free(); - z = null; - } - public override void Close() - { - try - { - try - { - finish(); - } - catch - { - } - } - finally - { - end(); - out_Renamed.Close(); - out_Renamed = null; - } - } - - public override void Flush() - { - out_Renamed.Flush(); - } - //UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"' - public override System.Int32 Read(System.Byte[] buffer, System.Int32 offset, System.Int32 count) - { - return 0; - } - //UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"' - public override void SetLength(System.Int64 value) - { - } - //UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"' - public override System.Int64 Seek(System.Int64 offset, System.IO.SeekOrigin origin) - { - return 0; - } - //UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"' - public override System.Boolean CanRead - { - get - { - return false; - } - - } - //UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"' - public override System.Boolean CanSeek - { - get - { - return false; - } - - } - //UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"' - public override System.Boolean CanWrite - { - get - { - return false; - } - - } - //UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"' - public override System.Int64 Length - { - get - { - return 0; - } - - } - //UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"' - public override System.Int64 Position - { - get - { - return 0; - } - - set - { - } - - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZStream.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZStream.cs deleted file mode 100644 index f419c52..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZStream.cs +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - sealed class ZStream - { - - private const int MAX_WBITS = 15; // 32K LZ77 window - private static readonly int DEF_WBITS = MAX_WBITS; - - private const int Z_NO_FLUSH = 0; - private const int Z_PARTIAL_FLUSH = 1; - private const int Z_SYNC_FLUSH = 2; - private const int Z_FULL_FLUSH = 3; - private const int Z_FINISH = 4; - - private const int MAX_MEM_LEVEL = 9; - - private const int Z_OK = 0; - private const int Z_STREAM_END = 1; - private const int Z_NEED_DICT = 2; - private const int Z_ERRNO = -1; - private const int Z_STREAM_ERROR = -2; - private const int Z_DATA_ERROR = -3; - private const int Z_MEM_ERROR = -4; - private const int Z_BUF_ERROR = -5; - private const int Z_VERSION_ERROR = -6; - - public byte[] next_in; // next input byte - public int next_in_index; - public int avail_in; // number of bytes available at next_in - public long total_in; // total nb of input bytes read so far - - public byte[] next_out; // next output byte should be put there - public int next_out_index; - public int avail_out; // remaining free space at next_out - public long total_out; // total nb of bytes output so far - - public System.String msg; - - internal Deflate dstate; - internal Inflate istate; - - internal int data_type; // best guess about the data type: ascii or binary - - public long adler; - internal Adler32 _adler = new Adler32(); - - public int inflateInit() - { - return inflateInit(DEF_WBITS); - } - public int inflateInit(int w) - { - istate = new Inflate(); - return istate.inflateInit(this, w); - } - - public int inflate(int f) - { - if (istate == null) - return Z_STREAM_ERROR; - return istate.inflate(this, f); - } - public int inflateEnd() - { - if (istate == null) - return Z_STREAM_ERROR; - int ret = istate.inflateEnd(this); - istate = null; - return ret; - } - public int inflateSync() - { - if (istate == null) - return Z_STREAM_ERROR; - return istate.inflateSync(this); - } - public int inflateSetDictionary(byte[] dictionary, int dictLength) - { - if (istate == null) - return Z_STREAM_ERROR; - return istate.inflateSetDictionary(this, dictionary, dictLength); - } - - public int deflateInit(int level) - { - return deflateInit(level, MAX_WBITS); - } - public int deflateInit(int level, int bits) - { - dstate = new Deflate(); - return dstate.deflateInit(this, level, bits); - } - public int deflate(int flush) - { - if (dstate == null) - { - return Z_STREAM_ERROR; - } - return dstate.deflate(this, flush); - } - public int deflateEnd() - { - if (dstate == null) - return Z_STREAM_ERROR; - int ret = dstate.deflateEnd(); - dstate = null; - return ret; - } - public int deflateParams(int level, int strategy) - { - if (dstate == null) - return Z_STREAM_ERROR; - return dstate.deflateParams(this, level, strategy); - } - public int deflateSetDictionary(byte[] dictionary, int dictLength) - { - if (dstate == null) - return Z_STREAM_ERROR; - return dstate.deflateSetDictionary(this, dictionary, dictLength); - } - - // Flush as much pending output as possible. All deflate() output goes - // through this function so some applications may wish to modify it - // to avoid allocating a large strm->next_out buffer and copying into it. - // (See also read_buf()). - internal void flush_pending() - { - int len = dstate.pending; - - if (len > avail_out) - len = avail_out; - if (len == 0) - return; - - if (dstate.pending_buf.Length <= dstate.pending_out || next_out.Length <= next_out_index || dstate.pending_buf.Length < (dstate.pending_out + len) || next_out.Length < (next_out_index + len)) - { - System.Console.Out.WriteLine(dstate.pending_buf.Length + ", " + dstate.pending_out + ", " + next_out.Length + ", " + next_out_index + ", " + len); - System.Console.Out.WriteLine("avail_out=" + avail_out); - } - - Array.Copy(dstate.pending_buf, dstate.pending_out, next_out, next_out_index, len); - - next_out_index += len; - dstate.pending_out += len; - total_out += len; - avail_out -= len; - dstate.pending -= len; - if (dstate.pending == 0) - { - dstate.pending_out = 0; - } - } - - // Read a new buffer from the current input stream, update the adler32 - // and total number of bytes read. All deflate() input goes through - // this function so some applications may wish to modify it to avoid - // allocating a large strm->next_in buffer and copying from it. - // (See also flush_pending()). - internal int read_buf(byte[] buf, int start, int size) - { - int len = avail_in; - - if (len > size) - len = size; - if (len == 0) - return 0; - - avail_in -= len; - - if (dstate.noheader == 0) - { - adler = _adler.adler32(adler, next_in, next_in_index, len); - } - Array.Copy(next_in, next_in_index, buf, start, len); - next_in_index += len; - total_in += len; - return len; - } - - public void free() - { - next_in = null; - next_out = null; - msg = null; - _adler = null; - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZStreamException.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZStreamException.cs deleted file mode 100644 index ea3c437..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/ZStreamException.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ -// [Serializable] - class ZStreamException:System.IO.IOException - { - public ZStreamException():base() - { - } - public ZStreamException(System.String s):base(s) - { - } - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Zlib.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Zlib.cs deleted file mode 100644 index 8cf60c9..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Provider/Source/zlib/Zlib.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2006, ComponentAce -// http://www.componentace.com -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -// Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote products -derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/* -* This program is based on zlib-1.1.3, so all credit should go authors -* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) -* and contributors of zlib. -*/ -using System; -namespace zlib -{ - - sealed class zlibConst - { - private const System.String version_Renamed_Field = "1.0.2"; - public static System.String version() - { - return version_Renamed_Field; - } - - // compression levels - public const int Z_NO_COMPRESSION = 0; - public const int Z_BEST_SPEED = 1; - public const int Z_BEST_COMPRESSION = 9; - public const int Z_DEFAULT_COMPRESSION = (- 1); - - // compression strategy - public const int Z_FILTERED = 1; - public const int Z_HUFFMAN_ONLY = 2; - public const int Z_DEFAULT_STRATEGY = 0; - - public const int Z_NO_FLUSH = 0; - public const int Z_PARTIAL_FLUSH = 1; - public const int Z_SYNC_FLUSH = 2; - public const int Z_FULL_FLUSH = 3; - public const int Z_FINISH = 4; - - public const int Z_OK = 0; - public const int Z_STREAM_END = 1; - public const int Z_NEED_DICT = 2; - public const int Z_ERRNO = - 1; - public const int Z_STREAM_ERROR = - 2; - public const int Z_DATA_ERROR = - 3; - public const int Z_MEM_ERROR = - 4; - public const int Z_BUF_ERROR = - 5; - public const int Z_VERSION_ERROR = - 6; - } -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/MySql.Data.CF.Tests.csproj b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/MySql.Data.CF.Tests.csproj deleted file mode 100644 index ee1d4ca..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/MySql.Data.CF.Tests.csproj +++ /dev/null @@ -1,119 +0,0 @@ - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {710D9251-17A3-4429-9A91-63F03267F310} - Library - Properties - MySql.Data.CF.Tests - MySql.Data.CF.Tests - {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.00 - MySql.Data.Tests.CF - v2.0 - - - - - 3.5 - Windows CE - - - - - true - full - false - bin\Debug\ - TRACE;DEBUG;CF - true - true - prompt - 512 - 4 - Off - - - pdbonly - true - bin\Release\ - TRACE;CF - true - true - prompt - 512 - 4 - Off - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - {587A47FB-C1CC-459D-93B6-179D95E41EFB} - MySql.Data.CF - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/MySql.Data.Tests.csproj b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/MySql.Data.Tests.csproj deleted file mode 100644 index 64cbc2f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/MySql.Data.Tests.csproj +++ /dev/null @@ -1,148 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {F29E5B3D-7F76-4CF9-BF5E-8E3A1377B1E4} - Library - Properties - MySql.Data.MySqlClient.Tests - MySql.Data.Tests - - - 3.5 - - - v2.0 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - true - full - false - bin\Debug\ - TRACE;DEBUG;NUNIT - prompt - 4 - - - false - AllRules.ruleset - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - AllRules.ruleset - - - - - - - - - - - - Properties\VersionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {E9DF5ED1-4CBD-4226-B931-9A51610AC14D} - MySql.Data - - - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Microsoft Visual Basic PowerPacks 10.0 - true - - - False - Windows Installer 3.1 - true - - - - - \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Properties/AssemblyInfo.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 641f37e..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("MySqlClientTests")] -[assembly: AssemblyDescription("Test fixtures for MySQL Connector/Net")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("MySQL AB")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("Copyright 2004-2007, MySQL AB")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Properties/Setup.sql b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Properties/Setup.sql deleted file mode 100644 index 5a7aa5c..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Properties/Setup.sql +++ /dev/null @@ -1,17 +0,0 @@ -DROP DATABASE IF EXISTS `[database0]`; CREATE DATABASE `[database0]`; -GRANT ALL ON `[database0]`.* to 'test'@'localhost' IDENTIFIED BY 'test'; -GRANT ALL ON `[database0]`.* to 'test'@'%' IDENTIFIED BY 'test'; - -DROP DATABASE IF EXISTS `[database1]`; CREATE DATABASE `[database1]`; -GRANT ALL ON `[database1]`.* to 'test'@'localhost' IDENTIFIED BY 'test'; -GRANT ALL ON `[database1]`.* to 'test'@'%' IDENTIFIED BY 'test'; - -FLUSH PRIVILEGES; - -SET GLOBAL max_allowed_packet = 1048576; - -DELETE FROM mysql.user WHERE length(user) = 0; -DELETE FROM mysql.user WHERE user='nopass'; -DELETE FROM mysql.user WHERE user='quotedUser'; - -FLUSH PRIVILEGES; diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/AsyncTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/AsyncTests.cs deleted file mode 100644 index dc8b81c..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/AsyncTests.cs +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class AsyncTests : BaseTest - { - [Test] - public void ExecuteNonQuery() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE test (id int)"); - execSQL("CREATE PROCEDURE spTest() BEGIN SET @x=0; REPEAT INSERT INTO test VALUES(@x); " + - "SET @x=@x+1; UNTIL @x = 300 END REPEAT; END"); - - MySqlCommand proc = new MySqlCommand("spTest", conn); - proc.CommandType = CommandType.StoredProcedure; - IAsyncResult iar = proc.BeginExecuteNonQuery(); - int count = 0; - while (!iar.IsCompleted) - { - count++; - System.Threading.Thread.Sleep(20); - } - proc.EndExecuteNonQuery(iar); - Assert.IsTrue(count > 0); - - proc.CommandType = CommandType.Text; - proc.CommandText = "SELECT COUNT(*) FROM test"; - object cnt = proc.ExecuteScalar(); - Assert.AreEqual(300, cnt); - } - - [Test] - public void ExecuteReader() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE test (id int)"); - execSQL("CREATE PROCEDURE spTest() BEGIN INSERT INTO test VALUES(1); " + - "SELECT SLEEP(2); SELECT 'done'; END"); - - MySqlCommand proc = new MySqlCommand("spTest", conn); - proc.CommandType = CommandType.StoredProcedure; - IAsyncResult iar = proc.BeginExecuteReader(); - int count = 0; - while (!iar.IsCompleted) - { - count++; - System.Threading.Thread.Sleep(20); - } - - using (MySqlDataReader reader = proc.EndExecuteReader(iar)) - { - Assert.IsNotNull(reader); - Assert.IsTrue(count > 0, "count > 0"); - Assert.IsTrue(reader.Read(), "can read"); - Assert.IsTrue(reader.NextResult()); - Assert.IsTrue(reader.Read()); - Assert.AreEqual("done", reader.GetString(0)); - reader.Close(); - - proc.CommandType = CommandType.Text; - proc.CommandText = "SELECT COUNT(*) FROM test"; - object cnt = proc.ExecuteScalar(); - Assert.AreEqual(1, cnt); - } - } - - [Test] - public void ThrowingExceptions() - { - MySqlCommand cmd = new MySqlCommand("SELECT xxx", conn); - IAsyncResult r = cmd.BeginExecuteReader(); - try - { - using (MySqlDataReader reader = cmd.EndExecuteReader(r)) - { - Assert.Fail("EndExecuteReader should have thrown an exception"); - } - } - catch (MySqlException) - { - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BaseTest.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BaseTest.cs deleted file mode 100644 index 8280e52..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BaseTest.cs +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using NUnit.Framework; -using System.Configuration; -using System.Data; -using MySql.Data.MySqlClient; -using System.Reflection; -using System.Diagnostics; -using System.Resources; -using System.IO; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for BaseTest. - /// - public class BaseTest - { - //statics - protected static int maxPacketSize; - protected static MySqlConnection rootConn; - protected static string host; - protected static string user; - protected static string password; - protected static int port; - protected static string pipeName; - protected static string memoryName; - protected static string rootUser; - protected static string rootPassword; - protected static string database0; - protected static string database1; - protected static Version version; - - protected string table; - protected string csAdditions = String.Empty; - protected MySqlConnection conn; - protected bool accessToMySqlDb; - - public BaseTest() - { - if (host == null) - LoadStaticConfiguration(); - } - - protected virtual void LoadStaticConfiguration() - { - Debug.Assert(host == null); - - user = "test"; - password = "test"; - port = 3306; - rootUser = "root"; - rootPassword = ""; - - host = ConfigurationManager.AppSettings["host"]; - string strPort = ConfigurationManager.AppSettings["port"]; - pipeName = ConfigurationManager.AppSettings["pipename"]; - memoryName = ConfigurationManager.AppSettings["memory_name"]; - - if (strPort != null) - port = Int32.Parse(strPort); - if (host == null) - host = "localhost"; - if (pipeName == null) - pipeName = "MYSQL"; - if (memoryName == null) - memoryName = "MYSQL"; - - // we don't use FileVersion because it's not available - // on the compact framework - if (database0 == null) - { - string fullname = Assembly.GetExecutingAssembly().FullName; - string[] parts = fullname.Split(new char[] { '=' }); - string[] versionParts = parts[1].Split(new char[] { '.' }); - database0 = String.Format("db{0}{1}{2}-a", versionParts[0], versionParts[1], port - 3300); - database1 = String.Format("db{0}{1}{2}-b", versionParts[0], versionParts[1], port - 3300); - } - - string connStr = GetConnectionString(rootUser, rootPassword, false); - rootConn = new MySqlConnection(connStr + ";database=mysql"); - rootConn.Open(); - - if (rootConn.ServerVersion.StartsWith("5")) - { - // run all tests in strict mode - MySqlCommand cmd = new MySqlCommand("SET GLOBAL SQL_MODE=STRICT_ALL_TABLES", rootConn); - cmd.ExecuteNonQuery(); - } - } - - #region Properties - - protected Version Version - { - get - { - if (version == null) - { - string versionString = rootConn.ServerVersion; - int i = 0; - while (i < versionString.Length && - (Char.IsDigit(versionString[i]) || versionString[i] == '.')) - i++; - version = new Version(versionString.Substring(0, i)); - } - return version; - } - } - - #endregion - - protected virtual string GetConnectionInfo() - { - return String.Format("protocol=sockets;port={0}", port); - } - - protected string GetConnectionString(string userId, string pw, bool includedb) - { - Debug.Assert(userId != null); - string connStr = String.Format("server={0};user id={1};pooling=false;" + - "persist security info=true;connection reset=true;allow user variables=true;", - host, userId); - if (pw != null) - connStr += String.Format(";password={0};", pw); - if (includedb) - connStr += String.Format("database={0};", database0); - connStr += GetConnectionInfo(); - connStr += csAdditions; - return connStr; - } - - protected string GetConnectionString(bool includedb) - { - return GetConnectionString(user, password, includedb); - } - - protected string GetPoolingConnectionString() - { - string s = GetConnectionString(true); - s = s.Replace("pooling=false", "pooling=true"); - return s; - } - - protected void Open() - { - string connString = GetConnectionString(true); - conn = new MySqlConnection(connString); - conn.Open(); - } - - protected void SetAccountPerms(bool includeProc) - { - // now allow our user to access them - suExecSQL(String.Format(@"GRANT ALL ON `{0}`.* to 'test'@'localhost' - identified by 'test'", database0)); - suExecSQL(String.Format(@"GRANT SELECT ON `{0}`.* to 'test'@'localhost' - identified by 'test'", database1)); - if (Version.Major >= 5) - suExecSQL(String.Format(@"GRANT EXECUTE ON `{0}`.* to 'test'@'localhost' - identified by 'test'", database1)); - - if (includeProc) - { - // now allow our user to access them - suExecSQL(@"GRANT ALL ON mysql.proc to 'test'@'localhost' identified by 'test'"); - } - - suExecSQL("FLUSH PRIVILEGES"); - } - - [SetUp] - public virtual void Setup() - { - Assembly executingAssembly = Assembly.GetExecutingAssembly(); - Stream stream = executingAssembly.GetManifestResourceStream("MySql.Data.MySqlClient.Tests.Properties.Setup.sql"); - StreamReader sr = new StreamReader(stream); - string sql = sr.ReadToEnd(); - sr.Close(); - - SetAccountPerms(accessToMySqlDb); - sql = sql.Replace("[database0]", database0); - sql = sql.Replace("[database1]", database1); - - ExecuteSQLAsRoot(sql); - Open(); - } - - protected void ExecuteSQLAsRoot(string sql) - { - MySqlScript s = new MySqlScript(rootConn, sql); - s.Execute(); - } - - [TearDown] - public virtual void Teardown() - { - conn.Close(); - if (Version.Major < 5) - suExecSQL("REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'test'"); - else - suExecSQL("DROP USER 'test'@'localhost'"); - - // wait up to 5 seconds for our connection to close - int procs = 0; - for (int x=0; x < 50; x++) - { - procs = CountProcesses(); - if (procs == 1) break; - System.Threading.Thread.Sleep(100); - } - Assert.AreEqual(1, procs, "Too many processes still running"); - - DropDatabase(database0); - DropDatabase(database1); - } - - private void DropDatabase(string name) - { - for (int i = 0; i < 5; i++) - { - try - { - suExecSQL(String.Format("DROP DATABASE IF EXISTS `{0}`", name)); - return; - } - catch (Exception) - { - System.Threading.Thread.Sleep(1000); - } - } - Assert.Fail("Unable to drop database " + name); - } - - protected void KillConnection(MySqlConnection c) - { - int threadId = c.ServerThread; - MySqlCommand cmd = new MySqlCommand("KILL " + threadId, conn); - cmd.ExecuteNonQuery(); - - // the kill flag might need a little prodding to do its thing - try - { - cmd.CommandText = "SELECT 1"; - cmd.Connection = c; - cmd.ExecuteNonQuery(); - } - catch (Exception) { } - - // now wait till the process dies - bool processStillAlive = false; - while (true) - { - MySqlDataAdapter da = new MySqlDataAdapter("SHOW PROCESSLIST", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - foreach (DataRow row in dt.Rows) - if (row["Id"].Equals(threadId)) - processStillAlive = true; - if (!processStillAlive) break; - System.Threading.Thread.Sleep(500); - } - } - - protected void KillPooledConnection(string connStr) - { - MySqlConnection c = new MySqlConnection(connStr); - c.Open(); - KillConnection(c); - } - - protected void createTable(string sql, string engine) - { - if (Version >= new Version(4,1)) - sql += " ENGINE=" + engine; - else - sql += " TYPE=" + engine; - execSQL(sql); - } - - protected void suExecSQL(string sql) - { - Debug.Assert(rootConn != null); - MySqlCommand cmd = new MySqlCommand(sql, rootConn); - cmd.ExecuteNonQuery(); - } - - protected void execSQL(string sql) - { - MySqlCommand cmd = new MySqlCommand(sql, conn); - cmd.ExecuteNonQuery(); - } - - protected IDataReader execReader(string sql) - { - MySqlCommand cmd = new MySqlCommand(sql, conn); - return cmd.ExecuteReader(); - } - - protected int CountProcesses() - { - MySqlDataAdapter da = new MySqlDataAdapter("SHOW PROCESSLIST", rootConn); - DataTable dt = new DataTable(); - da.Fill(dt); - return dt.Rows.Count; - } - - protected bool TableExists(string tableName) - { - string[] restrictions = new string[4]; - restrictions[2] = tableName; - DataTable dt = conn.GetSchema("Tables", restrictions); - return dt.Rows.Count > 0; - } - - protected DataTable FillTable(string sql) - { - MySqlDataAdapter da = new MySqlDataAdapter(sql, conn); - DataTable dt = new DataTable(); - da.Fill(dt); - return dt; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BlobTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BlobTests.cs deleted file mode 100644 index 5dabeab..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BlobTests.cs +++ /dev/null @@ -1,366 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Threading; -using MySql.Data.MySqlClient; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for BlobTests. - /// - [TestFixture] - public class BlobTests : BaseTest - { - [Test] - public void InsertBinary() - { - int lenIn = 400000; - byte[] dataIn = Utils.CreateBlob(lenIn); - - execSQL("CREATE TABLE Test (id INT NOT NULL, blob1 LONGBLOB, PRIMARY KEY(id))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, ?b1)", conn); - cmd.Parameters.Add(new MySqlParameter("?id", 1)); - cmd.Parameters.Add(new MySqlParameter("?b1", dataIn)); - int rows = cmd.ExecuteNonQuery(); - - byte[] dataIn2 = Utils.CreateBlob(lenIn); - cmd.Parameters[0].Value = 2; - cmd.Parameters[1].Value = dataIn2; - rows += cmd.ExecuteNonQuery(); - - Assert.AreEqual(2, rows, "Checking insert rowcount"); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.AreEqual(true, reader.HasRows, "Checking HasRows"); - - reader.Read(); - - byte[] dataOut = new byte[lenIn]; - long lenOut = reader.GetBytes(1, 0, dataOut, 0, lenIn); - - Assert.AreEqual(lenIn, lenOut, "Checking length of binary data (row 1)"); - - // now see if the buffer is intact - for (int x = 0; x < dataIn.Length; x++) - Assert.AreEqual(dataIn[x], dataOut[x], "Checking first binary array at " + x); - - // now we test chunking - int pos = 0; - int lenToRead = dataIn.Length; - while (lenToRead > 0) - { - int size = Math.Min(lenToRead, 1024); - int read = (int)reader.GetBytes(1, pos, dataOut, pos, size); - lenToRead -= read; - pos += read; - } - // now see if the buffer is intact - for (int x = 0; x < dataIn.Length; x++) - Assert.AreEqual(dataIn[x], dataOut[x], "Checking first binary array at " + x); - - reader.Read(); - lenOut = reader.GetBytes(1, 0, dataOut, 0, lenIn); - Assert.AreEqual(lenIn, lenOut, "Checking length of binary data (row 2)"); - - // now see if the buffer is intact - for (int x = 0; x < dataIn2.Length; x++) - Assert.AreEqual(dataIn2[x], dataOut[x], "Checking second binary array at " + x); - } - } - - [Test] - public void GetChars() - { - InternalGetChars(false); - } - - [Test] - public void GetCharsPrepared() - { - if (Version < new Version(4, 1)) return; - - InternalGetChars(true); - } - - private void InternalGetChars(bool prepare) - { - execSQL("CREATE TABLE Test (id INT NOT NULL, text1 LONGTEXT, PRIMARY KEY(id))"); - - char[] data = new char[20000]; - for (int x = 0; x < data.Length; x++) - data[x] = (char)(65 + (x % 20)); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, ?text1)", conn); - cmd.Parameters.AddWithValue("?text1", data); - if (prepare) - cmd.Prepare(); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - cmd.Parameters.Clear(); - if (prepare) - cmd.Prepare(); - - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - - // now we test chunking - char[] dataOut = new char[data.Length]; - int pos = 0; - int lenToRead = data.Length; - while (lenToRead > 0) - { - int size = Math.Min(lenToRead, 1024); - int read = (int)reader.GetChars(1, pos, dataOut, pos, size); - lenToRead -= read; - pos += read; - } - // now see if the buffer is intact - for (int x = 0; x < data.Length; x++) - Assert.AreEqual(data[x], dataOut[x], "Checking first text array at " + x); - } - } - - [Test] - public void InsertText() - { - InternalInsertText(false); - } - - [Test] - public void InsertTextPrepared() - { - if (Version < new Version(4, 1)) return; - - InternalInsertText(true); - } - - private void InternalInsertText(bool prepare) - { - execSQL("CREATE TABLE Test (id INT NOT NULL, blob1 LONGBLOB, text1 LONGTEXT, PRIMARY KEY(id))"); - - byte[] data = new byte[1024]; - for (int x = 0; x < 1024; x++) - data[x] = (byte)(65 + (x % 20)); - - // Create sample table - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, ?b1, ?t1)", conn); - cmd.Parameters.Add(new MySqlParameter("?t1", data)); - cmd.Parameters.Add(new MySqlParameter("?b1", "This is my blob data")); - if (prepare) cmd.Prepare(); - int rows = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, rows, "Checking insert rowcount"); - - cmd.CommandText = "INSERT INTO Test VALUES(2, ?b1, ?t1)"; - cmd.Parameters.Clear(); - cmd.Parameters.AddWithValue("?t1", DBNull.Value); - string str = "This is my text value"; - cmd.Parameters.Add(new MySqlParameter("?b1", MySqlDbType.LongBlob, str.Length, - ParameterDirection.Input, true, 0, 0, "b1", DataRowVersion.Current, str)); - rows = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, rows, "Checking insert rowcount"); - - cmd.CommandText = "SELECT * FROM Test"; - if (prepare) cmd.Prepare(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.AreEqual(true, reader.HasRows, "Checking HasRows"); - - Assert.IsTrue(reader.Read()); - - Assert.AreEqual("This is my blob data", reader.GetString(1)); - string s = reader.GetString(2); - Assert.AreEqual(1024, s.Length, "Checking length returned "); - Assert.AreEqual("ABCDEFGHI", s.Substring(0, 9), "Checking first few chars of string"); - - Assert.IsTrue(reader.Read()); - Assert.AreEqual(DBNull.Value, reader.GetValue(2)); - Assert.AreEqual("This is my text value", reader.GetString(1)); - } - } - - [Test] - public void UpdateDataSet() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, blob1 LONGBLOB, text1 LONGTEXT, PRIMARY KEY(id))"); - execSQL("INSERT INTO Test VALUES( 1, NULL, 'Text field' )"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - DataTable dt = new DataTable(); - da.Fill(dt); - - string s = (string)dt.Rows[0][2]; - Assert.AreEqual("Text field", s); - - byte[] inBuf = Utils.CreateBlob(512); - dt.Rows[0].BeginEdit(); - dt.Rows[0]["blob1"] = inBuf; - dt.Rows[0].EndEdit(); - DataTable changes = dt.GetChanges(); - da.Update(changes); - dt.AcceptChanges(); - - dt.Clear(); - da.Fill(dt); - cb.Dispose(); - - byte[] outBuf = (byte[])dt.Rows[0]["blob1"]; - Assert.AreEqual(inBuf.Length, outBuf.Length, - "checking length of updated buffer"); - for (int y = 0; y < inBuf.Length; y++) - Assert.AreEqual(inBuf[y], outBuf[y], "checking array data"); - } - - [Test] - public void GetCharsOnLongTextColumn() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, blob1 LONGBLOB, text1 LONGTEXT, PRIMARY KEY(id))"); - execSQL("INSERT INTO Test (id, text1) VALUES(1, 'Test')"); - - MySqlCommand cmd = new MySqlCommand("SELECT id, text1 FROM Test", conn); - char[] buf = new char[2]; - - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - reader.GetChars(1, 0, buf, 0, 2); - Assert.AreEqual('T', buf[0]); - Assert.AreEqual('e', buf[1]); - } - } - - [Test] - public void MediumIntBlobSize() - { - execSQL("CREATE TABLE test (id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, " + - "image MEDIUMBLOB NOT NULL, imageSize MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0, " + - "PRIMARY KEY (id))"); - - byte[] image = new byte[2048]; - for (int x = 0; x < image.Length; x++) - image[x] = (byte)(x % 47); - MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES(NULL, ?image, ?size)", conn); - cmd.Parameters.AddWithValue("?image", image); - cmd.Parameters.AddWithValue("?size", image.Length); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT imageSize, length(image), image FROM test WHERE id=?id"; - cmd.Parameters.AddWithValue("?id", 1); - cmd.Prepare(); - - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - uint actualsize = reader.GetUInt32(1); - Assert.AreEqual(image.Length, actualsize); - uint size = reader.GetUInt32(0); - byte[] outImage = new byte[size]; - long len = reader.GetBytes(reader.GetOrdinal("image"), 0, outImage, 0, (int)size); - Assert.AreEqual(image.Length, size); - Assert.AreEqual(image.Length, len); - } - } - - [Test] - public void BlobBiggerThanMaxPacket() - { - suExecSQL("SET GLOBAL max_allowed_packet=500000"); - execSQL("CREATE TABLE test (id INT(10), image BLOB)"); - - using (MySqlConnection c = new MySqlConnection(GetConnectionString(true))) - { - c.Open(); - byte[] image = Utils.CreateBlob(1000000); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES(NULL, ?image)", c); - cmd.Parameters.AddWithValue("?image", image); - try - { - cmd.ExecuteNonQuery(); - Assert.Fail("This should have thrown an exception"); - } - catch (MySqlException) - { - } - } - } - } - - #region Configs -#if !CF - [Category("Compressed")] - public class BlobTestsSocketCompressed : BlobTests - { - protected override string GetConnectionInfo() - { - return String.Format("port={0};compress=true", port); - } - } - - [Category("Pipe")] - public class BlobTestsPipe : BlobTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=pipe;pipe name={0}", pipeName); - } - } - - [Category("Compressed")] - [Category("Pipe")] - public class BlobTestsPipeCompressed : BlobTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=pipe;pipe name={0};compress=true", pipeName); - } - } - - [Category("SharedMemory")] - public class BlobTestsSharedMemory : BlobTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=memory; shared memory name={0}", memoryName); - } - } - - [Category("Compressed")] - [Category("SharedMemory")] - public class BlobTestsSharedMemoryCompressed : BlobTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=memory; shared memory name={0};compress=true", memoryName); - } - } -#endif - #endregion - -} \ No newline at end of file diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BulkLoading.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BulkLoading.cs deleted file mode 100644 index 8737c89..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/BulkLoading.cs +++ /dev/null @@ -1,366 +0,0 @@ -// Copyright (C) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using NUnit.Framework; -using System.IO; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class BulkLoading : BaseTest - { - [Test] - public void BulkLoadSimple() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - - // first create the external file - string path = Path.GetTempFileName(); - StreamWriter sw = new StreamWriter(path); - for (int i = 0; i < 200; i++) - sw.WriteLine(i + "\t'Test'"); - sw.Flush(); - sw.Close(); - - MySqlBulkLoader loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - int count = loader.Load(); - Assert.AreEqual(200, count); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(200, dt.Rows.Count); - Assert.AreEqual("'Test'", dt.Rows[0][1].ToString().Trim()); - } - - [Test] - public void BulkLoadReadOnlyFile() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - - // first create the external file - string path = Path.GetTempFileName(); - StreamWriter sw = new StreamWriter(path); - for (int i = 0; i < 200; i++) - sw.WriteLine(i + "\t'Test'"); - sw.Flush(); - sw.Close(); - - FileInfo fi = new FileInfo(path); - FileAttributes oldAttr = fi.Attributes; - fi.Attributes = fi.Attributes | FileAttributes.ReadOnly; - try - { - MySqlBulkLoader loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - int count = loader.Load(); - Assert.AreEqual(200, count); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(200, dt.Rows.Count); - Assert.AreEqual("'Test'", dt.Rows[0][1].ToString().Trim()); - } - finally - { - fi.Attributes = oldAttr; - fi.Delete(); - } - } - - [Test] - public void BulkLoadSimple2() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - - // first create the external file - string path = Path.GetTempFileName(); - StreamWriter sw = new StreamWriter(path); - for (int i = 0; i < 200; i++) - sw.Write(i + ",'Test' xxx"); - sw.Flush(); - sw.Close(); - - MySqlBulkLoader loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - loader.FieldTerminator = ","; - loader.LineTerminator = "xxx"; - int count = loader.Load(); - Assert.AreEqual(200, count); - - MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM Test", conn); - Assert.AreEqual(200, cmd.ExecuteScalar()); - } - - [Test] - public void BulkLoadSimple3() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - - // first create the external file - string path = Path.GetTempFileName(); - StreamWriter sw = new StreamWriter(path); - for (int i = 0; i < 200; i++) - sw.Write(i + ",'Test' xxx"); - sw.Flush(); - sw.Close(); - - MySqlBulkLoader loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - loader.FieldTerminator = ","; - loader.LineTerminator = "xxx"; - loader.NumberOfLinesToSkip = 50; - int count = loader.Load(); - Assert.AreEqual(150, count); - - MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM Test", conn); - Assert.AreEqual(150, cmd.ExecuteScalar()); - } - - [Test] - public void BulkLoadSimple4() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - - // first create the external file - string path = Path.GetTempFileName(); - StreamWriter sw = new StreamWriter(path); - for (int i = 0; i < 100; i++) - sw.Write("aaa" + i + ",'Test' xxx"); - for (int i = 100; i < 200; i++) - sw.Write("bbb" + i + ",'Test' xxx"); - for (int i = 200; i < 300; i++) - sw.Write("aaa" + i + ",'Test' xxx"); - for (int i = 300; i < 400; i++) - sw.Write("bbb" + i + ",'Test' xxx"); - sw.Flush(); - sw.Close(); - - MySqlBulkLoader loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - loader.FieldTerminator = ","; - loader.LineTerminator = "xxx"; - loader.LinePrefix = "bbb"; - int count = loader.Load(); - Assert.AreEqual(200, count); - - MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM Test", conn); - Assert.AreEqual(200, cmd.ExecuteScalar()); - } - - [Test] - public void BulkLoadFieldQuoting() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), name2 VARCHAR(250), PRIMARY KEY(id))"); - - // first create the external file - string path = Path.GetTempFileName(); - StreamWriter sw = new StreamWriter(path); - for (int i = 0; i < 200; i++) - sw.WriteLine(i + "\t`col1`\tcol2"); - sw.Flush(); - sw.Close(); - - MySqlBulkLoader loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - loader.FieldQuotationCharacter = '`'; - loader.FieldQuotationOptional = true; - int count = loader.Load(); - Assert.AreEqual(200, count); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(200, dt.Rows.Count); - Assert.AreEqual("col1", dt.Rows[0][1]); - Assert.AreEqual("col2", dt.Rows[0][2].ToString().Trim()); - } - - [Test] - public void BulkLoadEscaping() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), name2 VARCHAR(250), PRIMARY KEY(id))"); - - // first create the external file - string path = Path.GetTempFileName(); - StreamWriter sw = new StreamWriter(path); - for (int i = 0; i < 200; i++) - sw.WriteLine(i + ",col1\tstill col1,col2"); - sw.Flush(); - sw.Close(); - - MySqlBulkLoader loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - loader.EscapeCharacter = '\t'; - loader.FieldTerminator = ","; - int count = loader.Load(); - Assert.AreEqual(200, count); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(200, dt.Rows.Count); - Assert.AreEqual("col1still col1", dt.Rows[0][1]); - Assert.AreEqual("col2", dt.Rows[0][2].ToString().Trim()); - } - - [Test] - public void BulkLoadConflictOptionReplace() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - - // first create the external file - string path = Path.GetTempFileName(); - StreamWriter sw = new StreamWriter(path); - for (int i = 0; i < 20; i++) - sw.WriteLine(i + ",col1"); - sw.Flush(); - sw.Close(); - - MySqlBulkLoader loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - loader.FieldTerminator = ","; - int count = loader.Load(); - Assert.AreEqual(20, count); - - path = Path.GetTempFileName(); - sw = new StreamWriter(path); - for (int i = 0; i < 20; i++) - sw.WriteLine(i + ",col2"); - sw.Flush(); - sw.Close(); - - loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - loader.FieldTerminator = ","; - loader.ConflictOption = MySqlBulkLoaderConflictOption.Replace; - loader.Load(); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(20, dt.Rows.Count); - Assert.AreEqual("col2", dt.Rows[0][1].ToString().Trim()); - } - - [Test] - public void BulkLoadConflictOptionIgnore() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - - // first create the external file - string path = Path.GetTempFileName(); - StreamWriter sw = new StreamWriter(path); - for (int i = 0; i < 20; i++) - sw.WriteLine(i + ",col1"); - sw.Flush(); - sw.Close(); - - MySqlBulkLoader loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - loader.FieldTerminator = ","; - int count = loader.Load(); - Assert.AreEqual(20, count); - - path = Path.GetTempFileName(); - sw = new StreamWriter(path); - for (int i = 0; i < 20; i++) - sw.WriteLine(i + ",col2"); - sw.Flush(); - sw.Close(); - - loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - loader.FieldTerminator = ","; - loader.ConflictOption = MySqlBulkLoaderConflictOption.Ignore; - loader.Load(); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(20, dt.Rows.Count); - Assert.AreEqual("col1", dt.Rows[0][1].ToString().Trim()); - } - - [Test] - public void BulkLoadColumnOrder() - { - execSQL(@"CREATE TABLE Test (id INT NOT NULL, n1 VARCHAR(250), n2 VARCHAR(250), - n3 VARCHAR(250), PRIMARY KEY(id))"); - - // first create the external file - string path = Path.GetTempFileName(); - StreamWriter sw = new StreamWriter(path); - for (int i = 0; i < 20; i++) - sw.WriteLine(i + ",col3,col2,col1"); - sw.Flush(); - sw.Close(); - - MySqlBulkLoader loader = new MySqlBulkLoader(conn); - loader.TableName = "Test"; - loader.FileName = path; - loader.Timeout = 0; - loader.FieldTerminator = ","; - loader.LineTerminator = Environment.NewLine; - loader.Columns.Add("id"); - loader.Columns.Add("n3"); - loader.Columns.Add("n2"); - loader.Columns.Add("n1"); - int count = loader.Load(); - Assert.AreEqual(20, count); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(20, dt.Rows.Count); - Assert.AreEqual("col1", dt.Rows[0][1]); - Assert.AreEqual("col2", dt.Rows[0][2]); - Assert.AreEqual("col3", dt.Rows[0][3].ToString().Trim()); - } - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CharacterSetTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CharacterSetTests.cs deleted file mode 100644 index 5b3c1c8859f63075d0de0259eb98be8ea35450e2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25290 zcmeI4+io1k5r*5B43KwNFc+jxl&Mo>%ZG?GB@2-ynWQZnhT-riGm%J{TuGJ`8J2rj_cp@ga2U%U zsJ3IZa-ug+RR3Ohs3Y&)REeFi6n-6kC0fo6kG-%dN)A-2C)#-TzJ9m#UT<)BU)Ov3 z>#599*jKGj^_+WGb?=$(J=SqY_n?9MyYbDw&JV)2o{Bn&lAhcMx5MWuaYH2zW2vq1K-YKG{v@ z`UOSCS$O?O*E@R0`mq;&h?GAX)&rG&)t`8fbI171xX?33#M|dR#xcEjLtH|}5=F)X z8!?lOEz$ER@{#e)Tejz=Y%HnF7ix7+(vn)*7dIZnae>w!L{mviqG7bhNCu;{uj7Nr zt+nu_v}#TCZ%V@NNCr0a+)DZQ(06#d6S;M)G0fYnr#|P!s5IL+PNPesbs0CS6o04j zVf2k}NRI2o)7W$5dOJRU9Oc-!`c^i6rggn=Ph8mypNKP`>j;Y64qxebPiO1;<9btf z&}8a{XGkn9?nUi@-_FScX#J^9KGwJc3n@e>Hlt|ld)Y@4{pUP?tZQkcU5jfZy{-5py{B|nrN5~7xo9VflsEF zAW>gEMej+Z{)$GFh`kYyi4uZ;a+ZqIKLF$)$gWSFsY)YyP|t5 z;v6NgYfi(3a6$HwyDOp*+eZJm{xnKTPfyQ><@oouekuK1J?%+WHev~=;~$+t-{8%L zIPZ4yYU|Ub@UbXE0>+gChsKq;5yxj+wPBflj5QmojC*ra(uG8BMNFp`qiWYI`k1%+L|i+Fn*6z1-V;Bu=d^0$bs`V$^#Q$k&2uXIgZ_6! z86MnXm>1RS!mDedW=*th>TE?%?A-W+Klns6BNZUT&Y+*jxwU_+TJV|B7D^ru%PdOj z@gZN2TER%cD;ss{YATKQX&AjOTGvEZFLIh59;(iH)tF>qPW+pzj5B(O$CY>j-M#RE z{<)9+H&52&VzfLyu-#pXy({b65Vt`i)7dvw-@GVt-Y_bCwT5(z(ronN`QFjUB9Dxh z^{1{c4<+fzcX}8{p}8liG~)~R7|+$n!+adCYvk{U3x;=S0yg*)l|>@(l+u{f+Jfxk zf{xhdk9C~a|C>W8gYNknd9XLlCpcD5O>6Ud?&@AuDtPCbXxIqf>i4#2Usv1sQ;VXY zEWaSxT2LL^;{Jm8I3Hz=2qx#~j(E5$j;{?gz#@PRy+bdN*>VgR9}oj%-z%OzkNrk- zLG%1C;fHB&{*3b`O@`aY(mf=KvuClzx)uy6%6k3UZ04dy4+Kh4#QSR7CBOP?Q4t=x zyey8PcObc;-eIO=UVnKcwgdS=yiFa!M!406ER;2QTO42ty*3-~5;BSn7L7t7nu*75 zt@ea|eR&F3BrV&Ke^$oO*fcSfG3l6>_l8CvNs?DYtIJB+JHH;q&6|=-bZb586<3?m zCj1%i+ZU4ITha*R7z|yGTwYK)E3rI~R&Tp*tiAmzRwWIG7cYVbZ-}yl15UeZkl~-x z=d_f^+;>^bP}O~tb@dm|0C_a&N>^xly=LZbp_yjS%C`NwT_?QMwTLs&f&IU!t4*Ch z7G;YADK;vXG^$3kwQM-zwKN@%Bz=F>d)OR2XR|h@9bPY)fc^kktzERPTm5a+)0#(( z$u5nn*-)(PPr^1Zy~H!_HDTDTsFCRMa;?pTn-;}VOZ%9e7LL*K^nQ?eK&I_rW#)!>V!0lYR{17+W|t_cwoQ%4YQIi9p-=1dKG0#kLUlz zgKFx}>`>FBAmOI-wdy}5*&w^{d)a~N7&yxMIN11CQN&tmM#(n+rHU8VBEqeO?}c}G zJZ_I@p-RDYeh>NEbL!#yLemgYdU+jw^wK%%UW_?U=9unjltCr%*di=&oLoB*9rwv&SK~vQDe%m66-merZ7RB8 z)-bOR{BG|{Jr;W}{5UNRn-7lVWd062bw|B(TBk$ddT*87bM4tr(yBTS!E8Jk6)I9KpPvTJFb3qv=Q< zfVmdtb;v;xF_YuAoSsMS$(A(LGs=U>vC;iBGDcNjjI5DsY@KX6RaI-2@C^w+i^F?k zVmjxdX9iNfs3$KJ{|(fxid#A?bg9t9Eaj)1Tp~?ME^(15T7XaeJ6aQUu2k! zli}fpBJCfgzw>%FtM-W&>)Ky_!S=^R_|6|cPK&9Io-5)Kt2I2c!mNa6!0#*OIBgHN zuW|9rq9YkAESQDA5z*&M{no|gqe#?-1GJH{|0j|MveLdr#e5v6<-PE8_)GYE_-FV> z_?M)nU1CRT_SH64YZK~uYo52qYs1nmhL40y*!4sqwg)W(^~QU2Rf@3WL@pb#4%1k( zsOU%;(^x4o5R5*pLKpmRnlVY^(9Wl(tYaM&p!0NdKSuv-vXAv~glk^YaaI-w88t}) zXVUCQQ@eiO{rRf&*xbUBZ2GSL@HNUgwbAm-2{g;1dC#f0A1j->si=ebv89+XWtP#R zd&Z+(I=WDA=x%j`?aW@HV^wXQtev&W?9y}*R7pD$ojeVEnC3{TDWBi17fm|l_Ih1y zr`&yRr;T$iD^)J!Z(#xIZGiXMk3ZGM2>!G@=Co9^_uYE#^;NMB{A~6}k_A|d{`6!m zjq^yVQi#r;be8&htM7e$uDaU)>MUQH6)4}G)@LwZVOtn-qWHsR@Mhy7{7y(SJ`2X& zBmN1x&-@Ithj=gB;tp#d?&uf3m!)hz|5;X=wP37a%ipTwVad7jx@^hUOC`G8lgV2G z5At4gqpy4`wUO67O)tut$M>RZ^u=0N{G6}l6{i_p#?9`#zPdH?`(JB@n>T*a|2yK= z{=nPj{N3#QN^#x`&&SxAwJ1ThUf41x?!Opvl+TyqTHwB-UnDQRhix<;`fcS)QY>0Z zh+kK6%G>-_nv_t%wY%7_~i?!0_I$~d2(AHM+AF5V!^7y>T&&K}3@+cckt1Y{JaK{h8OiF@zXSGG z*I`!UG`A^k2gc#BkBPUIGNO4N)u|gT)je-YUs@p60`4QO4E<^7n6yXZIP0xdy;c0C`d&Jx?+C5ft3+P+ zfqKpg{-Z%2(*4=)nW1qpG7{G&bzQ7WiiFZST(>H=>%gU;JksY^&4yr;Q=D1akknUV z=`)LxMs%EYII}2S5$4slD82^3@oF{NHJdZMEzDxK(o)1LW{TK%B-N`(H+5154J*|J5Y$*Fcu$RrdDe@9&E$;>8_Lnt#bV-r4@1XE33wZ@! z55+kiDC-?ek653|we4Jc8rQ|L?l;f*d8TwhdB+XyB_eOb4ou2WlkZRVR`PE=kO8tU z-1u&LA1Ob2fAij4(YF%#dV=-F))-YKlgP<-gdB<@@}u4o**ecG`6_0o%=&K>Syqpo z=tzO@3Ae8sU6QwMyGC+;H|-RmOgR(Iy{5f#zG4npt&0?z_weT)to3o0nF4ZkNQdp4 z{a~0Ix~iTW#fS!(xv#v@zRH=8@3~|8J6DmKd_O3?JgrQzwQQ(v=jrPoV70}I0ktP?9qOg$S{o%^`})($o-3~w`S%0J>_*76Yy;Om^e~39doSArQXLd zUj?r9}*T5$!n-Esnxc{k`YXo(d73CRd!4Sc1SXN9ZSOU@#f z;_+)1O3sawHCuyVRJqKQb(Gg;MNR6{`K)Z~^5E+|a}lup9 z+}KWA(}i+9lF3t(hQE4tjWs~_?Lx=@eC)V4J6x^Wx<6Df;SZ8!zSIbEr?1R3SvxE? zm_ErjTIRGu%jJ`P*=_@$Zyc3p)6OK*yi@XK94@g^>rm?m%&y}n@2H1vUx+#aLZ*BJ91dGe($&W~M*zR%Fh z=O|Q%390|5yQ8rD{uWl-xpGqBif8;+2VV9@Ea@m)j$gYS&wD@nIDqdr!hat>{8qdI z?-%Ql(`bJX&sk^Y7+v*(o+Al*`kygj-`|za zOuH_xic;0Dpw+LyVx5_%%#&*9-D01X~ujd4SxN< z^HyAb&$KnI@pYago$l@*ygY5qee|v#LlqycMXx{qZrHp$$z~tYy_jYs8AnGwYE - /// Bug #8574 - MySqlCommandBuilder unable to support sub-queries - /// Bug #11947 - MySQLCommandBuilder mishandling CONCAT() aliased column - /// - [Test] - public void UsingFunctions() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), dt DATETIME, tm TIME, `multi word` int, PRIMARY KEY(id))"); - execSQL("INSERT INTO Test (id, name) VALUES (1,'test1')"); - execSQL("INSERT INTO Test (id, name) VALUES (2,'test2')"); - execSQL("INSERT INTO Test (id, name) VALUES (3,'test3')"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, name, now() as ServerTime FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - DataTable dt = new DataTable(); - da.Fill(dt); - - dt.Rows[0]["id"] = 4; - da.Update(dt); - - da.SelectCommand.CommandText = "SELECT id, name, CONCAT(name, ' boo') as newname from Test where id=4"; - dt.Clear(); - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual("test1", dt.Rows[0]["name"]); - Assert.AreEqual("test1 boo", dt.Rows[0]["newname"]); - - dt.Rows[0]["id"] = 5; - da.Update(dt); - - dt.Clear(); - da.SelectCommand.CommandText = "SELECT * FROM Test WHERE id=5"; - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual("test1", dt.Rows[0]["name"]); - - da.SelectCommand.CommandText = "SELECT *, now() as stime FROM Test WHERE id<4"; - cb = new MySqlCommandBuilder(da); - cb.ConflictOption = ConflictOption.OverwriteChanges; - da.InsertCommand = cb.GetInsertCommand(); - } - - /// - /// Bug #8382 Commandbuilder does not handle queries to other databases than the default one- - /// - [Test] - public void DifferentDatabase() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), dt DATETIME, tm TIME, `multi word` int, PRIMARY KEY(id))"); - execSQL("INSERT INTO Test (id, name) VALUES (1,'test1')"); - execSQL("INSERT INTO Test (id, name) VALUES (2,'test2')"); - execSQL("INSERT INTO Test (id, name) VALUES (3,'test3')"); - - conn.ChangeDatabase(database1); - - MySqlDataAdapter da = new MySqlDataAdapter( - String.Format("SELECT id, name FROM `{0}`.Test", database0), conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - DataSet ds = new DataSet(); - da.Fill(ds); - - ds.Tables[0].Rows[0]["id"] = 4; - DataSet changes = ds.GetChanges(); - da.Update(changes); - ds.Merge(changes); - ds.AcceptChanges(); - cb.Dispose(); - - conn.ChangeDatabase(database0); - } - - /// - /// Bug #13036 Returns error when field names contain any of the following chars %<>()/ etc - /// - [Test] - public void SpecialCharactersInFieldNames() - { - execSQL("CREATE TABLE Test (`col%1` int PRIMARY KEY, `col()2` int, `col<>3` int, `col/4` int)"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - cb.ToString(); // keep the compiler happy - DataTable dt = new DataTable(); - da.Fill(dt); - DataRow row = dt.NewRow(); - row[0] = 1; - row[1] = 2; - row[2] = 3; - row[3] = 4; - dt.Rows.Add(row); - da.Update(dt); - } - - /// - /// Bug #14631 "#42000Query was empty" - /// - [Test] - public void SemicolonAtEndOfSQL() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), PRIMARY KEY(id))"); - execSQL("INSERT INTO Test VALUES(1, 'Data')"); - - DataSet ds = new DataSet(); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM `Test`;", conn); - da.FillSchema(ds, SchemaType.Source, "Test"); - - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - DataTable dt = new DataTable(); - da.Fill(dt); - dt.Rows[0]["id"] = 2; - da.Update(dt); - - dt.Clear(); - da.Fill(dt); - cb.Dispose(); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(2, dt.Rows[0]["id"]); - } - - /// - /// Bug #23862 Problem with CommandBuilder 'GetInsertCommand' method - /// - [Test] - public void AutoIncrementColumnsOnInsert() - { - execSQL("CREATE TABLE Test (id INT UNSIGNED NOT NULL AUTO_INCREMENT, " + - "name VARCHAR(100), PRIMARY KEY(id))"); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - - da.InsertCommand = cb.GetInsertCommand(); - da.InsertCommand.CommandText += "; SELECT last_insert_id()"; - da.InsertCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord; - - DataTable dt = new DataTable(); - da.Fill(dt); - dt.Columns[0].AutoIncrement = true; - Assert.IsTrue(dt.Columns[0].AutoIncrement); - dt.Columns[0].AutoIncrementSeed = -1; - dt.Columns[0].AutoIncrementStep = -1; - DataRow row = dt.NewRow(); - row["name"] = "Test"; - - dt.Rows.Add(row); - da.Update(dt); - - dt.Clear(); - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(1, dt.Rows[0]["id"]); - Assert.AreEqual("Test", dt.Rows[0]["name"]); - cb.Dispose(); - } - - /// - /// Bug #25569 UpdateRowSource.FirstReturnedRecord does not work - /// - [Test] - public void AutoIncrementColumnsOnInsert2() - { - execSQL("CREATE TABLE Test (id INT UNSIGNED NOT NULL " + - "AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20))"); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - - MySqlCommand cmd = (MySqlCommand)(cb.GetInsertCommand() as ICloneable).Clone(); - cmd.CommandText += "; SELECT last_insert_id() as id"; - cmd.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord; - da.InsertCommand = cmd; - - DataTable dt = new DataTable(); - da.Fill(dt); - dt.Rows.Clear(); - - DataRow row = dt.NewRow(); - row["name"] = "Test"; - dt.Rows.Add(row); - da.Update(dt); - Assert.AreEqual(1, dt.Rows[0]["id"]); - Assert.AreEqual("Test", dt.Rows[0]["name"]); - - row = dt.NewRow(); - row["name"] = "Test2"; - dt.Rows.Add(row); - da.Update(dt); - Assert.AreEqual(2, dt.Rows[1]["id"]); - Assert.AreEqual("Test2", dt.Rows[1]["name"]); - - Assert.AreEqual(1, dt.Rows[0]["id"]); - } - - [Test] - public void MultiUpdate() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), dt DATETIME, tm TIME, `multi word` int, PRIMARY KEY(id))"); - execSQL("INSERT INTO Test (id, name) VALUES (1, 'test1')"); - execSQL("INSERT INTO Test (id, name) VALUES (2, 'test2')"); - execSQL("INSERT INTO Test (id, name) VALUES (3, 'test3')"); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - DataTable dt = new DataTable(); - da.Fill(dt); - - dt.Rows[0]["id"] = 4; - dt.Rows[0]["name"] = "test4"; - dt.Rows[1]["id"] = 5; - dt.Rows[1]["name"] = "test5"; - dt.Rows[2]["id"] = 6; - dt.Rows[2]["name"] = "test6"; - DataTable changes = dt.GetChanges(); - da.Update(changes); - dt.AcceptChanges(); - - dt.Rows[0]["id"] = 7; - dt.Rows[0]["name"] = "test7"; - dt.Rows[1]["id"] = 8; - dt.Rows[1]["name"] = "test8"; - dt.Rows[2]["id"] = 9; - dt.Rows[2]["name"] = "test9"; - changes = dt.GetChanges(); - da.Update(changes); - dt.AcceptChanges(); - cb.Dispose(); - } - - /// - /// Bug #30077 MySqlDataAdapter.Update() exception due to date field format - /// - [Test] - public void UpdatingWithDateInKey() - { - execSQL("CREATE TABLE Test (cod INT, dt DATE, PRIMARY KEY(cod, dt))"); - - execSQL("INSERT INTO Test (cod, dt) VALUES (1, '2006-1-1')"); - execSQL("INSERT INTO Test (cod, dt) VALUES (2, '2006-1-2')"); - execSQL("INSERT INTO Test (cod, dt) VALUES (3, '2006-1-3')"); - execSQL("INSERT INTO Test (cod, dt) VALUES (4, '2006-1-4')"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test ORDER BY cod", conn); - MySqlCommandBuilder bld = new MySqlCommandBuilder(da); - bld.ConflictOption = ConflictOption.OverwriteChanges; - DataTable dt = new DataTable(); - da.Fill(dt); - dt.Rows[0]["cod"] = 6; - da.Update(dt); - - dt.Clear(); - da.SelectCommand.CommandText = "SELECT * FROM Test WHERE cod=6"; - da.Fill(dt); - Assert.AreEqual(6, dt.Rows[0]["cod"]); - } - - /// - /// Bug #35492 Please implement DbCommandBuilder.QuoteIdentifier - /// - [Test] - public void QuoteAndUnquoteIdentifiers() - { - MySqlCommandBuilder cb = new MySqlCommandBuilder(); - Assert.AreEqual("`boo`", cb.QuoteIdentifier("boo")); - Assert.AreEqual("`bo``o`", cb.QuoteIdentifier("bo`o")); - Assert.AreEqual("`boo`", cb.QuoteIdentifier("`boo`")); - - // now do the unquoting - Assert.AreEqual("boo", cb.UnquoteIdentifier("`boo`")); - Assert.AreEqual("`boo", cb.UnquoteIdentifier("`boo")); - Assert.AreEqual("bo`o", cb.UnquoteIdentifier("`bo``o`")); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CommandTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CommandTests.cs deleted file mode 100644 index 2299c02..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CommandTests.cs +++ /dev/null @@ -1,498 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using NUnit.Framework; -using System.Threading; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class CommandTests : BaseTest - { - [Test] - public void InsertTest() - { - execSQL("CREATE TABLE Test (id int NOT NULL, name VARCHAR(100))"); - // do the insert - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id,name) VALUES(10,'Test')", conn); - int cnt = cmd.ExecuteNonQuery(); - Assert.AreEqual( 1, cnt, "Insert Count" ); - - // make sure we get the right value back out - cmd.CommandText = "SELECT name FROM Test WHERE id=10"; - string name = (string)cmd.ExecuteScalar(); - Assert.AreEqual( "Test", name, "Insert result" ); - - // now do the insert with parameters - cmd.CommandText = "INSERT INTO Test (id,name) VALUES(?id, ?name)"; - cmd.Parameters.Add( new MySqlParameter("?id", 11)); - cmd.Parameters.Add( new MySqlParameter("?name", "Test2")); - cnt = cmd.ExecuteNonQuery(); - Assert.AreEqual( 1, cnt, "Insert with Parameters Count" ); - - // make sure we get the right value back out - cmd.Parameters.Clear(); - cmd.CommandText = "SELECT name FROM Test WHERE id=11"; - name = (string)cmd.ExecuteScalar(); - Assert.AreEqual( "Test2", name, "Insert with parameters result" ); - } - - [Test] - public void UpdateTest() - { - execSQL("CREATE TABLE Test (id int NOT NULL, name VARCHAR(100))"); - execSQL("INSERT INTO Test (id,name) VALUES(10, 'Test')"); - execSQL("INSERT INTO Test (id,name) VALUES(11, 'Test2')"); - - // do the update - MySqlCommand cmd = new MySqlCommand("UPDATE Test SET name='Test3' WHERE id=10 OR id=11", conn); - MySqlConnection c = cmd.Connection; - Assert.AreEqual(conn, c); - int cnt = cmd.ExecuteNonQuery(); - Assert.AreEqual(2, cnt); - - // make sure we get the right value back out - cmd.CommandText = "SELECT name FROM Test WHERE id=10"; - string name = (string)cmd.ExecuteScalar(); - Assert.AreEqual("Test3", name); - - cmd.CommandText = "SELECT name FROM Test WHERE id=11"; - name = (string)cmd.ExecuteScalar(); - Assert.AreEqual("Test3", name); - - // now do the update with parameters - cmd.CommandText = "UPDATE Test SET name=?name WHERE id=?id"; - cmd.Parameters.Add( new MySqlParameter("?id", 11)); - cmd.Parameters.Add( new MySqlParameter("?name", "Test5")); - cnt = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, cnt, "Update with Parameters Count"); - - // make sure we get the right value back out - cmd.Parameters.Clear(); - cmd.CommandText = "SELECT name FROM Test WHERE id=11"; - name = (string)cmd.ExecuteScalar(); - Assert.AreEqual("Test5", name); - } - - [Test] - public void DeleteTest() - { - execSQL("CREATE TABLE Test (id int NOT NULL, name VARCHAR(100))"); - execSQL("INSERT INTO Test (id, name) VALUES(1, 'Test')"); - execSQL("INSERT INTO Test (id, name) VALUES(2, 'Test2')"); - - // make sure we get the right value back out - MySqlCommand cmd = new MySqlCommand("DELETE FROM Test WHERE id=1 or id=2", conn); - int delcnt = cmd.ExecuteNonQuery(); - Assert.AreEqual(2, delcnt); - - // find out how many rows we have now - cmd.CommandText = "SELECT COUNT(*) FROM Test"; - object after_cnt = cmd.ExecuteScalar(); - Assert.AreEqual(0, after_cnt); - } - - [Test] - public void CtorTest() - { - execSQL("CREATE TABLE Test (id int NOT NULL, name VARCHAR(100))"); - MySqlTransaction txn = conn.BeginTransaction(); - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - - MySqlCommand clone = new MySqlCommand(cmd.CommandText, (MySqlConnection)cmd.Connection, - (MySqlTransaction)cmd.Transaction); - clone.Parameters.AddWithValue("?test", 1); - txn.Rollback(); - } - - [Test] - public void CloneCommand() - { - MySqlCommand cmd = new MySqlCommand(); - MySqlCommand newCommand = cmd.Clone(); - IDbCommand newCommand2 = (IDbCommand)(cmd as ICloneable).Clone(); - } - - [Test] - public void TableWithOVer100Columns() - { - string sql = "create table IF NOT EXISTS zvan (id int(8) primary key " + - "unique auto_increment, name varchar(250)) ENGINE=INNODB; "; -/* "create table IF NOT EXISTS ljudyna (id int(8) primary key " + - "unique auto_increment, name varchar(250), data_narod date, " + - "id_in_zvan int(8), kandidat varchar(250), tel_rob_vn varchar(250), " + - "tel_rob_mis varchar(250), n_kabin varchar(250), n_nak_zvan varchar(250), " + - "d_nak_zvan date, sex tinyint(1), n_nak_pos varchar(250), " + - "d_nak_pos date, posad_data varchar(250), visl1 varchar(250), visl2 " + - "varchar(250), visl3 varchar(250), cpidr_f int(8), cposad_f int(8), sumis " + - "tinyint(1), zs_s date, zs_po date, ovs_z date, ovs_po date, naiavn_zviln " + - "tinyint(1), ovs_z1 date, ovs_po1 date, ovs_z2 date, ovs_po2 date, ovs_z3 date, " + - "ovs_po3 date, ovs_prakt varchar(250), data_atest date, data_sp date, v_akad_z " + - "date, z_akad_zvln tinyint(1), v_akad_period varchar(250), nauk_stup " + - "varchar(250), vch_zvan varchar(250), n_sprav varchar(250), n_posv varchar(250), " + - "nacional varchar(250), osvita varchar(250), osvita_zakin_sho varchar(250), " + - "osvita_zakin_koli date, osvita_special varchar(250), osvita_kvalifikac " + - "varchar(250), de_navchaet varchar(250), data_vstupu date, termin_navch " + - "varchar(250), adresa varchar(250), tel_dom varchar(250), marka_avto " + - "varchar(250), n_avto varchar(250), color_avto varchar(250), vikor_avto " + - "varchar(250), posv_avto varchar(250), marka_zbr varchar(250), nomer_calibr_zbr " + - "varchar(250), vid_zbr varchar(250), nomer_data_razreshen varchar(250), pasport " + - "varchar(250), oklad1 varchar(250), prem07_2003 varchar(250), nadb07_2003 " + - "varchar(250), osob_nom varchar(250), nadbavka_stag_max varchar(250), " + - "nadbavka_stag_08_2003 varchar(250), nadbavka_stag_10_2003 varchar(250), " + - "nadbavka_stag_11_2003 varchar(250), nadbavka_stag_02_2004 varchar(250), " + - "vidp_vikoristav varchar(250), vidp_plan varchar(250), vidp_vidgil varchar(250), " + - "vidp_nevidgil_dniv varchar(250), nadb111 varchar(250), prem_3_1 varchar(250), " + - "nadb_4_1 varchar(250), prem_3_2 varchar(250), nadb_3_2 varchar(250), nedolos " + - "varchar(250), sposl int(8), cposl int(8), czaoh int(8), 07_2003_oklad " + - "varchar(250), 05_2003_oklad varchar(250), deti_jeni varchar(250), nadb_volny " + - "varchar(250), prem_volny varchar(250), dispanser tinyint(1), posl_spisok " + - "tinyint(1), anketa_avtobiogr tinyint(1), photokartka tinyint(1), sp1 tinyint(1), " + - "inshe varchar(250), oklad2 varchar(250), slugbova tinyint(1), atestuvan " + - "varchar(250), 09_2004_oklad_vstan varchar(250), golosuvannia varchar(250), " + - "stag_kalendar varchar(250), data_stag_kalendar varchar(250), medali " + - "varchar(250), medali_mae varchar(250), visluga_cal_ovs_and_zs varchar(250), " + - "FOREIGN KEY (id_in_zvan) REFERENCES zvan(id) ON DELETE CASCADE ON UPDATE " + - "CASCADE) TYPE=INNODB DEFAULT CHARACTER SET cp1251 COLLATE cp1251_ukrainian_ci"; - */ - - MySqlCommand cmd = new MySqlCommand(sql, conn); - cmd.ExecuteNonQuery(); - } - - /// - /// Bug #12245 using Prepare() on an insert command causes null parameters to convert to "0" - /// - [Test] - public void InsertingPreparedNulls() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (id int NOT NULL, name VARCHAR(100))"); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, ?str)", conn); - cmd.Parameters.Add("?str", MySqlDbType.VarChar); - cmd.Prepare(); - - cmd.Parameters[0].Value = null; - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(DBNull.Value, reader[1]); - } - } - - /// - /// MySQL Bugs: #12163: Insert using prepared statement causes double insert - /// - [Test] - public void PreparedInsertUsingReader() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (id int NOT NULL, name VARCHAR(100))"); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, 'Test')", conn); - cmd.Prepare(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - } - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.IsFalse(reader.Read()); - Assert.IsFalse(reader.NextResult()); - } - } - - /// - /// Bug# 8119. Unable to reproduce but left in anyway - /// -/* [Test] - public void ReallyBigCommandString() - { - System.Text.StringBuilder sql = new System.Text.StringBuilder(); - - for (int i = 0; i < 10; i++) - sql.Append("DROP TABLE IF EXISTS idx" + i + ";CREATE TABLE idx" + i + "(aa int not null auto_increment primary key, a int, b varchar(50), c int);"); - - int c = 0; - for (int z = 0; z < 100; z++) - for (int x = 0; x < 10; x++, c++) - { - string s = String.Format("INSERT INTO idx{0} (a, b, c) values ({1}, 'field{1}', {2});", - x, z, c); - sql.Append(s); - } - - MySqlCommand cmd = new MySqlCommand(sql.ToString(), conn); - cmd.ExecuteNonQuery(); - - for (int i = 0; i < 10; i++) - { - cmd.CommandText = "SELECT COUNT(*) FROM idx" + i; - object count = cmd.ExecuteScalar(); - Assert.AreEqual(100, count); - execSQL("DROP TABLE IF EXISTS idx" + i); - } - } -*/ - /// - /// Bug #7248 There is already an open DataReader associated with this Connection which must - /// - [Test] - public void GenWarnings() - { - execSQL("CREATE TABLE Test (id INT, dt DATETIME)"); - execSQL("INSERT INTO Test VALUES (1, NOW())"); - execSQL("INSERT INTO Test VALUES (2, NOW())"); - execSQL("INSERT INTO Test VALUES (3, NOW())"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test WHERE dt = '" + - DateTime.Now + "'", conn); - DataSet ds = new DataSet(); - da.Fill(ds); - } - - /// - /// Bug #11991 ExecuteScalar - /// - [Test] - public void CloseReaderAfterFailedConvert() - { - execSQL("CREATE TABLE Test (dt DATETIME)"); - execSQL("INSERT INTO Test VALUES ('00-00-0000 00:00:00')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - try - { - cmd.ExecuteScalar(); - } - catch (Exception) - { - } - - conn.BeginTransaction(); - } - - /// - /// Bug #25443 ExecuteScalar() hangs when more than one bad result - /// - [Test] - public void ExecuteWithOneBadQuery() - { - MySqlCommand command = new MySqlCommand("SELECT 1; SELECT * FROM foo", conn); - try - { - command.ExecuteScalar(); - } - catch (MySqlException) - { - } - - // now try using ExecuteNonQuery - try - { - command.ExecuteNonQuery(); - } - catch (MySqlException) - { - } - } - - /// - /// Bug #27958 Cannot use Data Source Configuration Wizard on large databases - /// - [Test] - public void DefaultCommandTimeout() - { - MySqlConnection c = new MySqlConnection("server=localhost"); - MySqlCommand cmd = new MySqlCommand("", c); - Assert.AreEqual(30, cmd.CommandTimeout); - - c = new MySqlConnection("server=localhost;default command timeout=47"); - cmd = new MySqlCommand("", c); - Assert.AreEqual(47, cmd.CommandTimeout); - - cmd = new MySqlCommand(""); - Assert.AreEqual(30, cmd.CommandTimeout); - - cmd.CommandTimeout = 66; - cmd.Connection = c; - Assert.AreEqual(66, cmd.CommandTimeout); - } - - /// - /// Bug #38276 Short circuit evaluation error in MySqlCommand.CheckState() - /// - [Test] - public void SetNullConnection() - { - MySqlCommand command = new MySqlCommand(); - command.CommandText = "SELECT 1"; - command.Connection = null; - try - { - object o = command.ExecuteScalar(); - } - catch (InvalidOperationException) - { - } - } - - /// - /// Bug #45941 SQL-Injection attack - /// - [Test] - public void SqlInjection1() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test(name VARCHAR(100)) ENGINE=MyISAM DEFAULT CHARSET=utf8"); - execSQL("INSERT INTO Test VALUES ('name1'), ('name2'), ('name3')"); - - MySqlCommand cnt = new MySqlCommand("SELECT COUNT(*) FROM Test", conn); - Int64 count = (Int64)cnt.ExecuteScalar(); - - MySqlCommand cmd = new MySqlCommand("DELETE FROM Test WHERE name=?name", conn); - cmd.Parameters.Add("?name", MySqlDbType.VarChar); - cmd.Parameters[0].Value = "\u2032 OR 1=1;-- --"; - cmd.ExecuteNonQuery(); - - Assert.AreEqual(count, (Int64)cnt.ExecuteScalar()); - } - - /// - /// Bug #44194 ExecuteNonQuery for update commands does not match actual rows updated - /// - [Test] - public void UseAffectedRows() - { - execSQL("CREATE TABLE Test (id INT, name VARCHAR(20))"); - 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()); - } - } - - /// - /// Bug #45502 error if "Allow Batch=False" - /// - [Test] - public void DontAllowBatching() - { - string connStr = GetConnectionString(true) + ";allow batch=false;character set=utf8"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT 1", c); - cmd.ExecuteScalar(); - } - } - - [Test] - public void TableCommandType() - { - execSQL("CREATE TABLE Test (id INT, name VARCHAR(20))"); - execSQL("INSERT INTO Test VALUES (1, 'A')"); - execSQL("CREATE TABLE Test1 (id INT, name VARCHAR(20))"); - execSQL("INSERT INTO Test1 VALUES (2, 'B')"); - - MySqlCommand cmd = new MySqlCommand("Test,Test1", conn); - cmd.CommandType = CommandType.TableDirect; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual(1, reader.GetInt32(0)); - Assert.AreEqual("A", reader.GetString(1)); - Assert.AreEqual(2, reader.GetInt32(2)); - Assert.AreEqual("B", reader.GetString(3)); - } - } - } - - - #region Configs - - public class CommandTestsSocketCompressed : CommandTests - { - protected override string GetConnectionInfo() - { - return String.Format("port={0};compress=true", port); - } - } - -#if !CF - [Category("Pipe")] - public class CommandTestsPipe : CommandTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=namedpipe;pipe name={0}", pipeName); - } - } - - [Category("Compressed")] - [Category("Pipe")] - public class CommandTestsPipeCompressed : CommandTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=namedpipe;pipe name={0};compress=true", pipeName); - } - } - - [Category("SharedMemory")] - public class CommandTestsSharedMemory : CommandTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=sharedmemory; shared memory name={0}", memoryName); - } - } - - [Category("Compressed")] - [Category("SharedMemory")] - public class CommandTestsSharedMemoryCompressed : CommandTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=sharedmemory; shared memory name={0};compress=true", memoryName); - } - } -#endif - #endregion - -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConfigurationManager.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConfigurationManager.cs deleted file mode 100644 index 2fe5ba2..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConfigurationManager.cs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.IO; -using System.Collections.Specialized; -using System.Reflection; -using System.Xml; - -namespace MySql.Data.MySqlClient.Tests -{ - public static class ConfigurationManager - { - private static string configurationFile; - private static NameValueCollection appSettings = new NameValueCollection(); - - public static NameValueCollection AppSettings - { - get { return appSettings; } - } - - static ConfigurationManager() - { - ConfigurationManager.configurationFile = String.Format("{0}.config", - System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); - - if (!File.Exists(ConfigurationManager.configurationFile)) - { - throw new FileNotFoundException(String.Format( - "Configuration file ({0}) not be found.", - ConfigurationManager.configurationFile)); - } - - XmlDocument configXmlDocument = new XmlDocument(); - configXmlDocument.Load(ConfigurationManager.configurationFile); - - // Add keys and values to the AppSettings NameValueCollection - foreach (XmlNode node in configXmlDocument.SelectNodes("/configuration/appSettings/add")) - { - ConfigurationManager.AppSettings.Add( - node.Attributes["key"].Value, - node.Attributes["value"].Value); - } - } - - public static void Save() - { - XmlDocument configXmlDocument = new XmlDocument(); - configXmlDocument.Load(ConfigurationManager.configurationFile); - - XmlNode node = configXmlDocument.SelectSingleNode("/configuration/appSettings"); - - if (node != null) - { - // Remove all previous appSetting nodes - node.RemoveAll(); - - foreach (string key in AppSettings.AllKeys) - { - // Create a new appSetting node - XmlElement appNode = configXmlDocument.CreateElement("add"); - - // Create the key attribute and assign its value - XmlAttribute keyAttribute = configXmlDocument.CreateAttribute("key"); - keyAttribute.Value = key; - - // Create the value attribute and assign its value - XmlAttribute valueAttribute = configXmlDocument.CreateAttribute("value"); - valueAttribute.Value = AppSettings[key]; - - // Append the key and value attribute to the appSetting node - appNode.Attributes.Append(keyAttribute); - appNode.Attributes.Append(valueAttribute); - - // Append the appSetting node to the appSettings node - node.AppendChild(appNode); - } - } - - // Save config file - configXmlDocument.Save(ConfigurationManager.configurationFile); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConnectionStringBuilder.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConnectionStringBuilder.cs deleted file mode 100644 index 849137a..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConnectionStringBuilder.cs +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class ConnectionStringBuilder : BaseTest - { - [Test] - public void Simple() - { - MySqlConnectionStringBuilder sb = null; - sb = new MySqlConnectionStringBuilder(); - sb.ConnectionString = "server=localhost;uid=reggie;pwd=pass;port=1111;" + - "connection timeout=23; pooling=true; min pool size=33; " + - "max pool size=66;keepalive=1"; - Assert.AreEqual("localhost", sb.Server); - Assert.AreEqual("reggie", sb.UserID); - Assert.AreEqual("pass", sb.Password); - Assert.AreEqual(1111, sb.Port); - Assert.AreEqual(23, sb.ConnectionTimeout); - Assert.IsTrue(sb.Pooling); - Assert.AreEqual(33, sb.MinimumPoolSize); - Assert.AreEqual(66, sb.MaximumPoolSize); - Assert.AreEqual(sb.Keepalive, 1); - - try - { - sb.ConnectionString = "server=localhost;badkey=badvalue"; - Assert.Fail("This should not work"); - } - catch (ArgumentException) - { - } - - sb.Clear(); - Assert.AreEqual(15, sb.ConnectionTimeout); - Assert.AreEqual(true, sb.Pooling); - Assert.AreEqual(3306, sb.Port); - Assert.AreEqual(String.Empty, sb.Server); - Assert.AreEqual(false, sb.PersistSecurityInfo); - Assert.AreEqual(0, sb.ConnectionLifeTime); - Assert.IsFalse(sb.ConnectionReset); - Assert.AreEqual(0, sb.MinimumPoolSize); - Assert.AreEqual(100, sb.MaximumPoolSize); - Assert.AreEqual(String.Empty, sb.UserID); - Assert.AreEqual(String.Empty, sb.Password); - Assert.AreEqual(false, sb.UseUsageAdvisor); - Assert.AreEqual(String.Empty, sb.CharacterSet); - Assert.AreEqual(false, sb.UseCompression); - Assert.AreEqual("MYSQL", sb.PipeName); - Assert.IsFalse(sb.Logging); - Assert.IsFalse(sb.UseOldSyntax); - Assert.IsTrue(sb.AllowBatch); - Assert.IsFalse(sb.ConvertZeroDateTime); - Assert.AreEqual("MYSQL", sb.SharedMemoryName); - Assert.AreEqual(String.Empty, sb.Database); - Assert.AreEqual(MySqlConnectionProtocol.Sockets, sb.ConnectionProtocol); - Assert.IsFalse(sb.AllowZeroDateTime); - Assert.IsFalse(sb.UsePerformanceMonitor); - Assert.AreEqual(25, sb.ProcedureCacheSize); - Assert.AreEqual(0, sb.Keepalive); - } - - /// - /// Bug #37955 Connector/NET keeps adding the same option to the connection string - /// - [Test] - public void SettingValueMultipeTimes() - { - MySqlConnectionStringBuilder s = new MySqlConnectionStringBuilder(); - s["database"] = "test"; - s["database"] = "test2"; - Assert.AreEqual("database=test2", s.ConnectionString); - } - - [Test] - public void EncryptKeyword() - { - string connStr = "database=test;uid=root;server=localhost;encrypt=yes"; - MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder(connStr); - } - - /// - /// Bug #51209 error on parameter without value on connectionstring - /// - [Test] - public void NoValueGivenForConnectionStringOption() - { - MySqlConnectionStringBuilder s = new MySqlConnectionStringBuilder(); - s.ConnectionString = "compress=;pooling="; - Assert.IsFalse(s.UseCompression); - Assert.IsTrue(s.Pooling); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConnectionTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConnectionTests.cs deleted file mode 100644 index 7e7bcbf..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ConnectionTests.cs +++ /dev/null @@ -1,495 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using NUnit.Framework; -using System.Configuration; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for ConnectionTests. - /// - [TestFixture] - public class ConnectionTests : BaseTest - { - [Test] - public void TestConnectionStrings() - { - MySqlConnection c = new MySqlConnection(); - - // public properties - Assert.AreEqual(15, c.ConnectionTimeout, "ConnectionTimeout"); - Assert.AreEqual("", c.Database, "Database"); - Assert.AreEqual(String.Empty, c.DataSource, "DataSource"); - Assert.AreEqual(false, c.UseCompression, "Use Compression"); - Assert.AreEqual(System.Data.ConnectionState.Closed, c.State, "State"); - - c = new MySqlConnection("connection timeout=25; user id=myuser; " + - "password=mypass; database=Test;server=myserver; use compression=true; " + - "pooling=false;min pool size=5; max pool size=101"); - // public properties - Assert.AreEqual(25, c.ConnectionTimeout, "ConnectionTimeout"); - Assert.AreEqual("Test", c.Database, "Database"); - Assert.AreEqual("myserver", c.DataSource, "DataSource"); - Assert.AreEqual(true, c.UseCompression, "Use Compression"); - Assert.AreEqual(System.Data.ConnectionState.Closed, c.State, "State"); - - c.ConnectionString = "connection timeout=15; user id=newuser; " + - "password=newpass; port=3308; database=mydb; data source=myserver2; " + - "use compression=true; pooling=true; min pool size=3; max pool size=76"; - - // public properties - Assert.AreEqual(15, c.ConnectionTimeout, "ConnectionTimeout"); - Assert.AreEqual("mydb", c.Database, "Database"); - Assert.AreEqual("myserver2", c.DataSource, "DataSource"); - Assert.AreEqual(true, c.UseCompression, "Use Compression"); - Assert.AreEqual(System.Data.ConnectionState.Closed, c.State, "State"); - } - - [Test] - public void TestConnectingSocketBadUserName() - { - suExecSQL("DELETE FROM mysql.user WHERE length(user) = 0"); - suExecSQL("FLUSH PRIVILEGES"); - - string connStr = "server={0};user id=dummy;password=;database=Test;pooling=false"; - MySqlConnection c = new MySqlConnection( - String.Format(connStr, host)); - try - { - c.Open(); - c.Close(); - throw new Exception("Open should not have worked"); - } - catch (MySqlException) - { - } - } - - [Test] - public void TestConnectingSocketBadDbName() - { - string connStr = "server={0};user id={1};password={2};database=dummy; " + - "pooling=false"; - MySqlConnection c = new MySqlConnection( - String.Format(connStr, host, user, password)); - try - { - c.Open(); - c.Close(); - throw new Exception("Open should not have worked"); - } - catch (MySqlException) - { - } - } - - [Test] - public void TestPersistSecurityInfoCachingPasswords() - { - string connStr = GetConnectionString(true); - MySqlConnection c = new MySqlConnection(connStr); - c.Open(); - c.Close(); - - // this shouldn't work - connStr = GetConnectionString(user, "bad_password", true); - c = new MySqlConnection(connStr); - try - { - c.Open(); - Assert.Fail("Thn is should not work"); - c.Close(); - return; - } - catch (MySqlException) - { - } - - // this should work - connStr = GetConnectionString(true); - c = new MySqlConnection(connStr); - c.Open(); - c.Close(); - } - - [Test] - public void ChangeDatabase() - { - string connStr = GetConnectionString(true); - MySqlConnection c = new MySqlConnection(connStr + ";pooling=false"); - c.Open(); - Assert.IsTrue(c.State == ConnectionState.Open); - - Assert.AreEqual(database0.ToLower(), c.Database.ToLower()); - - c.ChangeDatabase(database1); - - Assert.AreEqual(database1.ToLower(), c.Database.ToLower()); - - c.Close(); - } - - [Test] - public void ConnectionTimeout() - { - MySqlConnection c = new MySqlConnection( - "server=1.1.1.1;user id=bogus;pwd=bogus;Connection timeout=5;" + - "pooling=false"); - DateTime start = DateTime.Now; - try - { - c.Open(); - } - catch (Exception) - { - TimeSpan diff = DateTime.Now.Subtract(start); - Assert.IsTrue(diff.TotalSeconds < 15, "Timeout exceeded"); - } - } - - /* [Test] - public void AnonymousLogin() - { - suExecSQL(String.Format("GRANT ALL ON *.* to ''@'{0}' IDENTIFIED BY 'set_to_blank'", host)); - suExecSQL("UPDATE mysql.user SET password='' WHERE password='set_to_blank'"); - - MySqlConnection c = new MySqlConnection(String.Empty); - c.Open(); - c.Close(); - } - */ - [Test] - public void ConnectInVariousWays() - { - // connect with no db - string connStr2 = GetConnectionString(false); - MySqlConnection c = new MySqlConnection(connStr2); - c.Open(); - c.Close(); - - suExecSQL("GRANT ALL ON *.* to 'nopass'@'%'"); - suExecSQL("GRANT ALL ON *.* to 'nopass'@'localhost'"); - suExecSQL("FLUSH PRIVILEGES"); - - // connect with no password - connStr2 = GetConnectionString("nopass", null, false); - c = new MySqlConnection(connStr2); - c.Open(); - c.Close(); - - connStr2 = GetConnectionString("nopass", "", false); - c = new MySqlConnection(connStr2); - c.Open(); - c.Close(); - } - - [Test] - public void ConnectingAsUTF8() - { - if (Version < new Version(4,1)) return; - - string connStr = GetConnectionString(true) + ";charset=utf8"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand( - "CREATE TABLE test (id varbinary(16), active bit) CHARACTER SET utf8", conn); - cmd.ExecuteNonQuery(); - cmd.CommandText = "INSERT INTO test (id, active) VALUES (CAST(0x1234567890 AS Binary), true)"; - cmd.ExecuteNonQuery(); - cmd.CommandText = "INSERT INTO test (id, active) VALUES (CAST(0x123456789a AS Binary), true)"; - cmd.ExecuteNonQuery(); - cmd.CommandText = "INSERT INTO test (id, active) VALUES (CAST(0x123456789b AS Binary), true)"; - cmd.ExecuteNonQuery(); - } - - using (MySqlConnection d = new MySqlConnection(connStr)) - { - d.Open(); - - MySqlCommand cmd2 = new MySqlCommand("SELECT id, active FROM test", d); - using (MySqlDataReader reader = cmd2.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.IsTrue(reader.GetBoolean(1)); - } - } - } - - /// - /// Bug #10281 Clone issue with MySqlConnection - /// Bug #27269 MySqlConnection.Clone does not mimic SqlConnection.Clone behaviour - /// - [Test] - public void TestConnectionClone() - { - MySqlConnection c = new MySqlConnection(); - MySqlConnection clone = (MySqlConnection)((ICloneable)c).Clone(); - clone.ToString(); - - string connStr = GetConnectionString(true); - connStr = connStr.Replace("persist security info=true", "persist security info=false"); - c = new MySqlConnection(connStr); - c.Open(); - c.Close(); - MySqlConnection c2 = (MySqlConnection)((ICloneable)c).Clone(); - c2.Open(); - c2.Close(); - } - - /// - /// Bug #13321 Persist security info does not woek - /// - [Test] - public void PersistSecurityInfo() - { - string s = GetConnectionString(true).ToLower(); - int start = s.IndexOf("persist security info"); - int end = s.IndexOf(";", start); - string connStr = s.Substring(0, start); - connStr += s.Substring(end, s.Length - (end)); - - string p = "password"; - if (connStr.IndexOf("pwd") != -1) - p = "pwd"; - else if (connStr.IndexOf("passwd") != -1) - p = "passwd"; - - string newConnStr = connStr + ";persist security info=true"; - MySqlConnection conn2 = new MySqlConnection(newConnStr); - Assert.IsTrue(conn2.ConnectionString.IndexOf(p) != -1); - conn2.Open(); - conn2.Close(); - Assert.IsTrue(conn2.ConnectionString.IndexOf(p) != -1); - - newConnStr = connStr + ";persist security info=false"; - conn2 = new MySqlConnection(newConnStr); - Assert.IsTrue(conn2.ConnectionString.IndexOf(p) != -1); - conn2.Open(); - conn2.Close(); - Assert.IsTrue(conn2.ConnectionString.IndexOf(p) == -1); - } - - /// - /// Bug #13658 connection.state does not update on Ping() - /// - [Test] - public void PingUpdatesState() - { - MySqlConnection conn2 = new MySqlConnection(GetConnectionString(true)); - conn2.Open(); - KillConnection(conn2); - Assert.IsFalse(conn2.Ping()); - Assert.IsTrue(conn2.State == ConnectionState.Closed); - conn2.Open(); - conn2.Close(); - } - - /// - /// Bug #16659 Can't use double quotation marks(") as password access server by Connector/NET - /// - [Test] - public void ConnectWithQuotePassword() - { - suExecSQL("GRANT ALL ON *.* to 'quotedUser'@'%' IDENTIFIED BY '\"'"); - suExecSQL("GRANT ALL ON *.* to 'quotedUser'@'localhost' IDENTIFIED BY '\"'"); - string connStr = GetConnectionString("quotedUser", null, false); - connStr += ";pwd='\"'"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - } - } - - /// - /// Bug #24802 Error Handling - /// - [Test] - public void TestConnectingSocketBadHostName() - { - string connStr = "server=foobar;user id=foouser;password=;database=Test;" + - "pooling=false"; - try - { - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - } - } - catch (MySqlException ex) - { - Assert.AreEqual((int)MySqlErrorCode.UnableToConnectToHost, ex.Number); - } - } - - /// - /// Bug #29123 Connection String grows with each use resulting in OutOfMemoryException - /// - [Test] - public void ConnectionStringNotAffectedByChangeDatabase() - { - for (int i = 0; i < 10; i++) - { - string connStr = GetConnectionString(true) + ";pooling=false"; - connStr = connStr.Replace("database", "Initial Catalog"); - connStr = connStr.Replace("persist security info=true", - "persist security info=false"); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - string str = c.ConnectionString; - int index = str.IndexOf("Database="); - Assert.AreEqual(-1, index); - } - } - } - - - class ConnectionClosedCheck - { - public bool closed = false; - public void stateChangeHandler(object sender, StateChangeEventArgs e) - { - if (e.CurrentState == ConnectionState.Closed) - closed = true; - } - } - [Test] - public void ConnectionCloseByGC() - { - int threadId; - ConnectionClosedCheck check = new ConnectionClosedCheck(); - string connStr = GetConnectionString(true)+";pooling=true"; - MySqlConnection c = new MySqlConnection(connStr); - c.StateChange += new StateChangeEventHandler(check.stateChangeHandler); - c.Open(); - threadId= c.ServerThread; - c = null; - GC.Collect(); - GC.WaitForPendingFinalizers(); - Assert.IsTrue(check.closed); - - MySqlCommand cmd = new MySqlCommand("KILL " + threadId, conn); - cmd.ExecuteNonQuery(); - } - /// - /// Bug #30964 StateChange imperfection - /// - MySqlConnection rqConnection; - [Test] - public void RunningAQueryFromStateChangeHandler() - { - string connStr = GetConnectionString(true); - using (rqConnection = new MySqlConnection(connStr)) - { - rqConnection.StateChange += new StateChangeEventHandler(RunningQueryStateChangeHandler); - rqConnection.Open(); - } - } - - void RunningQueryStateChangeHandler(object sender, StateChangeEventArgs e) - { - if (e.CurrentState == ConnectionState.Open) - { - MySqlCommand cmd = new MySqlCommand("SELECT 1", rqConnection); - object o = cmd.ExecuteScalar(); - Assert.AreEqual(1, o); - } - } - - /// - /// Bug #31262 NullReferenceException in MySql.Data.MySqlClient.NativeDriver.ExecuteCommand - /// - [Test] - public void ConnectionNotOpenThrowningBadException() - { - MySqlConnection c2 = new MySqlConnection(); - c2.ConnectionString = GetConnectionString(true); // "DataSource=localhost;Database=test;UserID=root;Password=********;PORT=3306;Allow Zero Datetime=True;logging=True;"; - //conn.Open(); << REM - MySqlCommand command = new MySqlCommand(); - command.Connection = c2; - - MySqlCommand cmdCreateTable = new MySqlCommand("DROP TABLE IF EXISTS `test`.`contents_catalog`", c2); - cmdCreateTable.CommandType = CommandType.Text; - cmdCreateTable.CommandTimeout = 0; - try - { - cmdCreateTable.ExecuteNonQuery(); - } - catch (InvalidOperationException) - { - } - } - - /// - /// Bug #31433 Username incorrectly cached for logon where case sensitive - /// - [Test] - public void CaseSensitiveUserId() - { - string connStr = GetConnectionString("Test", "test", true); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - try - { - c.Open(); - } - catch (MySqlException) - { - } - } - - connStr = GetConnectionString("test", "test", true); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - } - } - - /// - /// Bug #35619 creating a MySql connection from toolbox generates an error - /// - [Test] - public void NullConnectionString() - { - MySqlConnection c = new MySqlConnection(); - c.ConnectionString = null; - } - - /// - /// Test if keepalive parameters work. - /// - [Test] - public void Keepalive() - { - string connstr = GetConnectionString("test", "test", true); - connstr += ";keepalive=1;"; - using (MySqlConnection c = new MySqlConnection(connstr)) - { - c.Open(); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CultureTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CultureTests.cs deleted file mode 100644 index 95c8fa4..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CultureTests.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using System.Globalization; -using System.Threading; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class CultureTests : BaseTest - { -#if !CF - - [Test] - public void TestFloats() - { - InternalTestFloats(false); - } - - [Test] - public void TestFloatsPrepared() - { - if (Version < new Version(4, 1)) return; - - InternalTestFloats(true); - } - - private void InternalTestFloats(bool prepared) - { - CultureInfo curCulture = Thread.CurrentThread.CurrentCulture; - CultureInfo curUICulture = Thread.CurrentThread.CurrentUICulture; - CultureInfo c = new CultureInfo("de-DE"); - Thread.CurrentThread.CurrentCulture = c; - Thread.CurrentThread.CurrentUICulture = c; - - execSQL("CREATE TABLE Test (fl FLOAT, db DOUBLE, dec1 DECIMAL(5,2))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?fl, ?db, ?dec)", conn); - cmd.Parameters.Add("?fl", MySqlDbType.Float); - cmd.Parameters.Add("?db", MySqlDbType.Double); - cmd.Parameters.Add("?dec", MySqlDbType.Decimal); - cmd.Parameters[0].Value = 2.3; - cmd.Parameters[1].Value = 4.6; - cmd.Parameters[2].Value = 23.82; - if (prepared) - cmd.Prepare(); - int count = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, count); - - try - { - cmd.CommandText = "SELECT * FROM Test"; - if (prepared) cmd.Prepare(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual(2.3, (decimal)reader.GetFloat(0)); - Assert.AreEqual(4.6, reader.GetDouble(1)); - Assert.AreEqual(23.82, reader.GetDecimal(2)); - } - } - finally - { - Thread.CurrentThread.CurrentCulture = curCulture; - Thread.CurrentThread.CurrentUICulture = curUICulture; - } - } - - /// - /// Bug #8228 turkish character set causing the error - /// - [Test] - public void Turkish() - { - CultureInfo curCulture = Thread.CurrentThread.CurrentCulture; - CultureInfo curUICulture = Thread.CurrentThread.CurrentUICulture; - CultureInfo c = new CultureInfo("tr-TR"); - Thread.CurrentThread.CurrentCulture = c; - Thread.CurrentThread.CurrentUICulture = c; - - using (MySqlConnection newConn = new MySqlConnection(GetConnectionString(true))) - { - newConn.Open(); - } - - Thread.CurrentThread.CurrentCulture = curCulture; - Thread.CurrentThread.CurrentUICulture = curUICulture; - } - - /// - /// Bug #29931 Connector/NET does not handle Saudi Hijri calendar correctly - /// - [Test] - public void ArabicCalendars() - { - execSQL("CREATE TABLE test(dt DATETIME)"); - execSQL("INSERT INTO test VALUES ('2007-01-01 12:30:45')"); - - CultureInfo curCulture = Thread.CurrentThread.CurrentCulture; - CultureInfo curUICulture = Thread.CurrentThread.CurrentUICulture; - CultureInfo c = new CultureInfo("ar-SA"); - Thread.CurrentThread.CurrentCulture = c; - Thread.CurrentThread.CurrentUICulture = c; - - MySqlCommand cmd = new MySqlCommand("SELECT dt FROM test", conn); - DateTime dt = (DateTime)cmd.ExecuteScalar(); - Assert.AreEqual(2007, dt.Year); - Assert.AreEqual(1, dt.Month); - Assert.AreEqual(1, dt.Day); - Assert.AreEqual(12, dt.Hour); - Assert.AreEqual(30, dt.Minute); - Assert.AreEqual(45, dt.Second); - - Thread.CurrentThread.CurrentCulture = curCulture; - Thread.CurrentThread.CurrentUICulture = curUICulture; - } -#endif - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CursorTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CursorTests.cs deleted file mode 100644 index 540e92a..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/CursorTests.cs +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (C) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Threading; -using MySql.Data.MySqlClient; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for BlobTests. - /// - [TestFixture] - public class CursorTests : BaseTest - { - protected override void FixtureSetup() - { - Open(); - - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("DROP TABLE IF EXISTS Test2"); - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), PRIMARY KEY(id))"); - execSQL("CREATE TABLE Test2 (id INT NOT NULL, parent INT, PRIMARY KEY(id))"); - } - - protected override void TestFixtureTearDown() - { - execSQL("DROP TABLE IF EXISTS Test2"); - Close(); - } - -/* [Test] - public void NestedCursors() - { - execSQL("INSERT INTO Test VALUES (1, 'Test1')"); - execSQL("INSERT INTO Test VALUES (2, 'Test2')"); - execSQL("INSERT INTO Test VALUES (3, 'Test3')"); - execSQL("INSERT INTO Test2 VALUES (66, 1)"); - execSQL("INSERT INTO Test2 VALUES (77, 2)"); - execSQL("INSERT INTO Test2 VALUES (88, 3)"); - - MySqlCommand cmdOuter = new MySqlCommand("SELECT * FROM Test", conn); - MySqlDataReader reader = null; - MySqlDataReader reader2 = null; - try - { - cmdOuter.Prepare(1); - reader = cmdOuter.ExecuteReader(); - Assert.IsTrue( reader.Read() ); - Assert.AreEqual( 1, reader.GetInt32(0) ); - Assert.AreEqual( "Test1", reader.GetString(1) ); - - MySqlCommand cmd = new MySqlCommand( "SELECT * FROM Test2 WHERE parent=" + reader.GetInt32(0), conn ); - cmd.Prepare(1); - reader2 = cmd.ExecuteReader(); - Assert.IsTrue( reader2.Read() ); - Assert.AreEqual( 66, reader2.GetInt32(0) ); - reader2.Close(); - - Assert.IsTrue( reader.Read() ); - Assert.AreEqual( 2, reader.GetInt32(0) ); - Assert.AreEqual( "Test2", reader.GetString(1) ); - - cmd.CommandText = "SELECT * FROM Test2 WHERE parent=" + reader.GetInt32(0); - cmd.Prepare(1); - reader2 = cmd.ExecuteReader(); - Assert.IsTrue( reader2.Read() ); - Assert.AreEqual( 77, reader2.GetInt32(0) ); - reader2.Close(); - - Assert.IsTrue( reader.Read() ); - Assert.AreEqual( 3, reader.GetInt32(0) ); - Assert.AreEqual( "Test3", reader.GetString(1) ); - - cmd.CommandText = "SELECT * FROM Test2 WHERE parent=" + reader.GetInt32(0); - cmd.Prepare(1); - reader2 = cmd.ExecuteReader(); - Assert.IsTrue( reader2.Read() ); - Assert.AreEqual( 88, reader2.GetInt32(0) ); - reader2.Close(); - - Assert.IsFalse( reader.NextResult() ); - } - catch (Exception ex) - { - Assert.Fail( ex.Message ); - } - finally - { - if (reader != null) reader.Close(); - } - } -*/ -/* [Test] - public void SimpleCursors() - { - execSQL("INSERT INTO Test VALUES (1, 'Test1')"); - execSQL("INSERT INTO Test VALUES (2, 'Test2')"); - execSQL("INSERT INTO Test VALUES (3, 'Test3')"); - execSQL("INSERT INTO Test VALUES (4, 'Test4')"); - execSQL("INSERT INTO Test VALUES (5, 'Test5')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - MySqlDataReader reader =null; - try - { - cmd.Prepare(1); - reader = cmd.ExecuteReader(); - Assert.IsTrue( reader.Read() ); - Assert.AreEqual( 1, reader.GetInt32(0) ); - Assert.AreEqual( "Test1", reader.GetString(1) ); - Assert.IsTrue( reader.Read() ); - Assert.AreEqual( 2, reader.GetInt32(0) ); - Assert.AreEqual( "Test2", reader.GetString(1) ); - Assert.IsTrue( reader.Read() ); - Assert.AreEqual( 3, reader.GetInt32(0) ); - Assert.AreEqual( "Test3", reader.GetString(1) ); - Assert.IsTrue( reader.Read() ); - Assert.AreEqual( 4, reader.GetInt32(0) ); - Assert.AreEqual( "Test4", reader.GetString(1) ); - Assert.IsTrue( reader.Read() ); - Assert.AreEqual( 5, reader.GetInt32(0) ); - Assert.AreEqual( "Test5", reader.GetString(1) ); - - Assert.IsFalse( reader.NextResult() ); - } - catch (Exception ex) - { - Assert.Fail( ex.Message ); - } - finally - { - if (reader != null) reader.Close(); - } - }*/ - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataAdapterTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataAdapterTests.cs deleted file mode 100644 index bf1d244..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataAdapterTests.cs +++ /dev/null @@ -1,848 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using MySql.Data.MySqlClient; -using MySql.Data.Types; -using System.Data; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for ConnectionTests. - /// - [TestFixture] - public class DataAdapterTests : BaseTest - { - private void CreateDefaultTable() - { - execSQL("CREATE TABLE Test (id INT NOT NULL AUTO_INCREMENT, " + - "id2 INT NOT NULL, name VARCHAR(100), dt DATETIME, tm TIME, " + - "ts TIMESTAMP, OriginalId INT, PRIMARY KEY(id, id2))"); - } - - [Test] - public void TestFill() - { - FillImpl(false); - } - - [Test] - public void TestFillPrepared() - { - FillImpl(true); - } - - private void FillImpl(bool prepare) - { - CreateDefaultTable(); - execSQL("INSERT INTO Test (id, id2, name, dt) VALUES (NULL, 1, 'Name 1', Now())"); - execSQL("INSERT INTO Test (id, id2, name, dt) VALUES (NULL, 2, NULL, Now())"); - execSQL("INSERT INTO Test (id, id2, name, dt) VALUES (NULL, 3, '', Now())"); - - MySqlDataAdapter da = new MySqlDataAdapter("select * from Test", conn); - if (prepare) da.SelectCommand.Prepare(); - DataSet ds = new DataSet(); - da.Fill(ds, "Test"); - - Assert.AreEqual(1, ds.Tables.Count); - Assert.AreEqual(3, ds.Tables[0].Rows.Count); - - Assert.AreEqual(1, ds.Tables[0].Rows[0]["id2"]); - Assert.AreEqual(2, ds.Tables[0].Rows[1]["id2"]); - Assert.AreEqual(3, ds.Tables[0].Rows[2]["id2"]); - - Assert.AreEqual("Name 1", ds.Tables[0].Rows[0]["name"]); - Assert.AreEqual(DBNull.Value, ds.Tables[0].Rows[1]["name"]); - Assert.AreEqual(String.Empty, ds.Tables[0].Rows[2]["name"]); - } - - [Test] - public void TestUpdate() - { - CreateDefaultTable(); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - DataTable dt = new DataTable(); - da.Fill(dt); - - DataRow dr = dt.NewRow(); - dr["id2"] = 2; - dr["name"] = "TestName1"; - dt.Rows.Add(dr); - int count = da.Update(dt); - - // make sure our refresh of auto increment values worked - Assert.AreEqual(1, count, "checking insert count"); - Assert.IsNotNull(dt.Rows[ dt.Rows.Count-1 ]["id"], - "Checking auto increment column"); - - dt.Rows.Clear(); - da.Fill(dt); - dt.Rows[0]["id2"] = 3; - dt.Rows[0]["name"] = "TestName2"; - dt.Rows[0]["ts"] = DBNull.Value; - DateTime day1 = new DateTime(2003, 1, 16, 12, 24, 0); - dt.Rows[0]["dt"] = day1; - dt.Rows[0]["tm"] = day1.TimeOfDay; - count = da.Update(dt); - - Assert.IsNotNull(dt.Rows[0]["ts"], "checking refresh of record"); - Assert.AreEqual(3, dt.Rows[0]["id2"], "checking refresh of primary column"); - - dt.Rows.Clear(); - da.Fill(dt); - - Assert.AreEqual(1, count, "checking update count"); - DateTime dateTime = (DateTime)dt.Rows[0]["dt"]; - Assert.AreEqual(day1.Date, dateTime.Date, "checking date"); - Assert.AreEqual(day1.TimeOfDay, dt.Rows[0]["tm"], "checking time"); - - dt.Rows[0].Delete(); - count = da.Update(dt); - - Assert.AreEqual(1, count, "checking insert count"); - - dt.Rows.Clear(); - da.Fill(dt); - Assert.AreEqual(0, dt.Rows.Count, "checking row count"); - cb.Dispose(); - } - - [Test] - public void OriginalInName() - { - CreateDefaultTable(); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - cb.ToString(); // keep the compiler happy - DataTable dt = new DataTable(); - da.Fill(dt); - - DataRow row = dt.NewRow(); - row["id"] = DBNull.Value; - row["id2"] = 1; - row["name"] = "Test"; - row["dt"] = DBNull.Value; - row["tm"] = DBNull.Value; - row["ts"] = DBNull.Value; - row["OriginalId"] = 2; - dt.Rows.Add( row ); - da.Update(dt); - - Assert.AreEqual( 1, dt.Rows.Count ); - Assert.AreEqual( 2, dt.Rows[0]["OriginalId"] ); - } - - [Test] - public void UseAdapterPropertyOfCommandBuilder() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 1, 'Test')"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(); - cb.DataAdapter = da; - - DataTable dt = new DataTable(); - da.Fill(dt); - - dt.Rows[0]["name"] = "Test Update"; - int updateCnt = da.Update(dt); - - Assert.AreEqual( 1, updateCnt ); - - dt.Rows.Clear(); - da.Fill(dt); - - Assert.AreEqual( 1, dt.Rows.Count ); - Assert.AreEqual( "Test Update", dt.Rows[0]["name"] ); - } - - [Test] - public void UpdateNullTextFieldToEmptyString() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test (id, id2, name) VALUES (1, 1, NULL)"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - cb.ToString(); // keep the compiler happy - - DataTable dt = new DataTable(); - da.Fill(dt); - - dt.Rows[0]["name"] = ""; - int updateCnt = da.Update(dt); - - Assert.AreEqual( 1, updateCnt ); - - dt.Rows.Clear(); - da.Fill(dt); - - Assert.AreEqual( 1, dt.Rows.Count ); - Assert.AreEqual( "", dt.Rows[0]["name"] ); - } - - [Test] - public void UpdateExtendedTextFields() - { - execSQL("CREATE TABLE Test (id int, notes MEDIUMTEXT, PRIMARY KEY(id))"); - execSQL("INSERT INTO Test VALUES(1, 'This is my note')"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - cb.ToString(); // keep the compiler happy - DataTable dt = new DataTable(); - da.Fill(dt); - - dt.Rows[0]["notes"] = "This is my new note"; - da.Update( dt ); - - dt.Clear(); - da.Fill(dt); - Assert.AreEqual( "This is my new note", dt.Rows[0]["notes"]); - } - - [Test] - public void SelectMoreThan252Rows() - { - CreateDefaultTable(); - for (int i = 0; i < 500; i++) - execSQL("INSERT INTO Test(id, id2) VALUES(NULL, " + i + ")"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - - Assert.AreEqual( 500, dt.Rows.Count ); - } - -/* [Test] - [Explicit] - public void UpdateManyRows() - { - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - DataTable dt = new DataTable(); - da.Fill(dt); - - for (int i=0; i < 100000; i++) - { - DataRow dr = dt.NewRow(); - dr["id"] = DBNull.Value; - dr["id2"] = i; - dt.Rows.Add( dr ); - DataTable changes = dt.GetChanges(); - da.Update( changes ); - dt.AcceptChanges(); - } - - dt.Clear(); - da.Fill(dt); - Assert.AreEqual(100000, dt.Rows.Count); - } -*/ - [Test] - public void DiscreteValues() - { - execSQL("CREATE TABLE Test (id int, name varchar(200), dt DATETIME, b1 TEXT)"); - execSQL("INSERT INTO Test VALUES (1, 'Test', '2004-08-01', 'Text 1')"); - execSQL("INSERT INTO Test VALUES (2, 'Test 1', '2004-07-02', 'Text 2')"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - - Assert.AreEqual("Test", dt.Rows[0]["name"]); - Assert.AreEqual("Test 1", dt.Rows[1]["name"]); - - Assert.AreEqual("Text 1", dt.Rows[0]["b1"]); - Assert.AreEqual("Text 2", dt.Rows[1]["b1"]); - - Assert.AreEqual(new DateTime(2004, 8, 1, 0, 0, 0).ToString(), dt.Rows[0]["dt"].ToString()); - Assert.AreEqual(new DateTime(2004, 7, 2, 0, 0, 0).ToString(), dt.Rows[1]["dt"].ToString()); - } - - [Test] - public void Bug5798() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test (id, id2, name) VALUES (1, 1, '')"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - cb.ToString(); // keep the compiler happy - DataTable dt = new DataTable(); - da.Fill(dt); - - Assert.AreEqual(String.Empty, dt.Rows[0]["name"]); - - dt.Rows[0]["name"] = "Test"; - da.Update(dt); - - dt.Clear(); - da.Fill(dt); - Assert.AreEqual("Test", dt.Rows[0]["name"]); - } - - [Test] - public void ColumnMapping() - { - execSQL("CREATE TABLE Test (id int, dcname varchar(100), primary key(id))"); - execSQL("INSERT INTO Test VALUES (1, 'Test1')"); - execSQL("INSERT INTO Test VALUES (2, 'Test2')"); - execSQL("INSERT INTO Test VALUES (3, 'Test3')"); - execSQL("INSERT INTO Test VALUES (4, 'Test4')"); - -// MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); -// MySqlCommandBuilder cb = new MySqlCommandBuilder(da); -// DataTable dt = new DataTable(); - } - - [Test] - public void TestFillWithHelper() - { - execSQL("CREATE TABLE table1 (`key` INT, PRIMARY KEY(`key`))"); - execSQL("CREATE TABLE table2 (`key` INT, PRIMARY KEY(`key`))"); - execSQL("INSERT INTO table1 VALUES (1)"); - execSQL("INSERT INTO table2 VALUES (1)"); - - string sql = "SELECT table1.key FROM table1 WHERE table1.key=1; " + - "SELECT table2.key FROM table2 WHERE table2.key=1"; - DataSet ds = MySqlHelper.ExecuteDataset( conn, sql, null ); - Assert.AreEqual( 2, ds.Tables.Count ); - Assert.AreEqual( 1, ds.Tables[0].Rows.Count ); - Assert.AreEqual( 1, ds.Tables[1].Rows.Count ); - Assert.AreEqual( 1, ds.Tables[0].Rows[0]["key"] ); - Assert.AreEqual( 1, ds.Tables[1].Rows[0]["key"] ); - } - - /// - /// Bug #8509 - MySqlDataAdapter.FillSchema does not interpret unsigned integer - /// - [Test] - public void AutoIncrementColumns() - { - execSQL("CREATE TABLE Test (id int(10) unsigned NOT NULL auto_increment primary key)"); - execSQL("INSERT INTO Test VALUES(NULL)"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - DataSet ds = new DataSet(); - da.Fill(ds); - Assert.AreEqual(1, ds.Tables[0].Rows[0]["id"]); - DataRow row = ds.Tables[0].NewRow(); - ds.Tables[0].Rows.Add(row); - - da.Update(ds); - - ds.Clear(); - da.Fill(ds); - Assert.AreEqual(1, ds.Tables[0].Rows[0]["id"]); - Assert.AreEqual(2, ds.Tables[0].Rows[1]["id"]); - cb.Dispose(); - } - - /// - /// Bug #8292 GROUP BY / WITH ROLLUP with DataSet causes System.Data.ConstraintException - /// - [Test] - public void Rollup() - { - if (Version < new Version(4, 1)) - return; - - execSQL("CREATE TABLE Test ( id INT NOT NULL, amount INT )"); - execSQL("INSERT INTO Test VALUES (1, 44)"); - execSQL("INSERT INTO Test VALUES (2, 88)"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test GROUP BY id WITH ROLLUP", conn); - DataSet ds = new DataSet(); - da.Fill(ds); - - Assert.AreEqual(1, ds.Tables.Count); - Assert.AreEqual(3, ds.Tables[0].Rows.Count); - Assert.AreEqual(88, ds.Tables[0].Rows[2]["amount"]); - Assert.AreEqual(DBNull.Value, ds.Tables[0].Rows[2]["id"]); - } - - /// - /// Bug #8514 CURRENT_TIMESTAMP default not respected - /// -/* [Test] - public void DefaultValues() - { - execSQL("CREATE TABLE Test (id int, name VARCHAR(20) NOT NULL DEFAULT 'abc', dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommand insCmd = new MySqlCommand("INSERT INTO Test VALUES (?id, ?name, ?dt)", conn); - insCmd.Parameters.Add("?id", MySqlDbType.Int32, 0, "id"); - insCmd.Parameters.Add("?name", MySqlDbType.VarChar, 20, "name"); - insCmd.Parameters.Add("?dt", MySqlDbType.Datetime, 0, "dt"); - da.InsertCommand = insCmd; - - DataTable dt = new DataTable(); - - //da.FillSchema(ds, SchemaType.Source);//, "Test"); - da.MissingSchemaAction = MissingSchemaAction.AddWithKey; - try - { - da.Fill(dt); - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } - - - DataRow row = dt.NewRow(); - row["id"] = 1; - row["name"] = "xyz"; - dt.Rows.Add(row); - - DataRow row2 = dt.NewRow(); - row2["id"] = 2; - row2["name"] = DBNull.Value; - dt.Rows.Add(row2); - - da.Update(dt); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(1, reader["id"]); - Assert.AreEqual("xyz", reader["name"]); - Assert.AreEqual(DateTime.Now.Year, reader.GetDateTime(2).Year); - Assert.IsTrue(reader.Read()); - Assert.AreEqual(2, reader["id"]); - Assert.AreEqual("abc", reader["name"]); - Assert.AreEqual(DateTime.Now.Year, reader.GetDateTime(2).Year); - Assert.IsFalse(reader.Read()); - } - } -*/ - /// - /// Bug #16307 @@Identity returning incorrect value - /// - [Test] - public void Bug16307() - { - execSQL("CREATE TABLE Test (OrgNum int auto_increment, CallReportNum int, Stamp varchar(50), " + - "WasRealCall varchar(50), WasHangup varchar(50), primary key(orgnum))"); - - string strSQL = "INSERT INTO Test(OrgNum, CallReportNum, Stamp, WasRealCall, WasHangup) " + - "VALUES (?OrgNum, ?CallReportNum, ?Stamp, ?WasRealCall, ?WasHangup)"; - - MySqlCommand cmd = new MySqlCommand(strSQL, conn); - MySqlParameterCollection pc = cmd.Parameters; - - pc.Add("?OrgNum", MySqlDbType.Int32, 0, "OrgNum"); - pc.Add("?CallReportNum", MySqlDbType.Int32, 0, "CallReportNum"); - pc.Add("?Stamp", MySqlDbType.VarChar, 0, "Stamp"); - pc.Add("?WasRealCall", MySqlDbType.VarChar, 0, "WasRealCall"); - pc.Add("?WasHangup", MySqlDbType.VarChar, 0, "WasHangup"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - da.InsertCommand = cmd; - - DataSet ds = new DataSet(); - da.Fill(ds); - - DataRow row = ds.Tables[0].NewRow(); - row["CallReportNum"] = 1; - row["Stamp"] = "stamp"; - row["WasRealCall"] = "yes"; - row["WasHangup"] = "no"; - ds.Tables[0].Rows.Add(row); - - da.Update(ds.Tables[0]); - - strSQL = "SELECT @@IDENTITY AS 'Identity';"; - MySqlCommand cmd2 = new MySqlCommand(strSQL, conn); - using (MySqlDataReader reader = cmd2.ExecuteReader()) - { - reader.Read(); - int intCallNum = Int32.Parse(reader.GetValue(0).ToString()); - Assert.AreEqual(1, intCallNum); - } - } - - /// - /// Bug #8131 Data Adapter doesn't close connection - /// - [Test] - public void QuietOpenAndClose() - { - execSQL("CREATE TABLE Test (id INT, PRIMARY KEY(id))"); - execSQL("INSERT INTO Test VALUES(1)"); - - using (MySqlConnection c = new MySqlConnection(GetConnectionString(true))) - { - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", c); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - Assert.IsTrue(c.State == ConnectionState.Closed); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.IsTrue(c.State == ConnectionState.Closed); - Assert.AreEqual(1, dt.Rows.Count); - - dt.Rows[0][0] = 2; - DataRow[] rows = new DataRow[1]; - rows[0] = dt.Rows[0]; - da.Update(dt); - Assert.IsTrue(c.State == ConnectionState.Closed); - - dt.Clear(); - c.Open(); - Assert.IsTrue(c.State == ConnectionState.Open); - da.Fill(dt); - Assert.IsTrue(c.State == ConnectionState.Open); - Assert.AreEqual(1, dt.Rows.Count); - cb.Dispose(); - } - } - - [Test] - public void RangeFill() - { - execSQL("CREATE TABLE Test (id INT)"); - execSQL("INSERT INTO Test VALUES (1)"); - execSQL("INSERT INTO Test VALUES (2)"); - execSQL("INSERT INTO Test VALUES (3)"); - execSQL("INSERT INTO Test VALUES (4)"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataSet ds = new DataSet(); - da.Fill(ds, 1, 2, "Test"); - } - - [Test] - public void FillWithNulls() - { - execSQL(@"CREATE TABLE Test (id INT UNSIGNED NOT NULL AUTO_INCREMENT, - name VARCHAR(100), PRIMARY KEY(id))"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - DataTable dt = new DataTable(); - da.Fill(dt); - dt.Columns[0].AutoIncrement = true; - dt.Columns[0].AutoIncrementSeed = -1; - dt.Columns[0].AutoIncrementStep = -1; - DataRow row = dt.NewRow(); - row["name"] = "Test1"; - - dt.Rows.Add(row); - da.Update(dt); - - dt.Clear(); - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(1, dt.Rows[0]["id"]); - Assert.AreEqual("Test1", dt.Rows[0]["name"]); - - row = dt.NewRow(); - row["name"] = System.DBNull.Value; - - dt.Rows.Add(row); - da.Update(dt); - - dt.Clear(); - da.Fill(dt); - Assert.AreEqual(2, dt.Rows.Count); - Assert.AreEqual(2, dt.Rows[1]["id"]); - Assert.AreEqual(DBNull.Value, dt.Rows[1]["name"]); - - row = dt.NewRow(); - row["name"] = "Test3"; - - dt.Rows.Add(row); - da.Update(dt); - - dt.Clear(); - da.Fill(dt); - Assert.AreEqual(3, dt.Rows.Count); - Assert.AreEqual(3, dt.Rows[2]["id"]); - Assert.AreEqual("Test3", dt.Rows[2]["name"]); - cb.Dispose(); - } - - [Test] - public void PagingFill() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 1, 'Name 1')"); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 2, 'Name 2')"); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 3, 'Name 3')"); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 4, 'Name 4')"); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 5, 'Name 5')"); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 6, 'Name 6')"); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 7, 'Name 7')"); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 8, 'Name 8')"); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 9, 'Name 9')"); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 10, 'Name 10')"); - execSQL("INSERT INTO Test (id, id2, name) VALUES (NULL, 11, 'Name 11')"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(0, 10, new DataTable[] { dt }); - Assert.AreEqual(10, dt.Rows.Count); - } - - private string MakeLargeString(int len) - { - System.Text.StringBuilder sb = new System.Text.StringBuilder(len); - while (len-- > 0) - sb.Append('a'); - return sb.ToString(); - } - - [Test] - public void SkippingRowsLargerThan1024() - { - execSQL("CREATE TABLE Test (id INT, name TEXT)"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, ?name)", conn); - cmd.Parameters.Add("?id", MySqlDbType.Int32); - cmd.Parameters.Add("?name", MySqlDbType.Text); - for (int i = 0; i < 5; i++) - { - cmd.Parameters[0].Value = i; - cmd.Parameters[1].Value = MakeLargeString(2000); - cmd.ExecuteNonQuery(); - } - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(0, 2, new DataTable[] { dt }); - } - - [Test] - public void TestBatchingInserts() - { - execSQL("CREATE TABLE Test (id INT, name VARCHAR(20), PRIMARY KEY(id))"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommand ins = new MySqlCommand("INSERT INTO test (id, name) VALUES (?p1, ?p2)", conn); - da.InsertCommand = ins; - ins.UpdatedRowSource = UpdateRowSource.None; - ins.Parameters.Add("?p1", MySqlDbType.Int32).SourceColumn = "id"; - ins.Parameters.Add("?p2", MySqlDbType.VarChar, 20).SourceColumn = "name"; - - DataTable dt = new DataTable(); - da.Fill(dt); - - for (int i = 1; i <= 100; i++) - { - DataRow row = dt.NewRow(); - row["id"] = i; - row["name"] = "name " + i; - dt.Rows.Add(row); - } - - da.UpdateBatchSize = 10; - da.Update(dt); - - dt.Rows.Clear(); - da.Fill(dt); - Assert.AreEqual(100, dt.Rows.Count); - for (int i = 0; i < 100; i++) - { - Assert.AreEqual(i+1, dt.Rows[i]["id"]); - Assert.AreEqual("name " + (i+1), dt.Rows[i]["name"]); - } - } - - [Test] - public void TestBatchingUpdates() - { - execSQL("CREATE TABLE Test (id INT, name VARCHAR(20), PRIMARY KEY(id))"); - execSQL("INSERT INTO Test VALUES (1, 'Test 1')"); - execSQL("INSERT INTO Test VALUES (2, 'Test 2')"); - execSQL("INSERT INTO Test VALUES (3, 'Test 3')"); - - MySqlDataAdapter dummyDA = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(dummyDA); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - da.UpdateCommand = cb.GetUpdateCommand(); - da.UpdateCommand.UpdatedRowSource = UpdateRowSource.None; - - DataTable dt = new DataTable(); - da.Fill(dt); - - dt.Rows[0]["id"] = 4; - dt.Rows[1]["name"] = "new test value"; - dt.Rows[2]["id"] = 6; - dt.Rows[2]["name"] = "new test value #2"; - - da.UpdateBatchSize = 0; - da.Update(dt); - - dt.Rows.Clear(); - da.Fill(dt); - Assert.AreEqual(3, dt.Rows.Count); - Assert.AreEqual(4, dt.Rows[0]["id"]); - Assert.AreEqual(2, dt.Rows[1]["id"]); - Assert.AreEqual(6, dt.Rows[2]["id"]); - Assert.AreEqual("Test 1", dt.Rows[0]["name"]); - Assert.AreEqual("new test value", dt.Rows[1]["name"]); - Assert.AreEqual("new test value #2", dt.Rows[2]["name"]); - } - - [Test] - public void TestBatchingMixed() - { - execSQL("CREATE TABLE Test (id INT, name VARCHAR(20), PRIMARY KEY(id))"); - execSQL("INSERT INTO Test VALUES (1, 'Test 1')"); - execSQL("INSERT INTO Test VALUES (2, 'Test 2')"); - execSQL("INSERT INTO Test VALUES (3, 'Test 3')"); - - MySqlDataAdapter dummyDA = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(dummyDA); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test ORDER BY id", conn); - da.UpdateCommand = cb.GetUpdateCommand(); - da.InsertCommand = cb.GetInsertCommand(); - da.DeleteCommand = cb.GetDeleteCommand(); - da.UpdateCommand.UpdatedRowSource = UpdateRowSource.None; - da.InsertCommand.UpdatedRowSource = UpdateRowSource.None; - da.DeleteCommand.UpdatedRowSource = UpdateRowSource.None; - - DataTable dt = new DataTable(); - da.Fill(dt); - - dt.Rows[0]["id"] = 4; - dt.Rows[1]["name"] = "new test value"; - dt.Rows[2]["id"] = 6; - dt.Rows[2]["name"] = "new test value #2"; - - DataRow row = dt.NewRow(); - row["id"] = 7; - row["name"] = "foobar"; - dt.Rows.Add(row); - - dt.Rows[1].Delete(); - - da.UpdateBatchSize = 0; - da.Update(dt); - - dt.Rows.Clear(); - da.Fill(dt); - Assert.AreEqual(3, dt.Rows.Count); - Assert.AreEqual(4, dt.Rows[0]["id"]); - Assert.AreEqual(6, dt.Rows[1]["id"]); - Assert.AreEqual(7, dt.Rows[2]["id"]); - Assert.AreEqual("Test 1", dt.Rows[0]["name"]); - Assert.AreEqual("new test value #2", dt.Rows[1]["name"]); - Assert.AreEqual("foobar", dt.Rows[2]["name"]); - } - - [Test] - public void TestBatchingInsertsMoreThanMaxPacket() - { - int blobSize = 64000; - - execSQL("CREATE TABLE Test (id INT, img BLOB, PRIMARY KEY(id))"); - - int numRows = (maxPacketSize / blobSize) * 2; - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommand ins = new MySqlCommand("INSERT INTO test (id, img) VALUES (@p1, @p2)", conn); - da.InsertCommand = ins; - ins.UpdatedRowSource = UpdateRowSource.None; - ins.Parameters.Add("@p1", MySqlDbType.Int32).SourceColumn = "id"; - ins.Parameters.Add("@p2", MySqlDbType.Blob).SourceColumn = "img"; - - DataTable dt = new DataTable(); - da.Fill(dt); - - for (int i = 0; i < numRows; i++) - { - DataRow row = dt.NewRow(); - row["id"] = i; - row["img"] = Utils.CreateBlob(blobSize); - dt.Rows.Add(row); - } - - da.UpdateBatchSize = 0; - da.Update(dt); - - dt.Rows.Clear(); - da.Fill(dt); - Assert.AreEqual(numRows, dt.Rows.Count); - for (int i=0; i < numRows; i++) - Assert.AreEqual(i, dt.Rows[i]["id"]); - } - - [Test] - public void FunctionsReturnString() - { - string connStr = GetConnectionString(true) + ";functions return string=yes"; - - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT CONCAT(1,2)", c); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual("12", dt.Rows[0][0]); - Assert.IsTrue(dt.Rows[0][0] is string); - } - } - - /// - /// Bug #34657 MySqlDataAdapter.Update(DataRow[] rows) fails with MySqlCommandBuilder - /// - [Test] - public void ConnectionNotOpenForInsert() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL(@"CREATE TABLE Test (id int(11) NOT NULL default '0', - txt varchar(100) default NULL, val decimal(11,2) default NULL, - PRIMARY KEY(id)) ENGINE=InnoDB DEFAULT CHARSET=latin1"); - execSQL("INSERT INTO Test VALUES (1, 'name', 23.2)"); - - string connStr = GetConnectionString(true); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - string sql = "SELECT * FROM Test"; - MySqlDataAdapter da = new MySqlDataAdapter(sql, c); - MySqlCommandBuilder bld = new MySqlCommandBuilder(da); - DataSet ds = new DataSet(); - da.Fill(ds); - - ds.Tables[0].Rows[0]["val"] = 99.9M; - da.Update(new DataRow[] { ds.Tables[0].Rows[0] }); - - DataRow r = ds.Tables[0].NewRow(); - r["id"] = 4; - r["txt"] = "sds"; - r["val"] = 113.2M; - ds.Tables[0].Rows.Add(r); - da.Update(new DataRow[] { r }); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataReaderTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataReaderTests.cs deleted file mode 100644 index 267b38f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataReaderTests.cs +++ /dev/null @@ -1,801 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Diagnostics; -using MySql.Data.MySqlClient; -using MySql.Data.Types; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for ConnectionTests. - /// - [TestFixture] - public class DataReaderTests : BaseTest - { - private void CreateDefaultTable() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), d DATE, dt DATETIME, b1 LONGBLOB, PRIMARY KEY(id))"); - } - - [Test] - public void TestMultipleResultsets() - { - CreateDefaultTable(); - - MySqlCommand cmd = new MySqlCommand("", conn); - // insert 100 records - cmd.CommandText = "INSERT INTO Test (id,name) VALUES (?id, 'test')"; - cmd.Parameters.Add( new MySqlParameter("?id", 1)); - for (int i=1; i <= 100; i++) - { - cmd.Parameters[0].Value = i; - cmd.ExecuteNonQuery(); - } - - // execute it one time - cmd = new MySqlCommand("SELECT id FROM Test WHERE id<50; SELECT * FROM Test WHERE id >= 50;", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsNotNull(reader); - Assert.AreEqual(true, reader.HasRows); - Assert.IsTrue(reader.Read()); - Assert.AreEqual(1, reader.FieldCount); - Assert.IsTrue(reader.NextResult()); - Assert.AreEqual(true, reader.HasRows); - Assert.AreEqual(5, reader.FieldCount); - } - - // now do it again - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsNotNull(reader); - Assert.AreEqual(true, reader.HasRows); - Assert.IsTrue(reader.Read()); - Assert.AreEqual(1, reader.FieldCount); - Assert.IsTrue(reader.NextResult()); - Assert.AreEqual(true, reader.HasRows); - Assert.AreEqual(5, reader.FieldCount); - } - } - - [Test] - public void GetBytes() - { - CreateDefaultTable(); - int len = 50000; - byte[] bytes = Utils.CreateBlob(len); - MySqlCommand cmd = new MySqlCommand( - "INSERT INTO Test (id, name, b1) VALUES(1, 'Test', ?b1)", conn); - cmd.Parameters.AddWithValue("?b1", bytes); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - - long sizeBytes = reader.GetBytes(4, 0, null, 0, 0); - Assert.AreEqual(len, sizeBytes); - - byte[] buff1 = new byte[len / 2]; - byte[] buff2 = new byte[len - (len / 2)]; - long buff1cnt = reader.GetBytes(4, 0, buff1, 0, len / 2); - long buff2cnt = reader.GetBytes(4, buff1cnt, buff2, 0, buff2.Length); - Assert.AreEqual(buff1.Length, buff1cnt); - Assert.AreEqual(buff2.Length, buff2cnt); - - for (int i = 0; i < buff1.Length; i++) - Assert.AreEqual(bytes[i], buff1[i]); - - for (int i = 0; i < buff2.Length; i++) - Assert.AreEqual(bytes[buff1.Length + i], buff2[i]); - } - - // now check with sequential access - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) - { - Assert.IsTrue(reader.Read()); - int mylen = len; - byte[] buff = new byte[8192]; - int startIndex = 0; - while (mylen > 0) - { - int readLen = Math.Min(mylen, buff.Length); - int retVal = (int)reader.GetBytes(4, startIndex, buff, 0, readLen); - Assert.AreEqual(readLen, retVal); - for (int i = 0; i < readLen; i++) - Assert.AreEqual(bytes[startIndex + i], buff[i]); - startIndex += readLen; - mylen -= readLen; - } - } - } - - [Test] - public void TestSingleResultSetBehavior() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test (id, name, b1) VALUES (1, 'Test1', NULL)"); - execSQL("INSERT INTO Test (id, name, b1) VALUES (2, 'Test1', NULL)"); - - MySqlCommand cmd = new MySqlCommand( - "SELECT * FROM Test WHERE id=1; SELECT * FROM Test WHERE id=2", conn); - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleResult)) - { - bool result = reader.Read(); - Assert.AreEqual(true, result); - - result = reader.NextResult(); - Assert.AreEqual(false, result); - } - } - - [Test] - public void GetSchema() - { - string sql = "CREATE TABLE test2(id INT UNSIGNED AUTO_INCREMENT " + - "NOT NULL, name VARCHAR(255) NOT NULL, name2 VARCHAR(40), fl FLOAT, " + - "dt DATETIME, PRIMARY KEY(id))"; - - execSQL(sql); - execSQL("INSERT INTO test2 VALUES(1,'Test', 'Test', 1.0, now())"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM test2", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - DataTable dt = reader.GetSchemaTable(); - Assert.AreEqual(true, dt.Rows[0]["IsAutoIncrement"], "Checking auto increment"); - Assert.IsFalse((bool)dt.Rows[0]["IsUnique"], "Checking IsUnique"); - Assert.IsTrue((bool)dt.Rows[0]["IsKey"]); - Assert.AreEqual(false, dt.Rows[0]["AllowDBNull"], "Checking AllowDBNull"); - Assert.AreEqual(false, dt.Rows[1]["AllowDBNull"], "Checking AllowDBNull"); - Assert.AreEqual(255, dt.Rows[1]["ColumnSize"]); - Assert.AreEqual(40, dt.Rows[2]["ColumnSize"]); - } - } - - [Test] - public void CloseConnectionBehavior() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test(id,name) VALUES(1,'test')"); - - using (MySqlConnection c2 = new MySqlConnection(conn.ConnectionString)) - { - c2.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", c2); - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)) - { - Assert.IsTrue(reader.Read()); - reader.Close(); - Assert.IsTrue(c2.State == ConnectionState.Closed); - } - } - } - - [Test] - public void SingleRowBehavior() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test(id,name) VALUES(1,'test1')"); - execSQL("INSERT INTO Test(id,name) VALUES(2,'test2')"); - execSQL("INSERT INTO Test(id,name) VALUES(3,'test3')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) - { - Assert.IsTrue(reader.Read(), "First read"); - Assert.IsFalse(reader.Read(), "Second read"); - Assert.IsFalse(reader.NextResult(), "Trying NextResult"); - } - - cmd.CommandText = "SELECT * FROM Test where id=1"; - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual("test1", reader.GetString(1)); - Assert.IsFalse(reader.Read()); - Assert.IsFalse(reader.NextResult()); - } - } - - [Test] - public void SingleRowBehaviorWithLimit() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test(id,name) VALUES(1,'test1')"); - execSQL("INSERT INTO Test(id,name) VALUES(2,'test2')"); - execSQL("INSERT INTO Test(id,name) VALUES(3,'test3')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test LIMIT 2", conn); - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) - { - Assert.IsTrue(reader.Read(), "First read"); - Assert.IsFalse(reader.Read(), "Second read"); - Assert.IsFalse(reader.NextResult(), "Trying NextResult"); - } - - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) - { - Assert.IsTrue(reader.Read(), "First read"); - Assert.IsFalse(reader.Read(), "Second read"); - Assert.IsFalse(reader.NextResult(), "Trying NextResult"); - } - - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) - { - Assert.IsTrue(reader.Read(), "First read"); - Assert.IsFalse(reader.Read(), "Second read"); - Assert.IsFalse(reader.NextResult(), "Trying NextResult"); - } - } - - [Test] - public void SimpleSingleRow() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test(id,name) VALUES(1,'test1')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read(), "First read"); - Assert.AreEqual(1, reader.GetInt32(0)); - Assert.AreEqual("test1", reader.GetString(1)); - Assert.IsFalse(reader.Read(), "Second read"); - Assert.IsFalse(reader.NextResult(), "Trying NextResult"); - } - } - - [Test] - public void ConsecutiveNulls() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test (id, name, dt) VALUES (1, 'Test', NULL)"); - execSQL("INSERT INTO Test (id, name, dt) VALUES (2, NULL, now())"); - execSQL("INSERT INTO Test (id, name, dt) VALUES (3, 'Test2', NULL)"); - - MySqlCommand cmd = new MySqlCommand("SELECT id, name, dt FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual(1, reader.GetValue(0)); - Assert.AreEqual("Test", reader.GetValue(1)); - Assert.AreEqual("Test", reader.GetString(1)); - Assert.AreEqual(DBNull.Value, reader.GetValue(2)); - reader.Read(); - Assert.AreEqual(2, reader.GetValue(0)); - Assert.AreEqual(DBNull.Value, reader.GetValue(1)); - try - { - reader.GetString(1); - Assert.Fail("Should not get here"); - } - catch (Exception) { } - Assert.IsFalse(reader.IsDBNull(2)); - reader.Read(); - Assert.AreEqual(3, reader.GetValue(0)); - Assert.AreEqual("Test2", reader.GetValue(1)); - Assert.AreEqual("Test2", reader.GetString(1)); - Assert.AreEqual(DBNull.Value, reader.GetValue(2)); - try - { - reader.GetMySqlDateTime(2); - Assert.Fail("Should not get here"); - } - catch (Exception) { } - Assert.IsFalse(reader.Read()); - Assert.IsFalse(reader.NextResult()); - } - } - - [Test] - public void HungDataReader() - { - MySqlCommand cmd = new MySqlCommand("USE `" + database0 + "`; SHOW TABLES", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - reader.GetString(0); - } - } - } - - /// - /// Added test for IsDBNull from bug# 7399 - /// - [Test] - public void SequentialAccessBehavior() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test(id,name) VALUES(1,'test1')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) - { - Assert.IsTrue(reader.Read()); - Assert.IsFalse(reader.IsDBNull(0)); - int i = reader.GetInt32(0); - string s = reader.GetString(1); - Assert.AreEqual(1, i); - Assert.AreEqual("test1", s); - - // this next line should throw an exception - try - { - i = reader.GetInt32(0); - Assert.Fail("This line should not execute"); - } - catch (MySqlException) - { - } - } - } - - - [Test] - public void ReadingTextFields() - { - execSQL("CREATE TABLE Test (id int, t1 TEXT)"); - execSQL("INSERT INTO Test VALUES (1, 'Text value')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - string s = reader["t1"].ToString(); - Assert.AreEqual( "Text value", s ); - } - } - - [Test] - public void ReadingFieldsBeforeRead() - { - CreateDefaultTable(); - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - try - { - reader.GetInt32(0); - } - catch (MySqlException) - { - } - } - } - - [Test] - public void GetChar() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test (id, name) VALUES (1, 'a')"); - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - char achar = reader.GetChar( 1 ); - Assert.AreEqual( 'a', achar ); - } - } - - [Test] - public void ReaderOnNonQuery() - { - CreateDefaultTable(); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id,name) VALUES (1,'Test')", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsFalse( reader.Read() ); - reader.Close(); - - cmd.CommandText = "SELECT name FROM Test"; - object v = cmd.ExecuteScalar(); - Assert.AreEqual( "Test", v ); - } - } - - [Test] - public void TestManyDifferentResultsets() - { - CreateDefaultTable(); - MySqlCommand cmd = new MySqlCommand("", conn); - // insert 100 records - cmd.CommandText = "INSERT INTO Test (id,name,dt,b1) VALUES (?id, 'test','2004-12-05 12:57:00','long blob data')"; - cmd.Parameters.Add( new MySqlParameter("?id", 1)); - for (int i=1; i <= 100; i++) - { - cmd.Parameters[0].Value = i; - cmd.ExecuteNonQuery(); - } - - cmd = new MySqlCommand("SELECT id FROM Test WHERE id= ?param1; "+ - "SELECT id, dt, b1 FROM Test WHERE id = -50; "+ - "SELECT b1 FROM Test WHERE id = -50; "+ - "SELECT id, dt, b1 FROM Test WHERE id < ?param1; "+ - "SELECT b1 FROM Test WHERE id >= ?param1;", conn); - - cmd.Parameters.AddWithValue("?param1",50); - - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - //First ResultSet, should have 49 rows. - //SELECT id FROM Test WHERE id= ?param1; - Assert.IsTrue(reader.NextResult()); - Assert.AreEqual(true, reader.HasRows); - Assert.AreEqual(5, reader.FieldCount); - for (int i = 0; i < 51; i++) - { - Assert.IsTrue(reader.Read()); - } - Assert.AreEqual(false, reader.Read()); - - - //Fourth ResultSet, should have no rows. - //SELECT id, dt, b1 FROM Test WHERE id = -50; - Assert.IsTrue(reader.NextResult()); - Assert.AreEqual(false, reader.HasRows); - Assert.AreEqual(3, reader.FieldCount); //Will Fail if uncommented expected 3 returned 5 - Assert.AreEqual(false, reader.Read()); - - //Fifth ResultSet, should have no rows. - //SELECT b1 FROM Test WHERE id = -50; - Assert.IsTrue(reader.NextResult()); - Assert.AreEqual(false, reader.HasRows); - Assert.AreEqual(1, reader.FieldCount); //Will Fail if uncommented expected 1 returned 5 - Assert.AreEqual(false, reader.Read()); - - //Sixth ResultSet, should have 49 rows. - //SELECT id, dt, b1 FROM Test WHERE id < ?param1; - Assert.IsTrue(reader.NextResult()); - Assert.AreEqual(true, reader.HasRows); - Assert.AreEqual(3, reader.FieldCount); //Will Fail if uncommented expected 3 returned 5 - for (int i = 0; i < 49; i++) - { - Assert.IsTrue(reader.Read()); - } - Assert.AreEqual(false, reader.Read()); - - //Seventh ResultSet, should have 51 rows. - //SELECT b1 FROM Test WHERE id >= ?param1; - Assert.IsTrue(reader.NextResult()); - Assert.AreEqual(true, reader.HasRows); - Assert.AreEqual(1, reader.FieldCount); //Will Fail if uncommented expected 1 returned 5 - for (int i = 0; i < 51; i++) - { - Assert.IsTrue(reader.Read()); - } - Assert.AreEqual(false, reader.Read()); - } - } - - - [Test] - public void TestMultipleResultsWithQueryCacheOn() - { - CreateDefaultTable(); - execSQL("SET SESSION query_cache_type = ON"); - execSQL("INSERT INTO Test (id,name) VALUES (1, 'Test')"); - execSQL("INSERT INTO Test (id,name) VALUES (51, 'Test')"); - - // execute it one time - MySqlCommand cmd = new MySqlCommand("SELECT id FROM Test WHERE id<50; SELECT * FROM Test WHERE id >= 50;", conn); - - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsNotNull(reader); - Assert.AreEqual(true, reader.HasRows); - Assert.IsTrue(reader.Read()); - Assert.AreEqual(1, reader.FieldCount); - Assert.IsTrue(reader.NextResult()); - Assert.AreEqual(true, reader.HasRows); - Assert.AreEqual(5, reader.FieldCount); - } - - // now do it again - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsNotNull(reader); - Assert.AreEqual(true, reader.HasRows); - Assert.IsTrue(reader.Read()); - Assert.AreEqual(1, reader.FieldCount); - Assert.IsTrue(reader.NextResult()); - Assert.AreEqual(true, reader.HasRows); - Assert.AreEqual(5, reader.FieldCount); - } - } - - /// - /// Bug #8630 Executing a query with the SchemaOnly option reads the entire resultset - /// - [Test] - public void SchemaOnly() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test (id,name) VALUES(1,'test1')"); - execSQL("INSERT INTO Test (id,name) VALUES(2,'test2')"); - execSQL("INSERT INTO Test (id,name) VALUES(3,'test3')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly)) - { - DataTable table = reader.GetSchemaTable(); - Assert.AreEqual(5, table.Rows.Count); - Assert.AreEqual(22, table.Columns.Count); - Assert.IsFalse(reader.Read()); - } - } - - /// - /// Bug #9237 MySqlDataReader.AffectedRecords not set to -1 - /// - [Test] - public void AffectedRows() - { - MySqlCommand cmd = new MySqlCommand("SHOW TABLES", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - reader.Close(); - Assert.AreEqual(-1, reader.RecordsAffected); - } - } - - /// - /// Bug #11873 Invalid timestamp in query produces incorrect reader exception - /// - [Test] - public void InvalidTimestamp() - { - execSQL("CREATE TABLE Test (tm TIMESTAMP)"); - execSQL("INSERT INTO Test VALUES (NULL)"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test WHERE tm = '7/1/2005 12:00:00 AM'", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - } - } - - /// - /// Bug #19294 IDataRecord.GetString method should return null for null values - /// - [Test] - public void GetStringOnNull() - { - execSQL("CREATE TABLE Test (id int, PRIMARY KEY(id))"); - MySqlCommand cmd = new MySqlCommand( - String.Format("SHOW INDEX FROM Test FROM `{0}`", database0), conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - try - { - reader.GetString(reader.GetOrdinal("Sub_part")); - Assert.Fail("We should not get here"); - } - catch (System.Data.SqlTypes.SqlNullValueException) - { - } - } - } - - /// - /// Bug #23538 Exception thrown when GetSchemaTable is called and "fields" is null. - /// - [Test] - public void GetSchemaTableOnEmptyResultset() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest() BEGIN END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - DataTable dt = reader.GetSchemaTable(); - Assert.IsNull(dt); - } - } - - /// - /// Bug #24765 Retrieving empty fields results in check for isDBNull - /// - [Test] - public void IsDbNullOnNonNullFields() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test (id, name) VALUES (1, '')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.IsFalse(reader.IsDBNull(1)); - } - } - - /// - /// Bug #30204 Incorrect ConstraintException - /// - [Test] - public void ConstraintWithLoadingReader() - { - execSQL(@"CREATE TABLE Test (ID_A int(11) NOT NULL, - ID_B int(11) NOT NULL, PRIMARY KEY (ID_A,ID_B) - ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - dt.Load(reader); - } - - DataRow row = dt.NewRow(); - row["ID_A"] = 2; - row["ID_B"] = 3; - dt.Rows.Add(row); - - row = dt.NewRow(); - row["ID_A"] = 2; - row["ID_B"] = 4; - dt.Rows.Add(row); - } - - [Test] - public void CloseConnectionBehavior2() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test(id,name) VALUES(1,'test')"); - - using (MySqlConnection c2 = new MySqlConnection(conn.ConnectionString)) - { - c2.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", c2); - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)) - { - Assert.IsTrue(reader.Read()); - } - } - } - - /// - /// Test that using command behavior SchemaOnly does not hose the connection - /// by leaving SQL_SELECT_LIMIT set to 0 after the error (and in normal - /// case too) - /// - /// Bug#30518 - /// - [Test] - public void CommandBehaviorSchemaOnly() - { - - MySqlCommand cmd = new MySqlCommand("select * from doesnotexist", conn); - MySqlDataReader reader; - try - { - reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly); - Assert.Fail("should have failed"); - } - catch (MySqlException) - { - } - - // Check that failed ExecuteReader did not leave SQL_SELECT_LIMIT - // set to 0. - cmd.CommandText = "select now()"; - reader = cmd.ExecuteReader(); - Assert.IsTrue(reader.Read()); - reader.Close(); - - - // Check that CommandBehavior.SchemaOnly does not return rows - reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly); - Assert.IsFalse(reader.Read()); - reader.Close(); - - - reader = cmd.ExecuteReader(); - // Check that prior setting of CommandBehavior did not - // leave SQL_SELECT_LIMIT set to 0 - Assert.IsTrue(reader.Read()); - reader.Close(); - } - - /// - /// Bug #37239 MySqlReader GetOrdinal performance changes break existing functionality - /// - [Test] - public void ColumnsWithSameName() - { - CreateDefaultTable(); - execSQL("INSERT INTO Test (id, name) VALUES (1, 'test')"); - - MySqlCommand cmd = new MySqlCommand("SELECT a.name, a.name FROM Test a", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - string name1 = reader.GetString(0); - string name2 = reader.GetString(1); - Assert.AreEqual(name1, name2); - Assert.AreEqual(name1, "test"); - } - - cmd.CommandText = "SELECT 'a' AS XYZ, 'b' as Xyz"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - string name1 = reader.GetString(0); - string name2 = reader.GetString(1); - } - } - - /// - /// Bug #47467 Two simple changes for DataReader - /// - [Test] - public void Bug47467() - { - MySqlCommand cmd = new MySqlCommand("SELECT 1 as c1", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Type t = reader.GetFieldType("c1"); - - try - { - reader.GetOrdinal("nocol"); - Assert.Fail("This should have failed"); - } - catch (IndexOutOfRangeException ex) - { - Assert.IsTrue(ex.Message.IndexOf("nocol") != -1); - } - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataTypeTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataTypeTests.cs deleted file mode 100644 index c285a20..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DataTypeTests.cs +++ /dev/null @@ -1,1062 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using MySql.Data.MySqlClient; -using MySql.Data.Types; -using System.Data; -using NUnit.Framework; -using System.Data.Common; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for ConnectionTests. - /// - [TestFixture] - public class DataTypeTests : BaseTest - { - [Test] - public void BytesAndBooleans() - { - InternalBytesAndBooleans(false); - } - - [Test] - public void BytesAndBooleansPrepared() - { - if (Version < new Version(4, 1)) return; - - InternalBytesAndBooleans(true); - } - - private void InternalBytesAndBooleans(bool prepare) - { - execSQL("CREATE TABLE Test (id TINYINT, idu TINYINT UNSIGNED, i INT UNSIGNED)"); - execSQL("INSERT INTO Test VALUES (-98, 140, 20)"); - execSQL("INSERT INTO Test VALUES (0, 0, 0)"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - if (prepare) cmd.Prepare(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(-98, (sbyte)reader.GetByte(0)); - Assert.AreEqual(140, reader.GetByte(1)); - Assert.IsTrue(reader.GetBoolean(1)); - Assert.AreEqual(20, reader.GetUInt32(2)); - Assert.AreEqual(20, reader.GetInt32(2)); - - Assert.IsTrue(reader.Read()); - Assert.AreEqual(0, reader.GetByte(0)); - Assert.AreEqual(0, reader.GetByte(1)); - Assert.IsFalse(reader.GetBoolean(1)); - - Assert.IsFalse(reader.Read()); - } - } - - /// - /// Bug#46205 - tinyint as boolean does not work for utf8 default database character set. - /// - /// - /// Original bug occured only with mysqld started with --default-character-set=utf8. - /// It does not seem possible to reproduce the original buggy behaviorotherwise - /// Neither "set global character_set_server = utf8" , nor "create table /database with character set " - /// were sufficient. - /// - [Test] - public void TreatTinyAsBool() - { - if (version < new Version(4, 1)) return; - execSQL("CREATE TABLE Test2(i TINYINT(1))"); - execSQL("INSERT INTO Test2 VALUES(1)"); - execSQL("INSERT INTO Test2 VALUES(0)"); - execSQL("INSERT INTO Test2 VALUES(2)"); - MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(conn.ConnectionString); - Assert.IsTrue(builder.TreatTinyAsBoolean); - - MySqlCommand cmd = new MySqlCommand("SELECT * from Test2", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - bool b; - Assert.IsTrue(reader.Read()); - b = (bool)reader.GetValue(0); - Assert.IsTrue(b); - Assert.IsTrue(reader.Read()); - b = (bool)reader.GetValue(0); - Assert.IsFalse(b); - Assert.IsTrue(reader.Read()); - b = (bool)reader.GetValue(0); - Assert.IsTrue(b); - } - } - - [Test] - public void TestFloat() - { - InternalTestFloats(false); - } - - [Test] - public void TestFloatPrepared() - { - if (Version < new Version(4, 1)) return; - - InternalTestFloats(true); - } - - private void InternalTestFloats(bool prepared) - { - execSQL("CREATE TABLE Test (fl FLOAT, db DOUBLE, dec1 DECIMAL(5,2))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?fl, ?db, ?dec)", conn); - cmd.Parameters.Add("?fl", MySqlDbType.Float); - cmd.Parameters.Add("?db", MySqlDbType.Double); - cmd.Parameters.Add("?dec", MySqlDbType.Decimal); - cmd.Parameters[0].Value = 2.3; - cmd.Parameters[1].Value = 4.6; - cmd.Parameters[2].Value = 23.82; - if (prepared) - cmd.Prepare(); - int count = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, count); - - cmd.Parameters[0].Value = 1.5; - cmd.Parameters[1].Value = 47.85; - cmd.Parameters[2].Value = 123.85; - count = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, count); - - cmd.CommandText = "SELECT * FROM Test"; - if (prepared) - cmd.Prepare(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(2.3, (decimal)reader.GetFloat(0)); - Assert.AreEqual(4.6, reader.GetDouble(1)); - Assert.AreEqual(23.82, reader.GetDecimal(2)); - - Assert.IsTrue(reader.Read()); - Assert.AreEqual(1.5, (decimal)reader.GetFloat(0)); - Assert.AreEqual(47.85, reader.GetDouble(1)); - Assert.AreEqual(123.85, reader.GetDecimal(2)); - } - } - - [Test] - public void TestTime() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), d DATE, dt DATETIME, tm TIME, PRIMARY KEY(id))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, tm) VALUES (1, '00:00')", conn); - cmd.ExecuteNonQuery(); - cmd.CommandText = "INSERT INTO Test (id, tm) VALUES (2, '512:45:17')"; - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - - object value = reader["tm"]; - Assert.AreEqual(value.GetType(), typeof(TimeSpan)); - TimeSpan ts = (TimeSpan)reader["tm"]; - Assert.AreEqual(0, ts.Hours); - Assert.AreEqual(0, ts.Minutes); - Assert.AreEqual(0, ts.Seconds); - - reader.Read(); - value = reader["tm"]; - Assert.AreEqual(value.GetType(), typeof(TimeSpan)); - ts = (TimeSpan)reader["tm"]; - Assert.AreEqual(21, ts.Days); - Assert.AreEqual(8, ts.Hours); - Assert.AreEqual(45, ts.Minutes); - Assert.AreEqual(17, ts.Seconds); - } - } - - [Test] - public void YearType() - { - execSQL("CREATE TABLE Test (yr YEAR)"); - execSQL("INSERT INTO Test VALUES (98)"); - execSQL("INSERT INTO Test VALUES (1990)"); - execSQL("INSERT INTO Test VALUES (2004)"); - execSQL("SET SQL_MODE=''"); - execSQL("INSERT INTO Test VALUES (111111111111111111111)"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual(1998, reader.GetUInt32(0)); - reader.Read(); - Assert.AreEqual(1990, reader.GetUInt32(0)); - reader.Read(); - Assert.AreEqual(2004, reader.GetUInt32(0)); - reader.Read(); - Assert.AreEqual(0, reader.GetUInt32(0)); - } - } - - [Test] - public void TypeCoercion() - { - MySqlParameter p = new MySqlParameter("?test", 1); - Assert.AreEqual( DbType.Int32, p.DbType ); - Assert.AreEqual( MySqlDbType.Int32, p.MySqlDbType ); - - p.DbType = DbType.Int64; - Assert.AreEqual( DbType.Int64, p.DbType ); - Assert.AreEqual( MySqlDbType.Int64, p.MySqlDbType ); - - p.MySqlDbType = MySqlDbType.Int16; - Assert.AreEqual( DbType.Int16, p.DbType ); - Assert.AreEqual( MySqlDbType.Int16, p.MySqlDbType ); - } - - /// - /// Bug #7951 - Error reading timestamp column - /// - [Test] - public void Timestamp() - { - // don't run this test on 6 and higher - if (Version.Major >= 6) return; - - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test (id int, dt DATETIME, ts2 TIMESTAMP(2), ts4 TIMESTAMP(4), " + - "ts6 TIMESTAMP(6), ts8 TIMESTAMP(8), ts10 TIMESTAMP(10), ts12 TIMESTAMP(12), " + - "ts14 TIMESTAMP(14))"); - execSQL("INSERT INTO Test (id, dt, ts2, ts4, ts6, ts8, ts10, ts12, ts14) " + - "VALUES (1, Now(), Now(), Now(), Now(), Now(), Now(), Now(), Now())"); - - MySqlDataAdapter da = new MySqlDataAdapter( "SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - - DateTime now = (DateTime)dt.Rows[0]["dt"]; - Assert.AreEqual( 1, dt.Rows[0]["id"] ); - - DateTime ts2 = (DateTime)dt.Rows[0]["ts2"]; - Assert.AreEqual( now.Year, ts2.Year ); - - DateTime ts4 = (DateTime)dt.Rows[0]["ts4"]; - Assert.AreEqual( now.Year, ts4.Year ); - Assert.AreEqual( now.Month, ts4.Month ); - - DateTime ts6 = (DateTime)dt.Rows[0]["ts6"]; - Assert.AreEqual( now.Year, ts6.Year ); - Assert.AreEqual( now.Month, ts6.Month ); - Assert.AreEqual( now.Day, ts6.Day ); - - DateTime ts8 = (DateTime)dt.Rows[0]["ts8"]; - Assert.AreEqual( now.Year, ts8.Year ); - Assert.AreEqual( now.Month, ts8.Month ); - Assert.AreEqual( now.Day, ts8.Day ); - - DateTime ts10 = (DateTime)dt.Rows[0]["ts10"]; - Assert.AreEqual( now.Year, ts10.Year ); - Assert.AreEqual( now.Month, ts10.Month ); - Assert.AreEqual( now.Day, ts10.Day ); - Assert.AreEqual( now.Hour, ts10.Hour ); - Assert.AreEqual( now.Minute, ts10.Minute ); - - DateTime ts12 = (DateTime)dt.Rows[0]["ts12"]; - Assert.AreEqual( now.Year, ts12.Year ); - Assert.AreEqual( now.Month, ts12.Month ); - Assert.AreEqual( now.Day, ts12.Day ); - Assert.AreEqual( now.Hour, ts12.Hour ); - Assert.AreEqual( now.Minute, ts12.Minute ); - Assert.AreEqual( now.Second, ts12.Second ); - - DateTime ts14 = (DateTime)dt.Rows[0]["ts14"]; - Assert.AreEqual( now.Year, ts14.Year ); - Assert.AreEqual( now.Month, ts14.Month ); - Assert.AreEqual( now.Day, ts14.Day ); - Assert.AreEqual( now.Hour, ts14.Hour ); - Assert.AreEqual( now.Minute, ts14.Minute ); - Assert.AreEqual( now.Second, ts14.Second ); - } - - - [Test] - public void AggregateTypesTest() - { - execSQL("CREATE TABLE foo (abigint bigint, aint int)"); - execSQL("INSERT INTO foo VALUES (1, 2)"); - execSQL("INSERT INTO foo VALUES (2, 3)"); - execSQL("INSERT INTO foo VALUES (3, 4)"); - execSQL("INSERT INTO foo VALUES (3, 5)"); - - // Try a normal query - string NORMAL_QRY = "SELECT abigint, aint FROM foo WHERE abigint = {0}"; - string qry = String.Format(NORMAL_QRY, 3); - MySqlCommand cmd = new MySqlCommand(qry, conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - reader.GetInt64(0); - reader.GetInt32(1); // <--- aint... this succeeds - } - } - - cmd.CommandText = "SELECT abigint, max(aint) FROM foo GROUP BY abigint"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - reader.GetInt64(0); - reader.GetInt64(1); // <--- max(aint)... this fails - } - } - } - -/* [Test] - public void TypeBoundaries() - { - execSQL("CREATE TABLE Test ( MaxDouble DOUBLE, MinDouble DOUBLE, MaxFloat FLOAT, MinFloat FLOAT )"); - - MySqlCommand cmd = new MySqlCommand( - "INSERT Test (MaxDouble, MinDouble, MaxFloat, MinFloat) VALUES " + - "(?maxDouble, ?minDouble, ?maxFloat, ?minFloat)", conn); - cmd.Parameters.Add("?maxDouble", MySqlDouble.MaxValue); - cmd.Parameters.Add("?minDouble", MySqlDouble.MinValue); - cmd.Parameters.Add("?maxFloat", MySqlFloat.MaxValue); - cmd.Parameters.Add("?minFloat", MySqlFloat.MinValue); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual(MySqlDouble.MaxValue, reader.GetDouble(0)); - Assert.AreEqual(MySqlDouble.MinValue, reader.GetDouble(1)); - Assert.AreEqual(MySqlFloat.MaxValue, reader.GetFloat(2)); - Assert.AreEqual(MySqlFloat.MinValue, reader.GetFloat(3)); - } - }*/ - - [Test] - public void BitAndDecimal() - { - execSQL("CREATE TABLE Test (bt1 BIT(2), bt4 BIT(4), bt11 BIT(11), bt23 BIT(23), bt32 BIT(32)) engine=myisam"); - execSQL("INSERT INTO Test VALUES (2, 3, 120, 240, 1000)"); - execSQL("INSERT INTO Test VALUES (NULL, NULL, 100, NULL, NULL)"); - - string connStr = GetConnectionString(true) + ";treat tiny as boolean=false"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", c); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(2, reader.GetInt32(0)); - Assert.AreEqual(3, reader.GetInt32(1)); - Assert.AreEqual(120, reader.GetInt32(2)); - if (Version >= new Version(5, 0)) - { - Assert.AreEqual(240, reader.GetInt32(3)); - Assert.AreEqual(1000, reader.GetInt32(4)); - } - else - { - Assert.AreEqual(127, reader.GetInt32(3)); - Assert.AreEqual(127, reader.GetInt32(4)); - } - - Assert.IsTrue(reader.Read()); - Assert.IsTrue(reader.IsDBNull(0)); - Assert.IsTrue(reader.IsDBNull(1)); - Assert.AreEqual(100, reader.GetInt32(2)); - Assert.IsTrue(reader.IsDBNull(3)); - Assert.IsTrue(reader.IsDBNull(4)); - } - } - } - - /// - /// Bug #10486 MySqlDataAdapter.Update error for decimal column - /// - [Test] - public void UpdateDecimalColumns() - { - execSQL("CREATE TABLE Test (id int not null auto_increment primary key, " + - "dec1 decimal(10,1))"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - DataTable dt = new DataTable(); - da.Fill(dt); - DataRow row = dt.NewRow(); - row["id"] = DBNull.Value; - row["dec1"] = 23.4; - dt.Rows.Add(row); - da.Update(dt); - - dt.Clear(); - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(1, dt.Rows[0]["id"]); - Assert.AreEqual(23.4, dt.Rows[0]["dec1"]); - cb.Dispose(); - } - - [Test] - public void DecimalTests() - { - execSQL("CREATE TABLE Test (val decimal(10,1))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(?dec)", conn); - cmd.Parameters.AddWithValue("?dec", (decimal)2.4); - Assert.AreEqual(1, cmd.ExecuteNonQuery()); - - cmd.Prepare(); - Assert.AreEqual(1, cmd.ExecuteNonQuery()); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.IsTrue(reader[0] is Decimal); - Assert.AreEqual(2.4, reader[0]); - - Assert.IsTrue(reader.Read()); - Assert.IsTrue(reader[0] is Decimal); - Assert.AreEqual(2.4, reader[0]); - - Assert.IsFalse(reader.Read()); - Assert.IsFalse(reader.NextResult()); - } - } - - [Test] - public void DecimalTests2() - { - execSQL("CREATE TABLE Test (val decimal(10,1))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(?dec)", conn); - cmd.Parameters.AddWithValue("?dec", (decimal)2.4); - Assert.AreEqual(1, cmd.ExecuteNonQuery()); - - cmd.Prepare(); - Assert.AreEqual(1, cmd.ExecuteNonQuery()); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.IsTrue(reader[0] is Decimal); - Assert.AreEqual(2.4, reader[0]); - - Assert.IsTrue(reader.Read()); - Assert.IsTrue(reader[0] is Decimal); - Assert.AreEqual(2.4, reader[0]); - - Assert.IsFalse(reader.Read()); - Assert.IsFalse(reader.NextResult()); - } - } - - [Test] - public void Bit() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE Test (bit1 BIT, bit2 BIT(5), bit3 BIT(10))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?b1, ?b2, ?b3)", conn); - cmd.Parameters.Add(new MySqlParameter("?b1", MySqlDbType.Bit)); - cmd.Parameters.Add(new MySqlParameter("?b2", MySqlDbType.Bit)); - cmd.Parameters.Add(new MySqlParameter("?b3", MySqlDbType.Bit)); - cmd.Prepare(); - cmd.Parameters[0].Value = 1; - cmd.Parameters[1].Value = 2; - cmd.Parameters[2].Value = 3; - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - cmd.Prepare(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(1, reader[0]); - Assert.AreEqual(2, reader[1]); - Assert.AreEqual(3, reader[2]); - } - } - - /// - /// Bug #17375 CommandBuilder ignores Unsigned flag at Parameter creation - /// Bug #15274 Use MySqlDbType.UInt32, throwed exception 'Only byte arrays can be serialize' - /// - [Test] - public void UnsignedTypes() - { - execSQL("CREATE TABLE Test (b TINYINT UNSIGNED PRIMARY KEY)"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - - DataTable dt = new DataTable(); - da.Fill(dt); - - DataView dv = new DataView(dt); - DataRowView row; - - row = dv.AddNew(); - row["b"] = 120; - row.EndEdit(); - da.Update(dv.Table); - - row = dv.AddNew(); - row["b"] = 135; - row.EndEdit(); - da.Update(dv.Table); - cb.Dispose(); - - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test (b MEDIUMINT UNSIGNED PRIMARY KEY)"); - execSQL("INSERT INTO Test VALUES(20)"); - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test WHERE (b > ?id)", conn); - cmd.Parameters.Add("?id", MySqlDbType.UInt16).Value = 10; - using (MySqlDataReader dr = cmd.ExecuteReader()) - { - dr.Read(); - Assert.AreEqual(20, dr.GetUInt16(0)); - } - } - - /// - /// Bug #25912 selecting negative time values gets wrong results - /// - [Test] - public void TestNegativeTime() - { - execSQL("CREATE TABLE Test (t time)"); - execSQL("INSERT INTO Test SET T='-07:24:00'"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - - TimeSpan ts = (TimeSpan)dt.Rows[0]["t"]; - Assert.AreEqual(-7, ts.Hours); - Assert.AreEqual(-24, ts.Minutes); - Assert.AreEqual(0, ts.Seconds); - } - - /// - /// Bug #25605 BINARY and VARBINARY is returned as a string - /// - [Test] - public void BinaryAndVarBinary() - { - MySqlCommand cmd = new MySqlCommand("SELECT BINARY 'something' AS BinaryData", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - byte[] buffer = new byte[2]; - long read = reader.GetBytes(0, 0, buffer, 0, 2); - Assert.AreEqual('s', buffer[0]); - Assert.AreEqual('o', buffer[1]); - Assert.AreEqual(2, read); - - string s = reader.GetString(0); - Assert.AreEqual("something", s); - } - } - - [Test] - public void NumericAsBinary() - { - MySqlCommand cmd = new MySqlCommand("SELECT IFNULL(NULL,0) AS MyServerID", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual("BIGINT", reader.GetDataTypeName(0)); - Assert.AreEqual(typeof(Int64), reader.GetFieldType(0)); - Assert.AreEqual("System.Int64", reader.GetValue(0).GetType().FullName); - Assert.AreEqual(0, reader.GetValue(0)); - } - } - - [Test] - public void BinaryTypes() - { - execSQL(@"CREATE TABLE Test (c1 VARCHAR(20), c2 VARBINARY(20), - c3 TEXT, c4 BLOB, c6 VARCHAR(20) CHARACTER SET BINARY)"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(typeof(String), dt.Columns[0].DataType); - Assert.AreEqual(typeof(byte[]), dt.Columns[1].DataType); - Assert.AreEqual(typeof(String), dt.Columns[2].DataType); - Assert.AreEqual(typeof(byte[]), dt.Columns[3].DataType); - Assert.AreEqual(typeof(byte[]), dt.Columns[4].DataType); - } - - [Test] - public void ShowColumns() - { - if (Version < new Version(5, 0)) return; - - MySqlDataAdapter da = new MySqlDataAdapter( - @"SELECT TRIM(TRAILING ' unsigned' FROM - TRIM(TRAILING ' zerofill' FROM COLUMN_TYPE)) AS MYSQL_TYPE, - IF(COLUMN_DEFAULT IS NULL, NULL, - IF(ASCII(COLUMN_DEFAULT) = 1 OR COLUMN_DEFAULT = '1', 1, 0)) - AS TRUE_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS - WHERE TABLE_SCHEMA='test' AND TABLE_NAME='test'", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - - Assert.AreEqual(typeof(string), dt.Columns[0].DataType); - Assert.AreEqual(typeof(Int64), dt.Columns[1].DataType); - } - - [Test] - public void RespectBinaryFlag() - { - execSQL("CREATE TABLE Test (col1 VARBINARY(20), col2 BLOB)"); - - string connStr = GetConnectionString(true) + ";respect binary flags=false"; - - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", c); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.IsTrue(dt.Columns[0].DataType == typeof(System.String)); - Assert.IsTrue(dt.Columns[1].DataType == typeof(System.Byte[])); - } - } - - /// - /// Bug #27959 Bool datatype is not returned as System.Boolean by MySqlDataAdapter - /// - [Test] - public void Boolean() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE Test (id INT, `on` BOOLEAN, v TINYINT(2))"); - execSQL("INSERT INTO Test VALUES (1,1,1), (2,0,0)"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(typeof(Boolean), dt.Columns[1].DataType); - Assert.AreEqual(typeof(SByte), dt.Columns[2].DataType); - Assert.AreEqual(true, dt.Rows[0][1]); - Assert.AreEqual(false, dt.Rows[1][1]); - Assert.AreEqual(1, dt.Rows[0][2]); - Assert.AreEqual(0, dt.Rows[1][2]); - } - - [Test] - public void Binary16AsGuid() - { - if (Version < new Version(5, 0)) return; - - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test (id INT, g BINARY(16), c VARBINARY(16), c1 BINARY(255))"); - - string connStr = GetConnectionString(true) + ";old guids=true"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - Guid g = Guid.NewGuid(); - byte[] bytes = g.ToByteArray(); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, @g, @c, @c1)", c); - cmd.Parameters.AddWithValue("@g", bytes); - cmd.Parameters.AddWithValue("@c", bytes); - cmd.Parameters.AddWithValue("@c1", g.ToString()); - cmd.ExecuteNonQuery(); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", c); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.IsTrue(dt.Rows[0][1] is Guid); - Assert.IsTrue(dt.Rows[0][2] is byte[]); - Assert.IsTrue(dt.Rows[0][3] is byte[]); - - Assert.AreEqual(g, dt.Rows[0][1]); - - string s = BitConverter.ToString(bytes); - - s = s.Replace("-", ""); - string sql = String.Format("TRUNCATE TABLE Test;INSERT INTO Test VALUES(1,0x{0},NULL,NULL)", s); - execSQL(sql); - - cmd.CommandText = "SELECT * FROM Test"; - cmd.Parameters.Clear(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Guid g1 = reader.GetGuid(1); - Assert.AreEqual(g, g1); - } - } - } - - /// - /// Bug #35041 'Binary(16) as GUID' - columns lose IsGuid value after a NULL value found - /// - [Test] - public void Binary16AsGuidWithNull() - { - execSQL(@"CREATE TABLE Test (id int(10) NOT NULL AUTO_INCREMENT, - AGUID binary(16), PRIMARY KEY (id))"); - Guid g = new Guid(); - byte[] guid = g.ToByteArray(); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (NULL, @g)", conn); - cmd.Parameters.AddWithValue("@g", guid); - cmd.ExecuteNonQuery(); - execSQL("insert into Test (AGUID) values (NULL)"); - cmd.ExecuteNonQuery(); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - } - - /// - /// Bug #36313 BIT result is lost in the left outer join - /// - [Test] - public void BitInLeftOuterJoin() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE TABLE Main (Id int(10) unsigned NOT NULL AUTO_INCREMENT, - Descr varchar(45) NOT NULL, PRIMARY KEY (`Id`)) - ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1"); - execSQL(@"INSERT INTO Main (Id,Descr) VALUES (1,'AAA'), (2,'BBB'), (3, 'CCC')"); - - execSQL(@"CREATE TABLE Child (Id int(10) unsigned NOT NULL AUTO_INCREMENT, - MainId int(10) unsigned NOT NULL, Value int(10) unsigned NOT NULL, - Enabled bit(1) NOT NULL, PRIMARY KEY (`Id`)) - ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1"); - execSQL(@"INSERT INTO Child (Id, MainId, Value, Enabled) VALUES (1,2,12345,0x01)"); - - MySqlDataAdapter da = new MySqlDataAdapter( - @"SELECT m.Descr, c.Value, c.Enabled FROM Main m - LEFT OUTER JOIN Child c ON m.Id=c.MainId ORDER BY m.Descr", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(3, dt.Rows.Count); - Assert.AreEqual("AAA", dt.Rows[0][0]); - Assert.AreEqual("BBB", dt.Rows[1][0]); - Assert.AreEqual("CCC", dt.Rows[2][0]); - - Assert.AreEqual(DBNull.Value, dt.Rows[0][1]); - Assert.AreEqual(12345, dt.Rows[1][1]); - Assert.AreEqual(DBNull.Value, dt.Rows[2][1]); - - Assert.AreEqual(DBNull.Value, dt.Rows[0][2]); - Assert.AreEqual(1, dt.Rows[1][2]); - Assert.AreEqual(DBNull.Value, dt.Rows[2][2]); - } - - /// - /// Bug #36081 Get Unknown Datatype in C# .Net - /// - [Test] - public void GeometryType() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE TABLE Test (ID int(11) NOT NULL, ogc_geom geometry NOT NULL, - PRIMARY KEY (`ID`))"); - execSQL(@"INSERT INTO Test VALUES (1, - GeomFromText('GeometryCollection(Point(1 1), LineString(2 2, 3 3))'))"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - } - } - - /// - /// Bug #33322 Incorrect Double/Single value saved to MySQL database using MySQL Connector for - /// - [Test] - public void StoringAndRetrievingDouble() - { - if (version.Major < 5) return; - - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test (v DOUBLE(25,20) NOT NULL)"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?v)", conn); - cmd.Parameters.Add("?v", MySqlDbType.Double); - cmd.Parameters[0].Value = Math.PI; - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - double d = reader.GetDouble(0); - Assert.AreEqual(Math.PI, d); - } - } - - /// - /// Bug #40571 Add GetSByte to the list of public methods supported by MySqlDataReader - /// - [Test] - public void SByteFromReader() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test (c1 TINYINT, c2 TINYINT UNSIGNED)"); - execSQL("INSERT INTO Test VALUES (99, 217)"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual(99, reader.GetSByte(0)); - Assert.AreEqual(217, reader.GetByte(1)); - Assert.AreEqual(99, reader.GetByte(0)); - } - } - - [Test] - public void NewGuidDataType() - { - execSQL("CREATE TABLE Test(id INT, g BINARY(16))"); - - string connStr = GetConnectionString(true) + ";old guids=true"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - Guid guid = Guid.NewGuid(); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, @g)", c); - cmd.Parameters.Add(new MySqlParameter("@g", MySqlDbType.Guid)); - cmd.Parameters[0].Value = guid; - cmd.ExecuteNonQuery(); - - DataTable dt = new DataTable(); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", c); - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(1, dt.Rows[0]["id"]); - Assert.AreEqual(guid, dt.Rows[0]["g"]); - } - } - - /// - /// Bug #44507 Binary(16) considered as Guid - /// - [Test] - public void ReadBinary16AsBinary() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test (id INT, guid BINARY(16))"); - - string connStr = GetConnectionString(true) + ";old guids=true"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - Guid g = new Guid("32A48AC5-285A-46c6-A0D4-158E6E39729C"); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, ?guid)", c); - //MySqlParameter p = new MySqlParameter(); - //p.ParameterName = "guid"; - //p.Value = Guid.NewGuid(); - cmd.Parameters.AddWithValue("guid", Guid.NewGuid()); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - cmd.Parameters.Clear(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - - object o = reader.GetValue(1); - Assert.IsTrue(o is Guid); - - byte[] bytes = new byte[16]; - long size = reader.GetBytes(1, 0, bytes, 0, 16); - Assert.AreEqual(16, size); - } - } - } - - [Test] - public void ReadingUUIDAsGuid() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test (id INT, guid CHAR(36))"); - execSQL("INSERT INTO Test VALUES (1, UUID())"); - - MySqlCommand cmd = new MySqlCommand("SELECT CONCAT('A', guid) FROM Test", conn); - string serverGuidStr = cmd.ExecuteScalar().ToString().Substring(1); - Guid serverGuid = new Guid(serverGuidStr); - - cmd.CommandText = "SELECT guid FROM Test"; - Guid g = (Guid)cmd.ExecuteScalar(); - Assert.AreEqual(serverGuid, g); - } - - [Test] - public void NewGuidType() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test (id INT, guid CHAR(36))"); - - Guid g = Guid.NewGuid(); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, @g)", conn); - cmd.Parameters.AddWithValue("@g", g); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT guid FROM Test"; - Guid readG = (Guid)cmd.ExecuteScalar(); - Assert.AreEqual(g, readG); - } - - /// - /// Bug #47928 Old Guids=true setting is lost after null value is - /// encountered in a Binary(16) - /// - [Test] - public void OldGuidsWithNull() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test (id INT, guid BINARY(16))"); - - string connStr = GetConnectionString(true) + ";old guids=true"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, ?guid)", c); - cmd.Parameters.AddWithValue("guid", Guid.NewGuid()); - cmd.ExecuteNonQuery(); - - cmd.Parameters["guid"].Value = null; - cmd.ExecuteNonQuery(); - cmd.Parameters["guid"].Value = Guid.NewGuid(); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT guid FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - //In Bug #47928, following loop will crash after encountering - // null value. - while (reader.Read()) - { - object o = reader.GetValue(0); - } - } - } - } - - /// - /// Bug #47985 UTF-8 String Length Issue (guids etc) - /// - [Test] - public void UTF8Char12AsGuid() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test (id INT, name CHAR(12) CHARSET utf8)"); - execSQL("INSERT INTO Test VALUES (1, 'Name')"); - - string connStr = GetConnectionString(true) + ";charset=utf8"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", c); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - string s = reader.GetString(1); - Assert.AreEqual("Name", s); - } - } - } - - /// - /// Bug #48100 Impossible to retrieve decimal value if it doesn't fit into .Net System.Decimal - /// - [Test] - public void MySqlDecimal() - { - if (Version < new Version(5, 0)) return; - - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test (id INT, dec1 DECIMAL(36,2))"); - execSQL("INSERT INTO Test VALUES (1, 9999999999999999999999999999999999.99)"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - MySqlDecimal dec = reader.GetMySqlDecimal(1); - string s = dec.ToString(); - Assert.AreEqual(9999999999999999999999999999999999.99, dec.ToDouble()); - Assert.AreEqual("9999999999999999999999999999999999.99", dec.ToString()); - try - { - decimal d = dec.Value; - Assert.Fail("this should have failed"); - } - catch (Exception) - { - } - } - } - - /// - /// Bug #48171 MySqlDataReader.GetSchemaTable() returns 0 in "NumericPrecision" for newdecimal - /// - [Test] - public void DecimalPrecision() - { - execSQL("DROP TABLE IF EXISTS test"); - execSQL("CREATE TABLE test(a decimal(35,2), b decimal(36,2), c decimal(36,2) unsigned)"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - DataTable dt = reader.GetSchemaTable(); - DataRow columnDefinition = dt.Rows[0]; - Assert.AreEqual(35, columnDefinition[SchemaTableColumn.NumericPrecision]); - columnDefinition = dt.Rows[1]; - Assert.AreEqual(36, columnDefinition[SchemaTableColumn.NumericPrecision]); - columnDefinition = dt.Rows[2]; - Assert.AreEqual(36, columnDefinition[SchemaTableColumn.NumericPrecision]); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DateTimeTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DateTimeTests.cs deleted file mode 100644 index cbf8927..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/DateTimeTests.cs +++ /dev/null @@ -1,430 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.Data.Common; -using System.Threading; -using MySql.Data.MySqlClient; -using MySql.Data.Types; -using System.Globalization; -using NUnit.Framework; -using System.Text; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class DateTimeTests : BaseTest - { - [SetUp] - public override void Setup() - { - base.Setup(); - execSQL("CREATE TABLE Test (id INT NOT NULL, dt DATETIME, d DATE, " + - "t TIME, ts TIMESTAMP, PRIMARY KEY(id))"); - } - - [Test] - public void ConvertZeroDateTime() - { - execSQL("INSERT INTO Test VALUES(1, '0000-00-00', '0000-00-00', " + - "'00:00:00', NULL)"); - - string connStr = this.GetConnectionString(true); - connStr += ";convert zero datetime=yes"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", c); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(DateTime.MinValue.Date, reader.GetDateTime(1).Date); - Assert.AreEqual(DateTime.MinValue.Date, reader.GetDateTime(2).Date); - } - } - } - - [Test] - public void TestNotAllowZerDateAndTime() - { - execSQL("SET SQL_MODE=''"); - execSQL("INSERT INTO Test VALUES(1, 'Test', '0000-00-00', '0000-00-00', '00:00:00')"); - execSQL("INSERT INTO Test VALUES(2, 'Test', '2004-11-11', '2004-11-11', '06:06:06')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - - MySqlDateTime testDate = reader.GetMySqlDateTime(2); - Assert.IsFalse(testDate.IsValidDateTime, "IsZero is false"); - - try - { - reader.GetValue(2); - Assert.Fail("This should not work"); - } - catch (MySqlConversionException) - { - } - - Assert.IsTrue(reader.Read()); - - DateTime dt2 = (DateTime)reader.GetValue(2); - Assert.AreEqual(new DateTime(2004, 11, 11).Date, dt2.Date); - } - } - - [Test] - public void DateAdd() - { - MySqlCommand cmd = new MySqlCommand("select date_add(?someday, interval 1 hour)", - conn); - DateTime now = DateTime.Now; - DateTime later = now.AddHours(1); - later = later.AddMilliseconds(later.Millisecond * -1); - cmd.Parameters.AddWithValue("?someday", now); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - DateTime dt = reader.GetDateTime(0); - Assert.AreEqual(later.Date, dt.Date); - Assert.AreEqual(later.Hour, dt.Hour); - Assert.AreEqual(later.Minute, dt.Minute); - Assert.AreEqual(later.Second, dt.Second); - } - } - - /// - /// Bug #9619 Cannot update row using DbDataAdapter when row contains an invalid date - /// Bug #15112 MySqlDateTime Constructor - /// - [Test] - public void TestAllowZeroDateTime() - { - execSQL("TRUNCATE TABLE Test"); - execSQL("INSERT INTO Test (id, d, dt) VALUES (1, '0000-00-00', '0000-00-00 00:00:00')"); - - using (MySqlConnection c = new MySqlConnection( - conn.ConnectionString + ";pooling=false;AllowZeroDatetime=true")) - { - c.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", c); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - - Assert.IsTrue(reader.GetValue(1) is MySqlDateTime); - Assert.IsTrue(reader.GetValue(2) is MySqlDateTime); - - Assert.IsFalse(reader.GetMySqlDateTime(1).IsValidDateTime); - Assert.IsFalse(reader.GetMySqlDateTime(2).IsValidDateTime); - - try - { - reader.GetDateTime(1); - Assert.Fail("This should not succeed"); - } - catch (MySqlConversionException) - { - } - } - - DataTable dt = new DataTable(); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", c); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - da.Fill(dt); - dt.Rows[0]["id"] = 2; - DataRow row = dt.NewRow(); - row["id"] = 3; - row["d"] = new MySqlDateTime("2003-9-24"); - row["dt"] = new MySqlDateTime("0000/0/00 00:00:00"); - dt.Rows.Add(row); - - da.Update(dt); - - dt.Clear(); - da.Fill(dt); - Assert.AreEqual(2, dt.Rows.Count); - MySqlDateTime date = (MySqlDateTime)dt.Rows[1]["d"]; - Assert.AreEqual(2003, date.Year); - Assert.AreEqual(9, date.Month); - Assert.AreEqual(24, date.Day); - cb.Dispose(); - } - } - - [Test] - public void InsertDateTimeValue() - { - using (MySqlConnection c = new MySqlConnection(conn.ConnectionString + - ";allow zero datetime=yes")) - { - c.Open(); - MySqlDataAdapter da = new MySqlDataAdapter("SELECT id, dt FROM Test", c); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - - DataTable dt = new DataTable(); - dt.Columns.Add(new DataColumn("id", typeof(int))); - dt.Columns.Add(new DataColumn("dt", typeof(DateTime))); - - da.Fill(dt); - - DateTime now = DateTime.Now; - DataRow row = dt.NewRow(); - row["id"] = 1; - row["dt"] = now; - dt.Rows.Add(row); - da.Update(dt); - - dt.Clear(); - da.Fill(dt); - cb.Dispose(); - - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(now.Date, ((DateTime)dt.Rows[0]["dt"]).Date); - } - } - -#if !CF - [Test] - public void SortingMySqlDateTimes() - { - execSQL("INSERT INTO Test (id, dt) VALUES (1, '2004-10-01')"); - execSQL("INSERT INTO Test (id, dt) VALUES (2, '2004-10-02')"); - execSQL("INSERT INTO Test (id, dt) VALUES (3, '2004-11-01')"); - execSQL("INSERT INTO Test (id, dt) VALUES (4, '2004-11-02')"); - - CultureInfo curCulture = Thread.CurrentThread.CurrentCulture; - CultureInfo curUICulture = Thread.CurrentThread.CurrentUICulture; - CultureInfo cul = new CultureInfo("en-GB"); - Thread.CurrentThread.CurrentCulture = cul; - Thread.CurrentThread.CurrentUICulture = cul; - - using( MySqlConnection c = new MySqlConnection( conn.ConnectionString + ";allow zero datetime=yes" )) - { - MySqlDataAdapter da = new MySqlDataAdapter("SELECT dt FROM Test", c); - DataTable dt = new DataTable(); - da.Fill(dt); - - DataView dv = dt.DefaultView; - dv.Sort = "dt ASC"; - - Assert.AreEqual(new DateTime(2004, 10, 1).Date, Convert.ToDateTime(dv[0]["dt"]).Date); - Assert.AreEqual(new DateTime(2004, 10, 2).Date, Convert.ToDateTime(dv[1]["dt"]).Date); - Assert.AreEqual(new DateTime(2004, 11, 1).Date, Convert.ToDateTime(dv[2]["dt"]).Date); - Assert.AreEqual(new DateTime(2004, 11, 2).Date, Convert.ToDateTime(dv[3]["dt"]).Date); - - Thread.CurrentThread.CurrentCulture = curCulture; - Thread.CurrentThread.CurrentUICulture = curUICulture; - } - } -#endif - - [Test] - public void TestZeroDateTimeException() - { - execSQL("INSERT INTO Test (id, d, dt) VALUES (1, '0000-00-00', '0000-00-00 00:00:00')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - try - { - reader.Read(); - reader.GetDateTime(2); - Assert.Fail("Should throw an exception"); - } - catch (MySqlConversionException) - { - } - } - } - - /// - /// Bug #8929 Timestamp values with a date > 10/29/9997 cause problems - /// - [Test] - public void LargeDateTime() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, dt) VALUES(?id,?dt)", conn); - cmd.Parameters.Add(new MySqlParameter("?id", 1)); - cmd.Parameters.Add(new MySqlParameter("?dt", DateTime.Parse("9997-10-29"))); - cmd.ExecuteNonQuery(); - cmd.Parameters[0].Value = 2; - cmd.Parameters[1].Value = DateTime.Parse("9997-10-30"); - cmd.ExecuteNonQuery(); - cmd.Parameters[0].Value = 3; - cmd.Parameters[1].Value = DateTime.Parse("9999-12-31"); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT id,dt FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(DateTime.Parse("9997-10-29").Date, reader.GetDateTime(1).Date); - Assert.IsTrue(reader.Read()); - Assert.AreEqual(DateTime.Parse("9997-10-30").Date, reader.GetDateTime(1).Date); - Assert.IsTrue(reader.Read()); - Assert.AreEqual(DateTime.Parse("9999-12-31").Date, reader.GetDateTime(1).Date); - } - } - - [Test] - public void UsingDatesAsStrings() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, dt) VALUES (1, ?dt)", conn); - cmd.Parameters.Add("?dt", MySqlDbType.Date); - cmd.Parameters[0].Value = "2005-03-04"; - cmd.ExecuteNonQuery(); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - DateTime date = (DateTime)dt.Rows[0]["dt"]; - Assert.AreEqual(2005, date.Year); - Assert.AreEqual(3, date.Month); - Assert.AreEqual(4, date.Day); - } - - /// - /// Bug #19481 Where clause with datetime throws exception [any warning causes the exception] - /// - [Test] - public void Bug19481() - { - execSQL("DROP TABLE Test"); - execSQL("CREATE TABLE Test(ID INT NOT NULL AUTO_INCREMENT, " + - "SATELLITEID VARCHAR(3) NOT NULL, ANTENNAID INT, AOS_TIMESTAMP DATETIME NOT NULL, " + - "TEL_TIMESTAMP DATETIME, LOS_TIMESTAMP DATETIME, PRIMARY KEY (ID))"); - execSQL("INSERT INTO Test VALUES (NULL,'224','0','2005-07-24 00:00:00'," + - "'2005-07-24 00:02:00','2005-07-24 00:22:00')"); - execSQL("INSERT INTO Test VALUES (NULL,'155','24','2005-07-24 03:00:00'," + - "'2005-07-24 03:02:30','2005-07-24 03:20:00')"); - execSQL("INSERT INTO Test VALUES (NULL,'094','34','2005-07-24 09:00:00'," + - "'2005-07-24 09:00:30','2005-07-24 09:15:00')"); - execSQL("INSERT INTO Test VALUES (NULL,'224','54','2005-07-24 12:00:00'," + - "'2005-07-24 12:01:00','2005-07-24 12:33:00')"); - execSQL("INSERT INTO Test VALUES (NULL,'155','25','2005-07-24 15:00:00'," + - "'2005-07-24 15:02:00','2005-07-24 15:22:00')"); - execSQL("INSERT INTO Test VALUES (NULL,'094','0','2005-07-24 17:00:00'," + - "'2005-07-24 17:02:12','2005-07-24 17:20:00')"); - execSQL("INSERT INTO Test VALUES (NULL,'224','24','2005-07-24 19:00:00'," + - "'2005-07-24 19:02:00','2005-07-24 19:27:00')"); - execSQL("INSERT INTO Test VALUES (NULL,'155','34','2005-07-24 21:00:00'," + - "'2005-07-24 21:02:33','2005-07-24 21:22:55')"); - execSQL("INSERT INTO Test VALUES (NULL,'094','55','2005-07-24 23:00:00'," + - "'2005-07-24 23:00:45','2005-07-24 23:22:23')"); - - DateTime date = DateTime.Parse("7/24/2005"); - StringBuilder sql = new StringBuilder(); - sql.AppendFormat(CultureInfo.InvariantCulture, - @"SELECT ID, ANTENNAID, TEL_TIMESTAMP, LOS_TIMESTAMP FROM Test - WHERE TEL_TIMESTAMP >= '{0}'", date.ToString("u")); - MySqlDataAdapter da = new MySqlDataAdapter(sql.ToString(), conn); - DataSet dataSet = new DataSet(); - da.Fill(dataSet); - } - - /// - /// Bug #17736 Selecting a row with with empty date '0000-00-00' results in Read() hanging. - /// - [Test] - public void PreparedZeroDateTime() - { - if (Version < new Version(4, 1)) return; - - execSQL("INSERT INTO Test VALUES(1, Now(), '0000-00-00', NULL, NULL)"); - MySqlCommand cmd = new MySqlCommand("SELECT d FROM Test WHERE id=?id", conn); - cmd.Parameters.AddWithValue("?id", 1); - cmd.Prepare(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - } - } - - [Test] - public void DateTimeInDataTable() - { - execSQL("INSERT INTO Test VALUES(1, Now(), '0000-00-00', NULL, NULL)"); - - using (MySqlConnection c = new MySqlConnection( - conn.ConnectionString + ";pooling=false;AllowZeroDatetime=true")) - { - c.Open(); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", c); - MySqlCommandBuilder cb = new MySqlCommandBuilder(da); - DataTable dt = new DataTable(); - - da.Fill(dt); - DataRow row = dt.NewRow(); - row["id"] = 2; - row["dt"] = new MySqlDateTime(DateTime.Now); - row["d"] = new MySqlDateTime(DateTime.Now); - row["t"] = new TimeSpan(1, 1, 1); - row["ts"] = DBNull.Value; - dt.Rows.Add(row); - da.Update(dt); - - dt.Rows.Clear(); - da.Fill(dt); - Assert.AreEqual(2, dt.Rows.Count); - cb.Dispose(); - } - } - - /// - /// Bug #32010 Connector return incorrect value when pulling 0 datetime - /// - [Test] - public void MySqlDateTimeFormatting() - { - DateTime dt = DateTime.Now; - MySqlDateTime mdt = new MySqlDateTime(dt); - Assert.AreEqual(dt.ToString(), mdt.ToString()); - } - - /// - /// Bug #41021 DateTime format incorrect - /// - [Test] - public void DateFormat() - { - DateTime dt = DateTime.Now; - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, ?dt, NULL, NULL, NULL)", conn); - cmd.Parameters.AddWithValue("?dt", dt); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT dt FROM Test WHERE DATE_FORMAT(DATE(dt), GET_FORMAT(DATETIME, 'ISO'))=?datefilter"; - cmd.Parameters.Clear(); - cmd.Parameters.AddWithValue("?datefilter", dt.Date); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - } - } - } - -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/EventTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/EventTests.cs deleted file mode 100644 index ab98e05..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/EventTests.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using System.Globalization; -using System.Threading; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class EventTests : BaseTest - { - [Test] - public void Warnings() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (name VARCHAR(10))"); - - string connStr = GetConnectionString(true); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("SET SQL_MODE=''", c); - cmd.ExecuteNonQuery(); - - c.InfoMessage += new MySqlInfoMessageEventHandler(WarningsInfoMessage); - - cmd.CommandText = "INSERT INTO Test VALUES ('12345678901')"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - } - } - } - - private void WarningsInfoMessage(object sender, MySqlInfoMessageEventArgs args) - { - Assert.AreEqual(1, args.errors.Length); - } - - [Test] - public void StateChange() - { - MySqlConnection c = new MySqlConnection(GetConnectionString(true)); - c.StateChange += new StateChangeEventHandler(StateChangeHandler); - c.Open(); - c.Close(); - } - - private void StateChangeHandler(object sender, StateChangeEventArgs e) - { - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ExceptionTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ExceptionTests.cs deleted file mode 100644 index ca3c7d2..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ExceptionTests.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using System.Threading; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class ExceptionTests : BaseTest - { - public override void Setup() - { - base.Setup(); - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100))"); - } - - [Test] - public void Timeout() - { - for (int i=1; i < 10; i++) - execSQL("INSERT INTO Test VALUES (" + i + ", 'This is a long text string that I am inserting')"); - - // we create a new connection so our base one is not closed - MySqlConnection c2 = new MySqlConnection(conn.ConnectionString); - c2.Open(); - - KillConnection(c2); - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", c2); - MySqlDataReader reader = null; - - try - { - reader = cmd.ExecuteReader(); - reader.Read(); - reader.Read(); - reader.Close(); - Assert.Fail("We should not reach this code"); - } - catch (Exception) - { - Assert.AreEqual(ConnectionState.Closed, c2.State); - } - finally - { - if (reader != null) reader.Close(); - c2.Close(); - } - } -#if !CF - /// - /// Bug #27436 Add the MySqlException.Number property value to the Exception.Data Dictionary - /// - [Test] - public void ErrorData() - { - MySqlCommand cmd = new MySqlCommand("SELEDT 1", conn); - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception ex) - { - Assert.AreEqual(1064, ex.Data["Server Error Code"]); - } - } -#endif - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/GetSchemaTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/GetSchemaTests.cs deleted file mode 100644 index b09b905..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/GetSchemaTests.cs +++ /dev/null @@ -1,554 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using NUnit.Framework; -using System.Globalization; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class GetSchemaTests : BaseTest - { - [Test] - public void Collections() - { - DataTable dt = conn.GetSchema(); - - int row = 0; - Assert.AreEqual("MetaDataCollections", dt.Rows[row++][0]); - Assert.AreEqual("DataSourceInformation", dt.Rows[row++][0]); - Assert.AreEqual("DataTypes", dt.Rows[row++][0]); - Assert.AreEqual("Restrictions", dt.Rows[row++][0]); - Assert.AreEqual("ReservedWords", dt.Rows[row++][0]); - Assert.AreEqual("Databases", dt.Rows[row++][0]); - Assert.AreEqual("Tables", dt.Rows[row++][0]); - Assert.AreEqual("Columns", dt.Rows[row++][0]); - Assert.AreEqual("Users", dt.Rows[row++][0]); - Assert.AreEqual("Foreign Keys", dt.Rows[row++][0]); - Assert.AreEqual("IndexColumns", dt.Rows[row++][0]); - Assert.AreEqual("Indexes", dt.Rows[row++][0]); - Assert.AreEqual("Foreign Key Columns", dt.Rows[row++][0]); - Assert.AreEqual("UDF", dt.Rows[row++][0]); - - if (Version >= new Version(5, 0)) - { - Assert.AreEqual("Views", dt.Rows[row++][0]); - Assert.AreEqual("ViewColumns", dt.Rows[row++][0]); - Assert.AreEqual("Procedure Parameters", dt.Rows[row++][0]); - Assert.AreEqual("Procedures", dt.Rows[row++][0]); - Assert.AreEqual("Triggers", dt.Rows[row++][0]); - } - } - - /// - /// Bug #25907 DataType Column of DataTypes collection does'nt contain the correct CLR Datatype - /// Bug #25947 CreateFormat/CreateParameters Column of DataTypes collection incorrect for CHAR - /// - [Test] - public void DataTypes() - { - DataTable dt = conn.GetSchema("DataTypes", new string[] { }); - - foreach (DataRow row in dt.Rows) - { - string type = row["TYPENAME"].ToString(); - Type systemType = Type.GetType(row["DATATYPE"].ToString()); - if (type == "BIT") - Assert.AreEqual(typeof(System.UInt64), systemType); - else if (type == "DATE" || type == "DATETIME" || - type == "TIMESTAMP") - Assert.AreEqual(typeof(System.DateTime), systemType); - else if (type == "BLOB" || type == "TINYBLOB" || - type == "MEDIUMBLOB" || type == "LONGBLOB") - Assert.AreEqual(typeof(System.Byte[]), systemType); - else if (type == "TIME") - Assert.AreEqual(typeof(System.TimeSpan), systemType); - else if (type == "CHAR" || type == "VARCHAR") - { - Assert.AreEqual(typeof(System.String), systemType); - Assert.IsFalse(Convert.ToBoolean(row["IsFixedLength"])); - string format = type + "({0})"; - Assert.AreEqual(format, row["CreateFormat"].ToString()); - } - else if (type == "SET" || type == "ENUM") - Assert.AreEqual(typeof(System.String), systemType); - else if (type == "DOUBLE") - Assert.AreEqual(typeof(System.Double), systemType); - else if (type == "SINGLE") - Assert.AreEqual(typeof(System.Single), systemType); - else if (type == "TINYINT") - { - if (row["CREATEFORMAT"].ToString().EndsWith("UNSIGNED")) - Assert.AreEqual(typeof(System.Byte), systemType); - else - Assert.AreEqual(typeof(System.SByte), systemType); - } - else if (type == "SMALLINT") - { - if (row["CREATEFORMAT"].ToString().EndsWith("UNSIGNED")) - Assert.AreEqual(typeof(System.UInt16), systemType); - else - Assert.AreEqual(typeof(System.Int16), systemType); - } - else if (type == "MEDIUMINT" || type == "INT") - { - if (row["CREATEFORMAT"].ToString().EndsWith("UNSIGNED")) - Assert.AreEqual(typeof(System.UInt32), systemType); - else - Assert.AreEqual(typeof(System.Int32), systemType); - } - else if (type == "BIGINT") - { - if (row["CREATEFORMAT"].ToString().EndsWith("UNSIGNED")) - Assert.AreEqual(typeof(System.UInt64), systemType); - else - Assert.AreEqual(typeof(System.Int64), systemType); - } - else if (type == "DECIMAL") - { - Assert.AreEqual(typeof(System.Decimal), systemType); - Assert.AreEqual("DECIMAL({0},{1})", row["CreateFormat"].ToString()); - } - else if (type == "TINYINT") - Assert.AreEqual(typeof(System.Byte), systemType); - } - } - - [Test] - public void Databases() - { - DataTable dt = conn.GetSchema("Databases"); - Assert.AreEqual("Databases", dt.TableName); - - bool foundZero = false; - bool foundOne = false; - foreach (DataRow row in dt.Rows) - { - string dbName = row[1].ToString().ToLower(); - if (dbName == database0.ToLower()) - foundZero = true; - else if (dbName == database1.ToLower()) - foundOne = true; - } - Assert.IsTrue(foundZero); - Assert.IsTrue(foundOne); - - dt = conn.GetSchema("Databases", new string[1] { database0 }); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(database0.ToLower(), dt.Rows[0][1].ToString().ToLower()); - } - - [Test] - public void Tables() - { - execSQL("CREATE TABLE test1 (id int)"); - - string[] restrictions = new string[4]; - restrictions[1] = database0; - restrictions[2] = "test1"; - DataTable dt = conn.GetSchema("Tables", restrictions); - if (Version.Major >= 5 && Version.Minor >= 1) - { - Assert.IsTrue(dt.Columns["VERSION"].DataType == typeof(UInt64)); - Assert.IsTrue(dt.Columns["TABLE_ROWS"].DataType == typeof(UInt64)); - Assert.IsTrue(dt.Columns["AVG_ROW_LENGTH"].DataType == typeof(UInt64)); - Assert.IsTrue(dt.Columns["DATA_LENGTH"].DataType == typeof(UInt64)); - Assert.IsTrue(dt.Columns["MAX_DATA_LENGTH"].DataType == typeof(UInt64)); - Assert.IsTrue(dt.Columns["INDEX_LENGTH"].DataType == typeof(UInt64)); - Assert.IsTrue(dt.Columns["DATA_FREE"].DataType == typeof(UInt64)); - Assert.IsTrue(dt.Columns["AUTO_INCREMENT"].DataType == typeof(UInt64)); - Assert.IsTrue(dt.Columns["CHECKSUM"].DataType == typeof(UInt64)); - } - Assert.IsTrue(dt.Rows.Count == 1); - Assert.AreEqual("Tables", dt.TableName); - Assert.AreEqual("test1", dt.Rows[0][2]); - } - - [Test] - public void Columns() - { - execSQL("CREATE TABLE test (col1 int, col2 decimal(20,5), " + - "col3 varchar(50) character set utf8, col4 tinyint unsigned)"); - - string[] restrictions = new string[4]; - restrictions[1] = database0; - restrictions[2] = "test"; - DataTable dt = conn.GetSchema("Columns", restrictions); - Assert.AreEqual(4, dt.Rows.Count); - Assert.AreEqual("Columns", dt.TableName); - if (Version.Major >= 5 && Version.Minor >= 1) - { - Assert.IsTrue(dt.Columns["ORDINAL_POSITION"].DataType == typeof(UInt64)); - Assert.IsTrue(dt.Columns["CHARACTER_MAXIMUM_LENGTH"].DataType == typeof(UInt64)); - Assert.IsTrue(dt.Columns["NUMERIC_PRECISION"].DataType == typeof(UInt64)); - Assert.IsTrue(dt.Columns["NUMERIC_SCALE"].DataType == typeof(UInt64)); - } - - // first column - Assert.AreEqual(database0.ToUpper(), dt.Rows[0]["TABLE_SCHEMA"].ToString().ToUpper()); - Assert.AreEqual("COL1", dt.Rows[0]["COLUMN_NAME"].ToString().ToUpper()); - Assert.AreEqual(1, dt.Rows[0]["ORDINAL_POSITION"]); - Assert.AreEqual("YES", dt.Rows[0]["IS_NULLABLE"]); - Assert.AreEqual("INT", dt.Rows[0]["DATA_TYPE"].ToString().ToUpper()); - - // second column - Assert.AreEqual(database0.ToUpper(), dt.Rows[1]["TABLE_SCHEMA"].ToString().ToUpper()); - Assert.AreEqual("COL2", dt.Rows[1]["COLUMN_NAME"].ToString().ToUpper()); - Assert.AreEqual(2, dt.Rows[1]["ORDINAL_POSITION"]); - Assert.AreEqual("YES", dt.Rows[1]["IS_NULLABLE"]); - Assert.AreEqual("DECIMAL", dt.Rows[1]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual("DECIMAL(20,5)", dt.Rows[1]["COLUMN_TYPE"].ToString().ToUpper()); - Assert.AreEqual(20, dt.Rows[1]["NUMERIC_PRECISION"]); - Assert.AreEqual(5, dt.Rows[1]["NUMERIC_SCALE"]); - - // third column - Assert.AreEqual(database0.ToUpper(), dt.Rows[2]["TABLE_SCHEMA"].ToString().ToUpper()); - Assert.AreEqual("COL3", dt.Rows[2]["COLUMN_NAME"].ToString().ToUpper()); - Assert.AreEqual(3, dt.Rows[2]["ORDINAL_POSITION"]); - Assert.AreEqual("YES", dt.Rows[2]["IS_NULLABLE"]); - Assert.AreEqual("VARCHAR", dt.Rows[2]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual("VARCHAR(50)", dt.Rows[2]["COLUMN_TYPE"].ToString().ToUpper()); - - // fourth column - Assert.AreEqual(database0.ToUpper(), dt.Rows[3]["TABLE_SCHEMA"].ToString().ToUpper()); - Assert.AreEqual("COL4", dt.Rows[3]["COLUMN_NAME"].ToString().ToUpper()); - Assert.AreEqual(4, dt.Rows[3]["ORDINAL_POSITION"]); - Assert.AreEqual("YES", dt.Rows[3]["IS_NULLABLE"]); - Assert.AreEqual("TINYINT", dt.Rows[3]["DATA_TYPE"].ToString().ToUpper()); - } - - /// - /// Bug #46270 connection.GetSchema("Columns") fails on MySQL 4.1 - /// - [Test] - public void EnumAndSetColumns() - { - execSQL("DROP TABLE IF EXISTS test"); - execSQL("CREATE TABLE test (col1 set('A','B','C'), col2 enum('A','B','C'))"); - - DataTable dt = conn.GetSchema("Columns", new string[] { null, null, "test", null }); - Assert.AreEqual(2, dt.Rows.Count); - Assert.AreEqual("set", dt.Rows[0]["DATA_TYPE"]); - Assert.AreEqual("enum", dt.Rows[1]["DATA_TYPE"]); - Assert.AreEqual("set('A','B','C')", dt.Rows[0]["COLUMN_TYPE"]); - Assert.AreEqual("enum('A','B','C')", dt.Rows[1]["COLUMN_TYPE"]); - } - - [Test] - public void Procedures() - { - if (Version < new Version(5, 0)) return; - - execSQL("DROP PROCEDURE IF EXISTS spTest"); - execSQL("CREATE PROCEDURE spTest (id int) BEGIN SELECT 1; END"); - - string[] restrictions = new string[4]; - restrictions[1] = database0; - restrictions[2] = "spTest"; - DataTable dt = conn.GetSchema("Procedures", restrictions); - Assert.IsTrue(dt.Rows.Count == 1); - Assert.AreEqual("Procedures", dt.TableName); - Assert.AreEqual("spTest", dt.Rows[0][3]); - } - - [Test] - public void Functions() - { - if (Version < new Version(5, 0)) return; - - execSQL("DROP FUNCTION IF EXISTS spFunc"); - execSQL("CREATE FUNCTION spFunc (id int) RETURNS INT BEGIN RETURN 1; END"); - - string[] restrictions = new string[4]; - restrictions[1] = database0; - restrictions[2] = "spFunc"; - DataTable dt = conn.GetSchema("Procedures", restrictions); - Assert.IsTrue(dt.Rows.Count == 1); - Assert.AreEqual("Procedures", dt.TableName); - Assert.AreEqual("spFunc", dt.Rows[0][3]); - } - - [Test] - public void Indexes() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE test (id int, PRIMARY KEY(id))"); - string[] restrictions = new string[4]; - restrictions[2] = "test"; - restrictions[1] = database0; - DataTable dt = conn.GetSchema("Indexes", restrictions); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]); - Assert.AreEqual(true, dt.Rows[0]["PRIMARY"]); - Assert.AreEqual(true, dt.Rows[0]["UNIQUE"]); - - execSQL("DROP TABLE IF EXISTS test"); - execSQL("CREATE TABLE test (id int, name varchar(50), " + - "UNIQUE KEY key2 (name))"); - - dt = conn.GetSchema("Indexes", restrictions); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]); - Assert.AreEqual("key2", dt.Rows[0]["INDEX_NAME"]); - Assert.AreEqual(false, dt.Rows[0]["PRIMARY"]); - Assert.AreEqual(true, dt.Rows[0]["UNIQUE"]); - - restrictions[3] = "key2"; - dt = conn.GetSchema("Indexes", restrictions); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]); - Assert.AreEqual("key2", dt.Rows[0]["INDEX_NAME"]); - Assert.AreEqual(false, dt.Rows[0]["PRIMARY"]); - Assert.AreEqual(true, dt.Rows[0]["UNIQUE"]); - - /// - /// Bug #48101 MySqlConnection.GetSchema on "Indexes" throws when there's a table named "b`a`d" - /// - execSQL("DROP TABLE IF EXISTS test"); - execSQL(@"CREATE TABLE `te``s``t` (id int, name varchar(50), " + - "KEY key2 (name))"); - - restrictions[2] = "te`s`t"; - dt = conn.GetSchema("Indexes", restrictions); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual("te`s`t", dt.Rows[0]["TABLE_NAME"]); - Assert.AreEqual("key2", dt.Rows[0]["INDEX_NAME"]); - Assert.AreEqual(false, dt.Rows[0]["PRIMARY"]); - Assert.AreEqual(false, dt.Rows[0]["UNIQUE"]); - } - - [Test] - public void IndexColumns() - { - execSQL("CREATE TABLE test (id int, PRIMARY KEY(id))"); - string[] restrictions = new string[5]; - restrictions[2] = "test"; - restrictions[1] = database0; - DataTable dt = conn.GetSchema("IndexColumns", restrictions); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]); - Assert.AreEqual("id", dt.Rows[0]["COLUMN_NAME"]); - - execSQL("DROP TABLE IF EXISTS test"); - execSQL("CREATE TABLE test (id int, id1 int, id2 int, " + - "INDEX key1 (id1, id2))"); - restrictions[2] = "test"; - restrictions[1] = database0; - restrictions[4] = "id2"; - dt = conn.GetSchema("IndexColumns", restrictions); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]); - Assert.AreEqual("id2", dt.Rows[0]["COLUMN_NAME"]); - Assert.AreEqual(2, dt.Rows[0]["ORDINAL_POSITION"]); - - restrictions[3] = "key1"; - dt = conn.GetSchema("IndexColumns", restrictions); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]); - Assert.AreEqual("id2", dt.Rows[0]["COLUMN_NAME"]); - Assert.AreEqual(2, dt.Rows[0]["ORDINAL_POSITION"]); - - restrictions = new string[3]; - restrictions[1] = database0; - restrictions[2] = "test"; - dt = conn.GetSchema("IndexColumns", restrictions); - Assert.AreEqual(2, dt.Rows.Count); - Assert.AreEqual("test", dt.Rows[0]["TABLE_NAME"]); - Assert.AreEqual("id1", dt.Rows[0]["COLUMN_NAME"]); - Assert.AreEqual(1, dt.Rows[0]["ORDINAL_POSITION"]); - Assert.AreEqual("test", dt.Rows[1]["TABLE_NAME"]); - Assert.AreEqual("id2", dt.Rows[1]["COLUMN_NAME"]); - Assert.AreEqual(2, dt.Rows[1]["ORDINAL_POSITION"]); - - restrictions = new string[4]; - execSQL("DROP TABLE IF EXISTS test"); - execSQL("CREATE TABLE test (id int primary key, id1 int, KEY key1 (id1))"); - restrictions[2] = "test"; - restrictions[1] = database0; - restrictions[3] = "PRIMARY"; - dt = conn.GetSchema("IndexColumns", restrictions); - } - - [Test] - public void Views() - { - if (Version < new Version(5, 0)) return; - - execSQL("DROP VIEW IF EXISTS vw"); - execSQL("CREATE VIEW vw AS SELECT Now() as theTime"); - - string[] restrictions = new string[4]; - restrictions[1] = database0; - restrictions[2] = "vw"; - DataTable dt = conn.GetSchema("Views", restrictions); - Assert.IsTrue(dt.Rows.Count == 1); - Assert.AreEqual("Views", dt.TableName); - Assert.AreEqual("vw", dt.Rows[0]["TABLE_NAME"]); - } - - [Test] - public void ViewColumns() - { - if (Version < new Version(5, 0)) return; - - execSQL("DROP VIEW IF EXISTS vw"); - execSQL("CREATE VIEW vw AS SELECT Now() as theTime"); - - string[] restrictions = new string[4]; - restrictions[1] = database0; - restrictions[2] = "vw"; - DataTable dt = conn.GetSchema("ViewColumns", restrictions); - Assert.IsTrue(dt.Rows.Count == 1); - Assert.AreEqual("ViewColumns", dt.TableName); - Assert.AreEqual(database0.ToLower(), dt.Rows[0]["VIEW_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("vw", dt.Rows[0]["VIEW_NAME"]); - Assert.AreEqual("theTime", dt.Rows[0]["COLUMN_NAME"]); - } - - [Test] - public void SingleForeignKey() - { - execSQL("CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB"); - execSQL("CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), " + - "CONSTRAINT c1 FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE) ENGINE=INNODB"); - string[] restrictions = new string[4]; - restrictions[0] = null; - restrictions[1] = database0; - restrictions[2] = "child"; - DataTable dt = conn.GetSchema("Foreign Keys", restrictions); - Assert.AreEqual(1, dt.Rows.Count); - DataRow row = dt.Rows[0]; - Assert.AreEqual(database0.ToLower(), row["CONSTRAINT_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("c1", row["CONSTRAINT_NAME"]); - Assert.AreEqual(database0.ToLower(), row["TABLE_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("child", row["TABLE_NAME"]); - Assert.AreEqual(database0.ToLower(), row["REFERENCED_TABLE_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("parent", row["REFERENCED_TABLE_NAME"]); - } - - /// - /// Bug #26660 MySqlConnection.GetSchema fails with NullReferenceException for Foreign Keys - /// - [Test] - public void ForeignKeys() - { - execSQL("CREATE TABLE product (category INT NOT NULL, id INT NOT NULL, " + - "price DECIMAL, PRIMARY KEY(category, id)) ENGINE=INNODB"); - execSQL("CREATE TABLE customer (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB"); - execSQL("CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT, " + - "product_category INT NOT NULL, product_id INT NOT NULL, customer_id INT NOT NULL, " + - "PRIMARY KEY(no), INDEX (product_category, product_id), " + - "FOREIGN KEY (product_category, product_id) REFERENCES product(category, id) " + - "ON UPDATE CASCADE ON DELETE RESTRICT, INDEX (customer_id), " + - "FOREIGN KEY (customer_id) REFERENCES customer(id)) ENGINE=INNODB"); - - DataTable dt = conn.GetSchema("Foreign Keys"); - Assert.IsTrue(dt.Columns.Contains("REFERENCED_TABLE_CATALOG")); - } - - [Test] - public void MultiSingleForeignKey() - { - execSQL("CREATE TABLE product (category INT NOT NULL, id INT NOT NULL, " + - "price DECIMAL, PRIMARY KEY(category, id)) ENGINE=INNODB"); - execSQL("CREATE TABLE customer (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB"); - execSQL("CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT, " + - "product_category INT NOT NULL, product_id INT NOT NULL, customer_id INT NOT NULL, " + - "PRIMARY KEY(no), INDEX (product_category, product_id), " + - "FOREIGN KEY (product_category, product_id) REFERENCES product(category, id) " + - "ON UPDATE CASCADE ON DELETE RESTRICT, INDEX (customer_id), " + - "FOREIGN KEY (customer_id) REFERENCES customer(id)) ENGINE=INNODB"); - - string[] restrictions = new string[4]; - restrictions[0] = null; - restrictions[1] = database0; - restrictions[2] = "product_order"; - DataTable dt = conn.GetSchema("Foreign Keys", restrictions); - Assert.AreEqual(2, dt.Rows.Count); - DataRow row = dt.Rows[0]; - Assert.AreEqual(database0.ToLower(), row["CONSTRAINT_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("product_order_ibfk_1", row["CONSTRAINT_NAME"]); - Assert.AreEqual(database0.ToLower(), row["TABLE_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("product_order", row["TABLE_NAME"]); - Assert.AreEqual(database0.ToLower(), row["REFERENCED_TABLE_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("product", row["REFERENCED_TABLE_NAME"]); - - row = dt.Rows[1]; - Assert.AreEqual(database0.ToLower(), row["CONSTRAINT_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("product_order_ibfk_2", row["CONSTRAINT_NAME"]); - Assert.AreEqual(database0.ToLower(), row["TABLE_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("product_order", row["TABLE_NAME"]); - Assert.AreEqual(database0.ToLower(), row["REFERENCED_TABLE_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("customer", row["REFERENCED_TABLE_NAME"]); - } - - [Test] - public void Triggers() - { - if (Version < new Version(5, 1, 6)) return; - - execSQL("CREATE TABLE test1 (id int)"); - execSQL("CREATE TABLE test2 (count int)"); - execSQL("INSERT INTO test2 VALUES (0)"); - string sql = String.Format("CREATE TRIGGER `{0}`.trigger1 AFTER INSERT ON test1 FOR EACH ROW BEGIN " + - "UPDATE test2 SET count = count+1; END", database0); - suExecSQL(sql); - - string[] restrictions = new string[4]; - restrictions[1] = database0; - restrictions[2] = "test1"; - DataTable dt = rootConn.GetSchema("Triggers", restrictions); - Assert.IsTrue(dt.Rows.Count == 1); - Assert.AreEqual("Triggers", dt.TableName); - Assert.AreEqual("trigger1", dt.Rows[0]["TRIGGER_NAME"]); - Assert.AreEqual("INSERT", dt.Rows[0]["EVENT_MANIPULATION"]); - Assert.AreEqual("test1", dt.Rows[0]["EVENT_OBJECT_TABLE"]); - Assert.AreEqual("ROW", dt.Rows[0]["ACTION_ORIENTATION"]); - Assert.AreEqual("AFTER", dt.Rows[0]["ACTION_TIMING"]); - } - - [Test] - public void UsingQuotedRestrictions() - { - execSQL("CREATE TABLE test1 (id int)"); - - string[] restrictions = new string[4]; - restrictions[1] = database0; - restrictions[2] = "`test1`"; - DataTable dt = conn.GetSchema("Tables", restrictions); - Assert.IsTrue(dt.Rows.Count == 1); - Assert.AreEqual("Tables", dt.TableName); - Assert.AreEqual("test1", dt.Rows[0][2]); - Assert.AreEqual("`test1`", restrictions[2]); - } - - [Test] - public void ReservedWords() - { - DataTable dt = conn.GetSchema("ReservedWords"); - foreach (DataRow row in dt.Rows) - Assert.IsFalse(String.IsNullOrEmpty(row[0] as string)); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/InterfaceTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/InterfaceTests.cs deleted file mode 100644 index 7bea04f..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/InterfaceTests.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using NUnit.Framework; -using System.Data.Common; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class InterfaceTests : BaseTest - { -#if !CF - [Test] - public void ClientFactory() - { - DbProviderFactory f = new MySqlClientFactory(); - using (DbConnection c = f.CreateConnection()) - { - DbConnectionStringBuilder cb = f.CreateConnectionStringBuilder(); - cb.ConnectionString = GetConnectionString(true); - c.ConnectionString = cb.ConnectionString; - c.Open(); - - DbCommand cmd = f.CreateCommand(); - cmd.Connection = c; - cmd.CommandText = "SELECT 1"; - cmd.CommandType = CommandType.Text; - using (DbDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - } - } - } -#endif - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/LanguageTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/LanguageTests.cs deleted file mode 100644 index cc39712..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/LanguageTests.cs +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using System.Globalization; -using System.Threading; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class LanguageTests : BaseTest - { - [Test] - public void Unicode() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (u2 varchar(255) CHARACTER SET ucs2)"); - - using (MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";charset=utf8")) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES ( CONVERT('困巫忘否役' using ucs2))", c); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - string s1 = reader.GetString(0); - Assert.AreEqual("困巫忘否役", s1); - } - } - } - - /// - /// Bug #13806 Does not support Code Page 932 - /// - [Test] - public void CP932() - { - using (MySqlConnection c = new MySqlConnection(GetConnectionString(true) + ";charset=cp932")) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("SELECT '涯割晦叶角'", c); - string s = (string)cmd.ExecuteScalar(); - Assert.AreEqual("涯割晦叶角", s); - } - } - - [Test] - public void UTF8() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (id int, name VARCHAR(200) CHAR SET utf8)"); - - using (MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";charset=utf8")) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, 'ЁЄЉҖҚ')", c); //russian - cmd.ExecuteNonQuery(); - - cmd.CommandText = "INSERT INTO Test VALUES(2, '兣冘凥凷冋')"; // simplified Chinese - cmd.ExecuteNonQuery(); - - cmd.CommandText = "INSERT INTO Test VALUES(3, '困巫忘否役')"; // traditional Chinese - cmd.ExecuteNonQuery(); - - cmd.CommandText = "INSERT INTO Test VALUES(4, '涯割晦叶角')"; // Japanese - cmd.ExecuteNonQuery(); - - cmd.CommandText = "INSERT INTO Test VALUES(5, 'ברחפע')"; // Hebrew - cmd.ExecuteNonQuery(); - - cmd.CommandText = "INSERT INTO Test VALUES(6, 'ψόβΩΞ')"; // Greek - cmd.ExecuteNonQuery(); - - cmd.CommandText = "INSERT INTO Test VALUES(7, 'þðüçöÝÞÐÜÇÖ')"; // Turkish - cmd.ExecuteNonQuery(); - - cmd.CommandText = "INSERT INTO Test VALUES(8, 'ฅๆษ')"; // Thai - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual("ЁЄЉҖҚ", reader.GetString(1)); - reader.Read(); - Assert.AreEqual("兣冘凥凷冋", reader.GetString(1)); - reader.Read(); - Assert.AreEqual("困巫忘否役", reader.GetString(1)); - reader.Read(); - Assert.AreEqual("涯割晦叶角", reader.GetString(1)); - reader.Read(); - Assert.AreEqual("ברחפע", reader.GetString(1)); - reader.Read(); - Assert.AreEqual("ψόβΩΞ", reader.GetString(1)); - reader.Read(); - Assert.AreEqual("þðüçöÝÞÐÜÇÖ", reader.GetString(1)); - reader.Read(); - Assert.AreEqual("ฅๆษ", reader.GetString(1)); - } - } - } - - [Test] - public void UTF8PreparedAndUsingParameters() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (name VARCHAR(200) CHAR SET utf8)"); - - using (MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";charset=utf8")) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(?val)", c); - cmd.Parameters.Add("?val", MySqlDbType.VarChar); - cmd.Prepare(); - - cmd.Parameters[0].Value = "ЁЄЉҖҚ"; // Russian - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = "兣冘凥凷冋"; // simplified Chinese - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = "困巫忘否役"; // traditional Chinese - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = "涯割晦叶角"; // Japanese - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = "ברחפע"; // Hebrew - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = "ψόβΩΞ"; // Greek - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = "þðüçöÝÞÐÜÇÖ"; // Turkish - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = "ฅๆษ"; // Thai - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual("ЁЄЉҖҚ", reader.GetString(0)); - reader.Read(); - Assert.AreEqual("兣冘凥凷冋", reader.GetString(0)); - reader.Read(); - Assert.AreEqual("困巫忘否役", reader.GetString(0)); - reader.Read(); - Assert.AreEqual("涯割晦叶角", reader.GetString(0)); - reader.Read(); - Assert.AreEqual("ברחפע", reader.GetString(0)); - reader.Read(); - Assert.AreEqual("ψόβΩΞ", reader.GetString(0)); - reader.Read(); - Assert.AreEqual("þðüçöÝÞÐÜÇÖ", reader.GetString(0)); - reader.Read(); - Assert.AreEqual("ฅๆษ", reader.GetString(0)); - } - } - } - - [Test] - public void Chinese() - { - if (Version < new Version(4, 1)) return; - - using (MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";charset=utf8")) - { - c.Open(); - - execSQL("CREATE TABLE Test (id int, name VARCHAR(200) CHAR SET big5, name2 VARCHAR(200) CHAR SET gb2312)"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, '困巫忘否役', '涝搞谷侪魍' )", c); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual("困巫忘否役", reader.GetString(1)); - Assert.AreEqual("涝搞谷侪魍", reader.GetString(2)); - } - } - } - - [Test] - public void Turkish() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (id int, name VARCHAR(200) CHAR SET latin5 )"); - - using (MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";charset=utf8")) - { - c.Open(); - - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, 'ĞËÇÄŞ')", c); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual("ĞËÇÄŞ", reader.GetString(1)); - } - } - } - - [Test] - public void Russian() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (id int, name VARCHAR(200) CHAR SET cp1251)"); - - using (MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";charset=utf8")) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1, 'щьеи')", c); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual("щьеи", reader.GetString(1)); - } - } - } - - [Test] - public void VariousCollations() - { - if (Version < new Version(4, 1)) return; - - createTable(@"CREATE TABLE `test_tbl`(`test` VARCHAR(255) NOT NULL) - CHARACTER SET utf8 COLLATE utf8_swedish_ci", "MYISAM"); - execSQL("INSERT INTO test_tbl VALUES ('myval')"); - MySqlCommand cmd = new MySqlCommand("SELECT test FROM test_tbl", conn); - cmd.ExecuteScalar(); - } - - /// - /// Bug #25651 SELECT does not work properly when WHERE contains UTF-8 characters - /// - [Test] - public void UTF8Parameters() - { - execSQL("CREATE TABLE test (id int(11) NOT NULL, " + - "value varchar(100) NOT NULL, PRIMARY KEY (id)) " + - "ENGINE=MyISAM DEFAULT CHARSET=utf8"); - - string conString = GetConnectionString(true) + ";charset=utf8"; - using (MySqlConnection con = new MySqlConnection(conString)) - { - con.Open(); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (1, 'šđč枊ĐČĆŽ')", con); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT id FROM test WHERE value = ?parameter"; - cmd.Parameters.Add("?parameter", MySqlDbType.VarString); - cmd.Parameters[0].Value = "šđč枊ĐČĆŽ"; - object o = cmd.ExecuteScalar(); - Assert.AreEqual(1, o); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Logging.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Logging.cs deleted file mode 100644 index b85bfc9..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Logging.cs +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) 2009-2010 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Diagnostics; -using NUnit.Framework; -using System.Text; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class LoggingTests : BaseTest - { - public LoggingTests() - { - csAdditions = ";logging=true;"; - } - - public override void Setup() - { - base.Setup(); - createTable("CREATE TABLE Test (id int, name VARCHAR(200))", "INNODB"); - } - - [Test] - public void SimpleLogging() - { - execSQL("INSERT INTO Test VALUES (1, 'Test1')"); - execSQL("INSERT INTO Test VALUES (2, 'Test2')"); - execSQL("INSERT INTO Test VALUES (3, 'Test3')"); - execSQL("INSERT INTO Test VALUES (4, 'Test4')"); - - MySqlTrace.Listeners.Clear(); - MySqlTrace.Switch.Level = SourceLevels.All; - GenericListener listener = new GenericListener(); - MySqlTrace.Listeners.Add(listener); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - } - Assert.AreEqual(4, listener.Strings.Count); - Assert.IsTrue(listener.Strings[0].Contains("Query Opened: SELECT * FROM Test")); - Assert.IsTrue(listener.Strings[1].Contains("Resultset Opened: field(s) = 2, affected rows = -1, inserted id = -1")); - Assert.IsTrue(listener.Strings[2].Contains("Resultset Closed. Total rows=4, skipped rows=4, size (bytes)=32")); - Assert.IsTrue(listener.Strings[3].Contains("Query Closed")); - } - - [Test] - public void Warnings() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test(id INT, name VARCHAR(5))"); - - MySqlTrace.Listeners.Clear(); - MySqlTrace.Switch.Level = SourceLevels.All; - GenericListener listener = new GenericListener(); - MySqlTrace.Listeners.Add(listener); - - MySqlCommand cmd = new MySqlCommand("INSERT IGNORE INTO Test VALUES (1, 'abcdef')", conn); - cmd.ExecuteNonQuery(); - - Assert.AreEqual(9, listener.Strings.Count); - Assert.IsTrue(listener.Strings[0].Contains("Query Opened: INSERT IGNORE INTO Test VALUES (1, 'abcdef')")); - Assert.IsTrue(listener.Strings[1].Contains("Resultset Opened: field(s) = 0, affected rows = 1, inserted id = 0")); - Assert.IsTrue(listener.Strings[2].Contains("Resultset Closed. Total rows=0, skipped rows=0, size (bytes)=0")); - Assert.IsTrue(listener.Strings[3].Contains("Query Opened: SHOW WARNINGS")); - Assert.IsTrue(listener.Strings[4].Contains("Resultset Opened: field(s) = 3, affected rows = -1, inserted id = -1")); - Assert.IsTrue(listener.Strings[5].Contains("Resultset Closed. Total rows=1, skipped rows=0, size (bytes)=55")); - Assert.IsTrue(listener.Strings[6].Contains("Query Closed")); - Assert.IsTrue(listener.Strings[7].Contains("MySql Warning: Level=Warning, Code=1265, Message=Data truncated for column 'name' at row 1")); - Assert.IsTrue(listener.Strings[8].Contains("Query Closed")); - } - - [Test] - public void ProviderNormalizingQuery() - { - MySqlTrace.Listeners.Clear(); - MySqlTrace.Switch.Level = SourceLevels.All; - GenericListener listener = new GenericListener(); - MySqlTrace.Listeners.Add(listener); - - StringBuilder sql = new StringBuilder("SELECT '"); - for (int i=0; i < 400; i++) - sql.Append("a"); - sql.Append("'"); - MySqlCommand cmd = new MySqlCommand(sql.ToString(), conn); - cmd.ExecuteNonQuery(); - - Assert.AreEqual(5, listener.Strings.Count); - Assert.IsTrue(listener.Strings[1].EndsWith("SELECT ?")); - } - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ParameterTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ParameterTests.cs deleted file mode 100644 index 6dd0283..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ParameterTests.cs +++ /dev/null @@ -1,545 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using NUnit.Framework; -using System.Diagnostics; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for ConnectionTests. - /// - [TestFixture] - public class ParameterTests : BaseTest - { - [SetUp] - public override void Setup() - { - base.Setup(); - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(100), dt DATETIME, tm TIME, ts TIMESTAMP, PRIMARY KEY(id))"); - } - - [Test] - public void TestQuoting() - { - MySqlCommand cmd = new MySqlCommand("", conn); - cmd.CommandText = "INSERT INTO Test VALUES (?id, ?name, NULL,NULL,NULL)"; - cmd.Parameters.Add( new MySqlParameter("?id", 1)); - cmd.Parameters.Add( new MySqlParameter("?name", "my ' value")); - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = 2; - cmd.Parameters[1].Value = @"my "" value"; - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = 3; - cmd.Parameters[1].Value = @"my ` value"; - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = 4; - cmd.Parameters[1].Value = @"my value"; - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = 5; - cmd.Parameters[1].Value = @"my \ value"; - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - MySqlDataReader reader = null; - try - { - reader = cmd.ExecuteReader(); - reader.Read(); - Assert.AreEqual( "my ' value", reader.GetString(1)); - reader.Read(); - Assert.AreEqual( @"my "" value", reader.GetString(1)); - reader.Read(); - Assert.AreEqual( "my ` value", reader.GetString(1)); - reader.Read(); - Assert.AreEqual( "my value", reader.GetString(1)); - reader.Read(); - Assert.AreEqual( @"my \ value", reader.GetString(1)); - } - catch (Exception ex) - { - Assert.Fail( ex.Message ); - } - finally - { - if (reader != null) reader.Close(); - } - } - - [Test] - public void TestDateTimeParameter() - { - MySqlCommand cmd = new MySqlCommand("", conn); - - TimeSpan time = new TimeSpan(0, 1, 2, 3); - DateTime dt = new DateTime( 2003, 11, 11, 1, 2, 3 ); - cmd.CommandText = "INSERT INTO Test VALUES (1, 'test', ?dt, ?time, NULL)"; - cmd.Parameters.Add( new MySqlParameter("?time", time)); - cmd.Parameters.Add( new MySqlParameter("?dt", dt)); - int cnt = cmd.ExecuteNonQuery(); - Assert.AreEqual( 1, cnt, "Insert count" ); - - cmd = new MySqlCommand("SELECT tm, dt, ts FROM Test WHERE id=1", conn); - MySqlDataReader reader = cmd.ExecuteReader(); - reader.Read(); - TimeSpan time2 = (TimeSpan)reader.GetValue(0); - Assert.AreEqual( time, time2 ); - - DateTime dt2 = reader.GetDateTime(1); - Assert.AreEqual( dt, dt2 ); - - DateTime ts2 = reader.GetDateTime(2); - reader.Close(); - - // now check the timestamp column. We won't check the minute or second for obvious reasons - DateTime now = DateTime.Now; - Assert.AreEqual( now.Year, ts2.Year ); - Assert.AreEqual( now.Month, ts2.Month ); - Assert.AreEqual( now.Day, ts2.Day ); - Assert.AreEqual( now.Hour, ts2.Hour ); - - // now we'll set some nulls and see how they are handled - cmd = new MySqlCommand("UPDATE Test SET tm=?ts, dt=?dt WHERE id=1", conn); - cmd.Parameters.Add( new MySqlParameter("?ts", DBNull.Value )); - cmd.Parameters.Add( new MySqlParameter("?dt", DBNull.Value)); - cnt = cmd.ExecuteNonQuery(); - Assert.AreEqual( 1, cnt, "Update null count" ); - - cmd = new MySqlCommand("SELECT tm, dt FROM Test WHERE id=1", conn); - reader = cmd.ExecuteReader(); - reader.Read(); - object tso = reader.GetValue(0); - object dto = reader.GetValue(1); - Assert.AreEqual( DBNull.Value, tso, "Time column" ); - Assert.AreEqual( DBNull.Value, dto, "DateTime column" ); - - reader.Close(); - - cmd.CommandText = "DELETE FROM Test WHERE id=1"; - cmd.ExecuteNonQuery(); - } - - [Test] - public void NestedQuoting() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name) " + - "VALUES(1, 'this is ?\"my value\"')", conn); - int count = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, count); - } - - [Test] - public void SetDbType() - { - IDbCommand cmd = conn.CreateCommand(); - IDbDataParameter prm = cmd.CreateParameter(); - prm.DbType = DbType.Int64; - Assert.AreEqual(DbType.Int64, prm.DbType); - prm.Value = 3; - Assert.AreEqual(DbType.Int64, prm.DbType); - - MySqlParameter p = new MySqlParameter("name", MySqlDbType.Int64); - Assert.AreEqual(DbType.Int64, p.DbType); - Assert.AreEqual(MySqlDbType.Int64, p.MySqlDbType); - p.Value = 3; - Assert.AreEqual(DbType.Int64, p.DbType); - Assert.AreEqual(MySqlDbType.Int64, p.MySqlDbType); - } - -#if !CF - [Test] - public void UseOldSyntaxGivesWarning() - { - Trace.Listeners.Clear(); - GenericListener listener = new GenericListener(); - Trace.Listeners.Add(listener); - - string connStr = conn.ConnectionString + ";old syntax=yes;pooling=false"; - MySqlConnection conn2 = new MySqlConnection(connStr); - conn2.Open(); - - Assert.IsTrue(listener.Find("Use Old Syntax is now obsolete") != 0); - conn2.Close(); - Trace.Listeners.Clear(); - } -#endif - - [Test] - public void NullParameterObject() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name) VALUES (1, ?name)", conn); - try - { - cmd.Parameters.Add(null); - } - catch (ArgumentException) - { - } - } - - /// - /// Bug #7398 MySqlParameterCollection doesn't allow parameters without filled in names - /// - [Test] - public void AllowUnnamedParameters() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id,name) VALUES (?id, ?name)", conn); - - MySqlParameter p = new MySqlParameter(); - p.ParameterName = "?id"; - p.Value = 1; - cmd.Parameters.Add(p); - - p = new MySqlParameter(); - p.ParameterName = "?name"; - p.Value = "test"; - cmd.Parameters.Add(p); - - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT id FROM Test"; - Assert.AreEqual(1, cmd.ExecuteScalar()); - - cmd.CommandText = "SELECT name FROM Test"; - Assert.AreEqual( "test", cmd.ExecuteScalar()); - } - - [Test] - public void NullParameterValue() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name) VALUES (1, ?name)", conn); - cmd.Parameters.Add( new MySqlParameter("?name", null)); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT name FROM Test WHERE id=1"; - object name = cmd.ExecuteScalar(); - Assert.AreEqual( DBNull.Value, name ); - } - - /// - /// Bug #12646 Parameters are defaulted to Decimal - /// - [Test] - public void DefaultType() - { - IDbCommand cmd = conn.CreateCommand(); - IDbDataParameter p = cmd.CreateParameter(); - p.ParameterName = "?boo"; - p.Value = "test"; - MySqlParameter mp = (MySqlParameter)p; - Assert.AreEqual(MySqlDbType.VarChar, mp.MySqlDbType); - } - - [Test] - public void OddCharsInParameterNames() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name) VALUES (1, ?nam$es)", conn); - cmd.Parameters.Add( new MySqlParameter("?nam$es", "Test")); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "INSERT INTO Test (id, name) VALUES (2, ?nam_es)"; - cmd.Parameters.Clear(); - cmd.Parameters.Add( new MySqlParameter("?nam_es", "Test2")); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "INSERT INTO Test (id, name) VALUES (3, ?nam.es)"; - cmd.Parameters.Clear(); - cmd.Parameters.Add( new MySqlParameter("?nam.es", "Test3")); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT name FROM Test WHERE id=1"; - object name = cmd.ExecuteScalar(); - Assert.AreEqual( "Test", name ); - - cmd.CommandText = "SELECT name FROM Test WHERE id=2"; - name = cmd.ExecuteScalar(); - Assert.AreEqual( "Test2", name ); - - cmd.CommandText = "SELECT name FROM Test WHERE id=3"; - name = cmd.ExecuteScalar(); - Assert.AreEqual( "Test3", name ); - } - - /// - /// Bug #13276 Exception on serialize after inserting null value - /// - [Test] - public void InsertValueAfterNull() - { - execSQL("DROP TABLE Test"); - execSQL("CREATE TABLE Test (id int auto_increment primary key, foo int)"); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - MySqlCommand c = new MySqlCommand("INSERT INTO Test (foo) values (?foo)", conn); - c.Parameters.Add("?foo", MySqlDbType.Int32, 0, "foo"); - - da.InsertCommand = c; - DataTable dt = new DataTable(); - da.Fill(dt); - DataRow row = dt.NewRow(); - dt.Rows.Add(row); - row = dt.NewRow(); - row["foo"] = 2; - dt.Rows.Add(row); - da.Update(dt); - - dt.Clear(); - da.Fill(dt); - Assert.AreEqual(2, dt.Rows.Count); - Assert.AreEqual(2, dt.Rows[1]["foo"]); - } - - /// - /// Bug #24565 Inferring DbType fails when reusing commands and the first time the value is nul - /// - [Test] - public void UnTypedParameterBeingReused() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, dt) VALUES (?id, ?dt)", conn); - cmd.Parameters.AddWithValue("?id", 1); - MySqlParameter p = cmd.CreateParameter(); - p.ParameterName = "?dt"; - p.Value = DBNull.Value; - cmd.Parameters.Add(p); - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = 2; - p.Value = DateTime.Now; - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - cmd.Parameters.Clear(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.IsTrue(reader.IsDBNull(2)); - reader.Read(); - Assert.IsFalse(reader.IsDBNull(2)); - Assert.IsFalse(reader.Read()); - } - } - - [Test] - public void ParameterCacheNotClearing() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name) VALUES (?id, ?name)", conn); - cmd.Parameters.AddWithValue("?id", 1); - cmd.Parameters.AddWithValue("?name", "test"); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "INSERT INTO Test (id, name, dt) VALUES (?id1, ?name1, ?id)"; - cmd.Parameters[0].ParameterName = "?id1"; - cmd.Parameters[0].Value = 2; - cmd.Parameters[1].ParameterName = "?name1"; - cmd.Parameters.AddWithValue("?id", DateTime.Now); - cmd.ExecuteNonQuery(); - } - - [Test] - public void WithAndWithoutMarker() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name) VALUES (?id, ?name)", conn); - cmd.Parameters.AddWithValue("id", 1); - Assert.AreEqual(-1, cmd.Parameters.IndexOf("?id")); - cmd.Parameters.AddWithValue("name", "test"); - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); - cmd.Parameters.AddWithValue("?id", 2); - Assert.AreEqual(-1, cmd.Parameters.IndexOf("id")); - cmd.Parameters.AddWithValue("?name", "test2"); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT COUNT(*) FROM Test"; - object count = cmd.ExecuteScalar(); - Assert.AreEqual(2, count); - } - - [Test] - public void DoubleAddingParameters() - { - try - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name) VALUES (?id, ?name)", conn); - cmd.Parameters.AddWithValue("id", 1); - Assert.AreEqual(-1, cmd.Parameters.IndexOf("?id")); - Assert.AreEqual(-1, cmd.Parameters.IndexOf("@id")); - cmd.Parameters.AddWithValue("name", "test"); - cmd.Parameters.AddWithValue("?id", 2); - Assert.Fail("Should not get here"); - } - catch (Exception) - { - } - } - - /// - /// Bug #26904 MySqlParameterCollection fails to add MySqlParameter that previously removed - /// - [Test] - public void AddingParameterPreviouslyRemoved() - { - MySqlCommand cmd = new - MySqlCommand("Insert into sometable(s1, s2) values(?p1, ?p2)"); - - MySqlParameter param1 = cmd.CreateParameter(); - param1.ParameterName = "?p1"; - param1.DbType = DbType.String; - param1.Value = "Ali Gel"; - - cmd.Parameters.Add(param1); - cmd.Parameters.RemoveAt(0); - cmd.Parameters.Add(param1); - } - - /// - /// Bug #27135 MySqlParameterCollection and parameters added with Insert Method - /// - [Test] - public void AddingParametersUsingInsert() - { - MySqlCommand cmd = new MySqlCommand(); - cmd.Parameters.Insert(0, new MySqlParameter("?id", MySqlDbType.Int32)); - MySqlParameter p = cmd.Parameters["?id"]; - Assert.AreEqual("?id", p.ParameterName); - } - - /// - /// Bug #27187 cmd.Parameters.RemoveAt("Id") will cause an error if the last item is requested - /// - [Test] - public void FindParameterAfterRemoval() - { - MySqlCommand cmd = new MySqlCommand(); - - cmd.Parameters.Add("?id1", MySqlDbType.Int32); - cmd.Parameters.Add("?id2", MySqlDbType.Int32); - cmd.Parameters.Add("?id3", MySqlDbType.Int32); - cmd.Parameters.Add("?id4", MySqlDbType.Int32); - cmd.Parameters.Add("?id5", MySqlDbType.Int32); - cmd.Parameters.Add("?id6", MySqlDbType.Int32); - cmd.Parameters.RemoveAt("?id1"); - MySqlParameter p = cmd.Parameters["?id6"]; - Assert.AreEqual("?id6", p.ParameterName); - } - - /// - /// Bug #29312 System.FormatException if parameter not found - /// - [Test] - public void MissingParameter() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test(id) VALUES (?id)", conn); - try - { - cmd.ExecuteNonQuery(); - } - catch (MySqlException) - { - } - } - - /// - /// Bug #32094 Size property on string parameter throws an exception - /// - [Test] - public void StringParameterSizeSetAfterValue() - { - execSQL("DROP TABLE Test"); - execSQL("CREATE TABLE Test (v VARCHAR(10))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?p1)", conn); - cmd.Parameters.Add("?p1", MySqlDbType.VarChar); - cmd.Parameters[0].Value = "123"; - cmd.Parameters[0].Size = 10; - cmd.ExecuteNonQuery(); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual("123", dt.Rows[0][0]); - - cmd.Parameters.Clear(); - cmd.Parameters.Add("?p1", MySqlDbType.VarChar); - cmd.Parameters[0].Value = "123456789012345"; - cmd.Parameters[0].Size = 10; - cmd.ExecuteNonQuery(); - - dt.Clear(); - da.Fill(dt); - Assert.AreEqual("1234567890", dt.Rows[1][0]); - } - - /// - /// Bug #32093 MySqlParameter Constructor does not allow Direction of anything other than Input - /// - [Test] - public void NonInputParametersToCtor() - { - MySqlParameter p = new MySqlParameter("?p1", MySqlDbType.VarChar, 20, - ParameterDirection.InputOutput, true, 0, 0, "id", DataRowVersion.Current, 0); - Assert.AreEqual(ParameterDirection.InputOutput, p.Direction); - - MySqlParameter p1 = new MySqlParameter("?p1", MySqlDbType.VarChar, 20, - ParameterDirection.Output, true, 0, 0, "id", DataRowVersion.Current, 0); - Assert.AreEqual(ParameterDirection.Output, p1.Direction); - } - - /// - /// Bug #13991 oldsyntax configuration and ParameterMarker value bug - /// - [Test] - public void SetOldSyntaxAfterCommandCreation() - { - string connStr = this.GetConnectionString(true); - MySqlConnection c = new MySqlConnection(connStr); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id) VALUES (@id)", c); - c.ConnectionString = connStr += ";old syntax=yes"; - cmd.Parameters.AddWithValue("@id", 2); - c.Open(); - cmd.ExecuteNonQuery(); - c.Close(); - } - - [Test] - public void UseAtSignForParameters() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, name) VALUES (@id, @name)", conn); - cmd.Parameters.AddWithValue("@id", 33); - cmd.Parameters.AddWithValue("@name", "Test"); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual(33, reader.GetInt32(0)); - Assert.AreEqual("Test", reader.GetString(1)); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PerfMonTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PerfMonTests.cs deleted file mode 100644 index 24c2904..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PerfMonTests.cs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -#if !MONO - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using NUnit.Framework; -using System.Diagnostics; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for StoredProcedure. - /// - [TestFixture] - public class PerfMonTests : BaseTest - { - public PerfMonTests() - { - csAdditions = ";use performance monitor=true;"; - } - - public override void Setup() - { - base.Setup(); - execSQL("CREATE TABLE Test (id INT, name VARCHAR(100))"); - } - - /// - /// This test doesn't work from the CI setup currently - /// - [Test] - public void ProcedureFromCache() - { - return; - if (Version < new Version(5, 0)) return; - - execSQL("DROP PROCEDURE IF EXISTS spTest"); - execSQL("CREATE PROCEDURE spTest(id int) BEGIN END"); - - PerformanceCounter hardQuery = new PerformanceCounter( - ".NET Data Provider for MySQL", "HardProcedureQueries", true); - PerformanceCounter softQuery = new PerformanceCounter( - ".NET Data Provider for MySQL", "SoftProcedureQueries", true); - long hardCount = hardQuery.RawValue; - long softCount = softQuery.RawValue; - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?id", 1); - cmd.ExecuteScalar(); - - Assert.AreEqual(hardCount + 1, hardQuery.RawValue); - Assert.AreEqual(softCount, softQuery.RawValue); - hardCount = hardQuery.RawValue; - - MySqlCommand cmd2 = new MySqlCommand("spTest", conn); - cmd2.CommandType = CommandType.StoredProcedure; - cmd2.Parameters.AddWithValue("?id", 1); - cmd2.ExecuteScalar(); - - Assert.AreEqual(hardCount, hardQuery.RawValue); - Assert.AreEqual(softCount + 1, softQuery.RawValue); - } - - } -} - -#endif diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PoolingTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PoolingTests.cs deleted file mode 100644 index eaa3097..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PoolingTests.cs +++ /dev/null @@ -1,468 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using System.Data; -using System.Threading; -using MySql.Data.MySqlClient; -using NUnit.Framework; -using System.Reflection; -using System.Collections; -using System.Collections.Generic; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for PoolingTests. - /// - [TestFixture] - public class PoolingTests : BaseTest - { - [Test] - public void Connection() - { - string connStr = GetPoolingConnectionString(); - - MySqlConnection c = new MySqlConnection(connStr); - c.Open(); - int serverThread = c.ServerThread; - c.Close(); - - // first test that only a single connection get's used - for (int i = 0; i < 10; i++) - { - c = new MySqlConnection(connStr); - c.Open(); - Assert.AreEqual(serverThread, c.ServerThread); - c.Close(); - } - - c.Open(); - KillConnection(c); - c.Close(); - - connStr += ";Min Pool Size=10"; - MySqlConnection[] connArray = new MySqlConnection[10]; - for (int i = 0; i < connArray.Length; i++) - { - connArray[i] = new MySqlConnection(connStr); - connArray[i].Open(); - } - - // now make sure all the server ids are different - for (int i = 0; i < connArray.Length; i++) - { - for (int j = 0; j < connArray.Length; j++) - { - if (i != j) - Assert.IsTrue(connArray[i].ServerThread != connArray[j].ServerThread); - } - } - - for (int i = 0; i < connArray.Length; i++) - { - KillConnection(connArray[i]); - connArray[i].Close(); - } - } - - [Test] - public void OpenKilled() - { - string connStr = GetPoolingConnectionString() + ";min pool size=1; max pool size=1"; - MySqlConnection c = new MySqlConnection(connStr); - c.Open(); - int threadId = c.ServerThread; - // thread gets killed right here - KillConnection(c); - c.Close(); - - c.Dispose(); - - c = new MySqlConnection(connStr); - c.Open(); - int secondThreadId = c.ServerThread; - KillConnection(c); - c.Close(); - Assert.IsFalse(threadId == secondThreadId); - } - - [Test] - public void ReclaimBrokenConnection() - { - // now create a new connection string only allowing 1 connection in the pool - string connStr = GetPoolingConnectionString() + ";connect timeout=2;max pool size=1"; - - // now use up that connection - MySqlConnection c = new MySqlConnection(connStr); - c.Open(); - - // now attempting to open a connection should fail - try - { - MySqlConnection c2 = new MySqlConnection(connStr); - c2.Open(); - Assert.Fail("Open after using up pool should fail"); - } - catch (Exception) { } - - // we now kill the first connection to simulate a server stoppage - base.KillConnection(c); - - // now we do something on the first connection - try - { - c.ChangeDatabase("mysql"); - Assert.Fail("This change database should not work"); - } - catch (Exception) { } - - // Opening a connection now should work - MySqlConnection connection = new MySqlConnection(connStr); - connection.Open(); - KillConnection(connection); - connection.Close(); - } - - [Test] - public void TestUserReset() - { - string connStr = GetPoolingConnectionString(); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - MySqlCommand cmd = new MySqlCommand("SET @testvar='5'", c); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT @testvar"; - object var = cmd.ExecuteScalar(); - Assert.AreEqual("5", var); - c.Close(); - - c.Open(); - object var2 = cmd.ExecuteScalar(); - Assert.AreEqual(DBNull.Value, var2); - KillConnection(c); - } - } - - /// - /// Bug #25614 After connection is closed, and opened again UTF-8 characters are not read well - /// - [Test] - public void UTF8AfterClosing() - { - string originalValue = "??????????"; - - execSQL("CREATE TABLE test (id int(11) NOT NULL, " + - "value varchar(100) NOT NULL, PRIMARY KEY (`id`) " + - ") ENGINE=MyISAM DEFAULT CHARSET=utf8"); - - string connStr = GetPoolingConnectionString() + ";charset=utf8"; - using (MySqlConnection con = new MySqlConnection(connStr)) - { - con.Open(); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO test VALUES (1, '??????????')", con); - cmd.ExecuteNonQuery(); - - cmd = new MySqlCommand("SELECT value FROM test WHERE id = 1", con); - string firstS = cmd.ExecuteScalar().ToString(); - Assert.AreEqual(originalValue, firstS); - - con.Close(); - con.Open(); - - //Does not work: - cmd = new MySqlCommand("SELECT value FROM test WHERE id = 1", con); - string secondS = cmd.ExecuteScalar().ToString(); - - KillConnection(con); - con.Close(); - Assert.AreEqual(firstS, secondS); - } - } - -#if !CF - - private void PoolingWorker(object cn) - { - MySqlConnection conn = (cn as MySqlConnection); - - Thread.Sleep(5000); - conn.Close(); - } - - /// - /// Bug #24373 High CPU utilization when no idle connection - /// - [Test] - public void MultipleThreads() - { - string connStr = GetPoolingConnectionString() + ";max pool size=1"; - MySqlConnection c = new MySqlConnection(connStr); - c.Open(); - - ParameterizedThreadStart ts = new ParameterizedThreadStart(PoolingWorker); - Thread t = new Thread(ts); - t.Start(c); - - using (MySqlConnection c2 = new MySqlConnection(connStr)) - { - c2.Open(); - KillConnection(c2); - } - c.Close(); - } - -#endif - - - [Test] - public void NewTest() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE Test (id INT, name VARCHAR(50))"); - execSQL("CREATE PROCEDURE spTest(theid INT) BEGIN SELECT * FROM test WHERE id=theid; END"); - execSQL("INSERT INTO test VALUES (1, 'First')"); - execSQL("INSERT INTO test VALUES (2, 'Second')"); - execSQL("INSERT INTO test VALUES (3, 'Third')"); - execSQL("INSERT INTO test VALUES (4, 'Fourth')"); - - string connStr = GetPoolingConnectionString(); - - for (int i = 1; i < 5; i++) - { - using (MySqlConnection con = new MySqlConnection(connStr)) - { - con.Open(); - MySqlCommand reccmd = new MySqlCommand("spTest", con); - reccmd.CommandTimeout = 0; - reccmd.CommandType = CommandType.StoredProcedure; - MySqlParameter par = new MySqlParameter("@theid", MySqlDbType.String); - par.Value = i; - reccmd.Parameters.Add(par); - using (MySqlDataReader recdr = reccmd.ExecuteReader()) - { - if (recdr.Read()) - { - int x = recdr.GetOrdinal("name"); - Assert.AreEqual(1, x); - } - } - } - } - MySqlConnection c = new MySqlConnection(connStr); - c.Open(); - KillConnection(c); - } - - /// - /// Bug #29409 Bug on Open Connection with pooling=true to a MYSQL Server that is shutdown - /// - [Test] - public void ConnectAfterMaxPoolSizeTimeouts() - { - //TODO: refactor test suite to support starting/stopping services - /* string connStr = "server=localhost;uid=root;database=test;pooling=true;connect timeout=6; max pool size = 6"; - MySqlConnection c = new MySqlConnection(connStr); - for (int i = 0; i < 6; i++) - { - try - { - c.Open(); - } - catch (Exception ex) - { - } - } - c.Open(); - c.Close();*/ - } - - bool IsConnectionAlive(int serverThread) - { - MySqlDataAdapter da = new MySqlDataAdapter("SHOW PROCESSLIST", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - foreach (DataRow row in dt.Rows) - if ((long)row["Id"] == serverThread) - return true; - return false; - } - - [Test] - public void CleanIdleConnections() - { - string assemblyName = typeof(MySqlConnection).Assembly.FullName; - string pmName = String.Format("MySql.Data.MySqlClient.MySqlPoolManager, {0}", assemblyName); - - Type poolManager = Type.GetType(pmName, false); - FieldInfo poolManagerTimerField = poolManager.GetField("timer", - BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); - FieldInfo poolManagerMaxConnectionIdleTime = - poolManager.GetField ("maxConnectionIdleTime", - BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); - - Timer poolManagerTimer = (Timer)poolManagerTimerField.GetValue(null); - int origMaxConnectionIdleTime = (int) poolManagerMaxConnectionIdleTime.GetValue(null); - - - try - { - // Normally, idle connection would expire after 3 minutes and would - // be cleaned up by timer that also runs every 3 minutes. - // Since we do not want to wait that long during a unit tests, - // we use tricks. - // - temporarily reduce max.idle time for connections down to 1 - // second - // - temporarily change cleanup timer to run each second. - int threadId = -1; - string connStr = GetPoolingConnectionString(); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - threadId = c.ServerThread; - } - - // Pooled connection should be still alive - Assert.IsTrue(IsConnectionAlive(threadId)); - - poolManagerMaxConnectionIdleTime.SetValue(null, 1); - poolManagerTimer.Change(1000, 1000); - - // Let the idle connection expire and let cleanup timer run. - Thread.Sleep(2500); - - // The connection that was pooled must be dead now - Assert.IsFalse(IsConnectionAlive(threadId)); - } - finally - { - // restore values for connection idle time and timer interval - poolManagerMaxConnectionIdleTime.SetValue(null, origMaxConnectionIdleTime); - poolManagerTimer.Change(origMaxConnectionIdleTime*1000, - origMaxConnectionIdleTime*1000); - } - } - - [Test] - public void ClearPool() - { - string connStr = GetPoolingConnectionString() + ";min pool size=10"; - MySqlConnectionStringBuilder settings = new MySqlConnectionStringBuilder(connStr); - MySqlConnection[] connections = new MySqlConnection[10]; - connections[0] = new MySqlConnection(connStr); - connections[0].Open(); - - string assemblyName = typeof(MySqlConnection).Assembly.FullName; - string pmName = String.Format("MySql.Data.MySqlClient.MySqlPoolManager, {0}", assemblyName); - - Type poolManager = Type.GetType(pmName, false); - FieldInfo poolManagerHashTable = poolManager.GetField("pools", - BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); - Hashtable poolHash = (Hashtable)poolManagerHashTable.GetValue(null); - FieldInfo clearingPoolsFI = poolManager.GetField("clearingPools", - BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); - ICollection clearingPools = (ICollection)clearingPoolsFI.GetValue(null); - - // now we need to investigate - string poolName = String.Format("MySql.Data.MySqlClient.MySqlPool, {0}", assemblyName); - Type poolType = Type.GetType(poolName, false); - - FieldInfo inUsePool = poolType.GetField("inUsePool", BindingFlags.NonPublic | BindingFlags.Instance); - ICollection inUseList = (ICollection)inUsePool.GetValue(poolHash[settings.ConnectionString]); - Assert.AreEqual(1, inUseList.Count); - - FieldInfo idlePool = poolType.GetField("idlePool", BindingFlags.NonPublic | BindingFlags.Instance); - ICollection idleList = (ICollection)idlePool.GetValue(poolHash[settings.ConnectionString]); - Assert.AreEqual(9, idleList.Count); - - // now open 4 more of these. Now we shoudl have 5 open and five - // still in the pool - for (int i = 1; i < 5; i++) - { - connections[i] = new MySqlConnection(connStr); - connections[i].Open(); - } - - Assert.AreEqual(5, inUseList.Count); - Assert.AreEqual(5, idleList.Count); - - Assert.AreEqual(0, clearingPools.Count); - // now tell this connection to clear its pool - MySqlConnection.ClearPool(connections[0]); - Assert.AreEqual(1, clearingPools.Count); - Assert.AreEqual(0, idleList.Count); - - for (int i = 0; i < 5; i++) - connections[i].Close(); - Assert.AreEqual(0, clearingPools.Count); - } - - [Test] - public void TestBadConnections() - { - MySqlConnectionStringBuilder builder = new - MySqlConnectionStringBuilder(); - - builder.Pooling = true; - builder.Server = "xxxxxxxx"; // one that definitely does not exist. - builder.UserID = "whoever"; - builder.Password = "whatever"; - - int numberOfConnections = 1; - - for (int i = 0; i < numberOfConnections; ++i) - { - using (MySqlConnection connection = new MySqlConnection(builder.ConnectionString)) - { - try - { - connection.Open(); - Assert.Fail("Connection should throw an exception."); - } - catch (Exception) - { - } - } - Thread.Sleep(50); - } - MySqlConnection.ClearAllPools(); - } - - /// - /// Bug #42801 ClearPool .Net connector : NullReferenceException - /// - [Test] - public void DoubleClearingConnectionPool() - { - MySqlConnection c1 = new MySqlConnection(GetConnectionString(true)); - MySqlConnection c2 = new MySqlConnection(GetConnectionString(true)); - c1.Open(); - c2.Open(); - c1.Close(); - c2.Close(); - MySqlConnection.ClearPool(c1); - MySqlConnection.ClearPool(c2); - } - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PreparedStatements.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PreparedStatements.cs deleted file mode 100644 index f8475ca..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/PreparedStatements.cs +++ /dev/null @@ -1,898 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class PreparedStatements : BaseTest - { - public PreparedStatements() - { - csAdditions += ";ignore prepare=false;"; - } - - [Test] - public void Simple() - { - execSQL("CREATE TABLE Test (id INT, dec1 DECIMAL(5,2), name VARCHAR(100))"); - execSQL("INSERT INTO Test VALUES (1, 345.12, 'abcd')"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(1,345.12,'abcd')", conn); - cmd.Prepare(); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - cmd.Prepare(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(1, reader.GetInt32(0)); - Assert.AreEqual(345.12, reader.GetDecimal(1)); - Assert.AreEqual("abcd", reader.GetString(2)); - } - } - - - [Test] - public void SimplePrepareBeforeParms() - { - execSQL("CREATE TABLE Test (one INTEGER, two INTEGER)"); - execSQL("INSERT INTO Test VALUES (1, 2)"); - - // create the command and prepare the statement - IDbCommand cmd = conn.CreateCommand(); - cmd.CommandText = "SELECT * FROM Test WHERE one = ?p1"; - - // create the parameter - IDbDataParameter p1 = cmd.CreateParameter(); - p1.ParameterName = "?p1"; - p1.DbType = DbType.Int32; - p1.Precision = (byte)10; - p1.Scale = (byte)0; - p1.Size = 4; - cmd.Parameters.Add(p1); - p1.Value = 1; - - cmd.Prepare(); - // Execute the reader - using (IDataReader reader = cmd.ExecuteReader()) - { - // Fetch the first record - reader.Read(); - - Assert.AreEqual(1, reader.GetInt32(0)); - Assert.AreEqual(2, reader.GetInt32(1)); - } - } - - [Test] - public void DateAndTimes() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, d DATE, dt DATETIME, tm TIME, ts TIMESTAMP, PRIMARY KEY(id))"); - - string sql = "INSERT INTO Test VALUES(?id, ?d, ?dt, ?tm, NULL)"; - MySqlCommand cmd = new MySqlCommand(sql, conn); - - DateTime dt = DateTime.Now; - dt = dt.AddMilliseconds( dt.Millisecond * -1 ); - TimeSpan ts = new TimeSpan( 8, 11, 44, 56, 501 ); - - cmd.Parameters.AddWithValue("?id", 1); - cmd.Parameters.AddWithValue("?d", dt); - cmd.Parameters.AddWithValue("?dt", dt); - cmd.Parameters.AddWithValue("?tm", ts); - cmd.Prepare(); - int count = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, count, "Records affected by insert"); - - cmd.CommandText = "SELECT * FROM Test"; - cmd.Prepare(); - - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual(1, reader.GetInt32(0), "Id column"); - Assert.AreEqual(dt.Date, reader.GetDateTime(1).Date, "Date column"); - - DateTime dt2 = reader.GetDateTime(2); - Assert.AreEqual(dt.Date, dt2.Date); - Assert.AreEqual(dt.Hour, dt2.Hour); - Assert.AreEqual(dt.Minute, dt2.Minute); - Assert.AreEqual(dt.Second, dt2.Second); - - TimeSpan ts2 = reader.GetTimeSpan(3); - Assert.AreEqual(ts.Days, ts2.Days); - Assert.AreEqual(ts.Hours, ts2.Hours); - Assert.AreEqual(ts.Minutes, ts2.Minutes); - Assert.AreEqual(ts.Seconds, ts2.Seconds); - - Assert.AreEqual(dt.Date, reader.GetDateTime(4).Date, "Timestamp column"); - } - } - - [Test] - public void ResetCommandText() - { - execSQL("CREATE TABLE Test (id int, name varchar(100))"); - execSQL("INSERT INTO Test VALUES (1, 'Test')"); - - MySqlCommand cmd = new MySqlCommand("SELECT id FROM Test", conn); - cmd.Prepare(); - object o = cmd.ExecuteScalar(); - Assert.AreEqual( 1, o ); - - cmd.CommandText = "SELECT name FROM Test"; - cmd.Prepare(); - o = cmd.ExecuteScalar(); - Assert.AreEqual( "Test", o ); - - } - - [Test] - public void DifferentParameterOrder() - { - execSQL("CREATE TABLE Test (id int NOT NULL AUTO_INCREMENT, " + - "id2 int NOT NULL, name varchar(50) DEFAULT NULL, " + - "id3 int DEFAULT NULL, PRIMARY KEY (id))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id, id2, name, id3) " + - "VALUES(?id, ?id2, ?name,?id3)", conn); - - MySqlParameter id = new MySqlParameter(); - id.ParameterName = "?id"; - id.DbType = DbType.Int32; - id.Value = DBNull.Value; - - MySqlParameter id2 = new MySqlParameter(); - id2.ParameterName = "?id2"; - id2.DbType = DbType.Int32; - id2.Value = 2; - - MySqlParameter name = new MySqlParameter(); - name.ParameterName = "?name"; - name.DbType = DbType.String; - name.Value = "Test"; - - MySqlParameter id3 = new MySqlParameter(); - id3.ParameterName = "?id3"; - id3.DbType = DbType.Int32; - id3.Value = 3; - - cmd.Parameters.Add(id); - cmd.Parameters.Add(id2); - cmd.Parameters.Add(name); - cmd.Parameters.Add(id3); - cmd.Prepare(); - Assert.AreEqual(1, cmd.ExecuteNonQuery()); - - cmd.Parameters.Clear(); - - id3.Value = DBNull.Value; - name.Value = DBNull.Value; - cmd.Parameters.Add(id); - cmd.Parameters.Add(id2); - cmd.Parameters.Add(id3); - cmd.Parameters.Add(name); - - cmd.Prepare(); - Assert.AreEqual(1, cmd.ExecuteNonQuery()); - - cmd.CommandText = "SELECT id3 FROM Test WHERE id=1"; - Assert.AreEqual(3, cmd.ExecuteScalar()); - - cmd.CommandText = "SELECT name FROM Test WHERE id=2"; - Assert.AreEqual(DBNull.Value, cmd.ExecuteScalar()); - } - - [Test] - public void Blobs() - { - execSQL("CREATE TABLE Test (id INT, blob1 LONGBLOB, text1 LONGTEXT)"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, ?blob1, ?text1)", conn); - - byte[] bytes = Utils.CreateBlob( 400000 ); - string inStr = "This is my text"; - - cmd.Parameters.AddWithValue("?id", 1); - cmd.Parameters.AddWithValue("?blob1", bytes); - cmd.Parameters.AddWithValue("?text1", inStr); - cmd.Prepare(); - int count = cmd.ExecuteNonQuery(); - Assert.AreEqual( 1, count ); - - cmd.CommandText = "SELECT * FROM Test"; - cmd.Prepare(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue( reader.Read() ); - Assert.AreEqual( 1, reader.GetInt32(0) ); - Assert.AreEqual( bytes.Length, reader.GetBytes( 1, 0, null, 0, 0 )); - byte[] outBytes = new byte[ bytes.Length ]; - reader.GetBytes( 1, 0, outBytes, 0, bytes.Length ); - for (int x=0; x < bytes.Length; x++) - Assert.AreEqual( bytes[x], outBytes[x] ); - Assert.AreEqual( inStr, reader.GetString( 2 ) ); - } - } - - [Test] - public void SimpleTest2() - { - execSQL("CREATE TABLE Test (one integer, two integer, three integer, four integer, five integer, six integer, seven integer)"); - execSQL("INSERT INTO Test VALUES (1, 2, 3, 4, 5, 6, 7)"); - - // create the command and prepare the statement - IDbCommand cmd = conn.CreateCommand(); - cmd.CommandText = "SELECT one, two, three, four, five, six, seven FROM Test"; - cmd.Prepare(); - // Execute the reader - using (IDataReader reader = cmd.ExecuteReader()) - { - // Fetch the first record - reader.Read(); - - Assert.AreEqual( 1, reader.GetInt32(0) ); - Assert.AreEqual( 2, reader.GetInt32(1) ); - Assert.AreEqual( 3, reader.GetInt32(2) ); - Assert.AreEqual( 4, reader.GetInt32(3) ); - Assert.AreEqual( 5, reader.GetInt32(4) ); - Assert.AreEqual( 6, reader.GetInt32(5) ); - Assert.AreEqual( 7, reader.GetInt32(6) ); - } - } - - [Test] - public void Bug6271() - { - if (Version < new Version(4, 1)) return; - - // Create the table again - execSQL("CREATE TABLE `Test2` (id INT unsigned NOT NULL auto_increment, " + - "`xpDOSG_Name` text,`xpDOSG_Desc` text, `Avatar` MEDIUMBLOB, `dtAdded` DATETIME, `dtTime` TIMESTAMP, " + - "PRIMARY KEY(id)) ENGINE=InnoDB DEFAULT CHARSET=latin1" ); - - string sql = "INSERT INTO `Test2` (`xpDOSG_Name`,`dtAdded`, `xpDOSG_Desc`,`Avatar`, `dtTime`) " + - "VALUES(?name, ?dt, ?desc, ?Avatar, NULL)"; - - MySqlCommand cmd = new MySqlCommand(sql, conn); - - DateTime dt = DateTime.Now; - dt = dt.AddMilliseconds(dt.Millisecond * -1); - - byte[] xpDOSG_Avatar = Utils.CreateBlob(13000); - cmd.Parameters.AddWithValue("?name", "Ceci est un nom"); - - cmd.Parameters.AddWithValue("?desc", "Ceci est une description facile plantouiller"); - cmd.Parameters.AddWithValue("?avatar",xpDOSG_Avatar); - cmd.Parameters.AddWithValue("?dt", dt); - cmd.Prepare(); - int count = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, count); - - cmd.CommandText = "SELECT * FROM Test2"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual("Ceci est un nom", reader.GetString(1)); - Assert.AreEqual(dt.ToString("G"), reader.GetDateTime(4).ToString("G")); - Assert.AreEqual("Ceci est une description facile plantouiller", reader.GetString(2)); - - long len = reader.GetBytes(3, 0, null, 0, 0); - Assert.AreEqual(xpDOSG_Avatar.Length, len); - byte[] outBytes = new byte[len]; - reader.GetBytes(3, 0, outBytes, 0, (int)len); - - for (int x=0; x < xpDOSG_Avatar.Length; x++) - Assert.AreEqual(xpDOSG_Avatar[x], outBytes[x]); - } - } - - [Test] - public void SimpleTest() - { - execSQL("CREATE TABLE Test (one integer, two integer )"); - execSQL("INSERT INTO Test VALUES( 1, 2)"); - // create the command and prepare the statement - IDbCommand cmd = conn.CreateCommand(); - cmd.CommandText = "SELECT * FROM Test where one = ?p1"; - // create the parameter - IDbDataParameter p1 = cmd.CreateParameter(); - p1.ParameterName = "?p1"; - p1.DbType = DbType.Int32; - p1.Precision = (byte)10; - p1.Scale = (byte)0; - p1.Size = 4; - cmd.Parameters.Add(p1); - // prepare the command - cmd.Prepare(); - // set the parameter value - p1.Value = 1; - // Execute the reader - IDataReader reader = null; - try - { - reader = cmd.ExecuteReader(); - // Fetch the first record - reader.Read(); - } - catch (Exception ex) - { - Assert.Fail( ex.Message ); - } - finally - { - if (reader != null) reader.Close(); - } - } - - /// - /// Bug #13662 Prepare() truncates accented character input - /// - [Test] - public void InsertAccentedCharacters() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (id INT UNSIGNED NOT NULL PRIMARY KEY " + - "AUTO_INCREMENT, input TEXT NOT NULL) CHARACTER SET UTF8"); - // COLLATE " + - //"utf8_bin"); - using (MySqlConnection conn2 = new MySqlConnection(GetConnectionString(true) + - ";charset=utf8")) - { - conn2.Open(); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test(input) " + - "VALUES (?input) ON DUPLICATE KEY UPDATE " + - "id=LAST_INSERT_ID(id)", conn2); - cmd.Parameters.Add(new MySqlParameter("?input", "")); - cmd.Prepare(); - cmd.Parameters[0].Value = "irache martnez@yahoo.es aol.com"; - cmd.ExecuteNonQuery(); - - MySqlCommand cmd2 = new MySqlCommand("SELECT input FROM Test", conn2); - Assert.AreEqual("irache martnez@yahoo.es aol.com", - cmd2.ExecuteScalar()); - } - } - - /// - /// Bug #13541 Prepare breaks if a parameter is used more than once - /// - [Test] - public void UsingParametersTwice() - { - if (Version < new Version(4, 1)) return; - - execSQL(@"CREATE TABLE IF NOT EXISTS Test (input TEXT NOT NULL, - UNIQUE (input(100)), state INT NOT NULL, score INT NOT NULL)"); - - MySqlCommand cmd = new MySqlCommand(@"Insert into Test (input, - state, score) VALUES (?input, ?st, ?sc) ON DUPLICATE KEY - UPDATE state=state|?st;", conn); - cmd.Parameters.Add (new MySqlParameter("?input", "")); - cmd.Parameters.Add (new MySqlParameter("?st", Convert.ToInt32(0))); - cmd.Parameters.Add (new MySqlParameter("?sc", Convert.ToInt32(0))); - cmd.Prepare(); - - cmd.Parameters["?input"].Value = "test"; - cmd.Parameters["?st"].Value = 1; - cmd.Parameters["?sc"].Value = 42; - int result = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, result); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual("test", dt.Rows[0]["input"]); - Assert.AreEqual(1, dt.Rows[0]["state"]); - Assert.AreEqual(42, dt.Rows[0]["score"]); - } - - /// - /// Bug #19261 Supplying Input Parameters - /// - [Test] - public void MoreParametersOutOfOrder() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE `Test` (`BlackListID` int(11) NOT NULL auto_increment, " + - "`SubscriberID` int(11) NOT NULL, `Phone` varchar(50) default NULL, " + - "`ContactID` int(11) default NULL, " + - "`AdminJunk` tinyint(1) NOT NULL default '0', " + - "PRIMARY KEY (`BlackListID`), KEY `SubscriberID` (`SubscriberID`))"); - - IDbCommand cmd = conn.CreateCommand(); - cmd.CommandText = "INSERT INTO `Test`(`SubscriberID`,`Phone`,`ContactID`, " + - "`AdminJunk`) VALUES (?SubscriberID,?Phone,?ContactID, ?AdminJunk);"; - - MySqlParameter oParameterSubscriberID = new MySqlParameter(); - oParameterSubscriberID.ParameterName = "?SubscriberID"; - oParameterSubscriberID.DbType = DbType.Int32; - oParameterSubscriberID.Value = 1; - - MySqlParameter oParameterPhone = new MySqlParameter(); - oParameterPhone.ParameterName = "?Phone"; - oParameterPhone.DbType = DbType.String; - oParameterPhone.Value = DBNull.Value; - - MySqlParameter oParameterContactID = new MySqlParameter(); - oParameterContactID.ParameterName = "?ContactID"; - oParameterContactID.DbType = DbType.Int32; - oParameterContactID.Value = DBNull.Value; - - MySqlParameter oParameterAdminJunk = new MySqlParameter(); - oParameterAdminJunk.ParameterName = "?AdminJunk"; - oParameterAdminJunk.DbType = DbType.Boolean; - oParameterAdminJunk.Value = true; - - cmd.Parameters.Add(oParameterSubscriberID); - cmd.Parameters.Add(oParameterPhone); - cmd.Parameters.Add(oParameterAdminJunk); - cmd.Parameters.Add(oParameterContactID); - - cmd.Prepare(); - int cnt = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, cnt); - } - - /// - /// Bug #16627 Index and length must refer to a location within the string." when executing c - /// - [Test] - public void ParameterLengths() - { - if (Version < new Version(4, 1)) return; - execSQL("CREATE TABLE Test (id int, name VARCHAR(255))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, ?name)", conn); - cmd.Parameters.Add("?id", MySqlDbType.Int32); - cmd.Parameters.Add("?name", MySqlDbType.VarChar); - cmd.Parameters[1].Size = 255; - cmd.Prepare(); - - cmd.Parameters[0].Value = 1; - cmd.Parameters[1].Value = "short string"; - cmd.ExecuteNonQuery(); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(1, dt.Rows[0]["id"]); - Assert.AreEqual("short string", dt.Rows[0]["name"]); - } - - /// - /// Bug #18570 Unsigned tinyint (NET byte) incorrectly determined param type from param val - /// - [Test] - public void UnsignedTinyInt() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test(ID TINYINT UNSIGNED NOT NULL, " + - "Name VARCHAR(50) NOT NULL, PRIMARY KEY (ID), UNIQUE (ID), " + - "UNIQUE (Name))"); - execSQL("INSERT INTO Test VALUES ('127', 'name1')"); - execSQL("INSERT INTO Test VALUES ('128', 'name2')"); - execSQL("INSERT INTO Test VALUES ('255', 'name3')"); - - string sql = " SELECT count(*) FROM Test WHERE ID = ?id"; - - MySqlCommand command = new MySqlCommand(); - command.CommandText = sql; - command.CommandType = CommandType.Text; - command.Connection = (MySqlConnection)conn; - - command.Parameters.AddWithValue("?id", (byte)127); - command.Prepare(); - object count = command.ExecuteScalar(); - Assert.AreEqual(1, count); - - command.Parameters.Clear(); - command.Parameters.AddWithValue("?id", (byte)128); - count = command.ExecuteScalar(); - Assert.AreEqual(1, count); - - command.Parameters.Clear(); - command.Parameters.AddWithValue("?id", (byte)255); - count = command.ExecuteScalar(); - Assert.AreEqual(1, count); - - command.Parameters.Clear(); - command.Parameters.AddWithValue("?id", "255"); - count = command.ExecuteScalar(); - Assert.AreEqual(1, count); - } - - /// - /// Bug #16934 Unsigned values > 2^63 (UInt64) cannot be used in prepared statements - /// - [Test] - public void UnsignedValues() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (ulVal BIGINT UNSIGNED, lVal INT UNSIGNED, " + - "mVal MEDIUMINT UNSIGNED, sVal SMALLINT UNSIGNED)"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?ulVal, " + - "?lVal, ?mVal, ?sVal)", conn); - cmd.Parameters.Add("?ulVal", MySqlDbType.UInt64); - cmd.Parameters.Add("?lVal", MySqlDbType.UInt32); - cmd.Parameters.Add("?mVal", MySqlDbType.UInt24); - cmd.Parameters.Add("?sVal", MySqlDbType.UInt16); - cmd.Prepare(); - cmd.Parameters[0].Value = UInt64.MaxValue; - cmd.Parameters[1].Value = UInt32.MaxValue; - cmd.Parameters[2].Value = 16777215; - cmd.Parameters[3].Value = UInt16.MaxValue; - Assert.AreEqual(1, cmd.ExecuteNonQuery()); - cmd.CommandText = "SELECT * FROM Test"; - cmd.CommandType = CommandType.Text; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual(UInt64.MaxValue, reader.GetUInt64(0)); - Assert.AreEqual(UInt32.MaxValue, reader.GetUInt32(1)); - Assert.AreEqual(16777215, reader.GetUInt32(2)); - Assert.AreEqual(UInt16.MaxValue, reader.GetUInt16(3)); - } - } - - /// - /// Bug #18391 Better error handling for the .NET class "MySqlCommand" needed. - /// - [Test] - public void PrepareEmptyString() - { - try - { - MySqlCommand cmd = new MySqlCommand("", conn); - cmd.Prepare(); - cmd.ExecuteNonQuery(); - Assert.Fail("Should not get here"); - } - catch (InvalidOperationException) - { - } - } - - /// - /// Bug #14115 Prepare() with compound statements breaks - /// - [Test] - public void CompoundStatements() - { - execSQL("CREATE TABLE IF NOT EXISTS Test ("+ - "id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT," + - "test1 INT UNSIGNED, test2 INT UNSIGNED)"); - - try - { - MySqlCommand cmd = conn.CreateCommand(); - cmd.CommandText = "INSERT INTO Test VALUES (NULL, ?t1, ?t2);" + - "SELECT last_insert_id()"; - cmd.Parameters.Add("?t1", MySqlDbType.Int32); - cmd.Parameters.Add("?t2", MySqlDbType.Int32); - cmd.Prepare(); - Assert.Fail("Should not reach here"); - } - catch (Exception) - { - } - } - - [Test] - public void SchemaOnly() - { - execSQL("CREATE TABLE Test (id INT, name VARCHAR(50))"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - cmd.Prepare(); - using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly)) - { - reader.Read(); - } - } - - private int GetPreparedStatementCount() - { - MySqlCommand cmd = new MySqlCommand("SHOW GLOBAL STATUS LIKE 'Prepared%'", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - string s = reader.GetString(1); - return Int32.Parse(s); - } - } - - [Test] - public void ClosingCommandsProperly() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE Test (id INT, name VARCHAR(50))"); - - string connStr = GetConnectionString(true) + - ";ignore prepare=false"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - int initialCount = GetPreparedStatementCount(); - - for (int i = 0; i < 10; i++) - { - using (MySqlCommand cmd = - new MySqlCommand("INSERT INTO Test VALUES (?id, ?name)", c)) - { - cmd.Parameters.Add("?id", MySqlDbType.Int32); - cmd.Parameters.Add("?name", MySqlDbType.VarChar); - cmd.Prepare(); - cmd.Parameters[0].Value = i; - cmd.Parameters[1].Value = "foobar"; - cmd.ExecuteNonQuery(); - } - } - c.Ping(); - Assert.AreEqual(initialCount, GetPreparedStatementCount()); - } - } - - /// - /// Bug #37968 Prepared statements byte/tinyint causes data corruption. - /// - [Test] - public void InsertingUnsignedTinyInt() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL(@"CREATE TABLE Test(id TINYINT UNSIGNED NOT NULL, - id2 INT UNSIGNED, id3 TINYINT UNSIGNED, id4 INT UNSIGNED NOT NULL)"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, ?id2, ?id3, ?id4)", conn); - cmd.Parameters.Add("?id", MySqlDbType.UByte); - cmd.Parameters.Add("?id2", MySqlDbType.UByte); - cmd.Parameters.Add("?id3", MySqlDbType.UByte); - cmd.Parameters.Add("?id4", MySqlDbType.UByte); - cmd.Prepare(); - - cmd.Parameters[0].Value = 127; - cmd.Parameters[1].Value = 1; - cmd.Parameters[2].Value = 2; - cmd.Parameters[3].Value = 3; - cmd.ExecuteNonQuery(); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(127, dt.Rows[0][0]); - Assert.AreEqual(1, dt.Rows[0][1]); - Assert.AreEqual(2, dt.Rows[0][2]); - Assert.AreEqual(3, dt.Rows[0][3]); - } - - /// - /// Bug #39275 Inserting negative time value through the use of MySqlParameter throws exception - /// Bug #39294 Reading negative time value greater than -01:00:00 return positive value - /// - [Test] - public void NegativeTimePrepared() - { - NegativeTime(true); - ReadNegativeTime(true); - } - - /// - /// Bug #39275 Inserting negative time value through the use of MySqlParameter throws exception - /// Bug #39294 Reading negative time value greater than -01:00:00 return positive value - /// - [Test] - public void NegativeTimeNonPrepared() - { - NegativeTime(false); - ReadNegativeTime(false); - } - - public void NegativeTime(bool prepared) - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL(@"CREATE TABLE Test(id int, t time)"); - - MySqlCommand cmd = new MySqlCommand(@"INSERT INTO Test VALUES (1, @t)", conn); - cmd.Parameters.Add("@t", MySqlDbType.Time); - - TimeSpan[] times = new TimeSpan[8] { - new TimeSpan(-10, 0, 0), new TimeSpan(2, -5, 10, 20), - new TimeSpan(20, -10, 10), new TimeSpan(0, -15, 25), - new TimeSpan(-4, -10, 20, -10), new TimeSpan(3, 17, 23, 6), - new TimeSpan(-1,-2,-3,-4), new TimeSpan(0,0,0,-15) }; - if (prepared) - cmd.Prepare(); - foreach (TimeSpan ts in times) - { - cmd.Parameters[0].Value = ts; - cmd.ExecuteNonQuery(); - } - - cmd.CommandText = "SELECT * FROM Test"; - cmd.Parameters.Clear(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - foreach (TimeSpan ts in times) - { - reader.Read(); - TimeSpan t = reader.GetTimeSpan(1); - Assert.AreEqual(ts, t); - } - } - } - - private void ReadNegativeTime(bool prepared) - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test(id int, t time)"); - execSQL("INSERT INTO Test VALUES (1, '-00:10:00')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - if (prepared) - cmd.Prepare(); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - TimeSpan ts = reader.GetTimeSpan(1); - Assert.AreEqual(0, ts.Hours); - Assert.AreEqual(-10, ts.Minutes); - Assert.AreEqual(0, ts.Seconds); - } - } - - [Test] - public void SprocOutputParams() - { - if (Version < new Version(6, 0, 8)) return; - - execSQL("CREATE PROCEDURE spTest(id INT, OUT age INT) BEGIN SET age=id; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.Parameters.Add("@id", MySqlDbType.Int32); - cmd.Parameters.Add("@age", MySqlDbType.Int32).Direction = ParameterDirection.Output; - cmd.CommandType = CommandType.StoredProcedure; - cmd.Prepare(); - - cmd.Parameters[0].Value = 20; - Assert.AreEqual(0, cmd.ExecuteNonQuery()); - Assert.AreEqual(20, cmd.Parameters[1].Value); - - execSQL("DROP PROCEDURE IF EXISTS spTest"); - execSQL("CREATE PROCEDURE spTest(id INT, OUT age INT) BEGIN SET age=age*2; END"); - - cmd.Parameters[0].Value = 1; - cmd.Parameters[1].Value = 20; - Assert.AreEqual(0, cmd.ExecuteNonQuery()); - Assert.AreEqual(20, cmd.Parameters[1].Value); - } - - [Test] - public void SprocInputOutputParams() - { - if (Version < new Version(6, 0, 8)) return; - - execSQL("CREATE PROCEDURE spTest(id INT, INOUT age INT) BEGIN SET age=age*2; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.Parameters.Add("@id", MySqlDbType.Int32); - cmd.Parameters.Add("@age", MySqlDbType.Int32).Direction = ParameterDirection.InputOutput; - cmd.CommandType = CommandType.StoredProcedure; - cmd.Prepare(); - - cmd.Parameters[0].Value = 1; - cmd.Parameters[1].Value = 20; - Assert.AreEqual(0, cmd.ExecuteNonQuery()); - Assert.AreEqual(40, cmd.Parameters[1].Value); - } - - /// - /// Bug #49794 MySqlDataReader.GetUInt64 doesn't work for large BIGINT UNSIGNED - /// - [Test] - public void BigIntUnsigned() - { - execSQL("DROP TABLE IF EXISTS test"); - execSQL(@"CREATE TABLE test(id int(10) unsigned NOT NULL, testValue bigint(20) unsigned NOT NULL, - PRIMARY KEY USING BTREE (Id)) ENGINE=InnoDB DEFAULT CHARSET=latin1"); - execSQL("INSERT INTO test(Id,TestValue) VALUES(1, 3000000000)"); - - MySqlCommand cmd = new MySqlCommand("SELECT testValue FROM test WHERE id=@Id", conn); - cmd.Parameters.Add("@id", MySqlDbType.UInt32); - cmd.Prepare(); - - cmd.Parameters["@id"].Value = 1; - using (MySqlDataReader rdr = cmd.ExecuteReader()) - { - rdr.Read(); - UInt64 v = rdr.GetUInt64(0); - Assert.AreEqual(3000000000, v); - } - } - } - - #region Configs -#if !CF - [Category("Compressed")] - public class PreparedStatementsSocketCompressed : PreparedStatements - { - protected override string GetConnectionInfo() - { - return String.Format("port={0};compress=true", port); - } - } - - [Category("Pipe")] - public class PreparedStatementsPipe : PreparedStatements - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=pipe;pipe name={0}", pipeName); - } - } - - [Category("Compressed")] - [Category("Pipe")] - public class PreparedStatementsPipeCompressed : PreparedStatements - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=pipe;pipe name={0};compress=true", pipeName); - } - } - - [Category("SharedMemory")] - public class PreparedStatementsSharedMemory : PreparedStatements - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=memory; shared memory name={0}", memoryName); - } - } - - [Category("Compressed")] - [Category("SharedMemory")] - public class PreparedStatementsSharedMemoryCompressed : PreparedStatements - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=memory; shared memory name={0};compress=true", memoryName); - } - } -#endif - #endregion - -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ProcedureParameters.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ProcedureParameters.cs deleted file mode 100644 index 6437b4c..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ProcedureParameters.cs +++ /dev/null @@ -1,371 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class ProcedureParameterTests : BaseTest - { - public override void Setup() - { - accessToMySqlDb = true; - base.Setup(); - } - - [Test] - public void ProcedureParameters() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest (id int, name varchar(50)) BEGIN SELECT 1; END"); - - string[] restrictions = new string[5]; - restrictions[1] = database0; - restrictions[2] = "spTest"; - DataTable dt = conn.GetSchema("Procedure Parameters", restrictions); - Assert.IsTrue(dt.Rows.Count == 2); - Assert.AreEqual("Procedure Parameters", dt.TableName); - Assert.AreEqual(database0.ToLower(), dt.Rows[0]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[0]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("id", dt.Rows[0]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(1, dt.Rows[0]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[0]["PARAMETER_MODE"]); - - restrictions[4] = "name"; - dt.Clear(); - dt = conn.GetSchema("Procedure Parameters", restrictions); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(database0.ToLower(), dt.Rows[0]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[0]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("name", dt.Rows[0]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(2, dt.Rows[0]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[0]["PARAMETER_MODE"]); - - execSQL("DROP FUNCTION IF EXISTS spFunc"); - execSQL("CREATE FUNCTION spFunc (id int) RETURNS INT BEGIN RETURN 1; END"); - - restrictions[4] = null; - restrictions[1] = database0; - restrictions[2] = "spFunc"; - dt = conn.GetSchema("Procedure Parameters", restrictions); - Assert.IsTrue(dt.Rows.Count == 2); - Assert.AreEqual("Procedure Parameters", dt.TableName); - Assert.AreEqual(database0.ToLower(), dt.Rows[0]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("spfunc", dt.Rows[0]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual(0, dt.Rows[0]["ORDINAL_POSITION"]); - - Assert.AreEqual(database0.ToLower(), dt.Rows[1]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("spfunc", dt.Rows[1]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("id", dt.Rows[1]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(1, dt.Rows[1]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[1]["PARAMETER_MODE"]); - } - - /// - /// Bug #6902 Errors in parsing stored procedure parameters - /// - [Test] - public void ProcedureParameters2() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE PROCEDURE spTest(`/*id*/` /* before type 1 */ varchar(20), - /* after type 1 */ OUT result2 DECIMAL(/*size1*/10,/*size2*/2) /* p2 */) - BEGIN SELECT action, result; END"); - - string[] restrictions = new string[5]; - restrictions[1] = database0; - restrictions[2] = "spTest"; - DataTable dt = conn.GetSchema("Procedure Parameters", restrictions); - - Assert.IsTrue(dt.Rows.Count == 2); - Assert.AreEqual(database0.ToLower(), dt.Rows[0]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[0]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("/*id*/", dt.Rows[0]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(1, dt.Rows[0]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[0]["PARAMETER_MODE"]); - Assert.AreEqual("VARCHAR", dt.Rows[0]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual(20, dt.Rows[0]["CHARACTER_MAXIMUM_LENGTH"]); - Assert.AreEqual(20, dt.Rows[0]["CHARACTER_OCTET_LENGTH"]); - - Assert.AreEqual(database0.ToLower(), dt.Rows[1]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[1]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("result2", dt.Rows[1]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(2, dt.Rows[1]["ORDINAL_POSITION"]); - Assert.AreEqual("OUT", dt.Rows[1]["PARAMETER_MODE"]); - Assert.AreEqual("DECIMAL", dt.Rows[1]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual(10, dt.Rows[1]["NUMERIC_PRECISION"]); - Assert.AreEqual(2, dt.Rows[1]["NUMERIC_SCALE"]); - } - - [Test] - public void ProcedureParameters3() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE PROCEDURE spTest (_ACTION varchar(20), - `/*dumb-identifier-1*/` int, `#dumb-identifier-2` int, - `--dumb-identifier-3` int, - _CLIENT_ID int, -- ABC - _LOGIN_ID int, # DEF - _WHERE varchar(2000), - _SORT varchar(2000), - out _SQL varchar(/* inline right here - oh my gosh! */ 8000), - _SONG_ID int, - _NOTES varchar(2000), - out _RESULT varchar(10) - /* - , -- Generic result parameter - out _PERIOD_ID int, -- Returns the period_id. Useful when using @PREDEFLINK to return which is the last period - _SONGS_LIST varchar(8000), - _COMPOSERID int, - _PUBLISHERID int, - _PREDEFLINK int -- If the user is accessing through a predefined link: 0=none 1=last period - */) BEGIN SELECT 1; END"); - - string[] restrictions = new string[5]; - restrictions[1] = database0; - restrictions[2] = "spTest"; - DataTable dt = conn.GetSchema("Procedure Parameters", restrictions); - - Assert.IsTrue(dt.Rows.Count == 12); - Assert.AreEqual(database0.ToLower(), dt.Rows[0]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[0]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("_action", dt.Rows[0]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(1, dt.Rows[0]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[0]["PARAMETER_MODE"]); - Assert.AreEqual("VARCHAR", dt.Rows[0]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual(20, dt.Rows[0]["CHARACTER_OCTET_LENGTH"]); - - Assert.AreEqual(database0.ToLower(), dt.Rows[1]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[1]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("/*dumb-identifier-1*/", dt.Rows[1]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(2, dt.Rows[1]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[1]["PARAMETER_MODE"]); - Assert.AreEqual("INT", dt.Rows[1]["DATA_TYPE"].ToString().ToUpper()); - - Assert.AreEqual(database0.ToLower(), dt.Rows[2]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[2]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("#dumb-identifier-2", dt.Rows[2]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(3, dt.Rows[2]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[2]["PARAMETER_MODE"]); - Assert.AreEqual("INT", dt.Rows[2]["DATA_TYPE"].ToString().ToUpper()); - - Assert.AreEqual(database0.ToLower(), dt.Rows[3]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[3]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("--dumb-identifier-3", dt.Rows[3]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(4, dt.Rows[3]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[3]["PARAMETER_MODE"]); - Assert.AreEqual("INT", dt.Rows[3]["DATA_TYPE"].ToString().ToUpper()); - - Assert.AreEqual(database0.ToLower(), dt.Rows[4]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[4]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("_client_id", dt.Rows[4]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(5, dt.Rows[4]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[4]["PARAMETER_MODE"]); - Assert.AreEqual("INT", dt.Rows[4]["DATA_TYPE"].ToString().ToUpper()); - - Assert.AreEqual(database0.ToLower(), dt.Rows[5]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[5]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("_login_id", dt.Rows[5]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(6, dt.Rows[5]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[5]["PARAMETER_MODE"]); - Assert.AreEqual("INT", dt.Rows[5]["DATA_TYPE"].ToString().ToUpper()); - - Assert.AreEqual(database0.ToLower(), dt.Rows[6]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[6]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("_where", dt.Rows[6]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(7, dt.Rows[6]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[6]["PARAMETER_MODE"]); - Assert.AreEqual("VARCHAR", dt.Rows[6]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual(2000, dt.Rows[6]["CHARACTER_OCTET_LENGTH"]); - - Assert.AreEqual(database0.ToLower(), dt.Rows[7]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[7]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("_sort", dt.Rows[7]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(8, dt.Rows[7]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[7]["PARAMETER_MODE"]); - Assert.AreEqual("VARCHAR", dt.Rows[7]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual(2000, dt.Rows[7]["CHARACTER_OCTET_LENGTH"]); - - Assert.AreEqual(database0.ToLower(), dt.Rows[8]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[8]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("_sql", dt.Rows[8]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(9, dt.Rows[8]["ORDINAL_POSITION"]); - Assert.AreEqual("OUT", dt.Rows[8]["PARAMETER_MODE"]); - Assert.AreEqual("VARCHAR", dt.Rows[8]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual(8000, dt.Rows[8]["CHARACTER_OCTET_LENGTH"]); - - Assert.AreEqual(database0.ToLower(), dt.Rows[9]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[9]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("_song_id", dt.Rows[9]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(10, dt.Rows[9]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[9]["PARAMETER_MODE"]); - Assert.AreEqual("INT", dt.Rows[9]["DATA_TYPE"].ToString().ToUpper()); - - Assert.AreEqual(database0.ToLower(), dt.Rows[10]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[10]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("_notes", dt.Rows[10]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(11, dt.Rows[10]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[10]["PARAMETER_MODE"]); - Assert.AreEqual("VARCHAR", dt.Rows[10]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual(2000, dt.Rows[10]["CHARACTER_OCTET_LENGTH"]); - - Assert.AreEqual(database0.ToLower(), dt.Rows[11]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[11]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("_result", dt.Rows[11]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(12, dt.Rows[11]["ORDINAL_POSITION"]); - Assert.AreEqual("OUT", dt.Rows[11]["PARAMETER_MODE"]); - Assert.AreEqual("VARCHAR", dt.Rows[11]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual(10, dt.Rows[11]["CHARACTER_OCTET_LENGTH"]); - } - - [Test] - public void ProcedureParameters4() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE PROCEDURE spTest (name VARCHAR(1200) - CHARACTER /* hello*/ SET utf8) BEGIN SELECT name; END"); - - string[] restrictions = new string[5]; - restrictions[1] = database0; - restrictions[2] = "spTest"; - DataTable dt = conn.GetSchema("Procedure Parameters", restrictions); - - Assert.IsTrue(dt.Rows.Count == 1); - Assert.AreEqual(database0.ToLower(), dt.Rows[0]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[0]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("name", dt.Rows[0]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(1, dt.Rows[0]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[0]["PARAMETER_MODE"]); - Assert.AreEqual("VARCHAR", dt.Rows[0]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual(1200, dt.Rows[0]["CHARACTER_MAXIMUM_LENGTH"]); - if (Version.Major >= 6) - Assert.AreEqual(4800, dt.Rows[0]["CHARACTER_OCTET_LENGTH"]); - else - Assert.AreEqual(3600, dt.Rows[0]["CHARACTER_OCTET_LENGTH"]); - Assert.AreEqual("utf8", dt.Rows[0]["CHARACTER_SET_NAME"]); - Assert.AreEqual("utf8_general_ci", dt.Rows[0]["COLLATION_NAME"]); - } - - [Test] - public void ProcedureParameters5() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE PROCEDURE spTest (name VARCHAR(1200) ASCII BINARY, - name2 TEXT UNICODE) BEGIN SELECT name; END"); - - string[] restrictions = new string[5]; - restrictions[1] = database0; - restrictions[2] = "spTest"; - DataTable dt = conn.GetSchema("Procedure Parameters", restrictions); - - Assert.IsTrue(dt.Rows.Count == 2); - Assert.AreEqual(database0.ToLower(), dt.Rows[0]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[0]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("name", dt.Rows[0]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(1, dt.Rows[0]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[0]["PARAMETER_MODE"]); - Assert.AreEqual("VARCHAR", dt.Rows[0]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual("latin1", dt.Rows[0]["CHARACTER_SET_NAME"]); - Assert.AreEqual(1200, dt.Rows[0]["CHARACTER_OCTET_LENGTH"]); - - Assert.AreEqual(database0.ToLower(), dt.Rows[1]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[1]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("name2", dt.Rows[1]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(2, dt.Rows[1]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[1]["PARAMETER_MODE"]); - Assert.AreEqual("TEXT", dt.Rows[1]["DATA_TYPE"].ToString().ToUpper()); - Assert.AreEqual("ucs2", dt.Rows[1]["CHARACTER_SET_NAME"]); - } - - [Test] - public void DTD_Identifier() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE PROCEDURE spTest (id INT UNSIGNED ZEROFILL, - dec1 DECIMAL(10,2), - name VARCHAR(20) /* this is a comment */ CHARACTER SET ascii, - t1 TINYTEXT BINARY, t2 ENUM('a','b','c'), - t3 /* comment */ SET(/* comment */'1','2','3')) - BEGIN SELECT name; END"); - - string[] restrictions = new string[5]; - restrictions[1] = database0; - restrictions[2] = "spTest"; - DataTable dt = conn.GetSchema("Procedure Parameters", restrictions); - - Assert.IsTrue(dt.Rows.Count == 6); - Assert.AreEqual("INT(10) UNSIGNED ZEROFILL", - dt.Rows[0]["DTD_IDENTIFIER"].ToString().ToUpper()); - Assert.AreEqual("DECIMAL(10,2)", - dt.Rows[1]["DTD_IDENTIFIER"].ToString().ToUpper()); - Assert.AreEqual("VARCHAR(20)", - dt.Rows[2]["DTD_IDENTIFIER"].ToString().ToUpper()); - Assert.AreEqual("TINYTEXT", - dt.Rows[3]["DTD_IDENTIFIER"].ToString().ToUpper()); - Assert.AreEqual("ENUM('A','B','C')", - dt.Rows[4]["DTD_IDENTIFIER"].ToString().ToUpper()); - Assert.AreEqual("SET('1','2','3')", - dt.Rows[5]["DTD_IDENTIFIER"].ToString().ToUpper()); - } - - /// - /// Bug #48586 Expose defined possible enum values - /// - [Test] - public void PossibleValues() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE PROCEDURE spTest (id INT UNSIGNED ZEROFILL, - dec1 DECIMAL(10,2), - name VARCHAR(20) /* this is a comment */ CHARACTER SET ascii, - t1 TINYTEXT BINARY, t2 ENUM('a','b','c'), - t3 /* comment */ SET(/* comment */'1','2','3')) - BEGIN SELECT name; END"); - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - MySqlCommandBuilder.DeriveParameters(cmd); - Assert.IsNull(cmd.Parameters["@id"].PossibleValues); - Assert.IsNull(cmd.Parameters["@dec1"].PossibleValues); - Assert.IsNull(cmd.Parameters["@name"].PossibleValues); - Assert.IsNull(cmd.Parameters["@t1"].PossibleValues); - MySqlParameter t2 = cmd.Parameters["@t2"]; - Assert.IsNotNull(t2.PossibleValues); - Assert.AreEqual("a", t2.PossibleValues[0]); - Assert.AreEqual("b", t2.PossibleValues[1]); - Assert.AreEqual("c", t2.PossibleValues[2]); - MySqlParameter t3 = cmd.Parameters["@t3"]; - Assert.IsNotNull(t3.PossibleValues); - Assert.AreEqual("1", t3.PossibleValues[0]); - Assert.AreEqual("2", t3.PossibleValues[1]); - Assert.AreEqual("3", t3.PossibleValues[2]); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ScriptExecution.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ScriptExecution.cs deleted file mode 100644 index 2c6285e..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/ScriptExecution.cs +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (C) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Text; -using System.Data; -using System.IO; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class ScriptExecution : BaseTest - { - [SetUp] - public override void Setup() - { - base.Setup (); - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - } - - private int statementCount; - private string statementTemplate1 = @"CREATE PROCEDURE `spTest{0}`() NOT DETERMINISTIC - CONTAINS SQL SQL SECURITY DEFINER COMMENT '' - BEGIN - SELECT 1,2,3; - END{1}"; - - [Test] - public void ExecuteScriptWithProcedures() - { - if (Version < new Version(5, 0)) return; - - statementCount = 0; - string scriptText = String.Empty; - for (int i=0; i < 10; i++) - { - scriptText += String.Format(statementTemplate1, i, "$$"); - } - MySqlScript script = new MySqlScript(scriptText); - script.StatementExecuted += new MySqlStatementExecutedEventHandler(ExecuteScriptWithProcedures_QueryExecuted); - script.Connection = conn; - script.Delimiter = "$$"; - int count = script.Execute(); - Assert.AreEqual(10, count); - - MySqlCommand cmd = new MySqlCommand( - String.Format(@"SELECT COUNT(*) FROM information_schema.routines WHERE - routine_schema = '{0}' AND routine_name LIKE 'spTest%'", - database0), conn); - Assert.AreEqual(10, cmd.ExecuteScalar()); - } - - void ExecuteScriptWithProcedures_QueryExecuted(object sender, MySqlScriptEventArgs e) - { - string stmt = String.Format(statementTemplate1, statementCount++, null); - Assert.AreEqual(stmt, e.StatementText); - } - - private string statementTemplate2 = @"INSERT INTO Test (id, name) VALUES ({0}, 'a "" na;me'){1}"; - [Test] - public void ExecuteScriptWithInserts() - { - statementCount = 0; - string scriptText = String.Empty; - for (int i = 0; i < 10; i++) - { - scriptText += String.Format(statementTemplate2, i, ";"); - } - MySqlScript script = new MySqlScript(scriptText); - script.Connection = conn; - script.StatementExecuted += new MySqlStatementExecutedEventHandler(ExecuteScriptWithInserts_StatementExecuted); - int count = script.Execute(); - Assert.AreEqual(10, count); - - MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM Test", conn); - Assert.AreEqual(10, cmd.ExecuteScalar()); - } - - void ExecuteScriptWithInserts_StatementExecuted(object sender, MySqlScriptEventArgs e) - { - string stmt = String.Format(statementTemplate2, statementCount++, null); - Assert.AreEqual(stmt, e.StatementText); - } - - [Test] - public void ExecuteScriptContinueOnError() - { - statementCount = 0; - string scriptText = String.Empty; - for (int i = 0; i < 5; i++) - scriptText += String.Format(statementTemplate2, i, ";"); - scriptText += "bogus statement;"; - for (int i = 5; i < 10; i++) - scriptText += String.Format(statementTemplate2, i, ";"); - MySqlScript script = new MySqlScript(scriptText); - script.Connection = conn; - script.Error += new MySqlScriptErrorEventHandler(ExecuteScript_ContinueOnError); - int count = script.Execute(); - Assert.AreEqual(10, count); - Assert.AreEqual(1, statementCount); - - MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM Test", conn); - Assert.AreEqual(10, cmd.ExecuteScalar()); - } - - void ExecuteScript_ContinueOnError(object sender, MySqlScriptErrorEventArgs args) - { - args.Ignore = true; - statementCount++; - } - - [Test] - public void ExecuteScriptNotContinueOnError() - { - statementCount = 0; - string scriptText = String.Empty; - for (int i = 0; i < 5; i++) - scriptText += String.Format(statementTemplate2, i, ";"); - scriptText += "bogus statement;"; - for (int i = 5; i < 10; i++) - scriptText += String.Format(statementTemplate2, i, ";"); - MySqlScript script = new MySqlScript(scriptText); - script.Connection = conn; - script.Error += new MySqlScriptErrorEventHandler(ExecuteScript_NotContinueOnError); - int count = script.Execute(); - Assert.AreEqual(5, count); - Assert.AreEqual(1, statementCount); - - MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM Test", conn); - Assert.AreEqual(5, cmd.ExecuteScalar()); - } - - void ExecuteScript_NotContinueOnError(object sender, MySqlScriptErrorEventArgs args) - { - args.Ignore = false; - statementCount++; - } - - [Test] - public void ExecuteScriptWithUserVariables() - { - string connStr = conn.ConnectionString.ToLowerInvariant(); - connStr = connStr.Replace("allow user variables=true", - "allow user variables=false"); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - string scriptText = "SET @myvar = 1"; - MySqlScript script = new MySqlScript(scriptText); - script.Connection = c; - int count = script.Execute(); - Assert.AreEqual(1, count); - } - } - - /// - /// Bug #46429 use DELIMITER command in MySql.Data.MySqlClient.MySqlScript - /// - [Test] - public void ScriptWithDelimiterStatements() - { - if (Version < new Version(5, 0)) return; - - StringBuilder sql = new StringBuilder(); - - sql.AppendFormat("{0}DELIMITER $${0}", Environment.NewLine); - sql.AppendFormat(statementTemplate1, 1, "$$"); - sql.AppendFormat("{0}DELIMITER //{0}", Environment.NewLine); - sql.AppendFormat(statementTemplate1, 2, "//"); - - MySqlScript s = new MySqlScript(); - s.Query = sql.ToString(); - s.Delimiter = "XX"; - s.Connection = conn; - int count = s.Execute(); - } - - /// - /// Bug #46429 use DELIMITER command in MySql.Data.MySqlClient.MySqlScript - /// - [Test] - public void DelimiterInScriptV2() - { - var sql = new StringBuilder(); - - sql.AppendLine("DELIMITER MySuperDelimiter"); - sql.AppendLine("CREATE PROCEDURE TestProcedure1()"); - sql.AppendLine("BEGIN"); - sql.AppendLine(" SELECT * FROM mysql.proc;"); - sql.AppendLine("END MySuperDelimiter"); - sql.AppendLine("CREATE PROCEDURE TestProcedure2()"); - sql.AppendLine("BEGIN"); - sql.AppendLine(" SELECT * FROM mysql.proc;"); - sql.AppendLine("END mysuperdelimiter"); - - sql.AppendLine("DELIMITER ;"); - - var script = new MySqlScript(conn, sql.ToString()); - script.Execute(); - } - - - /// - /// Bug #50344 MySqlScript.Execute() throws InvalidOperationException - /// - [Test] - public void EmptyLastLineWithScriptExecute() - { - StringBuilder sb = new StringBuilder(); - sb.AppendLine("DROP FUNCTION IF EXISTS `BlaBla`;"); - sb.AppendLine("DELIMITER ;;"); - MySqlScript script = new MySqlScript(conn, sb.ToString()); - // InvalidOperationException : The CommandText property has not been properly initialized. - script.Execute(); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/SimpleTransactions.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/SimpleTransactions.cs deleted file mode 100644 index 226d4de..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/SimpleTransactions.cs +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using NUnit.Framework; -using System.Data.Common; -using System.Reflection; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class SimpleTransactions : BaseTest - { - public override void Setup() - { - base.Setup(); - createTable("CREATE TABLE Test (key2 VARCHAR(1), name VARCHAR(100), name2 VARCHAR(100))", "INNODB"); - } - - [Test] - public void TestReader() - { - execSQL("INSERT INTO Test VALUES('P', 'Test1', 'Test2')"); - - MySqlTransaction txn = conn.BeginTransaction(); - MySqlConnection c = txn.Connection; - Assert.AreEqual( conn, c ); - MySqlCommand cmd = new MySqlCommand("SELECT name, name2 FROM Test WHERE key2='P'", - conn, txn); - MySqlTransaction t2 = cmd.Transaction; - Assert.AreEqual( txn, t2 ); - MySqlDataReader reader = null; - try - { - reader = cmd.ExecuteReader(); - reader.Close(); - txn.Commit(); - } - catch (Exception ex) - { - Assert.Fail( ex.Message ); - txn.Rollback(); - } - finally - { - if (reader != null) reader.Close(); - } - } - - /// - /// Bug #22400 Nested transactions - /// - [Test] - public void NestedTransactions() - { - MySqlTransaction t1 = conn.BeginTransaction(); - try - { - MySqlTransaction t2 = conn.BeginTransaction(); - Assert.Fail("Exception should have been thrown"); - t2.Rollback(); - } - catch (InvalidOperationException) - { - } - finally - { - t1.Rollback(); - } - } - - [Test] - public void BeginTransactionOnPreviouslyOpenConnection() - { - string connStr = GetConnectionString(true); - MySqlConnection c = new MySqlConnection(connStr); - c.Open(); - c.Close(); - try - { - c.BeginTransaction(); - } - catch (Exception ex) - { - Assert.AreEqual("The connection is not open.", ex.Message); - } - } - - /// - /// Bug #37991 Connection fails when trying to close after a commit while network to db is bad - /// This test is not a perfect test of this bug as the kill connection is not quite the - /// same as unplugging the network but it's the best I've figured out so far - /// - [Test] - public void CommitAfterConnectionDead() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test(id INT, name VARCHAR(20))"); - - string connStr = GetConnectionString(true) + ";pooling=false"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - MySqlTransaction trans = c.BeginTransaction(); - - using (MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, 'boo')", c)) - { - cmd.ExecuteNonQuery(); - } - KillConnection(c); - try - { - trans.Commit(); - Assert.Fail("Should have thrown an exception"); - } - catch (Exception) - { - } - Assert.AreEqual(ConnectionState.Closed, c.State); - c.Close(); // this should work even though we are closed - } - } - - /// - /// Bug #39817 Transaction Dispose does not roll back - /// - [Test] - public void DisposingCallsRollback() - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES ('a', 'b', 'c')", conn); - MySqlTransaction txn = conn.BeginTransaction(); - using (txn) - { - cmd.ExecuteNonQuery(); - } - // the txn should be closed now as a rollback should have happened. - Type t = txn.GetType(); - FieldInfo fi = t.GetField("open", BindingFlags.Instance | BindingFlags.NonPublic); - bool isOpen = (bool)fi.GetValue(txn); - Assert.IsFalse(isOpen); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/SqlTokenizer.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/SqlTokenizer.cs deleted file mode 100644 index e7b75c2..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/SqlTokenizer.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Reflection; -using System.Collections.Generic; - -namespace MySql.Data.MySqlClient.Tests -{ - class SqlTokenizer - { - object tokenizer; - - public SqlTokenizer(string sql) - { - tokenizer = typeof(MySqlConnection).Assembly.CreateInstance("MySql.Data.MySqlClient.MySqlTokenizer", - false, System.Reflection.BindingFlags.CreateInstance, null, - new object[] { sql }, null, null); - } - - public bool ReturnComments - { - set - { - PropertyInfo pi = tokenizer.GetType().GetProperty("ReturnComments"); - pi.SetValue(tokenizer, value, null); - } - } - - public bool AnsiQuotes - { - set - { - PropertyInfo pi = tokenizer.GetType().GetProperty("AnsiQuotes"); - pi.SetValue(tokenizer, value, null); - } - } - - public bool Quoted - { - get - { - PropertyInfo pi = tokenizer.GetType().GetProperty("Quoted"); - return (bool)pi.GetValue(tokenizer, null); - } - } - - public string NextToken() - { - return (string)tokenizer.GetType().InvokeMember("NextToken", - System.Reflection.BindingFlags.InvokeMethod, - null, tokenizer, null); - } - - public string NextParameter() - { - return (string)tokenizer.GetType().InvokeMember("NextParameter", - System.Reflection.BindingFlags.InvokeMethod, - null, tokenizer, null); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StoredProcedure.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StoredProcedure.cs deleted file mode 100644 index 68bc215..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StoredProcedure.cs +++ /dev/null @@ -1,1293 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using NUnit.Framework; -using System.Globalization; -using System.Threading; -using MySql.Data.Types; -using System.Data.Common; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for StoredProcedure. - /// - [TestFixture] - public class StoredProcedure : BaseTest - { - private static string fillError = null; - - public StoredProcedure() - { - csAdditions = ";procedure cache size=0;"; - } - - /// - /// Bug #7623 Adding MySqlParameter causes error if MySqlDbType is Decimal - /// - [Test] - public void ReturningResultset() - { - if (Version < new Version(5, 0)) return; - - // create our procedure - execSQL("CREATE PROCEDURE spTest(val decimal(10,3)) begin select val; end"); - - using (MySqlCommand cmd = new MySqlCommand("spTest", conn)) - { - cmd.CommandType = CommandType.StoredProcedure; - - MySqlParameter p = cmd.Parameters.Add("?val", MySqlDbType.Decimal); - p.Precision = 10; - p.Scale = 3; - p.Value = 21; - - decimal id = (decimal)cmd.ExecuteScalar(); - Assert.AreEqual(21, id); - } - } - - [Test] - public void NonQuery() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE Test(id INT, name VARCHAR(20))"); - execSQL(@"CREATE PROCEDURE spTest(IN value INT) - BEGIN INSERT INTO Test VALUES(value, 'Test'); END"); - - //setup testing data - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?value", 2); - int rowsAffected = cmd.ExecuteNonQuery(); - Assert.AreEqual(1, rowsAffected); - - cmd.CommandText = "SELECT * FROM Test"; - cmd.CommandType = CommandType.Text; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(2, reader.GetInt32(0)); - Assert.AreEqual("Test", reader.GetString(1)); - Assert.IsFalse(reader.Read()); - Assert.IsFalse(reader.NextResult()); - } - } - - /// - /// Bug #17814 Stored procedure fails unless DbType set explicitly - /// Bug #23749 VarChar field size over 255 causes a System.OverflowException - /// - [Test] - public void OutputParameters() - { - if (Version < new Version(5, 0)) return; - - // we don't want to run this test under no access - string connInfo = GetConnectionInfo(); - if (connInfo.IndexOf("use procedure bodies=false") != -1) return; - - // create our procedure - execSQL("CREATE PROCEDURE spTest(out value VARCHAR(350), OUT intVal INT, " + - "OUT dateVal TIMESTAMP, OUT floatVal FLOAT, OUT noTypeVarChar VARCHAR(20), " + - "OUT noTypeInt INT) " + - "BEGIN SET value='42'; SET intVal=33; SET dateVal='2004-06-05 07:58:09'; " + - "SET floatVal = 1.2; SET noTypeVarChar='test'; SET noTypeInt=66; END"); - - // we use rootConn here since we are using parameters - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.Add(new MySqlParameter("?value", MySqlDbType.VarChar)); - cmd.Parameters.Add(new MySqlParameter("?intVal", MySqlDbType.Int32)); - cmd.Parameters.Add(new MySqlParameter("?dateVal", MySqlDbType.DateTime)); - cmd.Parameters.Add(new MySqlParameter("?floatVal", MySqlDbType.Float)); - MySqlParameter vcP = new MySqlParameter(); - vcP.ParameterName = "?noTypeVarChar"; - vcP.Direction = ParameterDirection.Output; - cmd.Parameters.Add(vcP); - MySqlParameter vcI = new MySqlParameter(); - vcI.ParameterName = "?noTypeInt"; - vcI.Direction = ParameterDirection.Output; - cmd.Parameters.Add(vcI); - cmd.Parameters[0].Direction = ParameterDirection.Output; - cmd.Parameters[1].Direction = ParameterDirection.Output; - cmd.Parameters[2].Direction = ParameterDirection.Output; - cmd.Parameters[3].Direction = ParameterDirection.Output; - int rowsAffected = cmd.ExecuteNonQuery(); - - Assert.AreEqual(0, rowsAffected); - Assert.AreEqual("42", cmd.Parameters[0].Value); - Assert.AreEqual(33, cmd.Parameters[1].Value); - Assert.AreEqual(new DateTime(2004, 6, 5, 7, 58, 9), - Convert.ToDateTime(cmd.Parameters[2].Value)); - Assert.AreEqual(1.2, (decimal)(float)cmd.Parameters[3].Value); - Assert.AreEqual("test", cmd.Parameters[4].Value); - Assert.AreEqual(66, cmd.Parameters[5].Value); - } - - [Test] - public void NoBatch() - { - if (Version < new Version(5, 0)) return; - - try - { - MySqlCommand cmd = new MySqlCommand("spTest;select * from Test", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.ExecuteNonQuery(); - Assert.Fail("Should have thrown an exception"); - } - catch (Exception) - { - } - } - - [Test] - public void WrongParameters() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest(p1 INT) BEGIN SELECT 1; END"); - try - { - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?p2", 1); - cmd.ExecuteNonQuery(); - Assert.Fail("Should have thrown an exception"); - } - catch (Exception) - { - } - } - - [Test] - public void NoInOutMarker() - { - if (Version < new Version(5, 0)) return; - - // create our procedure - execSQL("CREATE PROCEDURE spTest( valin varchar(50) ) BEGIN SELECT valin; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?valin", "myvalue"); - object val = cmd.ExecuteScalar(); - Assert.AreEqual("myvalue", val); - } - - [Test] - public void InputOutputParameters() - { - if (Version < new Version(5, 0)) return; - - // create our procedure - execSQL("CREATE PROCEDURE spTest( INOUT strVal VARCHAR(50), INOUT numVal INT, OUT outVal INT UNSIGNED ) " + - "BEGIN SET strVal = CONCAT(strVal,'ending'); SET numVal=numVal * 2; SET outVal=99; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?strVal", "beginning"); - cmd.Parameters.AddWithValue("?numVal", 33); - cmd.Parameters.AddWithValue("?outVal", MySqlDbType.Int32); - cmd.Parameters[0].Direction = ParameterDirection.InputOutput; - cmd.Parameters[1].Direction = ParameterDirection.InputOutput; - cmd.Parameters[2].Direction = ParameterDirection.Output; - int rowsAffected = cmd.ExecuteNonQuery(); - Assert.AreEqual(0, rowsAffected); - Assert.AreEqual("beginningending", cmd.Parameters[0].Value); - Assert.AreEqual(66, cmd.Parameters[1].Value); - Assert.AreEqual(99, cmd.Parameters[2].Value); - } - - [Test] - public void NoSPOnPre50() - { - if (Version < new Version(5, 0)) return; - - try - { - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.ExecuteNonQuery(); - Assert.Fail("This should not have worked"); - } - catch (Exception) - { - } - } - - [Test] - public void ExecuteScalar() - { - if (Version < new Version(5, 0)) return; - - // create our procedure - execSQL("CREATE PROCEDURE spTest( IN valin VARCHAR(50), OUT valout VARCHAR(50) ) " + - "BEGIN SET valout=valin; SELECT 'Test'; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?valin", "valuein"); - cmd.Parameters.Add(new MySqlParameter("?valout", MySqlDbType.VarChar)); - cmd.Parameters[1].Direction = ParameterDirection.Output; - object result = cmd.ExecuteScalar(); - Assert.AreEqual("Test", result); - Assert.AreEqual("valuein", cmd.Parameters[1].Value); - } - - /// - /// Bug #13590 ExecuteScalar returns only Int64 regardless of actual SQL type - /// - [Test] - public void ExecuteScalar2() - { - if (Version < new Version(5, 0)) return; - - // create our procedure - execSQL("CREATE PROCEDURE spTest() " + - "BEGIN DECLARE myVar1 INT; SET myVar1 := 1; SELECT myVar1; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - object result = cmd.ExecuteScalar(); - Assert.AreEqual(1, result); - Assert.IsTrue(result is Int32); - } - - [Test] - public void ExecuteReader() - { - if (Version < new Version(5, 0)) return; - - // create our procedure - execSQL("CREATE PROCEDURE spTest(OUT p INT) " + - "BEGIN SELECT 1; SET p=2; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.Parameters.Add("?p", MySqlDbType.Int32); - cmd.Parameters[0].Direction = ParameterDirection.Output; - cmd.CommandType = CommandType.StoredProcedure; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.AreEqual(true, reader.Read()); - Assert.AreEqual(false, reader.NextResult()); - Assert.AreEqual(false, reader.Read()); - } - Assert.AreEqual(2, cmd.Parameters[0].Value); - } - - [Test] - public void MultipleResultsets() - { - if (Version < new Version(5, 0)) return; - - MultipleResultsetsImpl(false); - } - - [Test] - public void MultipleResultsetsPrepared() - { - if (Version < new Version(5, 0)) return; - - MultipleResultsetsImpl(true); - } - - private void MultipleResultsetsImpl(bool prepare) - { - if (Version < new Version(5, 0)) return; - - // create our procedure - execSQL("CREATE PROCEDURE spTest() " + - "BEGIN SELECT 1; SELECT 2; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - if (prepare) cmd.Prepare(); - cmd.CommandType = CommandType.StoredProcedure; - MySqlDataReader reader = cmd.ExecuteReader(); - Assert.AreEqual(true, reader.Read()); - Assert.AreEqual(true, reader.NextResult()); - Assert.AreEqual(true, reader.Read()); - Assert.AreEqual(false, reader.NextResult()); - Assert.AreEqual(false, reader.Read()); - reader.Close(); - - DataSet ds = new DataSet(); - MySqlCommand cmd2 = new MySqlCommand("spTest", conn); - cmd2.CommandType = CommandType.StoredProcedure; - MySqlDataAdapter da = new MySqlDataAdapter(cmd2); - da.FillError += new FillErrorEventHandler(da_FillError); - fillError = null; - da.Fill(ds); - Assert.AreEqual(2, ds.Tables.Count); - Assert.AreEqual(1, ds.Tables[0].Rows.Count); - Assert.AreEqual(1, ds.Tables[1].Rows.Count); - Assert.AreEqual(1, ds.Tables[0].Rows[0][0]); - Assert.AreEqual(2, ds.Tables[1].Rows[0][0]); - Assert.IsNull(fillError); - } - - private static void da_FillError(object sender, FillErrorEventArgs e) - { - fillError = e.Errors.Message; - e.Continue = true; - } - - [Test] - public void FunctionNoParams() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE FUNCTION fnTest() RETURNS CHAR(50)" + - " LANGUAGE SQL DETERMINISTIC BEGIN RETURN \"Test\"; END"); - - MySqlCommand cmd = new MySqlCommand("SELECT fnTest()", conn); - cmd.CommandType = CommandType.Text; - object result = cmd.ExecuteScalar(); - Assert.AreEqual("Test", result); - } - - [Test] - public void FunctionParams() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE FUNCTION fnTest( val1 INT, val2 CHAR(40) ) RETURNS INT " + - " LANGUAGE SQL DETERMINISTIC BEGIN RETURN val1 + LENGTH(val2); END"); - - MySqlCommand cmd = new MySqlCommand("SELECT fnTest(22, 'Test')", conn); - cmd.CommandType = CommandType.Text; - object result = cmd.ExecuteScalar(); - Assert.AreEqual(26, result); - } - - [Test] - public void ExecuteWithCreate() - { - if (Version < new Version(5, 0)) return; - - // create our procedure - string sql = "CREATE PROCEDURE spTest(IN var INT) BEGIN SELECT var; END; call spTest(?v)"; - - MySqlCommand cmd = new MySqlCommand(sql, conn); - cmd.Parameters.Add(new MySqlParameter("?v", 33)); - object val = cmd.ExecuteScalar(); - Assert.AreEqual(33, val); - } - - /// - /// Bug #9722 Connector does not recognize parameters separated by a linefeed - /// - [Test] - public void OtherProcSigs() - { - if (Version < new Version(5, 0)) return; - - // create our procedure - execSQL("CREATE PROCEDURE spTest(IN \r\nvalin DECIMAL(10,2),\nIN val2 INT) " + - "SQL SECURITY INVOKER BEGIN SELECT valin; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?valin", 20.4); - cmd.Parameters.AddWithValue("?val2", 4); - decimal val = (decimal)cmd.ExecuteScalar(); - Decimal d = new Decimal(20.4); - Assert.AreEqual(d, val); - - // create our second procedure - execSQL("DROP PROCEDURE IF EXISTS spTest"); - execSQL("CREATE PROCEDURE spTest( \r\n) BEGIN SELECT 4; END"); - cmd.Parameters.Clear(); - object val1 = cmd.ExecuteScalar(); - Assert.AreEqual(4, val1); - } - - - /// - /// Bug #10644 Cannot call a stored function directly from Connector/Net - /// Bug #25013 Return Value parameter not found - /// - [Test] - public void CallingStoredFunctionasProcedure() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE FUNCTION fnTest(valin int) RETURNS INT " + - " LANGUAGE SQL DETERMINISTIC BEGIN return valin * 2; END"); - MySqlCommand cmd = new MySqlCommand("fnTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?valin", 22); - MySqlParameter retVal = cmd.CreateParameter(); - retVal.ParameterName = "?retval"; - retVal.MySqlDbType = MySqlDbType.Int32; - retVal.Direction = ParameterDirection.ReturnValue; - cmd.Parameters.Add(retVal); - cmd.ExecuteNonQuery(); - Assert.AreEqual(44, cmd.Parameters[1].Value); - } - - /// - /// Bug #11450 Connector/Net, current database and stored procedures - /// - [Test] - public void NoDefaultDatabase() - { - if (Version < new Version(5, 0)) return; - - // create our procedure - execSQL("CREATE PROCEDURE spTest() BEGIN SELECT 4; END"); - - string newConnStr = GetConnectionString(false); - using (MySqlConnection c = new MySqlConnection(newConnStr)) - { - c.Open(); - MySqlCommand cmd2 = new MySqlCommand(String.Format("use `{0}`", database0), c); - cmd2.ExecuteNonQuery(); - - MySqlCommand cmd = new MySqlCommand("spTest", c); - cmd.CommandType = CommandType.StoredProcedure; - object val = cmd.ExecuteScalar(); - Assert.AreEqual(4, val); - - cmd2.CommandText = String.Format("use `{0}`", database1); - cmd2.ExecuteNonQuery(); - - cmd.CommandText = String.Format("`{0}`.spTest", database0); - val = cmd.ExecuteScalar(); - Assert.AreEqual(4, val); - } - } - - /// - /// Bug #13590 ExecuteScalar returns only Int64 regardless of actual SQL type - /// - /* [Test] - public void TestSelectingInts() - { - execSQL("CREATE PROCEDURE spTest() BEGIN DECLARE myVar INT; " + - "SET MyVar := 1; SELECT CAST(myVar as SIGNED); END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - object val = cmd.ExecuteScalar(); - Assert.AreEqual(1, val, "Checking value"); - Assert.IsTrue(val is Int32, "Checking type"); - } - */ - - /// - /// Bug #11386 Numeric parameters with Precision and Scale not taken into account by Connector - /// - [Test] - public void DecimalAsParameter() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest(IN d DECIMAL(19,4)) BEGIN SELECT d; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?d", 21); - decimal d = (decimal)cmd.ExecuteScalar(); - Assert.AreEqual(21, d); - } - - /// - /// Bug #6902 Errors in parsing stored procedure parameters - /// - [Test] - public void ParmWithCharacterSet() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest(P longtext character set utf8) " + - "BEGIN SELECT P; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?P", "This is my value"); - string p = (string)cmd.ExecuteScalar(); - Assert.AreEqual("This is my value", p); - } - - /// - /// Bug #13753 Exception calling stored procedure with special characters in parameters - /// - [Test] - public void SpecialCharacters() - { - if (Version < new Version(5, 0)) return; - - execSQL("SET sql_mode=ANSI_QUOTES"); - try - { - execSQL("CREATE PROCEDURE spTest(\"@Param1\" text) BEGIN SELECT \"@Param1\"; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.Parameters.AddWithValue("?@Param1", "This is my value"); - cmd.CommandType = CommandType.StoredProcedure; - - string val = (string)cmd.ExecuteScalar(); - Assert.AreEqual("This is my value", val); - } - finally - { - execSQL("SET sql_mode=\"\""); - } - } - - [Test] - public void CallingSPWithPrepare() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest(P int) BEGIN SELECT P; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?P", 33); - cmd.Prepare(); - - int p = (int)cmd.ExecuteScalar(); - Assert.AreEqual(33, p); - } - - /// - /// Bug #13927 Multiple Records to same Table in Transaction Problem - /// - [Test] - public void MultipleRecords() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE Test (id INT, name VARCHAR(20))"); - execSQL("CREATE PROCEDURE spTest(id int, str VARCHAR(45)) " + - "BEGIN INSERT INTO Test VALUES(id, str); END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - - cmd.Parameters.AddWithValue("?id", 1); - cmd.Parameters.AddWithValue("?str", "First record"); - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); - cmd.Parameters.AddWithValue("?id", 2); - cmd.Parameters.AddWithValue("?str", "Second record"); - cmd.ExecuteNonQuery(); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - - Assert.AreEqual(1, dt.Rows[0]["id"]); - Assert.AreEqual(2, dt.Rows[1]["id"]); - Assert.AreEqual("First record", dt.Rows[0]["name"]); - Assert.AreEqual("Second record", dt.Rows[1]["name"]); - } - - /// - /// Bug #16788 Only byte arrays and strings can be serialized by MySqlBinary - /// - [Test] - public void Bug16788() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE Test (id integer(9), state varchar(2))"); - execSQL("CREATE PROCEDURE spTest(IN p1 integer(9), IN p2 varchar(2)) " + - "BEGIN " + - "INSERT INTO Test (id, state) VALUES (p1, p2); " + - "END"); - - MySqlCommand cmd = conn.CreateCommand(); - cmd.CommandType = CommandType.StoredProcedure; - cmd.CommandText = "spTest"; - cmd.Parameters.Add("?p1", MySqlDbType.UInt16, 9); - cmd.Parameters["?p1"].Value = 44; - cmd.Parameters.Add("?p2", MySqlDbType.VarChar, 2); - cmd.Parameters["?p2"].Value = "ss"; - cmd.ExecuteNonQuery(); - } - - [Test] - public void ReturningEmptyResultSet() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE test1 (id int AUTO_INCREMENT NOT NULL, " + - "Name VARCHAR(100) NOT NULL, PRIMARY KEY(id))"); - execSQL("CREATE TABLE test2 (id int AUTO_INCREMENT NOT NULL, " + - "id1 INT NOT NULL, id2 INT NOT NULL, PRIMARY KEY(id))"); - - execSQL("INSERT INTO test1 (Id, Name) VALUES (1, 'Item1')"); - execSQL("INSERT INTO test1 (Id, Name) VALUES (2, 'Item2')"); - execSQL("INSERT INTO test2 (Id, Id1, Id2) VALUES (1, 1, 1)"); - execSQL("INSERT INTO test2 (Id, Id1, Id2) VALUES (2, 2, 1)"); - - execSQL("CREATE PROCEDURE spTest(Name VARCHAR(100), OUT Table1Id INT) " + - "BEGIN SELECT t1.Id INTO Table1Id FROM test1 t1 WHERE t1.Name LIKE Name; " + - "SELECT t3.Id2 FROM test2 t3 WHERE t3.Id1 = Table1Id; END"); - - MySqlCommand cmd = conn.CreateCommand(); - cmd.CommandType = CommandType.StoredProcedure; - cmd.CommandText = "spTest"; - cmd.Parameters.AddWithValue("?Name", "Item3"); - cmd.Parameters.Add("?Table1Id", MySqlDbType.Int32); - cmd.Parameters["?Table1Id"].Direction = ParameterDirection.Output; - - DataSet ds = new DataSet(); - MySqlDataAdapter da = new MySqlDataAdapter(cmd); - try - { - da.Fill(ds); - } - catch (MySqlException) - { - // on 5.1 this throws an exception that no rows were returned. - } - } - -#if !CF - [Explicit] - [Test] - public void ProcedureCache() - { - if (Version < new Version(5, 0)) return; - - // open a new connection using a procedure cache - string connStr = GetConnectionString(true); - connStr += ";procedure cache size=25;logging=true"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - // install our custom trace listener - GenericListener myListener = new GenericListener(); - System.Diagnostics.Trace.Listeners.Add(myListener); - - for (int x = 0; x < 10; x++) - { - execSQL("CREATE PROCEDURE spTest" + x + "() BEGIN SELECT 1; END"); - MySqlCommand cmd = new MySqlCommand("spTest" + x, c); - cmd.CommandType = CommandType.StoredProcedure; - for (int y = 0; y < 20; y++) - { - cmd.ExecuteNonQuery(); - } - } - - // remove our custom trace listener - System.Diagnostics.Trace.Listeners.Remove(myListener); - - // now see how many times our listener recorded a cache hit - Assert.AreEqual(190, myListener.Find("from procedure cache")); - Assert.AreEqual(10, myListener.Find("from server")); - } - } -#endif - - /// - /// Bug #20581 Null Reference Exception when closing reader after stored procedure. - /// - [Test] - public void Bug20581() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest(p int) BEGIN SELECT p; END"); - MySqlParameter param1; - MySqlCommand command = new MySqlCommand("spTest", conn); - command.CommandType = CommandType.StoredProcedure; - - param1 = command.Parameters.Add("?p", MySqlDbType.Int32); - param1.Value = 3; - - command.Prepare(); - using (MySqlDataReader reader = command.ExecuteReader()) - { - reader.Read(); - } - } - - /// - /// Bug #17046 Null pointer access when stored procedure is used - /// - [Test] - public void PreparedReader() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE Test (id int(10) unsigned NOT NULL default '0', " + - "val int(10) unsigned default NULL, PRIMARY KEY (id)) " + - "ENGINE=InnoDB DEFAULT CHARSET=utf8"); - execSQL("CREATE PROCEDURE spTest (IN pp INTEGER) " + - "select * from Test where id > pp "); - - MySqlCommand c = new MySqlCommand("spTest", conn); - c.CommandType = CommandType.StoredProcedure; - IDataParameter p = c.CreateParameter(); - p.ParameterName = "?pp"; - p.Value = 10; - c.Parameters.Add(p); - c.Prepare(); - using (MySqlDataReader reader = c.ExecuteReader()) - { - while (reader.Read()) - { - - } - } - } - - [Test] - public void UnsignedOutputParameters() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE Test (id INT(10) UNSIGNED AUTO_INCREMENT, PRIMARY KEY (id)) "); - execSQL("CREATE PROCEDURE spTest (OUT id BIGINT UNSIGNED) " + - "BEGIN INSERT INTO Test VALUES (NULL); SET id=LAST_INSERT_ID(); END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.Add("?id", MySqlDbType.UInt64); - cmd.Parameters[0].Direction = ParameterDirection.Output; - cmd.ExecuteNonQuery(); - - object o = cmd.Parameters[0].Value; - Assert.IsTrue(o is ulong); - Assert.AreEqual(1, o); - } - -#if !CF - - /// - /// Bug #22452 MySql.Data.MySqlClient.MySqlException: - /// - [Test] - public void TurkishStoredProcs() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest(IN p_paramname INT) BEGIN SELECT p_paramname; END"); - CultureInfo uiCulture = Thread.CurrentThread.CurrentUICulture; - CultureInfo culture = Thread.CurrentThread.CurrentCulture; - Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); - Thread.CurrentThread.CurrentUICulture = new CultureInfo("tr-TR"); - - try - { - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.Parameters.AddWithValue("?p_paramname", 2); - cmd.CommandType = CommandType.StoredProcedure; - cmd.ExecuteScalar(); - } - finally - { - Thread.CurrentThread.CurrentCulture = culture; - Thread.CurrentThread.CurrentUICulture = uiCulture; - } - } - -#endif - - /// - /// Bug #23268 System.FormatException when invoking procedure with ENUM input parameter - /// - [Test] - public void ProcEnumParamTest() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE Test(str VARCHAR(50), e ENUM ('P','R','F','E'), i INT(6))"); - execSQL("CREATE PROCEDURE spTest(IN p_enum ENUM('P','R','F','E')) BEGIN " + - "INSERT INTO Test (str, e, i) VALUES (null, p_enum, 55); END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?p_enum", "P"); - cmd.Parameters["?p_enum"].Direction = ParameterDirection.Input; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - } - cmd.CommandText = "SELECT e FROM Test"; - cmd.CommandType = CommandType.Text; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual("P", reader.GetString(0)); - } - } - - /// - /// Bug #25625 Crashes when calling with CommandType set to StoredProcedure - /// - [Test] - public void RunWithoutSelectPrivsThrowException() - { - if (Version < new Version(5, 0)) return; - - // we don't want this test to run in our all access fixture - string connInfo = GetConnectionInfo(); - if (connInfo.IndexOf("use procedure bodies=false") == -1) - return; - - suExecSQL(String.Format( - "GRANT ALL ON `{0}`.* to 'testuser'@'%' identified by 'testuser'", - database0)); - suExecSQL(String.Format( - "GRANT ALL ON `{0}`.* to 'testuser'@'localhost' identified by 'testuser'", - database0)); - - execSQL("DROP PROCEDURE IF EXISTS spTest"); - execSQL("CREATE PROCEDURE spTest(id int, OUT outid int, INOUT inoutid int) " + - "BEGIN SET outid=id+inoutid; SET inoutid=inoutid+id; END"); - - string s = GetConnectionString("testuser", "testuser", true); - MySqlConnection c = new MySqlConnection(s); - c.Open(); - - try - { - - MySqlCommand cmd = new MySqlCommand("spTest", c); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?id", 2); - cmd.Parameters.AddWithValue("?outid", MySqlDbType.Int32); - cmd.Parameters[1].Direction = ParameterDirection.Output; - cmd.Parameters.AddWithValue("?inoutid", 4); - cmd.Parameters[2].Direction = ParameterDirection.InputOutput; - cmd.ExecuteNonQuery(); - - Assert.AreEqual(6, cmd.Parameters[1].Value); - Assert.AreEqual(6, cmd.Parameters[2].Value); - } - catch (InvalidOperationException iex) - { - Assert.IsTrue(iex.Message.StartsWith("Unable to retrieve")); - } - finally - { - if (c != null) - c.Close(); - suExecSQL("DELETE FROM mysql.user WHERE user = 'testuser'"); - } - } - - [Test] - public void CallingFunctionWithoutReturnParameter() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE FUNCTION fnTest (p_kiosk bigint(20), " + - "p_user bigint(20)) returns double begin declare v_return double; " + - "set v_return = 3.6; return v_return; end"); - - MySqlCommand cmd = new MySqlCommand("fnTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?p_kiosk", 2); - cmd.Parameters.AddWithValue("?p_user", 4); - cmd.ExecuteNonQuery(); - Assert.AreEqual(2, cmd.Parameters.Count); - } - - /// - /// Bug #25609 MySqlDataAdapter.FillSchema - /// - [Test] - public void GetSchema() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest() BEGIN SELECT * FROM Test; END"); - execSQL(@"CREATE TABLE Test(id INT AUTO_INCREMENT, name VARCHAR(20), PRIMARY KEY (id)) "); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - - MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly); - reader.Read(); - reader.Close(); - - MySqlDataAdapter da = new MySqlDataAdapter(cmd); - DataTable schema = new DataTable(); - da.FillSchema(schema, SchemaType.Source); - Assert.AreEqual(2, schema.Columns.Count); - } - - /// - /// Bug #27668 FillSchema and Stored Proc with an out parameter - /// - [Test] - public void GetSchema2() - { - if (Version.Major < 5) return; - - execSQL(@"CREATE TABLE Test(id INT AUTO_INCREMENT, PRIMARY KEY (id)) "); - execSQL(@"CREATE PROCEDURE spTest (OUT id INT) - BEGIN INSERT INTO Test VALUES (NULL); SET id=520; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.Add("?id", MySqlDbType.Int32); - cmd.Parameters[0].Direction = ParameterDirection.Output; - MySqlDataAdapter da = new MySqlDataAdapter(cmd); - DataTable dt = new DataTable(); - cmd.ExecuteNonQuery(); - da.Fill(dt); - da.FillSchema(dt, SchemaType.Mapped); - } - - /// - /// Bug #26139 MySqlCommand.LastInsertedId doesn't work for stored procedures - /// Currently this is borked on the server so we are marking this as notworking - /// until the server has this fixed. - /// - /* [Test] - public void LastInsertId() - { - execSQL("CREATE TABLE Test (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(200))"); - execSQL("INSERT INTO Test VALUES (NULL, 'Test1')"); - execSQL("CREATE PROCEDURE spTest() BEGIN " + - "INSERT INTO Test VALUES (NULL, 'test'); END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.ExecuteNonQuery(); - Assert.AreEqual(2, cmd.LastInsertedId); - } - */ - [Test] - public void NoAccessToProcedureBodies() - { - if (Version < new Version(5, 0)) return; - - string sql = String.Format("CREATE PROCEDURE `{0}`.`spTest`(in1 INT, INOUT inout1 INT, OUT out1 INT ) " + - "BEGIN SET inout1 = inout1+2; SET out1=inout1-3; SELECT in1; END", database0); - execSQL(sql); - - string connStr = GetConnectionString(true) + "; use procedure bodies=false"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("spTest", c); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?in1", 2); - cmd.Parameters.AddWithValue("?inout1", 4); - cmd.Parameters.Add("?out1", MySqlDbType.Int32); - cmd.Parameters[1].Direction = ParameterDirection.InputOutput; - cmd.Parameters[2].Direction = ParameterDirection.Output; - cmd.ExecuteNonQuery(); - - Assert.AreEqual(6, cmd.Parameters[1].Value); - Assert.AreEqual(3, cmd.Parameters[2].Value); - } - } - - [Test] - public void BinaryAndVarBinaryParameters() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest(OUT out1 BINARY(20), OUT out2 VARBINARY(20)) " + - "BEGIN SET out1 = 'out1'; SET out2='out2'; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.Add("out1", MySqlDbType.Binary); - cmd.Parameters[0].Direction = ParameterDirection.Output; - cmd.Parameters.Add("out2", MySqlDbType.VarBinary); - cmd.Parameters[1].Direction = ParameterDirection.Output; - cmd.ExecuteNonQuery(); - - byte[] out1 = (byte[])cmd.Parameters[0].Value; - Assert.AreEqual('o', out1[0]); - Assert.AreEqual('u', out1[1]); - Assert.AreEqual('t', out1[2]); - Assert.AreEqual('1', out1[3]); - - out1 = (byte[])cmd.Parameters[1].Value; - Assert.AreEqual('o', out1[0]); - Assert.AreEqual('u', out1[1]); - Assert.AreEqual('t', out1[2]); - Assert.AreEqual('2', out1[3]); - } - - /// - /// Bug #27093 Exception when using large values in IN UInt64 parameters - /// - [Test] - public void UsingUInt64AsParam() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE TABLE Test(f1 bigint(20) unsigned NOT NULL, - PRIMARY KEY(f1)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); - - execSQL(@"CREATE PROCEDURE spTest(in _val bigint unsigned) - BEGIN insert into Test set f1=_val; END"); - - DbCommand cmd = new MySqlCommand(); - cmd.Connection = conn; - cmd.CommandType = CommandType.StoredProcedure; - cmd.CommandText = "spTest"; - DbParameter param = cmd.CreateParameter(); - param.DbType = DbType.UInt64; - param.Direction = ParameterDirection.Input; - param.ParameterName = "?_val"; - ulong bigval = long.MaxValue; - bigval += 1000; - param.Value = bigval; - cmd.Parameters.Add(param); - cmd.ExecuteNonQuery(); - } - - /// - /// Bug #29526 syntax error: "show create procedure" with catalog names containing hyphens - /// - [Test] - public void CatalogWithHyphens() - { - if (Version < new Version(5, 0)) return; - - // make sure this test is valid - Assert.IsTrue(database0.IndexOf('-') != -1); - - MySqlCommand cmd = new MySqlCommand("CREATE PROCEDURE spTest() BEGIN SELECT 1; END", conn); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "spTest"; - cmd.CommandType = CommandType.StoredProcedure; - Assert.AreEqual(1, cmd.ExecuteScalar()); - } - - [Test] - public void ComplexDefinition() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE PROCEDURE `spTest`() NOT DETERMINISTIC - CONTAINS SQL SQL SECURITY DEFINER COMMENT '' - BEGIN - SELECT 1,2,3; - END"); - MySqlCommand command = new MySqlCommand("spTest", conn); - command.CommandType = CommandType.StoredProcedure; - using (MySqlDataReader reader = command.ExecuteReader()) - { - } - } - - [Test] - public void AmbiguousColumns() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE t1 (id INT)"); - execSQL("CREATE TABLE t2 (id1 INT, id INT)"); - execSQL(@"CREATE PROCEDURE spTest() BEGIN SELECT * FROM t1; - SELECT id FROM t1 JOIN t2 on t1.id=t2.id; - SELECT * FROM t2; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.CommandTimeout = 0; - MySqlDataAdapter da = new MySqlDataAdapter(cmd); - DataSet ds = new DataSet(); - try - { - da.Fill(ds); - Assert.Fail("The above should have thrown an exception"); - } - catch (Exception) - { - } - } - - /// - /// Bug #31930 Stored procedures with "ambiguous column name" error cause lock-ups - /// - [Test] - public void CallingFunction() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE FUNCTION `GetSupplierBalance`(SupplierID_ INTEGER(11)) - RETURNS double NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER - COMMENT '' - BEGIN - RETURN 1.0; - END"); - - MySqlCommand command = new MySqlCommand("GetSupplierBalance", conn); - command.CommandType = CommandType.StoredProcedure; - command.Parameters.Add("?SupplierID_", MySqlDbType.Int32).Value = 1; - command.Parameters.Add("?Balance", MySqlDbType.Double).Direction = ParameterDirection.ReturnValue; - command.ExecuteNonQuery(); - double balance = Convert.ToDouble(command.Parameters["?Balance"].Value); - Assert.AreEqual(1.0, balance); - } - - /// - /// - [Test] - public void OutputParametersWithNewParamHandling() - { - if (Version < new Version(5, 0)) return; - - // create our procedure - execSQL("CREATE PROCEDURE spTest(out val1 VARCHAR(350)) " + - "BEGIN SET val1 = '42'; END"); - - string connStr = GetConnectionString(true); - connStr = connStr.Replace("allow user variables=true", "allow user variables=false"); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("spTest", c); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.Add(new MySqlParameter("@val1", MySqlDbType.VarChar)).Direction = ParameterDirection.Output; - int rowsAffected = cmd.ExecuteNonQuery(); - - Assert.AreEqual(0, rowsAffected); - Assert.AreEqual("42", cmd.Parameters[0].Value); - } - } - - /// - /// - [Test] - public void FunctionWithNewParamHandling() - { - if (Version < new Version(5, 0)) return; - - // create our procedure - execSQL("CREATE FUNCTION spTest(`value` INT) RETURNS INT " + - "BEGIN RETURN value; END"); - - string connStr = GetConnectionString(true); - connStr = connStr.Replace("allow user variables=true", "allow user variables=false"); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("spTest", c); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.Add(new MySqlParameter("@value", MySqlDbType.Int32)).Value = 22; - cmd.Parameters.Add(new MySqlParameter("@returnvalue", MySqlDbType.Int32)).Direction = ParameterDirection.ReturnValue; - int rowsAffected = cmd.ExecuteNonQuery(); - - Assert.AreEqual(0, rowsAffected); - Assert.AreEqual(22, cmd.Parameters[1].Value); - } - } - - /// - /// Bug #41034 .net parameter not found in the collection - /// - [Test] - public void SPWithSpaceInParameterType() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest(myparam decimal (8,2)) BEGIN SELECT 1; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.Parameters.Add("@myparam", MySqlDbType.Decimal).Value = 20; - cmd.CommandType = CommandType.StoredProcedure; - object o = cmd.ExecuteScalar(); - Assert.AreEqual(1, o); - } - - private void ParametersInReverseOrderInternal(bool isOwner) - { - if (Version.Major < 5) return; - - execSQL(@"CREATE PROCEDURE spTest(IN p_1 VARCHAR(5), IN p_2 VARCHAR(5)) - BEGIN SELECT p_1 AS P1, p_2 AS P2; END"); - string spName = "spTest"; - - string connStr = GetConnectionString(true); - if (!isOwner) - connStr += ";use procedure bodies=false"; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - - MySqlCommand cmd = new MySqlCommand(spName, c); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("?p_2", ("World")); - cmd.Parameters[0].DbType = DbType.AnsiString; - cmd.Parameters[0].Direction = ParameterDirection.Input; - cmd.Parameters.AddWithValue("?p_1", ("Hello")); - cmd.Parameters[1].DbType = DbType.AnsiString; - cmd.Parameters[1].Direction = ParameterDirection.Input; - MySqlDataAdapter da = new MySqlDataAdapter(cmd); - DataTable dt = new DataTable(); - da.Fill(dt); - string s = GetConnectionString(true); - if (!isOwner) - { - Assert.AreEqual("World", dt.Rows[0][0]); - Assert.AreEqual("Hello", dt.Rows[0][1]); - } - else - { - Assert.AreEqual("Hello", dt.Rows[0]["P1"]); - Assert.AreEqual("World", dt.Rows[0]["P2"]); - } - } - } - - [Test] - public void ParametersInReverseOrderNotOwner() - { - ParametersInReverseOrderInternal(false); - } - - [Test] - public void ParametersInReverseOrderOwner() - { - ParametersInReverseOrderInternal(true); - } - - [Test] - public void DeriveParameters() - { - if (Version < new Version(5, 0)) return; - if (Version > new Version(6, 0, 6)) return; - - execSQL(@"CREATE PROCEDURE spTest (id INT, name VARCHAR(20)) - BEGIN SELECT name; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - MySqlCommandBuilder.DeriveParameters(cmd); - Assert.AreEqual(2, cmd.Parameters.Count); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StoredProcedureWithAccess.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StoredProcedureWithAccess.cs deleted file mode 100644 index 31664f3..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StoredProcedureWithAccess.cs +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using MySql.Data.MySqlClient; -using NUnit.Framework; -using System.Globalization; -using System.Threading; -using MySql.Data.Types; -using System.Data.Common; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class StoredProcedureAccess : StoredProcedure - { - public override void Setup() - { - accessToMySqlDb = true; - base.Setup(); - } - - /// - /// Bug #40139 ExecuteNonQuery hangs - /// - [Test] - public void CallingStoredProcWithOnlyExecPrivs() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest() BEGIN SELECT 1; END"); - execSQL("CREATE PROCEDURE spTest2() BEGIN SELECT 1; END"); - suExecSQL("CREATE USER abc IDENTIFIED BY 'abc'"); - try - { - suExecSQL(String.Format("GRANT SELECT ON `{0}`.* TO 'abc'@'%'", database0)); - suExecSQL(String.Format("GRANT EXECUTE ON PROCEDURE `{0}`.spTest TO abc", database0)); - - string connStr = GetConnectionString("abc", "abc", true); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - MySqlCommand cmd = new MySqlCommand("spTest", c); - cmd.CommandType = CommandType.StoredProcedure; - object o = cmd.ExecuteScalar(); - - try - { - cmd.CommandText = "spTest2"; - cmd.ExecuteScalar(); - } - catch (MySqlException ex) - { - string s = ex.Message; - } - } - } - finally - { - suExecSQL("DROP USER abc"); - } - } - - [Test] - public void ProcedureParameters() - { - if (Version < new Version(5, 0)) return; - - execSQL("DROP PROCEDURE IF EXISTS spTest"); - execSQL("CREATE PROCEDURE spTest (id int, name varchar(50)) BEGIN SELECT 1; END"); - - string[] restrictions = new string[5]; - restrictions[1] = database0; - restrictions[2] = "spTest"; - DataTable dt = conn.GetSchema("Procedure Parameters", restrictions); - Assert.IsTrue(dt.Rows.Count == 2); - Assert.AreEqual("Procedure Parameters", dt.TableName); - Assert.AreEqual(database0.ToLower(), dt.Rows[0]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[0]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("id", dt.Rows[0]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(1, dt.Rows[0]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[0]["PARAMETER_MODE"]); - - restrictions[4] = "name"; - dt.Clear(); - dt = conn.GetSchema("Procedure Parameters", restrictions); - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(database0.ToLower(), dt.Rows[0]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("sptest", dt.Rows[0]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("name", dt.Rows[0]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(2, dt.Rows[0]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[0]["PARAMETER_MODE"]); - - execSQL("DROP FUNCTION IF EXISTS spFunc"); - execSQL("CREATE FUNCTION spFunc (id int) RETURNS INT BEGIN RETURN 1; END"); - - restrictions[4] = null; - restrictions[1] = database0; - restrictions[2] = "spFunc"; - dt = conn.GetSchema("Procedure Parameters", restrictions); - Assert.IsTrue(dt.Rows.Count == 2); - Assert.AreEqual("Procedure Parameters", dt.TableName); - Assert.AreEqual(database0.ToLower(), dt.Rows[0]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("spfunc", dt.Rows[0]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual(0, dt.Rows[0]["ORDINAL_POSITION"]); - - Assert.AreEqual(database0.ToLower(), dt.Rows[1]["SPECIFIC_SCHEMA"].ToString().ToLower()); - Assert.AreEqual("spfunc", dt.Rows[1]["SPECIFIC_NAME"].ToString().ToLower()); - Assert.AreEqual("id", dt.Rows[1]["PARAMETER_NAME"].ToString().ToLower()); - Assert.AreEqual(1, dt.Rows[1]["ORDINAL_POSITION"]); - Assert.AreEqual("IN", dt.Rows[1]["PARAMETER_MODE"]); - } - - [Test] - public void SingleProcedureParameters() - { - if (Version < new Version(5, 0)) return; - - execSQL("DROP PROCEDURE IF EXISTS spTest"); - execSQL("CREATE PROCEDURE spTest(id int, IN id2 INT(11), " + - "INOUT io1 VARCHAR(20), OUT out1 FLOAT) BEGIN END"); - string[] restrictions = new string[4]; - restrictions[1] = database0; - restrictions[2] = "spTest"; - DataTable procs = conn.GetSchema("PROCEDURES", restrictions); - Assert.AreEqual(1, procs.Rows.Count); - Assert.AreEqual("spTest", procs.Rows[0][0]); - Assert.AreEqual(database0.ToLower(), procs.Rows[0][2].ToString().ToLower(CultureInfo.InvariantCulture)); - Assert.AreEqual("spTest", procs.Rows[0][3]); - - DataTable parameters = conn.GetSchema("PROCEDURE PARAMETERS", restrictions); - Assert.AreEqual(4, parameters.Rows.Count); - - DataRow row = parameters.Rows[0]; - Assert.AreEqual(database0.ToLower(CultureInfo.InvariantCulture), - row["SPECIFIC_SCHEMA"].ToString().ToLower(CultureInfo.InvariantCulture)); - Assert.AreEqual("spTest", row["SPECIFIC_NAME"]); - Assert.AreEqual(1, row["ORDINAL_POSITION"]); - Assert.AreEqual("IN", row["PARAMETER_MODE"]); - Assert.AreEqual("id", row["PARAMETER_NAME"]); - Assert.AreEqual("INT", row["DATA_TYPE"].ToString().ToUpper(CultureInfo.InvariantCulture)); - - row = parameters.Rows[1]; - Assert.AreEqual(database0.ToLower(CultureInfo.InvariantCulture), row["SPECIFIC_SCHEMA"].ToString().ToLower(CultureInfo.InvariantCulture)); - Assert.AreEqual("spTest", row["SPECIFIC_NAME"]); - Assert.AreEqual(2, row["ORDINAL_POSITION"]); - Assert.AreEqual("IN", row["PARAMETER_MODE"]); - Assert.AreEqual("id2", row["PARAMETER_NAME"]); - Assert.AreEqual("INT", row["DATA_TYPE"].ToString().ToUpper(CultureInfo.InvariantCulture)); - - row = parameters.Rows[2]; - Assert.AreEqual(database0.ToLower(CultureInfo.InvariantCulture), row["SPECIFIC_SCHEMA"].ToString().ToLower(CultureInfo.InvariantCulture)); - Assert.AreEqual("spTest", row["SPECIFIC_NAME"]); - Assert.AreEqual(3, row["ORDINAL_POSITION"]); - Assert.AreEqual("INOUT", row["PARAMETER_MODE"]); - Assert.AreEqual("io1", row["PARAMETER_NAME"]); - Assert.AreEqual("VARCHAR", row["DATA_TYPE"].ToString().ToUpper(CultureInfo.InvariantCulture)); - - row = parameters.Rows[3]; - Assert.AreEqual(database0.ToLower(CultureInfo.InvariantCulture), row["SPECIFIC_SCHEMA"].ToString().ToLower(CultureInfo.InvariantCulture)); - Assert.AreEqual("spTest", row["SPECIFIC_NAME"]); - Assert.AreEqual(4, row["ORDINAL_POSITION"]); - Assert.AreEqual("OUT", row["PARAMETER_MODE"]); - Assert.AreEqual("out1", row["PARAMETER_NAME"]); - Assert.AreEqual("FLOAT", row["DATA_TYPE"].ToString().ToUpper(CultureInfo.InvariantCulture)); - } - - /// - /// Bug #27679 MySqlCommandBuilder.DeriveParameters ignores UNSIGNED flag - /// - [Test] - public void UnsignedParametersInSP() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE PROCEDURE spTest(testid TINYINT UNSIGNED) BEGIN SELECT testid; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - MySqlCommandBuilder.DeriveParameters(cmd); - Assert.AreEqual(MySqlDbType.UByte, cmd.Parameters[0].MySqlDbType); - Assert.AreEqual(DbType.Byte, cmd.Parameters[0].DbType); - } - - [Test] - public void CheckNameOfReturnParameter() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE FUNCTION fnTest() RETURNS CHAR(50)" + - " LANGUAGE SQL DETERMINISTIC BEGIN RETURN \"Test\"; END"); - - MySqlCommand cmd = new MySqlCommand("fnTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - MySqlCommandBuilder.DeriveParameters(cmd); - Assert.AreEqual(1, cmd.Parameters.Count); - Assert.AreEqual("@RETURN_VALUE", cmd.Parameters[0].ParameterName); - } - - /// - /// Bug #13632 the MySQLCommandBuilder.deriveparameters has not been updated for MySQL 5 - /// Bug #15077 Error MySqlCommandBuilder.DeriveParameters for sp without parameters. - /// Bug #19515 DiscoverParameters fails on numeric datatype - /// - [Test] - public void DeriveParameters() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE test2 (c CHAR(20))"); - execSQL("INSERT INTO test2 values ( 'xxxx')"); - MySqlCommand cmd2 = new MySqlCommand("SELECT * FROM test2", conn); - using (MySqlDataReader reader = cmd2.ExecuteReader()) - { - } - - execSQL("CREATE PROCEDURE spTest(IN \r\nvalin DECIMAL(10,2), " + - "\nIN val2 INT, INOUT val3 FLOAT, OUT val4 DOUBLE, INOUT val5 BIT, " + - "val6 VARCHAR(155), val7 SET('a','b'), val8 CHAR, val9 NUMERIC(10,2)) " + - "BEGIN SELECT 1; END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - MySqlCommandBuilder.DeriveParameters(cmd); - - Assert.AreEqual(9, cmd.Parameters.Count); - Assert.AreEqual("@valin", cmd.Parameters[0].ParameterName); - Assert.AreEqual(ParameterDirection.Input, cmd.Parameters[0].Direction); - Assert.AreEqual(MySqlDbType.NewDecimal, cmd.Parameters[0].MySqlDbType); - - Assert.AreEqual("@val2", cmd.Parameters[1].ParameterName); - Assert.AreEqual(ParameterDirection.Input, cmd.Parameters[1].Direction); - Assert.AreEqual(MySqlDbType.Int32, cmd.Parameters[1].MySqlDbType); - - Assert.AreEqual("@val3", cmd.Parameters[2].ParameterName); - Assert.AreEqual(ParameterDirection.InputOutput, cmd.Parameters[2].Direction); - Assert.AreEqual(MySqlDbType.Float, cmd.Parameters[2].MySqlDbType); - - Assert.AreEqual("@val4", cmd.Parameters[3].ParameterName); - Assert.AreEqual(ParameterDirection.Output, cmd.Parameters[3].Direction); - Assert.AreEqual(MySqlDbType.Double, cmd.Parameters[3].MySqlDbType); - - Assert.AreEqual("@val5", cmd.Parameters[4].ParameterName); - Assert.AreEqual(ParameterDirection.InputOutput, cmd.Parameters[4].Direction); - Assert.AreEqual(MySqlDbType.Bit, cmd.Parameters[4].MySqlDbType); - - Assert.AreEqual("@val6", cmd.Parameters[5].ParameterName); - Assert.AreEqual(ParameterDirection.Input, cmd.Parameters[5].Direction); - Assert.AreEqual(MySqlDbType.VarChar, cmd.Parameters[5].MySqlDbType); - - Assert.AreEqual("@val7", cmd.Parameters[6].ParameterName); - Assert.AreEqual(ParameterDirection.Input, cmd.Parameters[6].Direction); - Assert.AreEqual(MySqlDbType.Set, cmd.Parameters[6].MySqlDbType); - - Assert.AreEqual("@val8", cmd.Parameters[7].ParameterName); - Assert.AreEqual(ParameterDirection.Input, cmd.Parameters[7].Direction); - Assert.AreEqual(MySqlDbType.String, cmd.Parameters[7].MySqlDbType); - - Assert.AreEqual("@val9", cmd.Parameters[8].ParameterName); - Assert.AreEqual(ParameterDirection.Input, cmd.Parameters[8].Direction); - Assert.AreEqual(MySqlDbType.NewDecimal, cmd.Parameters[8].MySqlDbType); - - execSQL("DROP PROCEDURE spTest"); - execSQL("CREATE PROCEDURE spTest() BEGIN END"); - cmd.CommandText = "spTest"; - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.Clear(); - MySqlCommandBuilder.DeriveParameters(cmd); - Assert.AreEqual(0, cmd.Parameters.Count); - } - - /// - /// Bug #13632 the MySQLCommandBuilder.deriveparameters has not been updated for MySQL 5 - /// - [Test] - public void DeriveParametersForFunction() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE FUNCTION fnTest(v1 DATETIME) RETURNS INT " + - " LANGUAGE SQL DETERMINISTIC BEGIN RETURN 1; END"); - - MySqlCommand cmd = new MySqlCommand("fnTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - MySqlCommandBuilder.DeriveParameters(cmd); - - Assert.AreEqual(2, cmd.Parameters.Count); - Assert.AreEqual("@v1", cmd.Parameters[1].ParameterName); - Assert.AreEqual(ParameterDirection.Input, cmd.Parameters[1].Direction); - Assert.AreEqual(MySqlDbType.DateTime, cmd.Parameters[1].MySqlDbType); - - Assert.AreEqual(ParameterDirection.ReturnValue, cmd.Parameters[0].Direction); - Assert.AreEqual(MySqlDbType.Int32, cmd.Parameters[0].MySqlDbType); - } - - /// - /// Bug #49642 FormatException when returning empty string from a stored function - /// - [Test] - public void NotSpecifyingDataTypeOfReturnValue() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE FUNCTION `TestFunction`() - RETURNS varchar(20) - RETURN ''"); - MySqlCommand cmd = new MySqlCommand("TestFunction", conn); - cmd.CommandType = CommandType.StoredProcedure; - MySqlParameter returnParam = new MySqlParameter(); - returnParam.ParameterName = "?RetVal_"; - returnParam.Direction = ParameterDirection.ReturnValue; - cmd.Parameters.Add(returnParam); - cmd.ExecuteNonQuery(); - } - - /// - /// Bug #50123 Batch updates bug when UpdateBatchSize > 1 - /// Bug #50444 Parameters.Clear() not working - /// - [Test] - public void UpdateBatchSizeMoreThanOne() - { - execSQL("DROP TABLE IF EXISTS test"); - execSQL(@"CREATE TABLE test(fldID INT NOT NULL, - fldValue VARCHAR(50) NOT NULL, PRIMARY KEY(fldID))"); - - MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM test", conn); - DataTable data = new DataTable(); - adapter.Fill(data); - - MySqlCommand ins = new MySqlCommand( - "INSERT INTO test(fldID, fldValue) VALUES (?p1, ?p2)", conn); - ins.Parameters.Add("p1", MySqlDbType.Int32).SourceColumn = "fldID"; - ins.Parameters.Add("p2", MySqlDbType.String).SourceColumn = "fldValue"; - - ins.UpdatedRowSource = UpdateRowSource.None; - adapter.InsertCommand = ins; - adapter.UpdateBatchSize = 10; - - int numToInsert = 20; - for (int i = 0; i < numToInsert; i++) - { - DataRow row = data.NewRow(); - row["fldID"] = i + 1; - row["fldValue"] = "ID = " + (i + 1); - data.Rows.Add(row); - } - Assert.AreEqual(numToInsert, adapter.Update(data)); - - //UPDATE VIA SP - MySqlCommand comm = new MySqlCommand("DROP PROCEDURE IF EXISTS pbug50123", conn); - comm.ExecuteNonQuery(); - comm.CommandText = "CREATE PROCEDURE pbug50123(" + - "IN pfldID INT, IN pfldValue VARCHAR(50)) " + - "BEGIN INSERT INTO test(fldID, fldValue) " + - "VALUES(pfldID, pfldValue); END"; - comm.ExecuteNonQuery(); - - // Set the Insert Command - ins.Parameters.Clear(); - ins.CommandText = "pbug50123"; - ins.CommandType = CommandType.StoredProcedure; - ins.Parameters.Add("pfldID", MySqlDbType.Int32).SourceColumn = "fldID"; - ins.Parameters.Add("pfldValue", MySqlDbType.String).SourceColumn = "fldValue"; - ins.UpdatedRowSource = UpdateRowSource.None; - - for (int i = 21; i < 41; i++) - { - DataRow row = data.NewRow(); - row["fldID"] = i + 1; - row["fldValue"] = "ID = " + (i + 1); - data.Rows.Add(row); - } - // Do the update - Assert.AreEqual(numToInsert, adapter.Update(data)); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StressTests.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StressTests.cs deleted file mode 100644 index f75c0a2..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/StressTests.cs +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using MySql.Data.MySqlClient; -using System.Data; -using NUnit.Framework; -using System.Threading; -using System.Collections; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for ConnectionTests. - /// - [TestFixture] - public class StressTests : BaseTest - { - public override void Setup() - { - base.Setup(); - execSQL("CREATE TABLE Test (id INT NOT NULL, name varchar(100), blob1 LONGBLOB, text1 TEXT, " + - "PRIMARY KEY(id))"); - } - -#if !CF - - [Test] - public void TestMultiPacket() - { - int len = 20000000; - - suExecSQL("SET GLOBAL max_allowed_packet=64000000"); - - // currently do not test this with compression - if (conn.UseCompression) return; - - using (MySqlConnection c = new MySqlConnection(GetConnectionString(true))) - { - c.Open(); - byte[] dataIn = Utils.CreateBlob(len); - byte[] dataIn2 = Utils.CreateBlob(len); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, NULL, ?blob, NULL )", c); - cmd.CommandTimeout = 0; - cmd.Parameters.Add(new MySqlParameter("?id", 1)); - cmd.Parameters.Add(new MySqlParameter("?blob", dataIn)); - cmd.ExecuteNonQuery(); - - cmd.Parameters[0].Value = 2; - cmd.Parameters[1].Value = dataIn2; - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - byte[] dataOut = new byte[len]; - long count = reader.GetBytes(2, 0, dataOut, 0, len); - Assert.AreEqual(len, count); - int i = 0; - try - { - for (; i < len; i++) - Assert.AreEqual(dataIn[i], dataOut[i]); - } - catch (Exception) - { - int z = i; - } - - reader.Read(); - count = reader.GetBytes(2, 0, dataOut, 0, len); - Assert.AreEqual(len, count); - - for (int x=0; x < len; x++) - Assert.AreEqual(dataIn2[x], dataOut[x]); - } - } - } - -#endif - - [Test] - public void TestSequence() - { - MySqlCommand cmd = new MySqlCommand("insert into Test (id, name) values (?id, 'test')", conn); - cmd.Parameters.Add( new MySqlParameter("?id", 1)); - - for (int i=1; i <= 8000; i++) - { - cmd.Parameters[0].Value = i; - cmd.ExecuteNonQuery(); - } - - int i2 = 0; - cmd = new MySqlCommand("select * from Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - Assert.AreEqual( i2+1, reader.GetInt32(0), "Sequence out of order" ); - i2++; - } - reader.Close(); - - Assert.AreEqual( 8000, i2 ); - cmd = new MySqlCommand("delete from Test where id >= 100", conn); - cmd.ExecuteNonQuery(); - } - } - } - - #region Configs - -#if !CF - [Category("Compressed")] - public class StressTestsSocketCompressed : StressTests - { - protected override string GetConnectionInfo() - { - return String.Format("port={0};compress=true", port); - } - } - - [Category("Pipe")] - public class StressTestsPipe : StressTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=pipe;pipe name={0}", pipeName); - } - } - - [Category("Compressed")] - [Category("Pipe")] - public class StressTestsPipeCompressed : StressTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=pipe;pipe name={0};compress=true", pipeName); - } - } - - [Category("SharedMemory")] - public class StressTestsSharedMemory : StressTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=memory; shared memory name={0}", memoryName); - } - } - - [Category("Compressed")] - [Category("SharedMemory")] - public class StressTestsSharedMemoryCompressed : StressTests - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=memory; shared memory name={0};compress=true", memoryName); - } - } -#endif - #endregion - -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Syntax.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Syntax.cs deleted file mode 100644 index 92b2e43..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Syntax.cs +++ /dev/null @@ -1,472 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using NUnit.Framework; -using System.Collections; -using System.Collections.Generic; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class Syntax : BaseTest - { - [Test] - public void ShowCreateTable() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - MySqlDataAdapter da = new MySqlDataAdapter("SHOW CREATE TABLE Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - - Assert.AreEqual(1, dt.Rows.Count); - Assert.AreEqual(2, dt.Columns.Count); - } - - [Test] - public void ProblemCharsInSQLUTF8() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), mt MEDIUMTEXT, " + - "PRIMARY KEY(id)) CHAR SET utf8"); - - using (MySqlConnection c = new MySqlConnection(GetConnectionString(true) + ";charset=utf8")) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, ?text, ?mt)", c); - cmd.Parameters.AddWithValue("?id", 1); - cmd.Parameters.AddWithValue("?text", "This is my;test ? string"); - cmd.Parameters.AddWithValue("?mt", "My MT string: ?"); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(1, reader.GetInt32(0)); - Assert.AreEqual("This is my;test ? string", reader.GetString(1)); - Assert.AreEqual("My MT string: ?", reader.GetString(2)); - } - } - } - - - [Test] - public void ProblemCharsInSQL() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), mt MEDIUMTEXT, " + - "PRIMARY KEY(id))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, ?text, ?mt)", conn); - cmd.Parameters.AddWithValue("?id", 1); - cmd.Parameters.AddWithValue("?text", "This is my;test ? string-'''\"\"."); - cmd.Parameters.AddWithValue("?mt", "My MT string: ?"); - cmd.ExecuteNonQuery(); - - cmd.CommandText = "SELECT * FROM Test"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.IsTrue(reader.Read()); - Assert.AreEqual(1, reader.GetInt32(0)); - Assert.AreEqual("This is my;test ? string-'''\"\".", reader.GetString(1)); - Assert.AreEqual("My MT string: ?", reader.GetString(2)); - } - } - - [Test] - public void LoadDataLocalInfile() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - string connString = conn.ConnectionString + ";pooling=false"; - MySqlConnection c = new MySqlConnection(connString); - c.Open(); - - string path = Path.GetTempFileName(); - StreamWriter sw = new StreamWriter(path); - for (int i = 0; i < 2000000; i++) - sw.WriteLine(i + ",'Test'"); - sw.Flush(); - sw.Close(); - - path = path.Replace(@"\", @"\\"); - MySqlCommand cmd = new MySqlCommand( - "LOAD DATA LOCAL INFILE '" + path + "' INTO TABLE Test FIELDS TERMINATED BY ','", conn); - cmd.CommandTimeout = 0; - - object cnt = 0; - cnt = cmd.ExecuteNonQuery(); - Assert.AreEqual(2000000, cnt); - - cmd.CommandText = "SELECT COUNT(*) FROM Test"; - cnt = cmd.ExecuteScalar(); - Assert.AreEqual(2000000, cnt); - - c.Close(); - } - - [Test] - public void ShowTablesInNonExistentDb() - { - MySqlCommand cmd = new MySqlCommand("SHOW TABLES FROM dummy", conn); - try - { - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - Assert.Fail("ExecuteReader should not succeed"); - } - } - catch (MySqlException) - { - Assert.AreEqual(ConnectionState.Open, conn.State); - } - } - - [Test] - public void Bug6135() - { - string sql = @"CREATE TABLE `KLANT` (`KlantNummer` int(11) NOT NULL auto_increment, - `Username` varchar(50) NOT NULL default '', `Password` varchar(100) NOT NULL default '', - `Naam` varchar(100) NOT NULL default '', `Voornaam` varchar(100) NOT NULL default '', - `Straat` varchar(100) NOT NULL default '', `StraatNr` varchar(10) NOT NULL default '', - `Gemeente` varchar(100) NOT NULL default '', `Postcode` varchar(10) NOT NULL default '', - `DefaultMail` varchar(255) default '', `BtwNr` varchar(50) default '', - `ReceiveMail` tinyint(1) NOT NULL default '0', `Online` tinyint(1) NOT NULL default '0', - `LastVisit` timestamp NOT NULL, `Categorie` int(11) NOT NULL default '0', - PRIMARY KEY (`KlantNummer`), UNIQUE KEY `UniqueUsername` (`Username`), - UNIQUE KEY `UniqueDefaultMail` (`DefaultMail`) )"; - createTable(sql, "MyISAM"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM KLANT", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) { } - } - } - - [Test] - public void Sum() - { - execSQL("CREATE TABLE Test (field1 mediumint(9) default '0', field2 float(9,3) " + - "default '0.000', field3 double(15,3) default '0.000') engine=innodb "); - execSQL("INSERT INTO Test values (1,1,1)"); - - MySqlCommand cmd2 = new MySqlCommand("SELECT sum(field2) FROM Test", conn); - using (MySqlDataReader reader = cmd2.ExecuteReader()) - { - reader.Read(); - object o = reader[0]; - Assert.AreEqual(1, o); - } - } - - [Test] - public void Sum2() - { - execSQL("CREATE TABLE Test (id int, count int)"); - execSQL("INSERT INTO Test VALUES (1, 21)"); - execSQL("INSERT INTO Test VALUES (1, 33)"); - execSQL("INSERT INTO Test VALUES (1, 16)"); - execSQL("INSERT INTO Test VALUES (1, 40)"); - - MySqlCommand cmd = new MySqlCommand("SELECT id, SUM(count) FROM Test GROUP BY id", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual( 1, reader.GetInt32(0) ); - Assert.AreEqual( 110, reader.GetDouble(1) ); - } - } - - [Test] - public void ForceWarnings() - { - if (Version < new Version(4, 1)) return; - - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - MySqlCommand cmd = new MySqlCommand( - "SELECT * FROM Test; DROP TABLE IF EXISTS test2; SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.NextResult()) { } - } - } - - [Test] - public void SettingAutoIncrementColumns() - { - execSQL("CREATE TABLE Test (id int auto_increment, name varchar(100), primary key(id))"); - execSQL("INSERT INTO Test VALUES (1, 'One')"); - execSQL("INSERT INTO Test VALUES (3, 'Two')"); - - MySqlCommand cmd = new MySqlCommand("SELECT name FROM Test WHERE id=1", conn); - object name = cmd.ExecuteScalar(); - Assert.AreEqual( "One", name ); - - cmd.CommandText = "SELECT name FROM Test WHERE id=3"; - name = cmd.ExecuteScalar(); - Assert.AreEqual( "Two", name ); - - try - { - execSQL("INSERT INTO Test (id, name2) values (5, 'Three')"); - Assert.Fail( "This should have failed" ); - } - catch (MySqlException) - { - } - } - - /// - /// Bug #16645 FOUND_ROWS() Bug - /// - [Test] - public void FoundRows() - { - execSQL("CREATE TABLE Test (testID int(11) NOT NULL auto_increment, testName varchar(100) default '', " + - "PRIMARY KEY (testID)) ENGINE=InnoDB DEFAULT CHARSET=latin1"); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (NULL, 'test')", conn); - for (int i=0; i < 1000; i++) - cmd.ExecuteNonQuery(); - cmd.CommandText = "SELECT SQL_CALC_FOUND_ROWS * FROM Test LIMIT 0, 10"; - cmd.ExecuteNonQuery(); - cmd.CommandText = "SELECT FOUND_ROWS()"; - object cnt = cmd.ExecuteScalar(); - Assert.AreEqual(1000, cnt); - } - - [Test] - public void AutoIncrement() - { - execSQL("CREATE TABLE Test (testID int(11) NOT NULL auto_increment, testName varchar(100) default '', " + - "PRIMARY KEY (testID)) ENGINE=InnoDB DEFAULT CHARSET=latin1"); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (NULL, 'test')", conn); - cmd.ExecuteNonQuery(); - cmd.CommandText = "SELECT @@IDENTITY as 'Identity'"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - int ident = Int32.Parse(reader.GetValue(0).ToString()); - Assert.AreEqual(1, ident); - } - } - - /// - /// Bug #21521 # Symbols not allowed in column/table names. - /// - [Test] - public void CommentSymbolInTableName() - { - execSQL("CREATE TABLE Test (`PO#` int(11) NOT NULL auto_increment, " + - "`PODate` date default NULL, PRIMARY KEY (`PO#`))"); - execSQL("INSERT INTO Test ( `PO#`, `PODate` ) " + - "VALUES ( NULL, '2006-01-01' )"); - - string sql = "SELECT `PO#` AS PurchaseOrderNumber, " + - "`PODate` AS OrderDate FROM Test"; - MySqlCommand cmd = new MySqlCommand(sql, conn); - MySqlDataAdapter da = new MySqlDataAdapter(cmd); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.AreEqual(1, dt.Rows.Count); - } - - /// - /// Bug #25178 Addition message in error - /// - [Test] - public void ErrorMessage() - { - MySqlCommand cmd = new MySqlCommand("SELEKT NOW() as theTime", conn); - try - { - cmd.ExecuteScalar(); - } - catch (MySqlException ex) - { - string s = ex.Message; - Assert.IsFalse(s.StartsWith("#")); - } - } - - /// - /// Bug #27221 describe SQL command returns all byte array on MySQL versions older than 4.1.15 - /// - [Test] - public void Describe() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - MySqlDataAdapter da = new MySqlDataAdapter("DESCRIBE Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - - Assert.IsTrue(dt.Columns[0].DataType == typeof(string)); - Assert.IsTrue(dt.Columns[1].DataType == typeof(string)); - Assert.IsTrue(dt.Columns[2].DataType == typeof(string)); - Assert.IsTrue(dt.Columns[3].DataType == typeof(string)); - Assert.IsTrue(dt.Columns[4].DataType == typeof(string)); - Assert.IsTrue(dt.Columns[5].DataType == typeof(string)); - } - - [Test] - public void ShowTableStatus() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - MySqlDataAdapter da = new MySqlDataAdapter( - String.Format("SHOW TABLE STATUS FROM `{0}` LIKE 'Test'", - database0), conn); - DataTable dt = new DataTable(); - da.Fill(dt); - - Assert.IsTrue(dt.Rows[0][0].GetType() == typeof(string)); - } - - /// - /// Bug #26960 Connector .NET 5.0.5 / Visual Studio Plugin 1.1.2 - /// - [Test] - public void NullAsAType() - { - MySqlDataAdapter da = new MySqlDataAdapter( - @"SELECT 'localhost' as SERVER_NAME, - null as CATALOG_NAME, database() as SCHEMA_NAME", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - Assert.IsTrue(dt.Rows[0][0].GetType() == typeof(string)); - Assert.AreEqual(DBNull.Value, dt.Rows[0][1]); - Assert.IsTrue(dt.Rows[0][2].GetType() == typeof(string)); - } - - [Test] - public void SpaceInDatabaseName() - { - string dbName = System.IO.Path.GetFileNameWithoutExtension( - System.IO.Path.GetTempFileName()) + " x"; - try - { - suExecSQL(String.Format("CREATE DATABASE `{0}`", dbName)); - suExecSQL(String.Format("GRANT ALL ON `{0}`.* to 'test'@'localhost' identified by 'test'", - dbName)); - suExecSQL(String.Format("GRANT ALL ON `{0}`.* to 'test'@'%' identified by 'test'", - dbName)); - suExecSQL("FLUSH PRIVILEGES"); - - string connStr = GetConnectionString(false) + ";database=" + dbName; - MySqlConnection c = new MySqlConnection(connStr); - c.Open(); - c.Close(); - } - finally - { - suExecSQL(String.Format("DROP DATABASE `{0}`", dbName)); - } - } - - /// - /// Bug #28448 show processlist; returns byte arrays in the resulting data table - /// - [Test] - public void ShowProcessList() - { - string connStr = GetConnectionString(true) + ";respect binary flags=false;"; - MySqlConnection c = new MySqlConnection(connStr); - using (c) - { - c.Open(); - - MySqlCommand cmd = new MySqlCommand("show processlist", c); - DataTable dt = new DataTable(); - - using (MySqlDataReader rdr = cmd.ExecuteReader()) - { - dt.Load(rdr); - } - DataRow row = dt.Rows[0]; - - Assert.IsTrue(row["User"].GetType().Name == "String"); - Assert.IsTrue(row["Host"].GetType().Name == "String"); - Assert.IsTrue(row["Command"].GetType().Name == "String"); - } - } - - [Test] - public void SemisAtStartAndEnd() - { - using (MySqlCommand cmd = new MySqlCommand(";;SELECT 1;;;", conn)) - { - Assert.AreEqual(1, cmd.ExecuteScalar()); - } - } - - /// - /// Bug #51610 Exception thrown inside Connector.NET - /// - [Test] - public void Bug51610() - { - MySqlCommand cmd = new MySqlCommand("SELECT 'ABC', (0/`QOH`) from (SELECT 1 as `QOH`) `d1`", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual("ABC", reader.GetString(0)); - Assert.AreEqual(0, reader.GetInt32(1)); - } - - cmd.CommandText = "SELECT 'ABC', (0-`QOH`) from (SELECT 1 as `QOH`) `d1`"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual("ABC", reader.GetString(0)); - Assert.AreEqual(-1, reader.GetInt32(1)); - } - - cmd.CommandText = "SELECT 'test 2010-03-04 @ 10:14'"; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - Assert.AreEqual("test 2010-03-04 @ 10:14", reader.GetString(0)); - } - - } - - /// - /// Bug #51788 Error in SQL syntax not reported. A CLR exception was thrown instead, - /// - [Test] - public void NonTerminatedString() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test(id INT, name1 VARCHAR(20), name2 VARCHAR(20))"); - - try - { - MySqlCommand cmd = new MySqlCommand( - "INSERT INTO test VALUES (1, 'test 2010-03-04 @ 10:14, name2=' joe')", conn); - cmd.ExecuteNonQuery(); - } - catch (MySqlException) - { - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Syntax2.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Syntax2.cs deleted file mode 100644 index d1d57dc..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Syntax2.cs +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class Syntax2 : BaseTest - { - [Test] - public void CommentsInSQL() - { - execSQL("CREATE TABLE Test (id INT NOT NULL, name VARCHAR(250), PRIMARY KEY(id))"); - string sql = "INSERT INTO Test /* my table */ VALUES (1 /* this is the id */, 'Test' );" + - "/* These next inserts are just for testing \r\n" + - " comments */\r\n" + - "INSERT INTO \r\n" + - " # This table is bogus\r\n" + - "Test VALUES (2, 'Test2')"; - MySqlCommand cmd = new MySqlCommand(sql, conn); - cmd.ExecuteNonQuery(); - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable table = new DataTable(); - da.Fill(table); - Assert.AreEqual(1, table.Rows[0]["id"]); - Assert.AreEqual("Test", table.Rows[0]["name"]); - Assert.AreEqual(2, table.Rows.Count); - Assert.AreEqual(2, table.Rows[1]["id"]); - Assert.AreEqual("Test2", table.Rows[1]["name"]); - } - - [Test] - public void LastInsertid() - { - execSQL("CREATE TABLE Test(id int auto_increment, name varchar(20), primary key(id))"); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES(NULL, 'test')", conn); - cmd.ExecuteNonQuery(); - Assert.AreEqual(1, cmd.LastInsertedId); - - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - } - Assert.AreEqual(2, cmd.LastInsertedId); - - cmd.CommandText = "SELECT id FROM Test"; - cmd.ExecuteScalar(); - Assert.AreEqual(-1, cmd.LastInsertedId); - } - - [Test] - public void ParsingBugTest() - { - if (Version.Major < 5) return; - - execSQL("DROP FUNCTION IF EXISTS `TestFunction`"); - execSQL(@"CREATE FUNCTION `TestFunction`(A INTEGER (11), B INTEGER (11), C VARCHAR (20)) - RETURNS int(11) - RETURN 1"); - - MySqlCommand command = new MySqlCommand("TestFunction", conn); - command.CommandType = CommandType.StoredProcedure; - command.CommandText = "TestFunction"; - command.Parameters.AddWithValue("@A", 1); - command.Parameters.AddWithValue("@B", 2); - command.Parameters.AddWithValue("@C", "test"); - command.ExecuteNonQuery(); - } - - /// - /// Bug #44960 backslash in string - connector return exeption - /// - [Test] - public void EscapedBackslash() - { - execSQL("CREATE TABLE Test(id INT, name VARCHAR(20))"); - - MySqlCommand cmd = new MySqlCommand(@"INSERT INTO Test VALUES (1, '\\=\\')", conn); - cmd.ExecuteNonQuery(); - } -/* [Category("NotWorking")] - [Test] - public void TestCase() - { - string importQuery = "SET FOREIGN_KEY_CHECKS = 1;DELETE FROM Category " + - "WHERE id=\'0205342903\';SET FOREIGN_KEY_CHECKS = 0;INSERT INTO Category " + - "VALUES(\'d0450f050a0dfd8e00e6da7bda3bb07e\',\'0205342903\',\'000000000000000 " + - "00000000000000000\',\'\',\'0\');INSERT INTO Attribute " + - "VALUES(\'d0450f050a0dfd8e00e6da7b00dfa3c5\',\'d0450f050a0dfd8e00e6da7bda3bb0 " + - "7e\',\'eType\',\'machine\',null);SET FOREIGN_KEY_CHECKS = 1;"; - string deleteQuery = "SET FOREIGN_KEY_CHECKS=1;DELETE FROM Attribute " + - "WHERE foreignuuid=\'d0450f050a0dfd8e00e6da7bda3bb07e\' AND " + - "name=\'eType\'"; - string insertQuery = "SET FOREIGN_KEY_CHECKS = 0;INSERT INTO Attribute " + - "VALUES(\'d0563ba70a0dfd8e01df43e22395b352\',\'d0450f050a0dfd8e00e6da7bda3bb0 " + - "7e\',\'eType\',\'machine\',null);SET FOREIGN_KEY_CHECKS = 1"; - string updateQuery = "SET FOREIGN_KEY_CHECKS = 1;DELETE FROM Attribute " + - "WHERE foreignuuid=\'d0450f050a0dfd8e00e6da7bda3bb07e\' AND " + - "name=\'eType\';SET FOREIGN_KEY_CHECKS = 0;INSERT INTO Attribute " + - "VALUES(\'d0563ba70a0dfd8e01df43e22395b352\',\'d0450f050a0dfd8e00e6da7bda3bb0 " + - "7e\',\'eType\',\'machine\',null);SET FOREIGN_KEY_CHECKS = 1;"; - string bugQuery = "SELECT name,value FROM Attribute WHERE " + - "foreignuuid=\'d0450f050a0dfd8e00e6da7bda3bb07e\'"; - - execSQL("SET FOREIGN_KEY_CHECKS=0"); - execSQL("DROP TABLE IF EXISTS Attribute"); - execSQL("CREATE TABLE IF NOT EXISTS Attribute (uuid char(32) NOT NULL," + - "foreignuuid char(32), name character varying(254), value character varying(254)," + - "fid integer, PRIMARY KEY (uuid), INDEX foreignuuid (foreignuuid), " + - "INDEX name (name(16)), INDEX value (value(8)), CONSTRAINT `attribute_fk_1` " + - "FOREIGN KEY (`foreignuuid`) REFERENCES `Category` (`uuid`) ON DELETE CASCADE" + - ") CHARACTER SET utf8 ENGINE=InnoDB;"); - - execSQL("DROP TABLE IF EXISTS Category"); - execSQL("CREATE TABLE IF NOT EXISTS Category (uuid char(32) NOT NULL," + - "id character varying(254), parentuuid char(32), name character varying(254)," + - "sort integer, PRIMARY KEY (uuid), INDEX parentuuid (parentuuid), INDEX id (id)," + - "CONSTRAINT `parent_fk_1` FOREIGN KEY (`parentuuid`) REFERENCES `Category` " + - "(`uuid`) ON DELETE CASCADE) CHARACTER SET utf8 ENGINE=InnoDB;"); - execSQL("SET FOREIGN_KEY_CHECKS=1"); - - conn.InfoMessage += new MySqlInfoMessageEventHandler(conn_InfoMessage); - MySqlCommand cmd = new MySqlCommand(importQuery, conn); - cmd.ExecuteNonQuery(); - - for (int i = 0; i <= 5000; i++) - { - cmd.CommandText = deleteQuery; - cmd.ExecuteNonQuery(); - - cmd.CommandText = insertQuery; - cmd.ExecuteNonQuery(); - - cmd.CommandText = bugQuery; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Close(); - } - } - } - - void conn_InfoMessage(object sender, MySqlInfoMessageEventArgs args) - { - throw new Exception("The method or operation is not implemented."); - } - */ - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tester/TestClasses.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tester/TestClasses.cs deleted file mode 100644 index 0d3773c..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tester/TestClasses.cs +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Collections.Generic; -using System.Text; - -namespace NUnit.Framework -{ - class TestFixtureAttribute : Attribute - { - } - - class TearDownAttribute : Attribute - { - } - - class TestFixtureSetUpAttribute : Attribute - { - } - - class TestFixtureTearDownAttribute : Attribute - { - } - - class SetUpAttribute : Attribute - { - } - - class TestAttribute : Attribute - { - } - - class Assert - { - public static void Fail(string message) - { - throw new Exception(message); - } - - public static void AreEqual(object expected, object value, string msg) - { - try - { - if (expected is UInt64) - { - ulong lValue = Convert.ToUInt64(value); - if (!expected.Equals(lValue)) - throw new Exception(msg); - } - else - { - long iExpected = Convert.ToInt64(expected); - long iValue = Convert.ToInt64(value); - if (iExpected != iValue) - throw new Exception(msg); - } - } - catch (Exception ex) - { - if (ex is InvalidCastException || - ex is FormatException) - { - if (!expected.Equals(value)) - throw new Exception(msg); - } - else - throw new Exception(msg); - } - - /* if (expected is string) - { - if (expected.ToString() != value.ToString()) - throw new Exception(msg); - } - else if (expected is DateTime) - { - if (!expected.Equals(value)) - throw new Exception(msg); - } - else*/ - } - - public static void AreEqual(object expected, object value) - { - AreEqual(expected, value, null); - } - - public static void IsTrue(bool value, string msg) - { - if (!value) - throw new Exception(msg); - } - - public static void IsTrue(bool value) - { - IsTrue(value, "Value should be true"); - } - - public static void IsFalse(bool value, string msg) - { - if (value) - throw new Exception(msg); - } - - public static void IsFalse(bool value) - { - IsFalse(value, "Value should be false"); - } - - public static void IsNull(object value, string msg) - { - if (value != null) - throw new Exception(msg); - } - - public static void IsNull(object value) - { - IsNull(value, "Should be null"); - } - - public static void IsNotNull(object value, string msg) - { - if (value == null) - throw new Exception(msg); - } - - public static void IsNotNull(object value) - { - IsNotNull(value, "Should not be null"); - } - - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tester/TestRunner.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tester/TestRunner.cs deleted file mode 100644 index f6dca36..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tester/TestRunner.cs +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Reflection; -using NUnit.Framework; -using System.Collections; - -namespace MySql.Data.MySqlClient.Tests -{ - public class TestRunner - { - private ArrayList tests = new ArrayList(); - - public event EventHandler FixtureStarted; - public event EventHandler FixtureDone; - public event EventHandler TestStarted; - public event EventHandler TestDone; - - public ArrayList LoadTests() - { - Assembly me = Assembly.GetExecutingAssembly(); - - Type[] types = me.GetTypes(); - - foreach (Type t in types) - { - object[] o = t.GetCustomAttributes(typeof(TestFixtureAttribute), false); - if (o == null || o.Length == 0) continue; - - TestCollection tc = new TestCollection(); - tc.name = t.Name; - tc.fixtureType = t; - - FindMethods(t, tc); - if (tc.testMethods.Count > 0) - tests.Add(tc); - } - return tests; - } - - private void FindMethods(Type t, TestCollection tc) - { - // now get all the methods on the fixture - MethodInfo[] methods = t.GetMethods( - BindingFlags.Public | BindingFlags.NonPublic | - BindingFlags.Instance); - - // if there is a fixture setup routine, invoke it - foreach (MethodInfo mi in methods) - { - if (mi.IsPrivate) continue; - - object[] attr = mi.GetCustomAttributes(true); - - foreach (Attribute a in attr) - { - if (a is TestFixtureSetUpAttribute) - tc.classSetup = mi; - else if (a is TestFixtureTearDownAttribute) - tc.classTeardown = mi; - else if (a is SetUpAttribute) - tc.setup = mi; - else if (a is TearDownAttribute) - tc.tearDown = mi; - else if (a is TestAttribute) - { - TestMethod tm = new TestMethod(); - tm.member = mi; - tc.testMethods.Add(tm); - } - } - } - } - - public void StartFixture(TestCollection tc) - { - try - { - if (tc.fixture == null) - tc.fixture = Activator.CreateInstance(tc.fixtureType); - - if (tc.classSetup != null) - tc.classSetup.Invoke(tc.fixture, null); - } - catch (Exception ex) - { - tc.message = ex.Message; - tc.stack = ex.StackTrace; - throw; - } - } - - public void EndFixture(TestCollection tc) - { - try - { - if (tc.classTeardown != null) - tc.classTeardown.Invoke(tc.fixture, null); - } - catch (Exception ex) - { - tc.message = ex.Message; - tc.stack = ex.StackTrace; - throw; - } - } - - public bool RunTest(int fixtureIndex, int methodIndex) - { - TestCollection tc = (TestCollection)tests[fixtureIndex]; - TestMethod tm = (TestMethod)tc.testMethods[methodIndex]; - try - { - if (tc.setup != null) - tc.setup.Invoke(tc.fixture, null); - - tm.member.Invoke(tc.fixture, null); - - if (tc.tearDown != null) - tc.tearDown.Invoke(tc.fixture, null); - - return true; - } - catch (Exception ex) - { - tm.message = ex.Message; - tm.stack = ex.StackTrace; - return false; - } - } - - private void OnTestDone() - { - if (TestDone != null) - TestDone(this, null); - } - - private void OnTestStarted() - { - if (TestStarted != null) - TestStarted(this, null); - } - - private void OnFixtureStated() - { - if (FixtureStarted != null) - FixtureStarted(this, null); - } - - private void OnFixtureDone() - { - if (FixtureDone != null) - FixtureDone(this, null); - } - } - - public class TestCollection - { - public string name; - public ArrayList testMethods; - public MethodInfo classSetup; - public MethodInfo classTeardown; - public MethodInfo setup; - public MethodInfo tearDown; - public object fixture; - public Type fixtureType; - public string message; - public string stack; - - public TestCollection() - { - testMethods = new ArrayList(); - } - } - - public class TestMethod - { - public MethodInfo member; - public string message; - public string stack; - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Threading.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Threading.cs deleted file mode 100644 index e733df9..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Threading.cs +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (C) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using MySql.Data.MySqlClient; -using System.Data; -using NUnit.Framework; -using System.Threading; -using System.Collections; -using System.Diagnostics; -using System.Text; -using System.Collections.Specialized; - -namespace MySql.Data.MySqlClient.Tests -{ - class GenericListener : TraceListener - { - StringCollection strings; - StringBuilder partial; - - public GenericListener() - { - strings = new StringCollection(); - partial = new StringBuilder(); - } - - public StringCollection Strings - { - get { return strings; } - } - - public int Find(string sToFind) - { - int count = 0; - foreach (string s in strings) - if (s.IndexOf(sToFind) != -1) - count++; - return count; - } - - public void Clear() - { - partial.Remove(0, partial.Length); - strings.Clear(); - } - - public override void Write(string message) - { - partial.Append(message); - } - - public override void WriteLine(string message) - { - Write(message); - strings.Add(partial.ToString()); - partial.Remove(0, partial.Length); - } - } - - /// - /// Summary description for ConnectionTests. - /// - [TestFixture] - public class ThreadingTests : BaseTest - { - private void MultipleThreadsWorker(object ev) - { - (ev as ManualResetEvent).WaitOne(); - - using (MySqlConnection c = new MySqlConnection(GetConnectionString(true))) - { - c.Open(); - } - } - - /// - /// Bug #17106 MySql.Data.MySqlClient.CharSetMap.GetEncoding thread synchronization issue - /// - [Test] - public void MultipleThreads() - { - GenericListener myListener = new GenericListener(); - ManualResetEvent ev = new ManualResetEvent(false); - ArrayList threads = new ArrayList(); - System.Diagnostics.Trace.Listeners.Add(myListener); - - for (int i = 0; i < 20; i++) - { - ParameterizedThreadStart ts = new ParameterizedThreadStart(MultipleThreadsWorker); - Thread t = new Thread(ts); - threads.Add(t); - t.Start(ev); - } - // now let the threads go - ev.Set(); - - // wait for the threads to end - int x = 0; - while (x < threads.Count) - { - while ((threads[x] as Thread).IsAlive) - Thread.Sleep(50); - x++; - } - } - } - -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/TimeoutAndCancel.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/TimeoutAndCancel.cs deleted file mode 100644 index d3493c7..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/TimeoutAndCancel.cs +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using System.Threading; -using NUnit.Framework; -using System.Globalization; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class TimeoutAndCancel : BaseTest - { - private delegate void CommandInvokerDelegate(MySqlCommand cmdToRun); - - private void CommandRunner(MySqlCommand cmdToRun) - { - object o = cmdToRun.ExecuteScalar(); - Assert.IsNull(o); - } - - [Test] - public void CancelSingleQuery() - { - if (Version < new Version(5, 0)) return; - - // first we need a routine that will run for a bit - execSQL(@"CREATE PROCEDURE spTest(duration INT) - BEGIN - SELECT SLEEP(duration); - END"); - - MySqlCommand cmd = new MySqlCommand("spTest", conn); - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("duration", 10); - - // now we start execution of the command - CommandInvokerDelegate d = new CommandInvokerDelegate(CommandRunner); - d.BeginInvoke(cmd, null, null); - - // sleep 1 seconds - Thread.Sleep(1000); - - // now cancel the command - cmd.Cancel(); - } - - int stateChangeCount; - [Test] - public void WaitTimeoutExpiring() - { - string connStr = GetConnectionString(true); - MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder(connStr); - - if (sb.ConnectionProtocol == MySqlConnectionProtocol.NamedPipe) - // wait timeout does not work for named pipe connections - return; - - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - c.StateChange += new StateChangeEventHandler(c_StateChange); - - // set the session wait timeout on this new connection - MySqlCommand cmd = new MySqlCommand("SET SESSION interactive_timeout=3", c); - cmd.ExecuteNonQuery(); - cmd.CommandText = "SET SESSION wait_timeout=2"; - cmd.ExecuteNonQuery(); - - stateChangeCount = 0; - // now wait 4 seconds - Thread.Sleep(4000); - - try - { - cmd.CommandText = "SELECT now()"; - cmd.ExecuteScalar(); - } - catch (Exception ex) - { - Assert.IsTrue(ex.Message.StartsWith("Fatal")); - } - - Assert.AreEqual(1, stateChangeCount); - Assert.AreEqual(ConnectionState.Closed, c.State); - } - - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT now() as thetime, database() as db", c); - using (MySqlDataReader r = cmd.ExecuteReader()) - { - Assert.IsTrue(r.Read()); - } - } - } - - void c_StateChange(object sender, StateChangeEventArgs e) - { - stateChangeCount++; - } - - [Test] - public void TimeoutExpiring() - { - if (version < new Version(5, 0)) return; - - DateTime start = DateTime.Now; - try - { - MySqlCommand cmd = new MySqlCommand("SELECT SLEEP(200)", conn); - cmd.CommandTimeout = 1; - cmd.ExecuteReader(CommandBehavior.SingleRow); - Assert.Fail("Should not get to this point"); - } - catch (MySqlException ex) - { - TimeSpan ts = DateTime.Now.Subtract(start); - Assert.IsTrue(ts.TotalSeconds <= 2); - Assert.IsTrue(ex.Message.StartsWith("Timeout expired"), "Message is wrong " +ex.Message); - } - - long x = (long)(new MySqlCommand("select 10", conn).ExecuteScalar()); - Assert.AreEqual(10, x); - - } - - [Test] - public void TimeoutNotExpiring() - { - if (Version < new Version(5, 0)) return; - - MySqlCommand cmd = new MySqlCommand("SELECT SLEEP(1)", conn); - cmd.CommandTimeout = 2; - cmd.ExecuteNonQuery(); - } - - [Test] - public void TimeoutDuringBatch() - { - if (Version < new Version(5, 0)) return; - - execSQL(@"CREATE PROCEDURE spTest(duration INT) - BEGIN - SELECT SLEEP(duration); - END"); - - execSQL("CREATE TABLE test (id INT)"); - - MySqlCommand cmd = new MySqlCommand( - "call spTest(5);INSERT INTO test VALUES(4)", conn); - cmd.CommandTimeout = 2; - try - { - cmd.ExecuteNonQuery(); - Assert.Fail("This should have timed out"); - } - catch (MySqlException ex) - { - Assert.IsTrue(ex.Message.StartsWith("Timeout expired"), "Message is wrong" +ex); - } - - // Check that connection is still usable - MySqlCommand cmd2 = new MySqlCommand("select 10", conn); - long res = (long)cmd2.ExecuteScalar(); - Assert.AreEqual(10, res); - } - - //[Test] - public void CancelSelect() - { - if (Version < new Version(5, 0)) return; - - execSQL("CREATE TABLE Test (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20))"); - for (int i=0; i < 10000; i++) - execSQL("INSERT INTO Test VALUES (NULL, 'my string')"); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - cmd.CommandTimeout = 0; - int rows = 0; - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - - cmd.Cancel(); - - while (reader.Read()) - { - rows++; - } - } - Assert.IsTrue(rows < 10000); - } - - /// - /// Bug #40091 mysql driver 5.2.3.0 connection pooling issue - /// - [Test] - public void ConnectionStringModifiedAfterCancel() - { - if (Version.Major < 5) return; - - string connStr = GetPoolingConnectionString(); - MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder(connStr); - - if (sb.ConnectionProtocol == MySqlConnectionProtocol.NamedPipe) - // idle named pipe connections cannot be KILLed (server bug#47571) - return; - - connStr = connStr.Replace("persist security info=true", "persist security info=false"); - - int threadId; - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - threadId = c.ServerThread; - string connStr1 = c.ConnectionString; - - MySqlCommand cmd = new MySqlCommand("SELECT SLEEP(2)", c); - cmd.CommandTimeout = 1; - - try - { - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - } - } - catch (MySqlException ex) - { - Assert.IsTrue(ex.InnerException is TimeoutException); - Assert.IsTrue(c.State == ConnectionState.Open); - } - string connStr2 = c.ConnectionString.ToLower(CultureInfo.InvariantCulture); - Assert.AreEqual(connStr1.ToLower(CultureInfo.InvariantCulture), connStr2); - } - execSQL("kill " + threadId); - } - } - - #region Configs - - public class TimeoutAndCancelSocketCompressed : TimeoutAndCancel - { - protected override string GetConnectionInfo() - { - return String.Format("port={0};compress=true", port); - } - } -#if !CF - [Category("Pipe")] - public class TimeoutAndCancelPipe : TimeoutAndCancel - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=namedpipe;pipe name={0}", pipeName); - } - } - - [Category("SharedMemory")] - public class TimeoutAndCancelSharedMemory : TimeoutAndCancel - { - protected override string GetConnectionInfo() - { - return String.Format("protocol=sharedmemory; shared memory name={0}", - memoryName); - } - } -#endif - - #endregion - -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tokenizer.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tokenizer.cs deleted file mode 100644 index 2bd7b69..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Tokenizer.cs +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright (C) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using NUnit.Framework; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class Tokenizer : BaseTest - { - -#if !CF - [Test] - public void Simple() - { - SqlTokenizer tokenizer = new SqlTokenizer("SELECT * FROM Test"); - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual("*", tokenizer.NextToken()); - Assert.AreEqual("FROM", tokenizer.NextToken()); - Assert.AreEqual("Test", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - } - - [Test] - public void DashSingleLineComment() - { - string comment = "-- this is my comment\r\n"; - string sql = String.Format("SELECT {0} * FROM Test", comment); - SqlTokenizer tokenizer = new SqlTokenizer(sql); - tokenizer.ReturnComments = true; - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual(comment.Trim(), tokenizer.NextToken()); - Assert.AreEqual("*", tokenizer.NextToken()); - Assert.AreEqual("FROM", tokenizer.NextToken()); - Assert.AreEqual("Test", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - - tokenizer = new SqlTokenizer(sql); - tokenizer.ReturnComments = false; - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual("*", tokenizer.NextToken()); - Assert.AreEqual("FROM", tokenizer.NextToken()); - Assert.AreEqual("Test", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - } - - [Test] - public void HashSingleLineComment() - { - string comment = "#this is my comment\r\n"; - string sql = String.Format("SELECT {0} * FROM Test", comment); - SqlTokenizer tokenizer = new SqlTokenizer(sql); - tokenizer.ReturnComments = true; - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual(comment.Trim(), tokenizer.NextToken()); - Assert.AreEqual("*", tokenizer.NextToken()); - Assert.AreEqual("FROM", tokenizer.NextToken()); - Assert.AreEqual("Test", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - - tokenizer = new SqlTokenizer(sql); - tokenizer.ReturnComments = false; - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual("*", tokenizer.NextToken()); - Assert.AreEqual("FROM", tokenizer.NextToken()); - Assert.AreEqual("Test", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - } - - [Test] - public void MultiLineComment() - { - string comment = "/* this is my comment \r\n lines 2 \r\n line 3*/"; - string sql = String.Format("SELECT{0} * FROM Test", comment); - SqlTokenizer tokenizer = new SqlTokenizer(sql); - tokenizer.ReturnComments = true; - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual(comment.Trim(), tokenizer.NextToken()); - Assert.AreEqual("*", tokenizer.NextToken()); - Assert.AreEqual("FROM", tokenizer.NextToken()); - Assert.AreEqual("Test", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - - tokenizer = new SqlTokenizer(sql); - tokenizer.ReturnComments = false; - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual("*", tokenizer.NextToken()); - Assert.AreEqual("FROM", tokenizer.NextToken()); - Assert.AreEqual("Test", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - } - - [Test] - public void Parameter() - { - string sql = "SELECT * FROM Test WHERE id=@id AND id2=?id2"; - SqlTokenizer tokenizer = new SqlTokenizer(sql); - tokenizer.ReturnComments = true; - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual("*", tokenizer.NextToken()); - Assert.AreEqual("FROM", tokenizer.NextToken()); - Assert.AreEqual("Test", tokenizer.NextToken()); - Assert.AreEqual("WHERE", tokenizer.NextToken()); - Assert.AreEqual("id", tokenizer.NextToken()); - Assert.AreEqual("=", tokenizer.NextToken()); - Assert.AreEqual("@id", tokenizer.NextToken()); - Assert.AreEqual("AND", tokenizer.NextToken()); - Assert.AreEqual("id2", tokenizer.NextToken()); - Assert.AreEqual("=", tokenizer.NextToken()); - Assert.AreEqual("?id2", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - } - - [Test] - public void NextParameter() - { - string sql = "SELECT * FROM Test WHERE id=@id AND id2=?id2"; - SqlTokenizer tokenizer = new SqlTokenizer(sql); - tokenizer.ReturnComments = true; - Assert.AreEqual("@id", tokenizer.NextParameter()); - Assert.AreEqual("?id2", tokenizer.NextParameter()); - Assert.IsNull(tokenizer.NextParameter()); - } - - [Test] - public void ParameterWithSpecialCharacters() - { - string sql = "SELECT * FROM Test WHERE id=@id_$123"; - SqlTokenizer tokenizer = new SqlTokenizer(sql); - tokenizer.ReturnComments = true; - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual("*", tokenizer.NextToken()); - Assert.AreEqual("FROM", tokenizer.NextToken()); - Assert.AreEqual("Test", tokenizer.NextToken()); - Assert.AreEqual("WHERE", tokenizer.NextToken()); - Assert.AreEqual("id", tokenizer.NextToken()); - Assert.AreEqual("=", tokenizer.NextToken()); - Assert.AreEqual("@id_$123", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - } - - [Test] - public void StringLiteral() - { - string sql = "SELECT 'a', 1, 'b'"; - SqlTokenizer tokenizer = new SqlTokenizer(sql); - tokenizer.ReturnComments = false; - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual("'a'", tokenizer.NextToken()); - Assert.AreEqual(",", tokenizer.NextToken()); - Assert.AreEqual("1", tokenizer.NextToken()); - Assert.AreEqual(",", tokenizer.NextToken()); - Assert.AreEqual("'b'", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - } - - [Test] - public void UserVariable() - { - string sql = "SELECT 'a', 1, @@myVar"; - SqlTokenizer tokenizer = new SqlTokenizer(sql); - tokenizer.ReturnComments = false; - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual("'a'", tokenizer.NextToken()); - Assert.AreEqual(",", tokenizer.NextToken()); - Assert.AreEqual("1", tokenizer.NextToken()); - Assert.AreEqual(",", tokenizer.NextToken()); - Assert.AreEqual("@@myVar", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - } - - [Test] - public void AnsiQuotes() - { - string sql = "SELECT 'a', \"a\", `a`"; - SqlTokenizer tokenizer = new SqlTokenizer(sql); - tokenizer.AnsiQuotes = false; - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual("'a'", tokenizer.NextToken()); - Assert.IsTrue(tokenizer.Quoted); - Assert.AreEqual(",", tokenizer.NextToken()); - Assert.AreEqual("\"a\"", tokenizer.NextToken()); - Assert.IsTrue(tokenizer.Quoted); - Assert.AreEqual(",", tokenizer.NextToken()); - Assert.AreEqual("`a`", tokenizer.NextToken()); - Assert.IsTrue(tokenizer.Quoted); - Assert.IsNull(tokenizer.NextToken()); - } - - [Test] - public void ParseProcBody() - { - string sql = "CREATE PROCEDURE spTest(testid INT, testname VARCHAR(20)) BEGIN SELECT 1; END"; - SqlTokenizer tokenizer = new SqlTokenizer(sql); - tokenizer.AnsiQuotes = false; - Assert.AreEqual("CREATE", tokenizer.NextToken()); - Assert.AreEqual("PROCEDURE", tokenizer.NextToken()); - Assert.AreEqual("spTest", tokenizer.NextToken()); - Assert.AreEqual("(", tokenizer.NextToken()); - Assert.AreEqual("testid", tokenizer.NextToken()); - Assert.AreEqual("INT", tokenizer.NextToken()); - Assert.AreEqual(",", tokenizer.NextToken()); - Assert.AreEqual("testname", tokenizer.NextToken()); - Assert.AreEqual("VARCHAR", tokenizer.NextToken()); - Assert.AreEqual("(", tokenizer.NextToken()); - Assert.AreEqual("20", tokenizer.NextToken()); - Assert.AreEqual(")", tokenizer.NextToken()); - Assert.AreEqual(")", tokenizer.NextToken()); - Assert.AreEqual("BEGIN", tokenizer.NextToken()); - Assert.AreEqual("SELECT", tokenizer.NextToken()); - Assert.AreEqual("1", tokenizer.NextToken()); - Assert.AreEqual(";", tokenizer.NextToken()); - Assert.AreEqual("END", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - } -#endif - - /// - /// Bug #44318 Tokenizer - /// - [Test] - public void NoSpaceAroundEquals() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test(name VARCHAR(40))"); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test SET name='test -- test';", conn); - cmd.ExecuteNonQuery(); - cmd.CommandText = "SELECT name FROM Test"; - object o = cmd.ExecuteScalar(); - Assert.AreEqual("test -- test", o); - - cmd.CommandText = "UPDATE Test SET name='Can you explain this ?';"; - cmd.ExecuteNonQuery(); - cmd.CommandText = "SELECT name FROM Test"; - o = cmd.ExecuteScalar(); - Assert.AreEqual("Can you explain this ?", o); - } - - [Test] - public void Slash() - { - string sql = "AND // OR"; - SqlTokenizer tokenizer = new SqlTokenizer(sql); - tokenizer.AnsiQuotes = false; - Assert.AreEqual("AND", tokenizer.NextToken()); - Assert.AreEqual("/", tokenizer.NextToken()); - Assert.AreEqual("/", tokenizer.NextToken()); - Assert.AreEqual("OR", tokenizer.NextToken()); - Assert.IsNull(tokenizer.NextToken()); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Transactions.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Transactions.cs deleted file mode 100644 index 9d05450..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Transactions.cs +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright (C) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Data; -using System.IO; -using NUnit.Framework; -using System.Transactions; -using System.Data.Common; -using System.Threading; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class Transactions : BaseTest - { - void TransactionScopeInternal(bool commit) - { - createTable("CREATE TABLE Test (key2 VARCHAR(1), name VARCHAR(100), name2 VARCHAR(100))", "INNODB"); - using (MySqlConnection c = new MySqlConnection(GetConnectionString(true))) - { - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES ('a', 'name', 'name2')", c); - - using (TransactionScope ts = new TransactionScope()) - { - c.Open(); - - cmd.ExecuteNonQuery(); - - if (commit) - ts.Complete(); - } - - cmd.CommandText = "SELECT COUNT(*) FROM Test"; - object count = cmd.ExecuteScalar(); - Assert.AreEqual(commit ? 1 : 0, count); - } - } - - [Test] - public void TransactionScopeRollback() - { - TransactionScopeInternal(false); - } - - [Test] - public void TransactionScopeCommit() - { - TransactionScopeInternal(true); - } - - // The following block is not currently supported -/* void TransactionScopeMultipleInternal(bool commit) - { - MySqlConnection c1 = new MySqlConnection(GetConnectionString(true)); - MySqlConnection c2 = new MySqlConnection(GetConnectionString(true)); - MySqlCommand cmd1 = new MySqlCommand("INSERT INTO Test VALUES ('a', 'name', 'name2')", c1); - MySqlCommand cmd2 = new MySqlCommand("INSERT INTO Test VALUES ('b', 'name', 'name2')", c1); - - try - { - using (TransactionScope ts = new TransactionScope()) - { - c1.Open(); - cmd1.ExecuteNonQuery(); - - c2.Open(); - cmd2.ExecuteNonQuery(); - - if (commit) - ts.Complete(); - } - - cmd1.CommandText = "SELECT COUNT(*) FROM Test"; - object count = cmd1.ExecuteScalar(); - Assert.AreEqual(commit ? 2 : 0, count); - } - catch (Exception ex) - { - Assert.Fail(ex.Message); - } - finally - { - if (c1 != null) - c1.Close(); - if (c2 != null) - c2.Close(); - } - } - - [Test] - public void TransactionScopeMultipleRollback() - { - TransactionScopeMultipleInternal(false); - } - - [Test] - public void TransactionScopeMultipleCommit() - { - TransactionScopeMultipleInternal(true); - } -*/ - /// - /// Bug #34448 Connector .Net 5.2.0 with Transactionscope doesnt use specified IsolationLevel - /// - [Test] - public void TransactionScopeWithIsolationLevel() - { - TransactionOptions opts = new TransactionOptions(); - opts.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; - - using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, opts)) - { - string connStr = GetConnectionString(true); - using (MySqlConnection myconn = new MySqlConnection(connStr)) - { - myconn.Open(); - MySqlCommand cmd = new MySqlCommand("SHOW VARIABLES LIKE 'tx_isolation'", myconn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - string level = reader.GetString(1); - Assert.AreEqual("READ-COMMITTED", level); - } - } - } - } - - /// - /// Bug #27289 Transaction is not rolledback when connection close - /// - [Test] - public void RollingBackOnClose() - { - execSQL("CREATE TABLE Test (id INT) ENGINE=InnoDB"); - - string connStr = GetPoolingConnectionString(); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1)", c); - c.BeginTransaction(); - cmd.ExecuteNonQuery(); - } - - using (MySqlConnection c2 = new MySqlConnection(connStr)) - { - c2.Open(); - MySqlCommand cmd2 = new MySqlCommand("SELECT COUNT(*) from Test", c2); - c2.BeginTransaction(); - object count = cmd2.ExecuteScalar(); - Assert.AreEqual(0, count); - } - - MySqlConnection connection = new MySqlConnection(connStr); - connection.Open(); - KillConnection(connection); - } - - - /// - /// Bug #22042 mysql-connector-net-5.0.0-alpha BeginTransaction - /// - [Test] - public void Bug22042() - { - DbProviderFactory factory = - new MySql.Data.MySqlClient.MySqlClientFactory(); - using (DbConnection conexion = factory.CreateConnection()) - { - conexion.ConnectionString = GetConnectionString(true); - conexion.Open(); - DbTransaction trans = conexion.BeginTransaction(); - trans.Rollback(); - } - } - - /// - /// Bug #26754 EnlistTransaction throws false MySqlExeption "Already enlisted" - /// - [Test] - public void EnlistTransactionNullTest() - { - try - { - MySqlCommand cmd = new MySqlCommand(); - cmd.Connection = conn; - cmd.Connection.EnlistTransaction(null); - } - catch { } - - using (TransactionScope ts = new TransactionScope()) - { - MySqlCommand cmd = new MySqlCommand(); - cmd.Connection = conn; - cmd.Connection.EnlistTransaction(Transaction.Current); - } - } - - /// - /// Bug #26754 EnlistTransaction throws false MySqlExeption "Already enlisted" - /// - [Test] - public void EnlistTransactionWNestedTrxTest() - { - MySqlTransaction t = conn.BeginTransaction(); - - using (TransactionScope ts = new TransactionScope()) - { - MySqlCommand cmd = new MySqlCommand(); - cmd.Connection = conn; - try - { - cmd.Connection.EnlistTransaction(Transaction.Current); - } - catch (InvalidOperationException) - { - /* caught NoNestedTransactions */ - } - } - - t.Rollback(); - - using (TransactionScope ts = new TransactionScope()) - { - MySqlCommand cmd = new MySqlCommand(); - cmd.Connection = conn; - cmd.Connection.EnlistTransaction(Transaction.Current); - } - } - - [Test] - public void ManualEnlistment() - { - createTable("CREATE TABLE Test (key2 VARCHAR(1), name VARCHAR(100), name2 VARCHAR(100))", "INNODB"); - string connStr = GetConnectionString(true) + ";auto enlist=false"; - MySqlConnection c = null; - using (TransactionScope ts = new TransactionScope()) - { - c = new MySqlConnection(connStr); - c.Open(); - - MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES ('a', 'name', 'name2')", c); - cmd.ExecuteNonQuery(); - } - MySqlCommand cmd2 = new MySqlCommand("SELECT COUNT(*) FROM Test", conn); - Assert.AreEqual(1, cmd2.ExecuteScalar()); - c.Dispose(); - KillPooledConnection(connStr); - } - - private void ManuallyEnlistingInitialConnection(bool complete) - { - createTable("CREATE TABLE Test (key2 VARCHAR(1), name VARCHAR(100), name2 VARCHAR(100))", "INNODB"); - string connStr = GetConnectionString(true) + ";auto enlist=false"; - - using (TransactionScope ts = new TransactionScope()) - { - using (MySqlConnection c1 = new MySqlConnection(connStr)) - { - c1.Open(); - c1.EnlistTransaction(Transaction.Current); - MySqlCommand cmd1 = new MySqlCommand("INSERT INTO Test (key2) VALUES ('a')", c1); - cmd1.ExecuteNonQuery(); - } - - using (MySqlConnection c2 = new MySqlConnection(connStr)) - { - c2.Open(); - c2.EnlistTransaction(Transaction.Current); - MySqlCommand cmd2 = new MySqlCommand("INSERT INTO Test (key2) VALUES ('b')", c2); - cmd2.ExecuteNonQuery(); - } - if (complete) - ts.Complete(); - } - - KillPooledConnection(connStr); - } - - [Test] - public void ManuallyEnlistingInitialConnection() - { - ManuallyEnlistingInitialConnection(true); - } - - [Test] - public void ManuallyEnlistingInitialConnectionNoComplete() - { - ManuallyEnlistingInitialConnection(false); - } - - [Test] - public void ManualEnlistmentWithActiveConnection() - { - using (TransactionScope ts = new TransactionScope()) - { - string connStr = GetConnectionString(true); - - using (MySqlConnection c1 = new MySqlConnection(connStr)) - { - c1.Open(); - - connStr += "; auto enlist=false"; - using (MySqlConnection c2 = new MySqlConnection(connStr)) - { - c2.Open(); - try - { - c2.EnlistTransaction(Transaction.Current); - } - catch (NotSupportedException) - { - } - } - } - } - } - - [Test] - public void AttemptToEnlistTwoConnections() - { - using (TransactionScope ts = new TransactionScope()) - { - string connStr = GetConnectionString(true); - - using (MySqlConnection c1 = new MySqlConnection(connStr)) - { - c1.Open(); - - using (MySqlConnection c2 = new MySqlConnection(connStr)) - { - try - { - c2.Open(); - } - catch (NotSupportedException) - { - } - } - } - } - } - - private void ReusingSameConnection(bool pooling, bool complete) - { - int c1Thread; - execSQL("TRUNCATE TABLE Test"); - - using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew, TimeSpan.MaxValue)) - { - string connStr = GetConnectionString(true); - if (!pooling) - connStr += ";pooling=false"; - - using (MySqlConnection c1 = new MySqlConnection(connStr)) - { - c1.Open(); - MySqlCommand cmd1 = new MySqlCommand("INSERT INTO Test (key2) VALUES ('a')", c1); - cmd1.ExecuteNonQuery(); - c1Thread = c1.ServerThread; - } - - using (MySqlConnection c2 = new MySqlConnection(connStr)) - { - c2.Open(); - MySqlCommand cmd2 = new MySqlCommand("INSERT INTO Test (key2) VALUES ('b')", c2); - cmd2.ExecuteNonQuery(); - Assert.AreEqual(c1Thread, c2.ServerThread); - } - - if (complete) - ts.Complete(); - } - - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn); - DataTable dt = new DataTable(); - da.Fill(dt); - if (complete) - { - Assert.AreEqual(2, dt.Rows.Count); - Assert.AreEqual("a", dt.Rows[0][0]); - Assert.AreEqual("b", dt.Rows[1][0]); - } - else - { - Assert.AreEqual(0, dt.Rows.Count); - } - } - - [Test] - public void ReusingSameConnection() - { - createTable("CREATE TABLE Test (key2 VARCHAR(1), name VARCHAR(100), name2 VARCHAR(100))", "INNODB"); - ReusingSameConnection(true, true); -// Assert.AreEqual(processes + 1, CountProcesses()); - - ReusingSameConnection(true, false); - // Assert.AreEqual(processes + 1, CountProcesses()); - - ReusingSameConnection(false, true); - // Assert.AreEqual(processes + 1, CountProcesses()); - - ReusingSameConnection(false, false); - // Assert.AreEqual(processes + 1, CountProcesses()); - } - - /// - /// bug#35330 - even if transaction scope has expired, rows can be inserted into - /// the table, due to race condition with the thread doing rollback - /// - [Test] - public void ScopeTimeoutWithMySqlHelper() - { - execSQL("DROP TABLE IF EXISTS Test"); - createTable("CREATE TABLE Test (id int)", "INNODB"); - string connStr = GetConnectionString(true); - using (new TransactionScope(TransactionScopeOption.RequiresNew,TimeSpan.FromSeconds(1))) - { - try - { - for (int i = 0; ; i++) - { - MySqlHelper.ExecuteNonQuery(connStr, String.Format("INSERT INTO Test VALUES({0})", i));; - } - } - catch (Exception) - { - } - } - long count = (long)MySqlHelper.ExecuteScalar(connStr,"select count(*) from test"); - Assert.AreEqual(0, count); - } - - /// - /// Variation of previous test, with a single connection and maual enlistment. - /// Checks that transaction rollback leaves the connection intact (does not close it) - /// and checks that no command is possible after scope has expired and - /// rollback by timer thread is finished. - /// - [Test] - public void AttemptToUseConnectionAfterScopeTimeout() - { - execSQL("DROP TABLE IF EXISTS Test"); - createTable("CREATE TABLE Test (id int)", "INNODB"); - string connStr = GetConnectionString(true); - using (MySqlConnection c = new MySqlConnection(connStr)) - { - c.Open(); - MySqlCommand cmd = new MySqlCommand("select 1", c); - using (new TransactionScope(TransactionScopeOption.RequiresNew, - TimeSpan.FromSeconds(1))) - { - c.EnlistTransaction(Transaction.Current); - cmd = new MySqlCommand("select 1", c); - try - { - for (int i = 0; ; i++) - { - cmd.CommandText = String.Format("INSERT INTO Test VALUES({0})", i); - cmd.ExecuteNonQuery(); - } - } - catch (Exception) - { - // Eat exception - } - - // Here, scope is timed out and rollback is in progress. - // Wait until timeout thread finishes rollback then try to - // use an aborted connection. - Thread.Sleep(500); - try - { - cmd.ExecuteNonQuery(); - Assert.Fail("Using aborted transaction"); - } - catch (TransactionAbortedException) - { - } - } - Assert.IsTrue(c.State == ConnectionState.Open); - cmd.CommandText = "select count(*) from Test"; - long count = (long)cmd.ExecuteScalar(); - Assert.AreEqual(0, count); - } - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/UsageAdvisor.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/UsageAdvisor.cs deleted file mode 100644 index a223669..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/UsageAdvisor.cs +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (C) 2004-2007 MySQL AB -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; -using System.Diagnostics; -using NUnit.Framework; - -namespace MySql.Data.MySqlClient.Tests -{ - [TestFixture] - public class UsageAdvisorTests : BaseTest - { - public UsageAdvisorTests() - { - csAdditions = ";Usage Advisor=true;"; - } - - public override void Setup() - { - base.Setup(); - createTable("CREATE TABLE Test (id int, name VARCHAR(200))", "INNODB"); - } - - [Test] - public void NotReadingEveryField() - { - execSQL("INSERT INTO Test VALUES (1, 'Test1')"); - execSQL("INSERT INTO Test VALUES (2, 'Test2')"); - execSQL("INSERT INTO Test VALUES (3, 'Test3')"); - execSQL("INSERT INTO Test VALUES (4, 'Test4')"); - - MySqlTrace.Listeners.Clear(); - MySqlTrace.Switch.Level = SourceLevels.All; - GenericListener listener = new GenericListener(); - MySqlTrace.Listeners.Add(listener); - - string sql = "SELECT * FROM Test; SELECT * FROM Test WHERE id > 2"; - MySqlCommand cmd = new MySqlCommand(sql, conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - reader.GetInt32(0); // access the first field - reader.Read(); - Assert.IsTrue(reader.NextResult()); - reader.Read(); - Assert.AreEqual("Test3", reader.GetString(1)); - Assert.IsFalse(reader.NextResult()); - } - - Assert.AreEqual(12, listener.Strings.Count); - Assert.IsTrue(listener.Strings[0].Contains("Query Opened: SELECT * FROM Test; SELECT * FROM Test WHERE id > 2")); - Assert.IsTrue(listener.Strings[1].Contains("Resultset Opened: field(s) = 2, affected rows = -1, inserted id = -1")); - Assert.IsTrue(listener.Strings[2].Contains("Usage Advisor Warning: Query does not use an index")); - Assert.IsTrue(listener.Strings[3].Contains("Usage Advisor Warning: Skipped 2 rows. Consider a more focused query.")); - Assert.IsTrue(listener.Strings[4].Contains("Usage Advisor Warning: The following columns were not accessed: name")); - Assert.IsTrue(listener.Strings[5].Contains("Resultset Closed. Total rows=4, skipped rows=2, size (bytes)=32")); - Assert.IsTrue(listener.Strings[6].Contains("Resultset Opened: field(s) = 2, affected rows = -1, inserted id = -1")); - Assert.IsTrue(listener.Strings[7].Contains("Usage Advisor Warning: Query does not use an index")); - Assert.IsTrue(listener.Strings[8].Contains("Usage Advisor Warning: Skipped 1 rows. Consider a more focused query.")); - Assert.IsTrue(listener.Strings[9].Contains("Usage Advisor Warning: The following columns were not accessed: id")); - Assert.IsTrue(listener.Strings[10].Contains("Resultset Closed. Total rows=2, skipped rows=1, size (bytes)=16")); - Assert.IsTrue(listener.Strings[11].Contains("Query Closed")); - } - - [Test] - public void NotReadingEveryRow() - { - execSQL("INSERT INTO Test VALUES (1, 'Test1')"); - execSQL("INSERT INTO Test VALUES (2, 'Test2')"); - execSQL("INSERT INTO Test VALUES (3, 'Test3')"); - execSQL("INSERT INTO Test VALUES (4, 'Test4')"); - - MySqlTrace.Listeners.Clear(); - MySqlTrace.Switch.Level = SourceLevels.All; - GenericListener listener = new GenericListener(); - MySqlTrace.Listeners.Add(listener); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test; SELECT * FROM Test WHERE id > 2", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - reader.Read(); - Assert.IsTrue(reader.NextResult()); - reader.Read(); - reader.Read(); - Assert.IsFalse(reader.NextResult()); - } - Assert.AreEqual(11, listener.Strings.Count); - Assert.IsTrue(listener.Strings[0].Contains("Query Opened: SELECT * FROM Test; SELECT * FROM Test WHERE id > 2")); - Assert.IsTrue(listener.Strings[1].Contains("Resultset Opened: field(s) = 2, affected rows = -1, inserted id = -1")); - Assert.IsTrue(listener.Strings[2].Contains("Usage Advisor Warning: Query does not use an index")); - Assert.IsTrue(listener.Strings[3].Contains("Usage Advisor Warning: Skipped 2 rows. Consider a more focused query.")); - Assert.IsTrue(listener.Strings[4].Contains("Usage Advisor Warning: The following columns were not accessed: id,name")); - Assert.IsTrue(listener.Strings[5].Contains("Resultset Closed. Total rows=4, skipped rows=2, size (bytes)=32")); - Assert.IsTrue(listener.Strings[6].Contains("Resultset Opened: field(s) = 2, affected rows = -1, inserted id = -1")); - Assert.IsTrue(listener.Strings[7].Contains("Usage Advisor Warning: Query does not use an index")); - Assert.IsTrue(listener.Strings[8].Contains("Usage Advisor Warning: The following columns were not accessed: id,name")); - Assert.IsTrue(listener.Strings[9].Contains("Resultset Closed. Total rows=2, skipped rows=0, size (bytes)=16")); - Assert.IsTrue(listener.Strings[10].Contains("Query Closed")); - } - - [Test] - public void FieldConversion() - { - execSQL("INSERT INTO Test VALUES (1, 'Test1')"); - - MySqlTrace.Listeners.Clear(); - MySqlTrace.Switch.Level = SourceLevels.All; - GenericListener listener = new GenericListener(); - MySqlTrace.Listeners.Add(listener); - - MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - short s = reader.GetInt16(0); - long l = reader.GetInt64(0); - string str = reader.GetString(1); - } - Assert.AreEqual(6, listener.Strings.Count); - Assert.IsTrue(listener.Strings[0].Contains("Query Opened: SELECT * FROM Test")); - Assert.IsTrue(listener.Strings[1].Contains("Resultset Opened: field(s) = 2, affected rows = -1, inserted id = -1")); - Assert.IsTrue(listener.Strings[2].Contains("Usage Advisor Warning: Query does not use an index")); - Assert.IsTrue(listener.Strings[3].Contains("Usage Advisor Warning: The field 'id' was converted to the following types: Int16,Int64")); - Assert.IsTrue(listener.Strings[4].Contains("Resultset Closed. Total rows=1, skipped rows=0, size (bytes)=8")); - Assert.IsTrue(listener.Strings[5].Contains("Query Closed")); - } - - [Test] - public void NoIndexUsed() - { - execSQL("INSERT INTO Test VALUES (1, 'Test1')"); - execSQL("INSERT INTO Test VALUES (2, 'Test1')"); - execSQL("INSERT INTO Test VALUES (3, 'Test1')"); - execSQL("INSERT INTO Test VALUES (4, 'Test1')"); - - MySqlTrace.Listeners.Clear(); - MySqlTrace.Switch.Level = SourceLevels.All; - GenericListener listener = new GenericListener(); - MySqlTrace.Listeners.Add(listener); - - MySqlCommand cmd = new MySqlCommand("SELECT name FROM Test WHERE id=3", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - } - Assert.AreEqual(6, listener.Strings.Count); - Assert.IsTrue(listener.Strings[0].Contains("Query Opened: SELECT name FROM Test WHERE id=3")); - Assert.IsTrue(listener.Strings[1].Contains("Resultset Opened: field(s) = 1, affected rows = -1, inserted id = -1")); - Assert.IsTrue(listener.Strings[2].Contains("Usage Advisor Warning: Query does not use an index")); - Assert.IsTrue(listener.Strings[3].Contains("Usage Advisor Warning: The following columns were not accessed: name")); - Assert.IsTrue(listener.Strings[4].Contains("Resultset Closed. Total rows=1, skipped rows=0, size (bytes)=6")); - Assert.IsTrue(listener.Strings[5].Contains("Query Closed")); - } - - [Test] - public void BadIndexUsed() - { - execSQL("DROP TABLE IF EXISTS Test"); - execSQL("CREATE TABLE Test(id INT, name VARCHAR(20) PRIMARY KEY)"); - execSQL("INSERT INTO Test VALUES (1, 'Test1')"); - execSQL("INSERT INTO Test VALUES (2, 'Test2')"); - execSQL("INSERT INTO Test VALUES (3, 'Test3')"); - execSQL("INSERT INTO Test VALUES (4, 'Test4')"); - - MySqlTrace.Listeners.Clear(); - MySqlTrace.Switch.Level = SourceLevels.All; - GenericListener listener = new GenericListener(); - MySqlTrace.Listeners.Add(listener); - - MySqlCommand cmd = new MySqlCommand("SELECT name FROM Test WHERE id=3", conn); - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - } - Assert.AreEqual(6, listener.Strings.Count); - Assert.IsTrue(listener.Strings[0].Contains("Query Opened: SELECT name FROM Test WHERE id=3")); - Assert.IsTrue(listener.Strings[1].Contains("Resultset Opened: field(s) = 1, affected rows = -1, inserted id = -1")); - Assert.IsTrue(listener.Strings[2].Contains("Usage Advisor Warning: Query does not use an index")); - Assert.IsTrue(listener.Strings[3].Contains("Usage Advisor Warning: The following columns were not accessed: name")); - Assert.IsTrue(listener.Strings[4].Contains("Resultset Closed. Total rows=1, skipped rows=0, size (bytes)=6")); - Assert.IsTrue(listener.Strings[5].Contains("Query Closed")); - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Utils.cs b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Utils.cs deleted file mode 100644 index 38e9991..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/Source/Utils.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2004-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation -// -// There are special exceptions to the terms and conditions of the GPL -// as it is applied to this software. View the full text of the -// exception in file EXCEPTIONS in the directory of this software -// distribution. -// -// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -using System; - -namespace MySql.Data.MySqlClient.Tests -{ - /// - /// Summary description for Utils. - /// - public class Utils - { - - public static byte[] CreateBlob( int size ) - { - byte[] buf = new byte[size]; - - Random r = new Random(); - r.NextBytes( buf ); - return buf; - } - } -} diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-41.config b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-41.config deleted file mode 100644 index 3513bce..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-41.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-50.config b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-50.config deleted file mode 100644 index 9325af3..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-50.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-51.config b/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-51.config deleted file mode 100644 index d7b110b..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/MySql.Data/Tests/configs/mysql-51.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/ThirdParty/mysql-connector-net-6.2.3/README b/ThirdParty/mysql-connector-net-6.2.3/README deleted file mode 100644 index b02b740..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/README +++ /dev/null @@ -1,68 +0,0 @@ -MySQL Connector/Net 6.2 -MySQL AB's ADO.Net Driver for MySQL -Copyright (c) 2004-2007 MySQL AB, 2008-2009 Sun Microsystems - -CONTENTS - -* License -* Documentation Location -* Included software - - -LICENSE - -MySQL Connector/Net is licensed under the GPL or a commercial license -from MySQL AB. - -If you have licensed this product under the GPL, please see the COPYING -file for more information. - -If you have licensed this product under a commercial license from -MySQL AB, please see the file "MySQLEULA.txt" that comes with this -distribution for the terms of the license. - -If you need non-GPL licenses for commercial distribution please contact -me or . - - -DOCUMENTATION LOCATION - -The documentation currently exists in MSDN help format and is located in the 'doc' -directory. - -This software is OSI Certified Open Source Software. -OSI Certified is a certification mark of the Open Source Initiative. - - -INCLUDED SOFTWARE - -The following software may be included in this product: -zlib - -Use of any of this software is governed by the terms of the license below: - -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.3, July 18th, 2005 - - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly jloup@gzip.org - Mark Adler madler@alumni.caltech.edu - -*/ diff --git a/ThirdParty/mysql-connector-net-6.2.3/Release Notes.txt b/ThirdParty/mysql-connector-net-6.2.3/Release Notes.txt deleted file mode 100644 index 8596f97..0000000 --- a/ThirdParty/mysql-connector-net-6.2.3/Release Notes.txt +++ /dev/null @@ -1,19 +0,0 @@ -Connector/Net 6.2 Release Notes ------------------------------------- - -Welcome to the release notes for Connector/Net 6.2 - -What's new in 6.2 --------------------- - -- Idle connection pool cleanup. We now use a timer thread to clean up dead connections from - the connection pool. -- Command timeout has been refactored to use network and stream timeouts instead of a timer. The - result of this is that fewer system resources are used and the system should be more reliable. -- Completely refactored MySqlConnectionStringBuilder -- Completely refactored logging system. It now users fewer cycles when logging is not enabled. - It also logs more information such as query time, number of results, and number of rows returned - by a query. It also keeps all the information for a given query together so it is easier to - follow in the log. - -