svn path=/trunk/mcs/; revision=39278
authorCarlos Guzmán Álvarez <carlos@mono-cvs.ximian.com>
Thu, 20 Jan 2005 20:30:07 +0000 (20:30 -0000)
committerCarlos Guzmán Álvarez <carlos@mono-cvs.ximian.com>
Thu, 20 Jan 2005 20:30:07 +0000 (20:30 -0000)
167 files changed:
mcs/class/FirebirdSql.Data.Firebird/Assembly/AssemblyInfo.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ArrayBase.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ArrayDesc.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BinaryEncoding.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BlobBase.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BlobParameterBuffer.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Charset.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/CharsetCollection.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DatabaseParameterBuffer.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbDataType.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbField.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbStatementType.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbValue.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Descriptor.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/EventParameterBuffer.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/GlobalizationHelper.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IDatabase.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IServiceManager.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ITransaction.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscCodes.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscError.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscErrorCollection.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscException.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscHelper.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ParameterBuffer.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/RemoteEvent.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Resources/isc_error_msg.resources [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Resources/isc_error_msg.txt [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ServiceParameterBuffer.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/StatementBase.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/StringCollection.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TransactionParameterBuffer.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeDecoder.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeEncoder.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeHelper.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/ArrayDescMarshal.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/ArrayDescMarshaler.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FbClient.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesArray.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesBlob.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesConnection.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesDatabase.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesServiceManager.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesStatement.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesTransaction.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/XSQLDA.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/XsqldaMarshaler.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.dll.resources [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.dll.sources [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.snk [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/ClientFactory.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCharacterSets.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCheckConstraints.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbChecksByTable.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCollations.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbColumnPrivileges.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbColumns.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDataTypes.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDbSchema.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDbSchemaFactory.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDomains.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbForeignKeys.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbFunctions.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbGenerators.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbIndexes.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbMetaDataCollections.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbPrimaryKeys.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedureParameters.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedurePrivileges.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedures.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbRestrictions.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbRoles.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTableConstraints.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTablePrivileges.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTables.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTriggers.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbUniqueKeys.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViewColumnUsage.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViewPrivileges.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViews.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCharset.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommand.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommandBuilder.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommandBuilderBehavior.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnection.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionInternal.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionPool.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionString.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDataAdapter.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDataReader.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDatabaseInfo.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDbSchemaType.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDbType.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbError.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbErrorCollection.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbException.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbInfoMessageEventArgs.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbParameter.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbParameterCollection.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRemoteEvent.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRemoteEventEventArgs.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRowUpdatedEventArgs.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRowUpdatingEventArgs.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbTransaction.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbTransactionOptions.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/CommandExecutedEventArgs.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/CommandExecutingEventArgs.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/FbBatchExecution.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/FbScript.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/StringParser.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackup.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackupFile.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackupFlags.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbConfiguration.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbDatabasesInfo.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbLog.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbRestore.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbRestoreFlags.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbSecurity.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServerConfig.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServerProperties.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbService.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServiceState.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbShutdownMode.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbStatistical.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbStatisticalFlags.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbUserData.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbValidation.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbValidationFlags.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/ServiceOutputEventArgs.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird_test.dll.sources [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsArray.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsBlob.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsConnection.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsDatabase.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsEventManager.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsResponse.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsServiceManager.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsStatement.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsTransaction.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/XdrStream.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Makefile [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/App.config [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/AssemblyInfo.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/BaseTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbArrayTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbBlobTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbCommandBuilderTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbCommandTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbConnectionTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbDataAdapterTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbDataReaderTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbDatabaseInfoTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbDatabaseSchemaTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbImplicitTransactionTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbParameterCollectionTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbParameterTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbScriptTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbServicesTests.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbStoredProcCallsTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/FbTransactionTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/Test/GuidTest.cs [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/changelog.txt [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/license.html [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/license.txt [new file with mode: 0644]
mcs/class/FirebirdSql.Data.Firebird/readme.txt [new file with mode: 0644]

diff --git a/mcs/class/FirebirdSql.Data.Firebird/Assembly/AssemblyInfo.cs b/mcs/class/FirebirdSql.Data.Firebird/Assembly/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..797056f
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.ibphoenix.com/main.nfs?a=ibphoenix&l=;PAGES;NAME='ibp_idpl'
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Resources;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: CLSCompliant(true)]
+[assembly: ComVisible(false)]
+[assembly: AssemblyTitle("Firebird .NET Data Provider")]
+[assembly: AssemblyDescription("Firebird .NET Data Provider")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("FirebirdSQL")]
+[assembly: AssemblyProduct("Firebird .NET Data Provider")]
+[assembly: AssemblyCopyright("(c) 2002-2004. Carlos Guzman Alvarez")]
+[assembly: AssemblyVersion("1.7.0.*")]
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("FirebirdSql.Data.Firebird.snk")]
+[assembly: AssemblyKeyName("")]
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ArrayBase.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ArrayBase.cs
new file mode 100644 (file)
index 0000000..22cc1e5
--- /dev/null
@@ -0,0 +1,350 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Text;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Common
+{
+       internal abstract class ArrayBase
+       {
+               #region Fields
+
+               private ArrayDesc       descriptor;
+               private string          tableName;
+               private string          fieldName;
+               private string          rdbFieldName;
+
+               #endregion
+
+               #region Properties
+
+               public ArrayDesc Descriptor
+               {
+                       get { return this.descriptor; }
+               }
+
+               #endregion
+
+               #region Abstract Properties
+
+               public abstract long Handle
+               {
+                       get;
+                       set;
+               }
+
+               public abstract IDatabase DB
+               {
+                       get;
+                       set;
+               }
+
+               public abstract ITransaction Transaction
+               {
+                       get;
+                       set;
+               }
+
+               #endregion
+
+               #region Constructors
+
+        protected ArrayBase(ArrayDesc descriptor)
+        {
+            this.tableName = descriptor.RelationName;
+            this.fieldName = descriptor.FieldName;
+            this.descriptor = descriptor;
+        }
+
+               protected ArrayBase(string tableName, string fieldName)
+               {
+                       this.tableName          = tableName;
+                       this.fieldName          = fieldName;
+                       this.rdbFieldName       = String.Empty;
+               }
+
+               #endregion
+
+               #region Abstract Methods
+
+               public abstract byte[] GetSlice(int slice_length);
+               public abstract void PutSlice(System.Array source_array, int slice_length);             
+               
+               #endregion
+
+               #region Protected Abstract Methods
+
+               protected abstract System.Array DecodeSlice(byte[] slice);
+
+               #endregion
+
+               #region Methods
+
+               public System.Array Read()
+               {
+                       byte[] slice = this.GetSlice(this.GetSliceLength(true));
+                       
+                       return this.DecodeSlice(slice);
+               }
+
+               public void Write(System.Array sourceArray)
+               {
+                       this.SetDesc(sourceArray);
+                       this.PutSlice(sourceArray, this.GetSliceLength(false));
+               }
+
+               public void SetDesc(System.Array sourceArray)
+               {
+                       this.descriptor.Dimensions      = (short)sourceArray.Rank;
+
+                       for (int i = 0; i < sourceArray.Rank; i++)
+                       {
+                               int lb = this.descriptor.Bounds[i].LowerBound;
+                               int ub = sourceArray.GetLength(i) - 1 + lb;
+
+                               this.descriptor.Bounds[i].UpperBound = ub;
+                       }
+               }
+
+               public void LookupBounds()
+               {
+                       this.LookupDesc();
+
+                       StatementBase lookup = this.DB.CreateStatement(this.Transaction);
+
+                       lookup.Prepare(this.GetArrayBounds());
+                       lookup.Execute();
+
+                       int i = 0;
+                       this.descriptor.Bounds = new ArrayBound[16];
+                       DbValue[] values;
+
+                       while((values = lookup.Fetch()) != null)
+                       {
+                               this.descriptor.Bounds[i].LowerBound = values[0].GetInt32();
+                               this.descriptor.Bounds[i].UpperBound = values[1].GetInt32();
+
+                               i++;
+                       }
+                       
+                       lookup.Release();
+                       lookup = null;
+               }
+       
+               public void LookupDesc()
+               {
+                       // Initializa array descriptor information
+                       this.descriptor = new ArrayDesc();
+                       
+                       // Create statement for retrieve information
+                       StatementBase lookup = this.DB.CreateStatement(this.Transaction);
+
+                       lookup.Prepare(this.GetArrayDesc());
+                       lookup.Execute();
+
+                       DbValue[] values = lookup.Fetch();
+                       if(values != null && values.Length > 0)
+                       {                                                               
+                               this.descriptor.RelationName    = tableName;
+                               this.descriptor.FieldName               = fieldName;
+                               this.descriptor.DataType                = values[0].GetByte();
+                               this.descriptor.Scale                   = values[1].GetInt16();
+                               this.descriptor.Length                  = values[2].GetInt16();
+                               this.descriptor.Dimensions              = values[3].GetInt16();
+                               this.descriptor.Flags                   = 0;
+
+                               this.rdbFieldName = values[4].GetString().Trim();
+                       }                       
+                       else
+                       {
+                               throw new InvalidOperationException();
+                       }
+                       
+                       lookup.Release();
+                       lookup = null;
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected int GetSliceLength(bool read)
+               {
+                       int             length                  = 0;
+                       int                     elements                = 0;
+
+                       for (int i = 0; i < this.descriptor.Dimensions; i++)
+                       {
+                               ArrayBound bound = this.descriptor.Bounds[i];
+                               
+                               elements += (bound.UpperBound - bound.LowerBound) + 1;
+                       }
+
+                       length =  elements * this.descriptor.Length;
+
+                       switch (this.descriptor.DataType)
+                       {
+                               case IscCodes.blr_varying:
+                               case IscCodes.blr_varying2:
+                                       length += elements * 2;
+                                       break;
+                       }
+                       
+                       return length;
+               }
+
+               protected Type GetSystemType()
+               {
+                       Type systemType;
+
+                       switch (this.descriptor.DataType)
+                       {
+                               case IscCodes.blr_text:
+                               case IscCodes.blr_text2:
+                               case IscCodes.blr_cstring:
+                               case IscCodes.blr_cstring2:
+                                       // Char
+                                       systemType = typeof(System.String);
+                                       break;
+
+                               case IscCodes.blr_varying:
+                               case IscCodes.blr_varying2:
+                                       // VarChar
+                                       systemType = typeof(System.String);
+                                       break;
+
+                               case IscCodes.blr_short:
+                                       // Short/Smallint
+                                       if (this.descriptor.Scale < 0)
+                                       {
+                                               systemType = typeof(System.Decimal);
+                                       }
+                                       else
+                                       {
+                                               systemType = typeof(System.Int16);
+                                       }
+                                       break;
+
+                               case IscCodes.blr_long:
+                                       // Integer
+                                       if (this.descriptor.Scale < 0)
+                                       {
+                                               systemType = typeof(System.Decimal);
+                                       }
+                                       else
+                                       {
+                                               systemType = typeof(System.Int32);
+                                       }
+                                       break;
+                               
+                               case IscCodes.blr_float:
+                                       // Float
+                                       systemType = typeof(System.Single);
+                                       break;
+                                                                       
+                               case IscCodes.blr_double:
+                               case IscCodes.blr_d_float:
+                                       // Double
+                                       systemType = typeof(System.Double);
+                                       break;
+                                                                                               
+                               case IscCodes.blr_quad:
+                               case IscCodes.blr_int64:
+                                       // Long/Quad
+                                       if (this.descriptor.Scale < 0)
+                                       {
+                                               systemType = typeof(System.Decimal);
+                                       }
+                                       else
+                                       {
+                                               systemType = typeof(System.Int64);
+                                       }
+                                       break;
+                               
+                               case IscCodes.blr_timestamp:
+                                       // Timestamp
+                                       systemType = typeof(System.DateTime);
+                                       break;
+
+                               case IscCodes.blr_sql_time:                     
+                                       // Time
+                                       systemType = typeof(System.DateTime);
+                                       break;
+
+                               case IscCodes.blr_sql_date:                             
+                                       // Date
+                                       systemType = typeof(System.DateTime);
+                                       break;
+                               
+                               default:
+                                       throw new NotSupportedException("Unknown data type");
+                       }
+
+                       return systemType;
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private string GetArrayDesc()
+               {
+                       StringBuilder sql = new StringBuilder();
+
+                       sql.Append(
+                               "SELECT Y.RDB$FIELD_TYPE, Y.RDB$FIELD_SCALE, Y.RDB$FIELD_LENGTH, Y.RDB$DIMENSIONS, X.RDB$FIELD_SOURCE " +
+                               "FROM RDB$RELATION_FIELDS X, RDB$FIELDS Y " +
+                               "WHERE X.RDB$FIELD_SOURCE = Y.RDB$FIELD_NAME ");
+
+                       if (this.tableName != null && this.tableName.Length != 0)
+                       {
+                               sql.AppendFormat(
+                    CultureInfo.CurrentUICulture, " AND X.RDB$RELATION_NAME = '{0}'", tableName);
+                       }
+                                       
+                       if (this.fieldName != null && this.fieldName.Length != 0)
+                       {
+                               sql.AppendFormat(
+                    CultureInfo.CurrentUICulture, " AND X.RDB$FIELD_NAME = '{0}'", fieldName);
+                       }
+                                                                       
+                       return sql.ToString();
+               }
+
+               private string GetArrayBounds()
+               {
+                       StringBuilder sql = new StringBuilder();
+
+                       sql.Append("SELECT X.RDB$LOWER_BOUND, X.RDB$UPPER_BOUND FROM RDB$FIELD_DIMENSIONS X ");                         
+                                       
+                       if (this.fieldName != null && this.fieldName.Length != 0)
+                       {
+                               sql.AppendFormat(
+                    CultureInfo.CurrentUICulture, "WHERE X.RDB$FIELD_NAME = '{0}'", rdbFieldName);
+                       }
+
+                       sql.Append(" ORDER BY X.RDB$DIMENSION");
+
+                       return sql.ToString();
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ArrayDesc.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ArrayDesc.cs
new file mode 100644 (file)
index 0000000..1a500da
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace FirebirdSql.Data.Common
+{
+       internal struct ArrayDesc
+       {
+               #region Fields
+
+               private byte            dataType;
+               private short           scale;
+               private short           length;
+               private string          fieldName;
+               private string          relationName;
+               private short           dimensions;
+               private short           flags;
+               private ArrayBound[] bounds;
+
+               #endregion
+
+               #region Properties
+
+               public byte     DataType
+               {
+                       get { return this.dataType; }
+                       set { this.dataType = value; }
+               }
+
+               // Scale for numeric datatypes
+               public short Scale
+               {
+                       get { return this.scale; }
+                       set { this.scale = value; }
+               }
+
+               // Legth in bytes of each array element
+               public short Length
+               {
+                       get { return this.length; }
+                       set { this.length = value; }
+               }
+
+               // Column name - 32
+               public string FieldName
+               {
+                       get { return this.fieldName; }
+                       set { this.fieldName = value; }
+               }
+
+               // Table name -32
+               public string RelationName
+               {
+                       get { return this.relationName; }
+                       set { this.relationName = value; }
+               }
+
+               // Number of array dimensions 
+               public short Dimensions
+               {
+                       get { return this.dimensions; }
+                       set { this.dimensions = value; }
+               }
+
+               // Specifies wheter array is to be accesed in
+               // row mayor or column-mayor order
+               public short Flags
+               {
+                       get { return this.flags; }
+                       set { this.flags = value; }
+               }
+
+               // Lower and upper bounds for each dimension - 16
+               public ArrayBound[] Bounds
+               {
+                       get { return this.bounds; }
+                       set { this.bounds = value; }
+               }
+
+               #endregion
+       }
+
+       internal struct ArrayBound
+       {
+               #region Fields
+
+               private int lowerBound;
+               private int upperBound;
+
+               #endregion
+
+               #region Properties
+
+               public int LowerBound
+               {
+                       get { return this.lowerBound; }
+                       set { this.lowerBound = value; }
+               }
+
+               public int UpperBound
+               {
+                       get { return this.upperBound; }
+                       set { this.upperBound = value; }
+               }
+
+               #endregion 
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BinaryEncoding.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BinaryEncoding.cs
new file mode 100644 (file)
index 0000000..9581ea4
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ *  BinaryEncoding handler for .Net.  This class implements
+ *     a symmetric encoding that will convert string to byte[]
+ *  and byte[] to string without any character set
+ *  transliteration.
+ *
+ *  The contents of this file were written by jimb
+ *  at connectedsw.com on Dec 9, 2004.  It is placed in
+ *  the Public Domain and may be used as you see fit.
+ */
+
+using System;
+using System.Text;
+
+namespace FirebirdSql.Data.Common
+{
+       internal class BinaryEncoding : Encoding
+       {
+               #region Static Methods
+
+        public static string BytesToString(byte[] byteArray)
+        {
+            // This code isn't great because it requires a double copy,
+            // but it requires unsafe code to solve the problem efficiently.
+            char[] charArray = new char[byteArray.GetLength(0)];
+            Array.Copy(byteArray, charArray, byteArray.Length);
+
+            return new string(charArray);
+        }
+
+               static void Validate(object data, int dataLength, int index, int count)
+               {
+                       if (data == null)
+                       {
+                               throw new ArgumentNullException();
+                       }
+
+                       if (index < 0 || count < 0 || dataLength - index < count)
+                       {
+                               throw new ArgumentOutOfRangeException();
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override int GetByteCount(char[] chars, int index, int count)
+               {
+                       Validate(chars, chars.Length, index, count);
+
+                       return count;
+               }
+
+               public override int GetByteCount(string chars)
+               {
+                       return chars.Length;
+               }
+
+               public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int index)
+               {
+                       Validate(chars, chars.Length, charIndex, charCount);
+
+                       if (index < 0 || index > bytes.Length)
+                       {
+                               throw new ArgumentOutOfRangeException();
+                       }
+                       if (bytes.Length - index < charCount)
+                       {
+                               throw new ArgumentException();
+                       }
+
+                       int charEnd = charIndex + charCount;
+                       while (charIndex < charEnd)
+                       {
+                               bytes[index++] = (byte)chars[charIndex++];
+                       }
+
+                       return charCount;
+               }
+
+               public override int GetBytes(string chars, int charIndex, int charCount, byte[] bytes, int index)
+               {
+                       Validate(chars, chars.Length, charIndex, charCount);
+
+                       if (index < 0 || index > bytes.Length)
+                       {
+                               throw new ArgumentOutOfRangeException();
+                       }
+                       if (bytes.Length - index < charCount)
+                       {
+                               throw new ArgumentException();
+                       }
+
+                       int charEnd = charIndex + charCount;
+                       while (charIndex < charEnd)
+                       {
+                               bytes[index++] = (byte)chars[charIndex++];
+                       }
+
+                       return charCount;
+               }
+
+               public override int GetCharCount(byte[] bytes, int index, int count)
+               {
+                       Validate(bytes, bytes.Length, index, count);
+
+                       return (count);
+               }
+
+               public override int GetChars(byte[] bytes, int index, int count, char[] chars, int charIndex)
+               {
+                       Validate(bytes, bytes.Length, index, count);
+
+                       if (charIndex < 0 || charIndex > chars.Length)
+                       {
+                               throw new ArgumentOutOfRangeException();
+                       }
+                       if (chars.Length - charIndex < count)
+                       {
+                               throw new ArgumentException();
+                       }
+
+                       int byteEnd = index + count;
+                       while (index < byteEnd)
+                       {
+                               chars[charIndex++] = (char)bytes[index++];
+                       }
+
+                       return count;
+               }
+
+               public override string GetString(byte[] bytes)
+               {
+                       return BytesToString(bytes);
+               }
+
+               public override string GetString(byte[] bytes, int index, int count)
+               {
+                       Validate(bytes, bytes.Length, index, count);
+
+                       return BytesToString(bytes);
+               }
+
+               public override int GetMaxByteCount(int charCount)
+               {
+                       return charCount;
+               }
+
+               public override int GetMaxCharCount(int count)
+               {
+                       return count;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BlobBase.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BlobBase.cs
new file mode 100644 (file)
index 0000000..5793b97
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Text;
+using System.IO;
+using System.Collections;
+
+namespace FirebirdSql.Data.Common
+{
+       internal abstract class BlobBase
+       {
+               #region Fields
+
+               private int             rblFlags;
+               private Charset charset;
+               private int             segmentSize;
+
+               #endregion
+
+               #region Protected Fields
+
+               protected long                  blobId;
+               protected int                   blobHandle;
+               protected int                   position;
+               protected ITransaction  transaction;
+
+               #endregion
+
+               #region Properties
+
+               public int Handle
+               {
+                       get { return this.blobHandle; }
+               }
+
+               public long Id
+               {
+                       get { return this.blobId; }
+               }
+
+               public bool EOF
+               {
+                       get { return (this.rblFlags & IscCodes.RBL_eof_pending) != 0; }
+               }
+
+               #endregion
+
+               #region Protected Properties
+
+               protected int SegmentSize
+               {
+                       get { return this.segmentSize; }
+               }
+
+               #endregion
+
+               #region Abstract Properties
+
+               public abstract IDatabase DB
+               {
+                       get;
+               }
+
+               #endregion
+
+               #region Constructors
+
+               protected BlobBase(IDatabase db)
+               {
+                       this.segmentSize        = db.PacketSize;
+                       this.charset            = db.Charset;
+               }
+
+               #endregion
+
+               #region Protected Abstract Methods
+
+               protected abstract void Create();
+               protected abstract void Open();
+               protected abstract byte[] GetSegment();
+               protected abstract void PutSegment(byte[] buffer);
+               protected abstract void Seek(int position);
+               protected abstract void GetBlobInfo();
+               protected abstract void Close();
+               protected abstract void Cancel();
+
+               #endregion
+
+               #region Methods
+
+               public string ReadString()
+               {
+                       byte[] buffer = this.Read();
+                       return this.charset.GetString(buffer, 0, buffer.Length);
+               }
+
+               public byte[] Read()
+               {
+                       MemoryStream ms = new MemoryStream();
+
+                       try
+                       {
+                               this.Open();
+
+                               while (!EOF)
+                               {
+                                       byte[] segment = this.GetSegment();
+                                       ms.Write(segment, 0, segment.Length);
+                               }
+
+                               this.Close();
+                       }
+                       catch (Exception)
+                       {
+                               // Cancel the blob and rethrow the exception
+                               this.Cancel();
+
+                               throw;
+                       }
+
+                       return ms.ToArray();
+               }
+
+               public void Write(string data)
+               {
+                       this.Write(this.charset.GetBytes(data));
+               }
+
+               public void Write(byte[] buffer)
+               {
+                       this.Write(buffer, 0, buffer.Length);
+               }
+
+               public void Write(byte[] buffer, int index, int count)
+               {
+                       try
+                       {
+                               this.Create();
+
+                               byte[] tmpBuffer = null;
+
+                               int length = count;
+                               int offset = index;
+                               int chunk = length >= this.segmentSize ? this.segmentSize : length;
+
+                               tmpBuffer = new byte[chunk];
+
+                               while (length > 0)
+                               {
+                                       if (chunk > length)
+                                       {
+                                               chunk = (int)length;
+                                               tmpBuffer = new byte[chunk];
+                                       }
+                                       System.Array.Copy(buffer, offset, tmpBuffer, 0, chunk);
+                                       this.PutSegment(tmpBuffer);
+
+                                       offset += chunk;
+                                       length -= chunk;
+                               }
+
+                               this.Close();
+                       }
+                       catch (Exception)
+                       {
+                               // Cancel the blob and rethrow the exception
+                               this.Cancel();
+
+                               throw;
+                       }
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected void RblAddValue(int rblValue)
+               {
+                       this.rblFlags |= rblValue;
+               }
+
+               protected void RblRemoveValue(int rblValue)
+               {
+                       this.rblFlags &= ~rblValue;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BlobParameterBuffer.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BlobParameterBuffer.cs
new file mode 100644 (file)
index 0000000..eb54688
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class BlobParameterBuffer : ParameterBuffer
+       {
+               #region Constructors
+
+               public BlobParameterBuffer(bool isLittleEndian) : base(isLittleEndian)
+               {
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Charset.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Charset.cs
new file mode 100644 (file)
index 0000000..5cdd015
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Text;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class Charset
+       {
+               #region Static Fields
+
+               private static CharsetCollection supportedCharsets;
+
+               #endregion
+
+               #region Static Properties
+
+               public static CharsetCollection SupportedCharsets
+               {
+                       get
+                       {
+                               if (Charset.supportedCharsets == null)
+                               {
+                                       Charset.InitializeSupportedCharsets();
+                               }
+
+                               return Charset.supportedCharsets;
+                       }
+               }
+
+               public static Charset DefaultCharset
+               {
+                       get { return Charset.SupportedCharsets[0]; }
+               }
+
+               #endregion
+
+               #region Fields
+
+               private int             id;
+               private string  name;
+               private string  systemName;
+               private int             bytesPerCharacter;
+
+               #endregion
+
+               #region Properties
+
+               public int ID
+               {
+                       get { return this.id; }
+               }
+
+               public string Name
+               {
+                       get { return this.name; }
+               }
+
+               public int BytesPerCharacter
+               {
+                       get { return this.bytesPerCharacter; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public Charset(
+                       int             id,
+                       string  name,
+                       int             bytesPerCharacter,
+                       string  systemName)
+               {
+                       this.id                 = id;
+                       this.name               = name;
+                       this.bytesPerCharacter  = bytesPerCharacter;
+                       this.systemName         = systemName;
+               }
+
+               #endregion
+
+               #region Methods
+
+               /*
+               public int GetByteCount(string s)
+               {
+                       return this.encoding.GetByteCount(s);
+               }
+               */
+
+               public byte[] GetBytes(string s)
+               {
+                       return this.GetEncoding().GetBytes(s);
+               }
+
+               public int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
+               {
+                       return this.GetEncoding().GetBytes(s, charIndex, charCount, bytes, byteIndex);
+               }       
+
+               public string GetString(byte[] buffer)
+               {
+                       return this.GetString(buffer, 0, buffer.Length);
+               }
+
+               public string GetString(byte[] buffer, int index, int count)
+               {
+                       return this.GetEncoding().GetString(buffer, index, count);
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private Encoding GetEncoding()
+               {
+                       switch (this.systemName)
+                       {
+                               case "NONE":
+                                       return Encoding.Default;
+
+                               case "OCTETS":
+                                       return new BinaryEncoding();
+
+                               default:
+                                       return Encoding.GetEncoding(this.systemName);
+                       }                       
+               }
+
+               #endregion
+
+               #region Static Methods
+
+               public static void InitializeSupportedCharsets()
+               {
+                       Charset.supportedCharsets = new CharsetCollection();
+
+                       // NONE
+                       Charset.AddCharset(0, "NONE", 1, "NONE");
+                       // OCTETS
+                       Charset.AddCharset(1, "OCTETS", 1, "OCTETS");
+                       // American Standard Code for Information Interchange   
+                       Charset.AddCharset(2, "ASCII", 1, "ascii");
+                       // Eight-bit Unicode Transformation Format
+                       Charset.AddCharset(3, "UNICODE_FSS", 3, "UTF-8");
+                       // Shift-JIS, Japanese
+                       Charset.AddCharset(5, "SJIS_0208", 2, "shift_jis");
+                       // JIS X 0201, 0208, 0212, EUC encoding, Japanese
+                       Charset.AddCharset(6, "EUCJ_0208", 2, "euc-jp");
+                       // Windows Japanese     
+                       Charset.AddCharset(7, "ISO2022-JP", 2, "iso-2022-jp");
+                       // MS-DOS United States, Australia, New Zealand, South Africa   
+                       Charset.AddCharset(10, "DOS437", 1, "IBM437");
+                       // MS-DOS Latin-1                               
+                       Charset.AddCharset(11, "DOS850", 1, "ibm850");
+                       // MS-DOS Nordic        
+                       Charset.AddCharset(12, "DOS865", 1, "IBM865");
+                       // MS-DOS Portuguese    
+                       Charset.AddCharset(13, "DOS860", 1, "IBM860");
+                       // MS-DOS Canadian French       
+                       Charset.AddCharset(14, "DOS863", 1, "IBM863");
+                       // ISO 8859-1, Latin alphabet No. 1
+                       Charset.AddCharset(21, "ISO8859_1", 1, "iso-8859-1");
+                       // ISO 8859-2, Latin alphabet No. 2
+                       Charset.AddCharset(22, "ISO8859_2", 1, "iso-8859-2");
+                       // Windows Korean       
+                       Charset.AddCharset(44, "KSC_5601", 2, "ks_c_5601-1987");
+                       // MS-DOS Icelandic     
+                       Charset.AddCharset(47, "DOS861", 1, "ibm861");
+                       // Windows Eastern European
+                       Charset.AddCharset(51, "WIN1250", 1, "windows-1250");
+                       // Windows Cyrillic
+                       Charset.AddCharset(52, "WIN1251", 1, "windows-1251");
+                       // Windows Latin-1
+                       Charset.AddCharset(53, "WIN1252", 1, "windows-1252");
+                       // Windows Greek
+                       Charset.AddCharset(54, "WIN1253", 1, "windows-1253");
+                       // Windows Turkish
+                       Charset.AddCharset(55, "WIN1254", 1, "windows-1254");
+                       // Big5, Traditional Chinese
+                       Charset.AddCharset(56, "BIG_5", 2, "big5");
+                       // GB2312, EUC encoding, Simplified Chinese     
+                       Charset.AddCharset(57, "GB_2312", 2, "gb2312");
+                       // Windows Hebrew
+                       Charset.AddCharset(58, "WIN1255", 1, "windows-1255");
+                       // Windows Arabic       
+                       Charset.AddCharset(59, "WIN1256", 1, "windows-1256");
+                       // Windows Baltic       
+                       Charset.AddCharset(60, "WIN1257", 1, "windows-1257");
+               }
+
+               private static void AddCharset(
+                       int             id,
+                       string  charset,
+                       int             bytesPerCharacter,
+                       string  systemName)
+               {
+                       Charset.SupportedCharsets.Add(
+                                       id,
+                                       charset,
+                                       bytesPerCharacter,
+                                       systemName);
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/CharsetCollection.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/CharsetCollection.cs
new file mode 100644 (file)
index 0000000..0d6255e
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Text;
+using System.Collections;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class CharsetCollection : CollectionBase
+       {
+               #region Indexers
+
+               public Charset this[int index]
+               {
+                       get { return (Charset)this.List[index]; }
+               }
+
+               public Charset this[string name]
+               {
+                       get { return (Charset)this[this.IndexOf(name)]; }
+               }
+
+               #endregion
+
+               #region Methods
+
+               public int IndexOf(int id)
+               {
+                       int index = 0;
+
+                       foreach (Charset item in this)
+                       {
+                               if (item.ID == id)
+                               {
+                                       return index;
+                               }
+                               index++;
+                       }
+
+                       return -1;
+               }
+
+               public int IndexOf(string name)
+               {
+                       int index = 0;
+
+                       foreach (Charset item in this)
+                       {
+                               if (GlobalizationHelper.CultureAwareCompare(item.Name, name))
+                               {
+                                       return index;
+                               }
+                               index++;
+                       }
+
+                       return -1;
+               }
+
+               internal Charset Add(
+                       int             id,
+                       string  charset,
+                       int             bytesPerCharacter,
+                       string  systemCharset)
+               {
+                       Charset charSet = new Charset(
+                               id,
+                               charset,
+                               bytesPerCharacter,
+                               systemCharset);
+
+                       return this.Add(charSet);
+               }
+
+               internal Charset Add(Charset charset)
+               {
+                       this.List.Add(charset);
+
+                       return charset;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DatabaseParameterBuffer.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DatabaseParameterBuffer.cs
new file mode 100644 (file)
index 0000000..8132930
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using System.Text;
+using System.Net;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class DatabaseParameterBuffer : ParameterBuffer
+       {                       
+               #region Constructors
+
+               public DatabaseParameterBuffer() : base()
+               {
+               }
+               
+               public DatabaseParameterBuffer(bool isLittleEndian) : base(isLittleEndian)
+               {
+               }
+
+               #endregion
+               
+               #region Methods
+
+               public void Append(int type, byte value)
+               {                                               
+                       this.WriteByte(type);
+                       this.WriteByte(1);
+                       this.Write(value);
+               }
+
+               public void Append(int type, short value)
+               {                                               
+                       this.WriteByte(type);
+                       this.WriteByte(2);
+                       this.Write(value);
+               }
+
+               public void Append(int type, int value)
+               {
+                       this.WriteByte(type);
+                       this.WriteByte((byte)4);
+                       this.Write(value);
+               }
+
+               public void Append(int type, string content)
+               {
+                       this.Append(type, Encoding.Default.GetBytes(content));
+               }
+
+               public void Append(int type, byte[] buffer)
+               {                                               
+                       this.WriteByte(type);
+                       this.WriteByte(buffer.Length);
+                       this.Write(buffer);
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbDataType.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbDataType.cs
new file mode 100644 (file)
index 0000000..86ddb8c
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Common
+{
+       internal enum DbDataType
+       {
+               Array                   ,
+               BigInt                  ,
+               Binary                  ,
+               Char                    ,
+               Date                    ,
+               Decimal                 ,
+               Double                  ,
+               Float                   ,
+               Guid                    ,
+               Integer                 ,
+               Numeric                 ,
+               SmallInt                ,
+               Text                    ,
+               Time                    ,
+               TimeStamp               ,
+               VarChar
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbField.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbField.cs
new file mode 100644 (file)
index 0000000..18c31ec
--- /dev/null
@@ -0,0 +1,660 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Text;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class DbField
+       {
+               #region Fields
+
+               private short           dataType;
+               private short           numericScale;
+               private short           subType;
+               private short           length;
+               private short           nullFlag;
+               private string          name;
+               private string          relation;
+               private string          owner;
+               private string          alias;
+               private int                     charCount;
+               private DbValue         dbValue;
+               private Charset         charset;
+               private ArrayBase       arrayHandle;
+
+               #endregion
+
+               #region Properties
+
+               public DbDataType DbDataType
+               {
+                       get { return this.GetDbDataType(); }
+               }
+
+               public int SqlType
+               {
+                       get { return this.dataType & ~1; }
+               }
+
+               public short DataType
+               {
+                       get { return this.dataType; }
+                       set { this.dataType = value; }
+               }
+
+               public short NumericScale
+               {
+                       get { return this.numericScale; }
+                       set { this.numericScale = value; }
+               }
+
+               public short SubType
+               {
+                       get { return this.subType; }
+                       set
+                       {
+                               this.subType = value;
+                               if (this.IsCharacter())
+                               {
+                                       // Bits 0-7 of sqlsubtype is charset_id (127 is a special value -
+                                       // current attachment charset).
+                                       // Bits 8-17 hold collation_id for this value.
+                                       byte[] cs = BitConverter.GetBytes(value);
+
+                                       int index = Charset.SupportedCharsets.IndexOf(cs[0]);
+                                       if (index != -1)
+                                       {
+                                               this.charset = Charset.SupportedCharsets[index];
+                                       }
+                                       else
+                                       {
+                                               this.charset = Charset.SupportedCharsets[0];
+                                       }
+                               }
+                       }
+               }
+
+               public short Length
+               {
+                       get { return this.length; }
+                       set
+                       {
+                               this.length = value;
+                               if (this.IsCharacter())
+                               {
+                                       this.charCount = this.length / this.charset.BytesPerCharacter;
+                               }
+                       }
+               }
+
+               public short NullFlag
+               {
+                       get { return this.nullFlag; }
+                       set { this.nullFlag = value; }
+               }
+
+               public string Name
+               {
+                       get { return this.name; }
+                       set { this.name = value.Trim(); }
+               }
+
+               public string Relation
+               {
+                       get { return this.relation; }
+                       set { this.relation = value.Trim(); }
+               }
+
+               public string Owner
+               {
+                       get { return this.owner; }
+                       set { this.owner = value.Trim(); }
+               }
+
+               public string Alias
+               {
+                       get { return this.alias; }
+                       set { this.alias = value.Trim(); }
+               }
+
+               public Charset Charset
+               {
+                       get { return this.charset; }
+               }
+
+               public int CharCount
+               {
+                       get { return this.charCount; }
+               }
+
+               public ArrayBase ArrayHandle
+               {
+                       get
+                       {
+                               if (this.IsArray())
+                               {
+                                       return this.arrayHandle;
+                               }
+                               else
+                               {
+                                       throw new IscException("Field is not an array type");
+                               }
+                       }
+
+                       set
+                       {
+                               if (this.IsArray())
+                               {
+                                       this.arrayHandle = value;
+                               }
+                               else
+                               {
+                                       throw new IscException("Field is not an array type");
+                               }
+                       }
+               }
+
+               public DbValue DbValue
+               {
+                       get { return this.dbValue; }
+               }
+
+               public object Value
+               {
+                       get { return this.dbValue.Value; }
+                       set { this.dbValue.Value = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public DbField()
+               {
+                       this.charCount  = -1;
+                       this.name               = String.Empty;
+                       this.relation   = String.Empty;
+                       this.owner              = String.Empty;
+                       this.alias              = String.Empty;
+                       this.dbValue    = new DbValue(this, DBNull.Value);
+               }
+
+               #endregion
+
+               #region Methods
+
+               public bool IsNumeric()
+               {
+                       if (this.dataType == 0)
+                       {
+                               return false;
+                       }
+
+                       switch (this.DbDataType)
+                       {
+                               case DbDataType.SmallInt:
+                               case DbDataType.Integer:
+                               case DbDataType.BigInt:
+                               case DbDataType.Numeric:
+                               case DbDataType.Decimal:
+                               case DbDataType.Float:
+                               case DbDataType.Double:
+                                       return true;
+
+                               default:
+                                       return false;
+                       }
+               }
+
+               public bool IsDecimal()
+               {
+                       if (this.dataType == 0)
+                       {
+                               return false;
+                       }
+
+                       switch (this.DbDataType)
+                       {
+                               case DbDataType.Numeric:
+                               case DbDataType.Decimal:
+                                       return true;
+
+                               default:
+                                       return false;
+                       }
+               }
+
+               public bool IsLong()
+               {
+                       if (this.dataType == 0)
+                       {
+                               return false;
+                       }
+
+                       switch (this.DbDataType)
+                       {
+                               case DbDataType.Binary:
+                               case DbDataType.Text:
+                                       return true;
+
+                               default:
+                                       return false;
+                       }
+               }
+
+               public bool IsCharacter()
+               {
+                       if (this.dataType == 0)
+                       {
+                               return false;
+                       }
+
+                       switch (this.DbDataType)
+                       {
+                               case DbDataType.Char:
+                               case DbDataType.VarChar:
+                               case DbDataType.Text:
+                                       return true;
+
+                               default:
+                                       return false;
+                       }
+               }
+
+               public bool IsArray()
+               {
+                       if (this.dataType == 0)
+                       {
+                               return false;
+                       }
+
+                       switch (this.DbDataType)
+                       {
+                               case DbDataType.Array:
+                                       return true;
+
+                               default:
+                                       return false;
+                       }
+               }
+
+               public bool IsAliased()
+               {
+                       return (this.Name != this.Alias) ? true : false;
+               }
+
+               public bool IsExpression()
+               {
+                       return this.Name.Length == 0 ? true : false;
+               }
+
+               public int GetSize()
+               {
+                       if (this.IsLong())
+                       {
+                               return System.Int32.MaxValue;
+                       }
+                       else
+                       {
+                               if (this.IsCharacter())
+                               {
+                                       return this.CharCount;
+                               }
+                               else
+                               {
+                                       return this.Length;
+                               }
+                       }
+               }
+
+               public bool AllowDBNull()
+               {
+                       return ((this.DataType & 1) == 1);
+               }
+
+               public void SetValue(byte[] buffer)
+               {
+                       if (buffer == null || this.NullFlag == -1)
+                       {
+                               this.Value = System.DBNull.Value;
+                       }
+                       else
+                       {
+                               switch (this.SqlType)
+                               {
+                                       case IscCodes.SQL_TEXT:
+                                       case IscCodes.SQL_VARYING:
+                                               if (this.DbDataType == DbDataType.Guid)
+                                               {
+                                                       this.Value = new Guid(buffer);
+                                               }
+                                               else
+                                               {
+                                                       string s = this.Charset.GetString(buffer, 0, buffer.Length);
+                                                       if ((this.Length % this.Charset.BytesPerCharacter) == 0 &&
+                                                               s.Length > this.CharCount)
+                                                       {
+                                                               s = s.Substring(0, this.CharCount);
+                                                       }
+                                                       this.Value = s;
+                                               }
+                                               break;
+
+                                       case IscCodes.SQL_SHORT:
+                                               if (this.numericScale < 0)
+                                               {
+                                                       this.Value = TypeDecoder.DecodeDecimal(
+                                                               BitConverter.ToInt16(buffer, 0),
+                                                               this.numericScale,
+                                                               this.dataType);
+                                               }
+                                               else
+                                               {
+                                                       this.Value = BitConverter.ToInt16(buffer, 0);
+                                               }
+                                               break;
+
+                                       case IscCodes.SQL_LONG:
+                                               if (this.NumericScale < 0)
+                                               {
+                                                       this.Value = TypeDecoder.DecodeDecimal(
+                                                               BitConverter.ToInt32(buffer, 0),
+                                                               this.numericScale,
+                                                               this.dataType);
+                                               }
+                                               else
+                                               {
+                                                       this.Value = BitConverter.ToInt32(buffer, 0);
+                                               }
+                                               break;
+
+                                       case IscCodes.SQL_FLOAT:
+                                               this.Value = BitConverter.ToSingle(buffer, 0);
+                                               break;
+
+                                       case IscCodes.SQL_DOUBLE:
+                                       case IscCodes.SQL_D_FLOAT:
+                                               this.Value = BitConverter.ToDouble(buffer, 0);
+                                               break;
+
+                                       case IscCodes.SQL_QUAD:
+                                       case IscCodes.SQL_INT64:
+                                       case IscCodes.SQL_BLOB:
+                                       case IscCodes.SQL_ARRAY:
+                                               if (this.NumericScale < 0)
+                                               {
+                                                       this.Value = TypeDecoder.DecodeDecimal(
+                                                               BitConverter.ToInt64(buffer, 0),
+                                                               this.numericScale,
+                                                               this.dataType);
+                                               }
+                                               else
+                                               {
+                                                       this.Value = BitConverter.ToInt64(buffer, 0);
+                                               }
+                                               break;
+
+                                       case IscCodes.SQL_TIMESTAMP:
+                                               DateTime date = TypeDecoder.DecodeDate(
+                                                       BitConverter.ToInt32(buffer, 0));
+
+                                               DateTime time = TypeDecoder.DecodeTime(
+                                                       BitConverter.ToInt32(buffer, 4));
+
+                                               this.Value = new System.DateTime(
+                                                       date.Year, date.Month, date.Day,
+                                                       time.Hour, time.Minute, time.Second, time.Millisecond);
+                                               break;
+
+                                       case IscCodes.SQL_TYPE_TIME:
+                                               this.Value = TypeDecoder.DecodeTime(BitConverter.ToInt32(buffer, 0));
+                                               break;
+
+                                       case IscCodes.SQL_TYPE_DATE:
+                                               this.Value = TypeDecoder.DecodeDate(BitConverter.ToInt32(buffer, 0));
+                                               break;
+
+                                       default:
+                                               throw new NotSupportedException("Unknown data type");
+                               }
+                       }
+               }
+
+               public void FixNull()
+               {
+                       if (this.NullFlag == -1 && this.dbValue.IsDBNull())
+                       {
+                               switch (this.DbDataType)
+                               {
+                                       case DbDataType.Char:
+                                       case DbDataType.VarChar:
+                                       case DbDataType.Guid:
+                                               this.Value = String.Empty;
+                                               break;
+
+                                       case DbDataType.SmallInt:
+                                               this.Value = (short)0;
+                                               break;
+
+                                       case DbDataType.Integer:
+                                               this.Value = (int)0;
+                                               break;
+
+                                       case DbDataType.BigInt:
+                                       case DbDataType.Binary:
+                                       case DbDataType.Array:
+                                       case DbDataType.Text:
+                                               this.Value = (long)0;
+                                               break;
+
+                                       case DbDataType.Numeric:
+                                       case DbDataType.Decimal:
+                                               this.Value = (decimal)0;
+                                               break;
+
+                                       case DbDataType.Float:
+                                               this.Value = (float)0;
+                                               break;
+
+                                       case DbDataType.Double:
+                                               this.Value = (double)0;
+                                               break;
+
+                                       case DbDataType.Date:
+                                       case DbDataType.Time:
+                                       case DbDataType.TimeStamp:
+                                               this.Value = new System.DateTime(0 * 10000L + 621355968000000000);
+                                               break;
+
+                                       default:
+                                               throw new IscException("Unknown sql data type: " + this.DataType);
+                               }
+                       }
+               }
+
+               public Type GetSystemType()
+               {
+                       switch (this.DbDataType)
+                       {
+                               case DbDataType.Char:
+                               case DbDataType.VarChar:
+                               case DbDataType.Text:
+                                       return Type.GetType("System.String");
+
+                               case DbDataType.SmallInt:
+                                       return Type.GetType("System.Int16");
+
+                               case DbDataType.Integer:
+                                       return Type.GetType("System.Int32");
+
+                               case DbDataType.BigInt:
+                                       return Type.GetType("System.Int64");
+
+                               case DbDataType.Numeric:
+                               case DbDataType.Decimal:
+                                       return Type.GetType("System.Decimal");
+
+                               case DbDataType.Float:
+                                       return Type.GetType("System.Single");
+
+                               case DbDataType.Guid:
+                                       return Type.GetType("System.Guid");
+
+                               case DbDataType.Double:
+                                       return Type.GetType("System.Double");
+
+                               case DbDataType.Date:
+                               case DbDataType.Time:
+                               case DbDataType.TimeStamp:
+                                       return Type.GetType("System.DateTime");
+
+                               case DbDataType.Binary:
+                               case DbDataType.Array:
+                                       return Type.GetType("System.Array");
+
+                               default:
+                                       throw new SystemException("Invalid data type");
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private DbDataType GetDbDataType()
+               {
+                       // Special case for Guid handling
+                       if (this.SqlType == IscCodes.SQL_TEXT && this.Length == 16 &&
+                               (this.Charset != null && this.Charset.Name == "OCTETS"))
+                       {
+                               return DbDataType.Guid;
+                       }
+
+                       switch (this.SqlType)
+                       {
+                               case IscCodes.SQL_TEXT:
+                                       return DbDataType.Char;
+
+                               case IscCodes.SQL_VARYING:
+                                       return DbDataType.VarChar;
+
+                               case IscCodes.SQL_SHORT:
+                                       if (this.numericScale < 0)
+                                       {
+                                               if (this.subType == 2)
+                                               {
+                                                       return DbDataType.Decimal;
+                                               }
+                                               else
+                                               {
+                                                       return DbDataType.Numeric;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               return DbDataType.SmallInt;
+                                       }
+
+                               case IscCodes.SQL_LONG:
+                                       if (this.numericScale < 0)
+                                       {
+                                               if (this.subType == 2)
+                                               {
+                                                       return DbDataType.Decimal;
+                                               }
+                                               else
+                                               {
+                                                       return DbDataType.Numeric;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               return DbDataType.Integer;
+                                       }
+
+                               case IscCodes.SQL_FLOAT:
+                                       return DbDataType.Float;
+
+                               case IscCodes.SQL_DOUBLE:
+                               case IscCodes.SQL_D_FLOAT:
+                                       if (this.numericScale < 0)
+                                       {
+                                               if (this.subType == 2)
+                                               {
+                                                       return DbDataType.Decimal;
+                                               }
+                                               else
+                                               {
+                                                       return DbDataType.Numeric;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               return DbDataType.Double;
+                                       }
+
+                               case IscCodes.SQL_BLOB:
+                                       if (this.subType == 1)
+                                       {
+                                               return DbDataType.Text;
+                                       }
+                                       else
+                                       {
+                                               return DbDataType.Binary;
+                                       }
+
+                               case IscCodes.SQL_QUAD:
+                               case IscCodes.SQL_INT64:
+                                       if (this.numericScale < 0)
+                                       {
+                                       if (this.subType == 2)
+                                               {
+                                                       return DbDataType.Decimal;
+                                               }
+                                               else
+                                               {
+                                                       return DbDataType.Numeric;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               return DbDataType.BigInt;
+                                       }
+
+                               case IscCodes.SQL_TIMESTAMP:
+                                       return DbDataType.TimeStamp;
+
+                               case IscCodes.SQL_TYPE_TIME:
+                                       return DbDataType.Time;
+
+                               case IscCodes.SQL_TYPE_DATE:
+                                       return DbDataType.Date;
+
+                               case IscCodes.SQL_ARRAY:
+                                       return DbDataType.Array;
+
+                               default:
+                                       throw new SystemException("Invalid data type");
+                       }
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbStatementType.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbStatementType.cs
new file mode 100644 (file)
index 0000000..c5ace9d
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Common
+{
+       internal enum DbStatementType : int
+       {
+               None                    = 0,
+               Select                  = IscCodes.isc_info_sql_stmt_select,
+               Insert                  = IscCodes.isc_info_sql_stmt_insert,
+               Update                  = IscCodes.isc_info_sql_stmt_update,
+               Delete                  = IscCodes.isc_info_sql_stmt_delete,
+               DDL                             = IscCodes.isc_info_sql_stmt_ddl,
+               GetSegment              = IscCodes.isc_info_sql_stmt_get_segment,
+               PutSegment              = IscCodes.isc_info_sql_stmt_put_segment,
+               StoredProcedure = IscCodes.isc_info_sql_stmt_exec_procedure,
+               StartTrans              = IscCodes.isc_info_sql_stmt_start_trans,
+               Commit                  = IscCodes.isc_info_sql_stmt_commit,
+               Rollback                = IscCodes.isc_info_sql_stmt_rollback,
+               SelectForUpdate = IscCodes.isc_info_sql_stmt_select_for_upd,
+               SetGenerator    = IscCodes.isc_info_sql_stmt_set_generator,
+               SavePoint               = IscCodes.isc_info_sql_stmt_savepoint
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbValue.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbValue.cs
new file mode 100644 (file)
index 0000000..003c614
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class DbValue
+       {
+               #region Fields
+
+               private StatementBase   statement;
+               private DbField                 field;
+               private object                  value;
+
+               #endregion
+
+               #region Properties
+
+               public DbField Field
+               {
+                       get { return this.field; }
+               }
+
+               public object Value
+               {
+                       get { return this.GetValue(); }
+                       set { this.value = value; }
+               }
+
+               #endregion
+
+               #region Constructor
+
+               public DbValue(DbField field, object value)
+               {
+                       this.field = field;
+                       this.value = value == null ? System.DBNull.Value : value;
+               }
+
+               public DbValue(StatementBase statement, DbField field)
+               {
+                       this.statement = statement;
+                       this.field = field;
+                       this.value = field.Value;
+               }
+
+               public DbValue(StatementBase statement, DbField field, object value)
+               {
+                       this.statement = statement;
+                       this.field = field;
+                       this.value = value == null ? System.DBNull.Value : value;
+               }
+
+               #endregion
+
+               #region Methods
+
+               public bool IsDBNull()
+               {
+                       if (this.value == null || this.value == System.DBNull.Value)
+                       {
+                               return true;
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               }
+
+               public string GetString()
+               {
+                       if (this.Field.DbDataType == DbDataType.Text)
+                       {
+                               // This is for ascii blobs
+                               this.value = this.GetClobData((long)this.value);
+                       }
+                       return this.value.ToString();
+               }
+
+               public char GetChar()
+               {
+                       return Convert.ToChar(this.value, CultureInfo.CurrentUICulture);
+               }
+
+               public bool GetBoolean()
+               {
+                       return Convert.ToBoolean(this.value, CultureInfo.InvariantCulture);
+               }
+
+               public byte GetByte()
+               {
+                       return Convert.ToByte(this.value, CultureInfo.InvariantCulture);
+               }
+
+               public short GetInt16()
+               {
+                       return Convert.ToInt16(this.value, CultureInfo.InvariantCulture);
+               }
+
+               public int GetInt32()
+               {
+                       return Convert.ToInt32(this.value, CultureInfo.InvariantCulture);
+               }
+
+               public long GetInt64()
+               {
+                       return Convert.ToInt64(this.value, CultureInfo.InvariantCulture);
+               }
+
+               public decimal GetDecimal()
+               {
+                       return Convert.ToDecimal(this.value, CultureInfo.InvariantCulture);
+               }
+
+               public float GetFloat()
+               {
+                       return Convert.ToSingle(this.value, CultureInfo.InvariantCulture);
+               }
+
+               public Guid GetGuid()
+               {
+                       if (this.Value is Guid)
+                       {
+                               return (Guid)this.Value;
+                       }
+                       else if (this.Value is byte[])
+                       {
+                               return new Guid((byte[])this.value);
+                       }
+
+                       throw new InvalidOperationException("Incorrect Guid value");
+               }
+
+               public double GetDouble()
+               {
+                       return Convert.ToDouble(this.value, CultureInfo.InvariantCulture);
+               }
+
+               public DateTime GetDateTime()
+               {
+                       return Convert.ToDateTime(this.value, CultureInfo.CurrentUICulture.DateTimeFormat);
+               }
+
+               public Array GetArray()
+               {
+                       if (this.value is long)
+                       {
+                               this.value = this.GetArrayData((long)this.value);
+                       }
+                       return (Array)this.value;
+               }
+
+               public byte[] GetBinary()
+               {
+                       if (this.value is long)
+                       {
+                               this.value = this.GetBlobData((long)this.value);
+                       }
+                       return (byte[])this.value;
+               }
+
+               public int EncodeDate()
+               {
+                       return TypeEncoder.EncodeDate(this.GetDateTime());
+               }
+
+               public int EncodeTime()
+               {
+                       return TypeEncoder.EncodeTime(this.GetDateTime());
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private object GetValue()
+               {
+                       if (this.IsDBNull())
+                       {
+                               return System.DBNull.Value;
+                       }
+
+                       switch (this.field.DbDataType)
+                       {
+                               case DbDataType.Text:
+                                       if (this.statement == null)
+                                       {
+                                               return this.GetInt64();
+                                       }
+                                       else
+                                       {
+                                               return this.GetString();
+                                       }
+
+                               case DbDataType.Binary:
+                                       if (this.statement == null)
+                                       {
+                                               return this.GetInt64();
+                                       }
+                                       else
+                                       {
+                                               return this.GetBinary();
+                                       }
+
+                               case DbDataType.Array:
+                                       if (this.statement == null)
+                                       {
+                                               return this.GetInt64();
+                                       }
+                                       else
+                                       {
+                                               return this.GetArray();
+                                       }
+
+                               default:
+                                       return this.value;
+                       }
+               }
+
+               private string GetClobData(long blobId)
+               {
+                       BlobBase clob = this.statement.CreateBlob(blobId);
+
+                       return clob.ReadString();
+               }
+
+               private byte[] GetBlobData(long blobId)
+               {
+                       BlobBase blob = this.statement.CreateBlob(blobId);
+
+                       return blob.Read();
+               }
+
+               private Array GetArrayData(long handle)
+               {
+            if (this.field.ArrayHandle == null)
+            {
+                this.field.ArrayHandle = this.statement.CreateArray(handle, this.Field.Relation, this.Field.Name);
+            }
+            
+            ArrayBase gdsArray      = this.statement.CreateArray(this.field.ArrayHandle.Descriptor);
+            gdsArray.Handle         = handle;
+            gdsArray.DB             = this.statement.DB;
+            gdsArray.Transaction    = this.statement.Transaction;
+
+                       return gdsArray.Read();
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Descriptor.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Descriptor.cs
new file mode 100644 (file)
index 0000000..17203b5
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.IO;
+
+namespace FirebirdSql.Data.Common
+{
+       /// <summary>
+       /// Descriptor of query input and output parameters.
+       /// </summary>
+       /// <remarks>
+       /// This is similar to the XSQLDA structure described 
+       /// in the Interbase 6.0 API docs.
+       /// </remarks>
+       internal sealed class Descriptor : ICloneable
+       {
+               #region Fields
+
+               private short           version;
+               private short           count;
+               private short           actualCount;
+               private DbField[]       fields;
+
+               #endregion
+
+               #region Properties
+
+               public short Version
+               {
+                       get { return this.version; }
+                       set { this.version = value; }
+               }
+
+               public short Count
+               {
+                       get { return this.count; }
+               }
+
+               public short ActualCount
+               {
+                       get { return this.actualCount; }
+                       set { this.actualCount = value; }
+               }
+
+               #endregion
+
+               #region Indexers
+
+               public DbField this[int index]
+               {
+                       get { return this.fields[index]; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public Descriptor(short n)
+               {
+                       this.version            = IscCodes.SQLDA_VERSION1;
+                       this.count                      = n;
+                       this.actualCount        = n;
+                       this.fields                     = new DbField[n];
+
+                       for (int i = 0; i < n; i++)
+                       {
+                               this.fields[i] = new DbField();
+                       }
+               }
+
+               #endregion
+
+               #region ICloneable Methods
+
+               public object Clone()
+               {
+                       Descriptor descriptor   = new Descriptor(this.Count);
+                       descriptor.Version              = this.version;
+
+                       for (int i = 0; i < descriptor.Count; i++)
+                       {
+                               descriptor[i].DataType          = this.fields[i].DataType;
+                               descriptor[i].NumericScale      = this.fields[i].NumericScale;
+                               descriptor[i].SubType           = this.fields[i].SubType;
+                               descriptor[i].Length            = this.fields[i].Length;
+                               descriptor[i].Value                     = this.fields[i].Value;
+                               descriptor[i].NullFlag          = this.fields[i].NullFlag;
+                               descriptor[i].Name                      = this.fields[i].Name;
+                               descriptor[i].Relation          = this.fields[i].Relation;
+                               descriptor[i].Owner                     = this.fields[i].Owner;
+                               descriptor[i].Alias                     = this.fields[i].Alias;
+                       }
+
+                       return descriptor;
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void ResetValues()
+               {
+                       for (int i = 0; i < this.fields.Length; i++)
+                       {
+                               this.fields[i].Value = null;
+                       }
+               }
+
+               public byte[] ToBlrArray()
+               {
+                       MemoryStream blr = new MemoryStream();
+                       int par_count = this.Count * 2;
+
+                       blr.WriteByte(IscCodes.blr_version5);
+                       blr.WriteByte(IscCodes.blr_begin);
+                       blr.WriteByte(IscCodes.blr_message);
+                       blr.WriteByte(0);
+                       blr.WriteByte((byte)(par_count & 255));
+                       blr.WriteByte((byte)(par_count >> 8));
+
+                       for (int i = 0; i < this.fields.Length; i++)
+                       {
+                               int dtype = this.fields[i].SqlType;
+                               int len = this.fields[i].Length;
+
+                               switch (dtype)
+                               {
+                                       case IscCodes.SQL_VARYING:
+                                               blr.WriteByte(IscCodes.blr_varying);
+                                               blr.WriteByte((byte)(len & 255));
+                                               blr.WriteByte((byte)(len >> 8));
+                                               break;
+
+                                       case IscCodes.SQL_TEXT:
+                                               blr.WriteByte(IscCodes.blr_text);
+                                               blr.WriteByte((byte)(len & 255));
+                                               blr.WriteByte((byte)(len >> 8));
+                                               break;
+
+                                       case IscCodes.SQL_DOUBLE:
+                                               blr.WriteByte(IscCodes.blr_double);
+                                               break;
+
+                                       case IscCodes.SQL_FLOAT:
+                                               blr.WriteByte(IscCodes.blr_float);
+                                               break;
+
+                                       case IscCodes.SQL_D_FLOAT:
+                                               blr.WriteByte(IscCodes.blr_d_float);
+                                               break;
+
+                                       case IscCodes.SQL_TYPE_DATE:
+                                               blr.WriteByte(IscCodes.blr_sql_date);
+                                               break;
+
+                                       case IscCodes.SQL_TYPE_TIME:
+                                               blr.WriteByte(IscCodes.blr_sql_time);
+                                               break;
+
+                                       case IscCodes.SQL_TIMESTAMP:
+                                               blr.WriteByte(IscCodes.blr_timestamp);
+                                               break;
+
+                                       case IscCodes.SQL_BLOB:
+                                               blr.WriteByte(IscCodes.blr_quad);
+                                               blr.WriteByte(0);
+                                               break;
+
+                                       case IscCodes.SQL_ARRAY:
+                                               blr.WriteByte(IscCodes.blr_quad);
+                                               blr.WriteByte(0);
+                                               break;
+
+                                       case IscCodes.SQL_LONG:
+                                               blr.WriteByte(IscCodes.blr_long);
+                                               blr.WriteByte((byte)this.fields[i].NumericScale);
+                                               break;
+
+                                       case IscCodes.SQL_SHORT:
+                                               blr.WriteByte(IscCodes.blr_short);
+                                               blr.WriteByte((byte)this.fields[i].NumericScale);
+                                               break;
+
+                                       case IscCodes.SQL_INT64:
+                                               blr.WriteByte(IscCodes.blr_int64);
+                                               blr.WriteByte((byte)this.fields[i].NumericScale);
+                                               break;
+
+                                       case IscCodes.SQL_QUAD:
+                                               blr.WriteByte(IscCodes.blr_quad);
+                                               blr.WriteByte((byte)this.fields[i].NumericScale);
+                                               break;
+                               }
+
+                               blr.WriteByte(IscCodes.blr_short);
+                               blr.WriteByte(0);
+                       }
+
+                       blr.WriteByte(IscCodes.blr_end);
+                       blr.WriteByte(IscCodes.blr_eoc);
+
+                       return blr.ToArray();
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/EventParameterBuffer.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/EventParameterBuffer.cs
new file mode 100644 (file)
index 0000000..520225a
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class EventParameterBuffer : ParameterBuffer
+       {
+               #region Constructors
+
+               public EventParameterBuffer() : base(true)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void Append(string content, int actualCount)
+               {
+                       this.Append(Encoding.Default.GetBytes(content), actualCount);
+               }
+
+               public void Append(byte[] content, int actualCount)
+               {
+                       this.WriteByte(content.Length);
+                       this.Write(content);
+                       this.Write(actualCount);
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/GlobalizationHelper.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/GlobalizationHelper.cs
new file mode 100644 (file)
index 0000000..ac50e19
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Common
+{
+       internal class GlobalizationHelper
+       {
+               #region Constructors
+
+               private GlobalizationHelper()
+               {
+               }
+
+               #endregion
+
+               #region Static Methods
+
+               public static bool CultureAwareCompare(string strA, string strB)
+               {
+                       return CultureInfo.CurrentCulture.CompareInfo.Compare(
+                               strA, 
+                               strB,
+                               CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth |
+                               CompareOptions.IgnoreCase) == 0 ? true : false;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IDatabase.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IDatabase.cs
new file mode 100644 (file)
index 0000000..84aceae
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace FirebirdSql.Data.Common
+{
+       #region Delegates
+
+       internal delegate void WarningMessageCallback(IscException warning);
+
+       #endregion
+
+       internal interface IDatabase : IDisposable
+       {
+               #region Callback
+
+               WarningMessageCallback WarningMessage
+               {
+                       get;
+                       set;
+               }
+
+               #endregion
+
+               #region Properties
+
+               int Handle
+               {
+                       get;
+               }
+
+               int TransactionCount
+               {
+                       get;
+                       set;
+               }
+
+               string ServerVersion
+               {
+                       get;
+               }
+
+               Charset Charset
+               {
+                       get;
+                       set;
+               }
+
+               short PacketSize
+               {
+                       get;
+                       set;
+               }
+
+               short Dialect
+               {
+                       get;
+                       set;
+               }
+
+        bool HasRemoteEventSupport
+        {
+            get;
+        }
+
+               #endregion
+
+               #region Methods
+
+               void Attach(DatabaseParameterBuffer dpb, string dataSource, int port, string database);
+               void Detach();
+
+               void CreateDatabase(DatabaseParameterBuffer dpb, string dataSource, int port, string database);
+               void DropDatabase();
+
+               ITransaction BeginTransaction(TransactionParameterBuffer tpb);
+
+               StatementBase CreateStatement();
+               StatementBase CreateStatement(ITransaction transaction);
+
+               BlobParameterBuffer             CreateBlobParameterBuffer();
+               DatabaseParameterBuffer CreateDatabaseParameterBuffer();
+               EventParameterBuffer    CreateEventParameterBuffer();
+               TransactionParameterBuffer CreateTransactionParameterBuffer();
+
+               ArrayList GetDatabaseInfo(byte[] items);
+               ArrayList GetDatabaseInfo(byte[] items, int bufferLength);
+
+        void CloseEventManager();
+               RemoteEvent CreateEvent();
+               void QueueEvents(RemoteEvent events);
+               void CancelEvents(RemoteEvent events);
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IServiceManager.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IServiceManager.cs
new file mode 100644 (file)
index 0000000..0f49d4e
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Common
+{
+       internal interface IServiceManager
+       {
+               #region Properties
+
+               int     Handle
+               {
+                       get;
+               }
+
+               bool IsLittleEndian
+               {
+                       get;
+               }
+
+               #endregion
+
+               #region Methods
+
+               void Attach(ServiceParameterBuffer spb, string dataSource, int port, string     service);
+               
+               void Detach();
+
+               void Start(ServiceParameterBuffer spb);
+
+               ServiceParameterBuffer CreateParameterBuffer();
+
+               void Query(ServiceParameterBuffer spb   ,
+                       int             requestLength   ,
+                       byte[]  requestBuffer   ,
+                       int             bufferLength    ,
+                       byte[]  buffer);
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ITransaction.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ITransaction.cs
new file mode 100644 (file)
index 0000000..dd46f7e
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+
+namespace FirebirdSql.Data.Common
+{
+       #region Enumerations
+
+       internal enum TransactionState
+       {
+               NoTransaction,
+               TrasactionStarting,
+               TransactionStarted,
+               TransactionPreparing,
+               TransactionPrepared,
+               TransactionCommiting,
+               TransactionRollbacking
+       }
+
+       #endregion
+
+       #region Delegates
+
+       internal delegate void TransactionUpdateEventHandler(object     sender, EventArgs e);
+
+       #endregion
+
+       internal interface ITransaction : IDisposable
+       {
+               #region Events
+
+               event TransactionUpdateEventHandler     Update;
+
+               #endregion
+
+               #region Properties
+
+               int     Handle
+               {
+                       get;
+               }
+       
+               TransactionState State
+               {
+                       get;
+               }
+
+               #endregion
+
+               #region Methods
+               
+               void Commit();
+               void Rollback();
+               void CommitRetaining();
+               void RollbackRetaining();
+               void Prepare();
+               void Prepare(byte[]     buffer);
+               void BeginTransaction(TransactionParameterBuffer tpb);
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscCodes.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscCodes.cs
new file mode 100644 (file)
index 0000000..2a06418
--- /dev/null
@@ -0,0 +1,1547 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ * 
+ *     This file was originally ported from Jaybird
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class IscCodes
+       {
+               #region Constructors
+
+               private IscCodes()
+               {
+               }
+
+               #endregion
+
+               #region General
+
+               public const int SQLDA_VERSION1                         = 1;
+               public const int SQL_DIALECT_V5                         = 1;
+               public const int SQL_DIALECT_V6_TRANSITION      = 2;
+               public const int SQL_DIALECT_V6                         = 3;
+               public const int SQL_DIALECT_CURRENT            = SQL_DIALECT_V6;
+
+               public const int DSQL_close       =      1;
+               public const int DSQL_drop        =      2;
+
+               public const int ARRAY_DESC_COLUMN_MAJOR = 1;   /* Set for FORTRAN */
+
+               public const int ISC_STATUS_LENGTH = 20;
+
+               #endregion
+
+               #region Buffer sizes
+
+               public const int BUFFER_SIZE_128 = 128;
+               public const int BUFFER_SIZE_256 = 256;
+               public const int MAX_BUFFER_SIZE = 1024;
+
+               public const int ROWS_AFFECTED_BUFFER_SIZE      = 34;
+               public const int STATEMENT_TYPE_BUFFER_SIZE     = 8;
+
+               #endregion
+
+               #region Protocol Codes
+
+               /* The protocol is defined blocks, rather than messages, to
+                * separate     the     protocol from the transport     layer.  
+                */
+               public const int CONNECT_VERSION2       = 2;
+
+               /* Protocol     4 is protocol 3 plus server     management functions */
+               public const int PROTOCOL_VERSION3      = 3;
+               public const int PROTOCOL_VERSION4      = 4;
+
+               /* Protocol     5 includes support for a d_float data type */
+               public const int PROTOCOL_VERSION5      = 5;
+
+               /* Protocol     6 includes support for cancel remote events, blob seek,
+                * and unknown message type     
+                */
+               public const int PROTOCOL_VERSION6      = 6;
+
+               /* Protocol     7 includes DSQL support */
+               public const int PROTOCOL_VERSION7      = 7;
+
+               /* Protocol     8 includes collapsing first     receive into a send, drop database,
+                * DSQL execute 2, DSQL execute immediate 2, DSQL insert, services,     and
+                * transact     request.
+                */
+               public const int PROTOCOL_VERSION8      = 8;
+
+               /* Protocol     9 includes support for SPX32
+                * SPX32 uses WINSOCK instead of Novell SDK
+                * In order     to differentiate between the old implementation
+                * of SPX and this one, different PROTOCOL VERSIONS     are     used 
+                */
+               public const int PROTOCOL_VERSION9      = 9;
+
+               /* Protocol     10 includes     support for     warnings and removes the requirement for
+                * encoding     and     decoding status codes.
+                */
+               public const int PROTOCOL_VERSION10     = 10;
+
+               #endregion
+
+               #region Server Class
+
+               public const int isc_info_db_class_classic_access       = 13;
+               public const int isc_info_db_class_server_access        = 14;
+
+               #endregion
+
+               #region Operation Codes
+
+               // Operation (packet) types
+               public const int op_void                                = 0;    // Packet has been voided
+               public const int op_connect                             = 1;    // Connect to remote server
+               public const int op_exit                                = 2;    // Remote end has exitted
+               public const int op_accept                              = 3;    // Server accepts connection
+               public const int op_reject                              = 4;    // Server rejects connection
+               public const int op_protocol                    = 5;    // Protocol     selection
+               public const int op_disconnect                  = 6;    // Connect is going     away
+               public const int op_credit                              = 7;    // Grant (buffer) credits
+               public const int op_continuation                = 8;    // Continuation packet
+               public const int op_response                    = 9;    // Generic response     block
+
+               // Page server operations
+
+               public const int op_open_file                   = 10;   // Open file for page service
+               public const int op_create_file                 = 11;   // Create file for page service
+               public const int op_close_file                  = 12;   // Close file for page service
+               public const int op_read_page                   = 13;   // optionally lock and read     page
+               public const int op_write_page                  = 14;   // write page and optionally release lock
+               public const int op_lock                                = 15;   // sieze lock
+               public const int op_convert_lock                = 16;   // convert existing     lock
+               public const int op_release_lock                = 17;   // release existing     lock
+               public const int op_blocking                    = 18;   // blocking     lock message
+
+               // Full context server operations
+
+               public const int op_attach                              = 19;   // Attach database
+               public const int op_create                              = 20;   // Create database
+               public const int op_detach                              = 21;   // Detach database
+               public const int op_compile                             = 22;   // Request based operations
+               public const int op_start                               = 23;
+               public const int op_start_and_send              = 24;
+               public const int op_send                                = 25;
+               public const int op_receive                             = 26;
+               public const int op_unwind                              = 27;
+               public const int op_release                             = 28;
+
+               public const int op_transaction                 = 29;   // Transaction operations
+               public const int op_commit                              = 30;
+               public const int op_rollback                    = 31;
+               public const int op_prepare                             = 32;
+               public const int op_reconnect                   = 33;
+
+               public const int op_create_blob                 = 34;   // Blob operations //
+               public const int op_open_blob                   = 35;
+               public const int op_get_segment                 = 36;
+               public const int op_put_segment                 = 37;
+               public const int op_cancel_blob                 = 38;
+               public const int op_close_blob                  = 39;
+
+               public const int op_info_database               = 40;   // Information services
+               public const int op_info_request                = 41;
+               public const int op_info_transaction    = 42;
+               public const int op_info_blob                   = 43;
+
+               public const int op_batch_segments              = 44;   // Put a bunch of blob segments
+
+               public const int op_mgr_set_affinity    = 45;   // Establish server     affinity
+               public const int op_mgr_clear_affinity  = 46;   // Break server affinity
+               public const int op_mgr_report                  = 47;   // Report on server
+
+               public const int op_que_events                  = 48;   // Que event notification request
+               public const int op_cancel_events               = 49;   // Cancel event notification request
+               public const int op_commit_retaining    = 50;   // Commit retaining     (what else)
+               public const int op_prepare2                    = 51;   // Message form of prepare
+               public const int op_event                               = 52;   // Completed event request (asynchronous)
+               public const int op_connect_request             = 53;   // Request to establish connection
+               public const int op_aux_connect                 = 54;   // Establish auxiliary connection
+               public const int op_ddl                                 = 55;   // DDL call
+               public const int op_open_blob2                  = 56;
+               public const int op_create_blob2                = 57;
+               public const int op_get_slice                   = 58;
+               public const int op_put_slice                   = 59;
+               public const int op_slice                               = 60;   // Successful response to public const int op_get_slice
+               public const int op_seek_blob                   = 61;   // Blob seek operation
+
+               // DSQL operations //
+
+               public const int op_allocate_statement  = 62;   // allocate     a statment handle
+               public const int op_execute                             = 63;   // execute a prepared statement
+               public const int op_exec_immediate              = 64;   // execute a statement
+               public const int op_fetch                               = 65;   // fetch a record
+               public const int op_fetch_response              = 66;   // response     for     record fetch
+               public const int op_free_statement              = 67;   // free a statement
+               public const int op_prepare_statement   = 68;   // prepare a statement
+               public const int op_set_cursor                  = 69;   // set a cursor name
+               public const int op_info_sql                    = 70;
+
+               public const int op_dummy                               = 71;   // dummy packet to detect loss of client
+
+               public const int op_response_piggyback  = 72;   // response     block for piggybacked messages
+               public const int op_start_and_receive   = 73;
+               public const int op_start_send_and_receive      = 74;
+
+               public const int op_exec_immediate2             = 75;   // execute an immediate statement with msgs
+               public const int op_execute2                    = 76;   // execute a statement with     msgs
+               public const int op_insert                              = 77;
+               public const int op_sql_response                = 78;   // response     from execute; exec immed; insert
+
+               public const int op_transact                    = 79;
+               public const int op_transact_response   = 80;
+               public const int op_drop_database               = 81;
+
+               public const int op_service_attach              = 82;
+               public const int op_service_detach              = 83;
+               public const int op_service_info                = 84;
+               public const int op_service_start               = 85;
+
+               public const int op_rollback_retaining  = 86;
+
+               #endregion
+               
+               #region Database Parameter Block
+
+               public const int isc_dpb_version1                                = 1;
+               public const int isc_dpb_cdd_pathname                    = 1;
+               public const int isc_dpb_allocation                              = 2;
+               public const int isc_dpb_journal                                 = 3;
+               public const int isc_dpb_page_size                               = 4;
+               public const int isc_dpb_num_buffers                     = 5;
+               public const int isc_dpb_buffer_length                   = 6;
+               public const int isc_dpb_debug                                   = 7;
+               public const int isc_dpb_garbage_collect                 = 8;
+               public const int isc_dpb_verify                                  = 9;
+               public const int isc_dpb_sweep                                   = 10;
+               public const int isc_dpb_enable_journal                  = 11;
+               public const int isc_dpb_disable_journal                 = 12;
+               public const int isc_dpb_dbkey_scope                     = 13;
+               public const int isc_dpb_number_of_users                 = 14;
+               public const int isc_dpb_trace                                   = 15;
+               public const int isc_dpb_no_garbage_collect              = 16;
+               public const int isc_dpb_damaged                                 = 17;
+               public const int isc_dpb_license                                 = 18;
+               public const int isc_dpb_sys_user_name                   = 19;
+               public const int isc_dpb_encrypt_key                     = 20;
+               public const int isc_dpb_activate_shadow                 = 21;
+               public const int isc_dpb_sweep_interval                  = 22;
+               public const int isc_dpb_delete_shadow                   = 23;
+               public const int isc_dpb_force_write                     = 24;
+               public const int isc_dpb_begin_log                               = 25;
+               public const int isc_dpb_quit_log                                = 26;
+               public const int isc_dpb_no_reserve                              = 27;
+               public const int isc_dpb_user_name                               = 28;
+               public const int isc_dpb_password                                = 29;
+               public const int isc_dpb_password_enc                    = 30;
+               public const int isc_dpb_sys_user_name_enc               = 31;
+               public const int isc_dpb_interp                                  = 32;
+               public const int isc_dpb_online_dump                     = 33;
+               public const int isc_dpb_old_file_size                   = 34;
+               public const int isc_dpb_old_num_files                   = 35;
+               public const int isc_dpb_old_file                                = 36;
+               public const int isc_dpb_old_start_page                  = 37;
+               public const int isc_dpb_old_start_seqno                 = 38;
+               public const int isc_dpb_old_start_file                  = 39;
+               public const int isc_dpb_drop_walfile                    = 40;
+               public const int isc_dpb_old_dump_id                     = 41;
+               /*
+               public const int isc_dpb_wal_backup_dir                  = 42;
+               public const int isc_dpb_wal_chkptlen                    = 43;
+               public const int isc_dpb_wal_numbufs                     = 44;
+               public const int isc_dpb_wal_bufsize                     = 45;
+               public const int isc_dpb_wal_grp_cmt_wait                = 46;
+               */
+               public const int isc_dpb_lc_messages                     = 47;          
+               public const int isc_dpb_lc_ctype                                = 48;
+               public const int isc_dpb_cache_manager                   = 49;
+               public const int isc_dpb_shutdown                                = 50;
+               public const int isc_dpb_online                                  = 51;
+               public const int isc_dpb_shutdown_delay                  = 52;
+               public const int isc_dpb_reserved                                = 53;
+               public const int isc_dpb_overwrite                               = 54;
+               public const int isc_dpb_sec_attach                              = 55;
+               /*
+               public const int isc_dpb_disable_wal                     = 56;
+               */
+               public const int isc_dpb_connect_timeout                 = 57;
+               public const int isc_dpb_dummy_packet_interval   = 58;
+               public const int isc_dpb_gbak_attach                     = 59;
+               public const int isc_dpb_sql_role_name                   = 60;
+               public const int isc_dpb_set_page_buffers                = 61;
+               public const int isc_dpb_working_directory               = 62;
+               public const int isc_dpb_sql_dialect                     = 63;
+               public const int isc_dpb_set_db_readonly                 = 64;
+               public const int isc_dpb_set_db_sql_dialect              = 65;
+               public const int isc_dpb_gfix_attach                     = 66;
+               public const int isc_dpb_gstat_attach                    = 67;
+               public const int isc_dpb_set_db_charset                  = 68;
+
+               #endregion
+
+               #region Transaction     Parameter Block
+
+               public const int isc_tpb_version1                                = 1;
+               public const int isc_tpb_version3                                = 3;
+               public const int isc_tpb_consistency                     = 1;
+               public const int isc_tpb_concurrency                     = 2;
+               public const int isc_tpb_shared                                  = 3;
+               public const int isc_tpb_protected                               = 4;
+               public const int isc_tpb_exclusive                               = 5;
+               public const int isc_tpb_wait                                    = 6;
+               public const int isc_tpb_nowait                                  = 7;
+               public const int isc_tpb_read                                    = 8;
+               public const int isc_tpb_write                                   = 9;
+               public const int isc_tpb_lock_read                               = 10;
+               public const int isc_tpb_lock_write                              = 11;
+               public const int isc_tpb_verb_time                               = 12;
+               public const int isc_tpb_commit_time                     = 13;
+               public const int isc_tpb_ignore_limbo                    = 14;
+               public const int isc_tpb_read_committed                  = 15;
+               public const int isc_tpb_autocommit                              = 16;
+               public const int isc_tpb_rec_version                     = 17;
+               public const int isc_tpb_no_rec_version                  = 18;
+               public const int isc_tpb_restart_requests                = 19;
+               public const int isc_tpb_no_auto_undo                    = 20;
+
+               #endregion
+               
+               #region Services Parameter Block
+
+               public const int isc_spb_version1                                = 1;
+               public const int isc_spb_current_version                 = 2;
+               public const int isc_spb_version                                 = isc_spb_current_version;
+               public const int isc_spb_user_name                               = isc_dpb_user_name;
+               public const int isc_spb_sys_user_name                   = isc_dpb_sys_user_name;
+               public const int isc_spb_sys_user_name_enc               = isc_dpb_sys_user_name_enc;
+               public const int isc_spb_password                                = isc_dpb_password;
+               public const int isc_spb_password_enc                    = isc_dpb_password_enc;
+               public const int isc_spb_command_line                    = 105;
+               public const int isc_spb_dbname                                  = 106;
+               public const int isc_spb_verbose                                 = 107;
+               public const int isc_spb_options                                 = 108;
+               
+               public const int isc_spb_connect_timeout                 = isc_dpb_connect_timeout;
+               public const int isc_spb_dummy_packet_interval   = isc_dpb_dummy_packet_interval;
+               public const int isc_spb_sql_role_name                   = isc_dpb_sql_role_name;
+
+               public const int isc_spb_num_att                                 = 5;
+               public const int isc_spb_num_db                                  = 6;
+
+               #endregion
+               
+               #region Services Actions
+
+               public const int isc_action_svc_backup                  = 1;    /* Starts database backup process on the server */
+               public const int isc_action_svc_restore                 = 2;    /* Starts database restore process on the server */
+               public const int isc_action_svc_repair                  = 3;    /* Starts database repair process on the server */
+               public const int isc_action_svc_add_user                = 4;    /* Adds a new user to the security database     */
+               public const int isc_action_svc_delete_user             = 5;    /* Deletes a user record from the security database     */
+               public const int isc_action_svc_modify_user             = 6;    /* Modifies     a user record in the security database */
+               public const int isc_action_svc_display_user    = 7;    /* Displays     a user record from the security database */
+               public const int isc_action_svc_properties              = 8;    /* Sets database properties     */
+               public const int isc_action_svc_add_license             = 9;    /* Adds a license to the license file */
+               public const int isc_action_svc_remove_license  = 10;   /* Removes a license from the license file */
+               public const int isc_action_svc_db_stats                = 11;   /* Retrieves database statistics */
+               public const int isc_action_svc_get_ib_log              = 12;   /* Retrieves the InterBase log file     from the server */
+
+               #endregion
+               
+               #region Services Information
+               public const int isc_info_svc_svr_db_info               = 50;   /* Retrieves the number of attachments and databases */
+               public const int isc_info_svc_get_license               = 51;   /* Retrieves all license keys and IDs from the license file     */
+               public const int isc_info_svc_get_license_mask  = 52;   /* Retrieves a bitmask representing     licensed options on     the     server */
+               public const int isc_info_svc_get_config                = 53;   /* Retrieves the parameters     and     values for IB_CONFIG */
+               public const int isc_info_svc_version                   = 54;   /* Retrieves the version of     the     services manager */
+               public const int isc_info_svc_server_version    = 55;   /* Retrieves the version of     the     InterBase server */
+               public const int isc_info_svc_implementation    = 56;   /* Retrieves the implementation of the InterBase server */
+               public const int isc_info_svc_capabilities              = 57;   /* Retrieves a bitmask representing     the     server's capabilities */
+               public const int isc_info_svc_user_dbpath               = 58;   /* Retrieves the path to the security database in use by the server     */
+               public const int isc_info_svc_get_env                   = 59;   /* Retrieves the setting of     $INTERBASE */
+               public const int isc_info_svc_get_env_lock              = 60;   /* Retrieves the setting of     $INTERBASE_LCK */
+               public const int isc_info_svc_get_env_msg               = 61;   /* Retrieves the setting of     $INTERBASE_MSG */
+               public const int isc_info_svc_line                              = 62;   /* Retrieves 1 line     of service output per call */
+               public const int isc_info_svc_to_eof                    = 63;   /* Retrieves as much of the     server output as will fit in the supplied buffer */
+               public const int isc_info_svc_timeout                   = 64;   /* Sets / signifies     a timeout value for     reading service information     */
+               public const int isc_info_svc_get_licensed_users = 65;  /* Retrieves the number of users licensed for accessing the     server */
+               public const int isc_info_svc_limbo_trans               = 66;   /* Retrieve     the     limbo transactions */
+               public const int isc_info_svc_running                   = 67;   /* Checks to see if     a service is running on an attachment */
+               public const int isc_info_svc_get_users                 = 68;   /* Returns the user     information     from isc_action_svc_display_users */
+
+               #endregion
+
+               #region Services Properties
+               
+               public const int isc_spb_prp_page_buffers                = 5;
+               public const int isc_spb_prp_sweep_interval              = 6;
+               public const int isc_spb_prp_shutdown_db                 = 7;
+               public const int isc_spb_prp_deny_new_attachments =     9;
+               public const int isc_spb_prp_deny_new_transactions = 10;
+               public const int isc_spb_prp_reserve_space               = 11;
+               public const int isc_spb_prp_write_mode                  = 12;
+               public const int isc_spb_prp_access_mode                 = 13;
+               public const int isc_spb_prp_set_sql_dialect     = 14;
+
+               // WRITE_MODE_PARAMETERS
+               public const int isc_spb_prp_wm_async                    = 37;
+               public const int isc_spb_prp_wm_sync                     = 38;
+
+               // ACCESS_MODE_PARAMETERS
+               public const int isc_spb_prp_am_readonly                 = 39;
+               public const int isc_spb_prp_am_readwrite                = 40;
+
+               // RESERVE_SPACE_PARAMETERS
+               public const int isc_spb_prp_res_use_full                = 35;
+               public const int isc_spb_prp_res                                 = 36;
+
+               // Option Flags         
+               public const int isc_spb_prp_activate                    = 0x0100;
+               public const int isc_spb_prp_db_online                   = 0x0200;
+               
+               #endregion
+               
+               #region Backup Service
+               
+               public const int isc_spb_bkp_file                                = 5;
+               public const int isc_spb_bkp_factor                              = 6;
+               public const int isc_spb_bkp_length                              = 7;
+               
+               #endregion
+
+               #region Restore Service
+               
+               public const int isc_spb_res_buffers                     = 9;
+               public const int isc_spb_res_page_size                   = 10;
+               public const int isc_spb_res_length                              = 11;
+               public const int isc_spb_res_access_mode                 = 12;
+
+               public const int isc_spb_res_am_readonly                 = isc_spb_prp_am_readonly;
+               public const int isc_spb_res_am_readwrite                = isc_spb_prp_am_readwrite;
+               
+               #endregion
+               
+               #region Repair Service
+               
+               public const int isc_spb_rpr_commit_trans                = 15;
+               public const int isc_spb_rpr_rollback_trans              = 34;
+               public const int isc_spb_rpr_recover_two_phase   = 17;
+               public const int isc_spb_tra_id                                  = 18;
+               public const int isc_spb_single_tra_id                   = 19;
+               public const int isc_spb_multi_tra_id                    = 20;
+               public const int isc_spb_tra_state                               = 21;
+               public const int isc_spb_tra_state_limbo                 = 22;
+               public const int isc_spb_tra_state_commit                = 23;
+               public const int isc_spb_tra_state_rollback              = 24;
+               public const int isc_spb_tra_state_unknown               = 25;
+               public const int isc_spb_tra_host_site                   = 26;
+               public const int isc_spb_tra_remote_site                 = 27;
+               public const int isc_spb_tra_db_path                     = 28;
+               public const int isc_spb_tra_advise                              = 29;
+               public const int isc_spb_tra_advise_commit               = 30;
+               public const int isc_spb_tra_advise_rollback     = 31;
+               public const int isc_spb_tra_advise_unknown              = 33;
+                               
+               #endregion
+
+               #region Security Service
+               
+               public const int isc_spb_sec_userid                              = 5;
+               public const int isc_spb_sec_groupid                     = 6;
+               public const int isc_spb_sec_username                    = 7;
+               public const int isc_spb_sec_password                    = 8;
+               public const int isc_spb_sec_groupname                   = 9;
+               public const int isc_spb_sec_firstname                   = 10;
+               public const int isc_spb_sec_middlename                  = 11;
+               public const int isc_spb_sec_lastname                    = 12;
+
+               #endregion
+               
+               #region Configuration Keys
+               
+               public const int ISCCFG_LOCKMEM_KEY                              = 0;
+               public const int ISCCFG_LOCKSEM_KEY                              = 1;
+               public const int ISCCFG_LOCKSIG_KEY                              = 2;
+               public const int ISCCFG_EVNTMEM_KEY                              = 3;
+               public const int ISCCFG_DBCACHE_KEY                              = 4;
+               public const int ISCCFG_PRIORITY_KEY                     = 5;
+               public const int ISCCFG_IPCMAP_KEY                               = 6;
+               public const int ISCCFG_MEMMIN_KEY                               = 7;
+               public const int ISCCFG_MEMMAX_KEY                               = 8;
+               public const int ISCCFG_LOCKORDER_KEY                    = 9;
+               public const int ISCCFG_ANYLOCKMEM_KEY                   = 10;
+               public const int ISCCFG_ANYLOCKSEM_KEY                   = 11;
+               public const int ISCCFG_ANYLOCKSIG_KEY                   = 12;
+               public const int ISCCFG_ANYEVNTMEM_KEY                   = 13;
+               public const int ISCCFG_LOCKHASH_KEY                     = 14;
+               public const int ISCCFG_DEADLOCK_KEY                     = 15;
+               public const int ISCCFG_LOCKSPIN_KEY                     = 16;
+               public const int ISCCFG_CONN_TIMEOUT_KEY                 = 17;
+               public const int ISCCFG_DUMMY_INTRVL_KEY                 = 18;
+               public const int ISCCFG_TRACE_POOLS_KEY                  = 19; /* Internal Use only     */
+               public const int ISCCFG_REMOTE_BUFFER_KEY                = 20;
+               
+               #endregion
+
+               #region Common Structural Codes
+
+               public const int isc_info_end                                    = 1;
+               public const int isc_info_truncated                              = 2;
+               public const int isc_info_error                                  = 3;
+               public const int isc_info_data_not_ready                 = 4;
+               public const int isc_info_flag_end                               = 127;
+
+               #endregion
+
+               #region SQL     Information
+
+               public const int isc_info_sql_select                      =     4;
+               public const int isc_info_sql_bind                                =     5;
+               public const int isc_info_sql_num_variables               =     6;
+               public const int isc_info_sql_describe_vars               =     7;
+               public const int isc_info_sql_describe_end                =     8;
+               public const int isc_info_sql_sqlda_seq                   =     9;
+               public const int isc_info_sql_message_seq                 =     10;
+               public const int isc_info_sql_type                                =     11;
+               public const int isc_info_sql_sub_type                    =     12;
+               public const int isc_info_sql_scale                               =     13;
+               public const int isc_info_sql_length                      =     14;
+               public const int isc_info_sql_null_ind                    =     15;
+               public const int isc_info_sql_field                               =     16;
+               public const int isc_info_sql_relation                    =     17;
+               public const int isc_info_sql_owner                               =     18;
+               public const int isc_info_sql_alias                               =     19;
+               public const int isc_info_sql_sqlda_start                 =     20;
+               public const int isc_info_sql_stmt_type                   =     21;
+               public const int isc_info_sql_get_plan                    =     22;
+               public const int isc_info_sql_records                     =     23;
+               public const int isc_info_sql_batch_fetch                 =     24;
+
+               #endregion
+
+               #region Database Information
+
+               public const int isc_info_db_id                                   =     4;
+               public const int isc_info_reads                                   =     5;
+               public const int isc_info_writes                                  =     6;
+               public const int isc_info_fetches                                 =     7;
+               public const int isc_info_marks                                   =     8;
+
+               public const int isc_info_implementation                  =     11;
+               public const int isc_info_isc_version                     =     12;
+               public const int isc_info_base_level                      =     13;
+               public const int isc_info_page_size                               =     14;
+               public const int isc_info_num_buffers                     =     15;
+               public const int isc_info_limbo                                   =     16;
+               public const int isc_info_current_memory                  =     17;
+               public const int isc_info_max_memory                      =     18;
+               public const int isc_info_window_turns                    =     19;
+               public const int isc_info_license                                 =     20;
+
+               public const int isc_info_allocation                      =     21;
+               public const int isc_info_attachment_id                   =     22;
+               public const int isc_info_read_seq_count                  =     23;
+               public const int isc_info_read_idx_count                  =     24;
+               public const int isc_info_insert_count                    =     25;
+               public const int isc_info_update_count                    =     26;
+               public const int isc_info_delete_count                    =     27;
+               public const int isc_info_backout_count                   =     28;
+               public const int isc_info_purge_count                     =     29;
+               public const int isc_info_expunge_count                   =     30;     
+
+               public const int isc_info_sweep_interval                  =     31;
+               public const int isc_info_ods_version                     =     32;
+               public const int isc_info_ods_minor_version               =     33;
+               public const int isc_info_no_reserve                      =     34;
+               public const int isc_info_logfile                                 =     35;
+               public const int isc_info_cur_logfile_name                =     36;
+               public const int isc_info_cur_log_part_offset     =     37;
+               public const int isc_info_num_wal_buffers                 =     38;
+               public const int isc_info_wal_buffer_size                 =     39;
+               public const int isc_info_wal_ckpt_length                 =     40;       
+
+               public const int isc_info_wal_cur_ckpt_interval   =     41;      
+               public const int isc_info_wal_prv_ckpt_fname      =     42;
+               public const int isc_info_wal_prv_ckpt_poffset    =     43;
+               public const int isc_info_wal_recv_ckpt_fname     =     44;
+               public const int isc_info_wal_recv_ckpt_poffset   =     45;
+               public const int isc_info_wal_grpc_wait_usecs     =     47;
+               public const int isc_info_wal_num_io                      =     48;
+               public const int isc_info_wal_avg_io_size                 =     49;
+               public const int isc_info_wal_num_commits                 =     50;      
+
+               public const int isc_info_wal_avg_grpc_size               =     51;
+               public const int isc_info_forced_writes                   =     52;
+               public const int isc_info_user_names                      =     53;
+               public const int isc_info_page_errors                     =     54;
+               public const int isc_info_record_errors                   =     55;
+               public const int isc_info_bpage_errors                    =     56;
+               public const int isc_info_dpage_errors                    =     57;
+               public const int isc_info_ipage_errors                    =     58;
+               public const int isc_info_ppage_errors                    =     59;
+               public const int isc_info_tpage_errors                    =     60;
+
+               public const int isc_info_set_page_buffers                =     61;
+               public const int isc_info_db_sql_dialect                  =     62;       
+               public const int isc_info_db_read_only                    =     63;
+               public const int isc_info_db_size_in_pages                =     64;
+
+               /* Values 65 -100 unused to     avoid conflict with     InterBase */
+       
+               public const int frb_info_att_charset                     =     101;
+               public const int isc_info_db_class                                =     102;
+               public const int isc_info_firebird_version                =     103;
+               public const int isc_info_oldest_transaction      =     104;
+               public const int isc_info_oldest_active                   =     105;
+               public const int isc_info_oldest_snapshot                 =     106;
+               public const int isc_info_next_transaction                =     107; 
+               public const int isc_info_db_provider                     =     108;
+               public const int isc_info_active_transactions     =     109;
+
+               #endregion
+
+               #region SQL     Information     Return Values
+
+               public const int isc_info_sql_stmt_select                 =     1;
+               public const int isc_info_sql_stmt_insert                 =     2;
+               public const int isc_info_sql_stmt_update                 =     3;
+               public const int isc_info_sql_stmt_delete                 =     4;
+               public const int isc_info_sql_stmt_ddl                    =     5;
+               public const int isc_info_sql_stmt_get_segment    =     6;
+               public const int isc_info_sql_stmt_put_segment    =     7;
+               public const int isc_info_sql_stmt_exec_procedure =     8;
+               public const int isc_info_sql_stmt_start_trans    =     9;
+               public const int isc_info_sql_stmt_commit                 =     10;
+               public const int isc_info_sql_stmt_rollback               =     11;
+               public const int isc_info_sql_stmt_select_for_upd =     12;
+               public const int isc_info_sql_stmt_set_generator  =     13;
+               public const int isc_info_sql_stmt_savepoint      =     14;
+
+               #endregion
+
+               #region Information     Request
+
+               public const int isc_info_number_messages                =      4;
+               public const int isc_info_max_message                    =      5;
+               public const int isc_info_max_send                               =      6;
+               public const int isc_info_max_receive                    =      7;
+               public const int isc_info_state                                  =      8;
+               public const int isc_info_message_number                 =      9;
+               public const int isc_info_message_size                   =      10;
+               public const int isc_info_request_cost                   =      11;
+               public const int isc_info_access_path                    =      12;
+               public const int isc_info_req_select_count               =      13;
+               public const int isc_info_req_insert_count               =      14;
+               public const int isc_info_req_update_count               =      15;
+               public const int isc_info_req_delete_count               =      16;
+
+               #endregion
+
+               #region Array Slice     Description     Language
+               
+               public const int isc_sdl_version1                               = 1;
+               public const int isc_sdl_eoc                                    = 255;
+               public const int isc_sdl_relation                               = 2;
+               public const int isc_sdl_rid                                    = 3;
+               public const int isc_sdl_field                                  = 4;
+               public const int isc_sdl_fid                                    = 5;
+               public const int isc_sdl_struct                                 = 6;
+               public const int isc_sdl_variable                               = 7;
+               public const int isc_sdl_scalar                                 = 8;
+               public const int isc_sdl_tiny_integer                   = 9;
+               public const int isc_sdl_short_integer                  = 10;
+               public const int isc_sdl_long_integer                   = 11;
+               public const int isc_sdl_literal                                = 12;
+               public const int isc_sdl_add                                    = 13;
+               public const int isc_sdl_subtract                               = 14;
+               public const int isc_sdl_multiply                               = 15;
+               public const int isc_sdl_divide                                 = 16;
+               public const int isc_sdl_negate                                 = 17;
+               public const int isc_sdl_eql                                    = 18;
+               public const int isc_sdl_neq                                    = 19;
+               public const int isc_sdl_gtr                                    = 20;
+               public const int isc_sdl_geq                                    = 21;
+               public const int isc_sdl_lss                                    = 22;
+               public const int isc_sdl_leq                                    = 23;
+               public const int isc_sdl_and                                    = 24;
+               public const int isc_sdl_or                                             = 25;
+               public const int isc_sdl_not                                    = 26;
+               public const int isc_sdl_while                                  = 27;
+               public const int isc_sdl_assignment                             = 28;
+               public const int isc_sdl_label                                  = 29;
+               public const int isc_sdl_leave                                  = 30;
+               public const int isc_sdl_begin                                  = 31;
+               public const int isc_sdl_end                                    = 32;
+               public const int isc_sdl_do3                                    = 33;
+               public const int isc_sdl_do2                                    = 34;
+               public const int isc_sdl_do1                                    = 35;
+               public const int isc_sdl_element                                = 36;
+               
+               #endregion
+
+               #region Blob Parametr Block
+
+               public const int isc_bpb_version1                               =  1;
+               public const int isc_bpb_source_type                    =  1;
+               public const int isc_bpb_target_type                    =  2;
+               public const int isc_bpb_type                                   =  3;
+               public const int isc_bpb_source_interp                  =  4;
+               public const int isc_bpb_target_interp                  =  5;
+               public const int isc_bpb_filter_parameter               =  6;
+
+               public const int isc_bpb_type_segmented                 =  0;
+               public const int isc_bpb_type_stream                    =  1;
+
+               public const int RBL_eof                                                = 1;
+               public const int RBL_segment                                    = 2;
+               public const int RBL_eof_pending                                = 4;
+               public const int RBL_create                                             = 8;
+
+               #endregion
+
+               #region Blob Information
+
+               public const int isc_info_blob_num_segments              = 4;
+               public const int isc_info_blob_max_segment               = 5;
+               public const int isc_info_blob_total_length              = 6;
+               public const int isc_info_blob_type                              = 7;
+
+               #endregion
+
+               #region Event Codes
+
+               public const int P_REQ_async    = 1;    // Auxiliary asynchronous port
+               public const int EPB_version1   = 1;
+
+               #endregion
+
+               #region Facilities
+
+               public const int JRD    = 0;
+               public const int GFIX   = 3;
+               public const int DSQL   = 7;
+               public const int DYN    = 8;
+               public const int GBAK   = 12;
+               public const int GDEC   = 18;
+               public const int LICENSE= 19;
+               public const int GSTAT  = 21;
+
+               #endregion
+
+               #region Error code generation
+
+               public const int ISC_MASK       = 0x14000000;   // Defines the code     as a valid ISC code
+               /*
+               public const int FAC_MASK       = 0x00FF0000;   // Specifies the facility where the     code is located
+               public const int CODE_MASK      = 0x0000FFFF;   // Specifies the code in the message file
+               public const int CLASS_MASK     = 0xF0000000;   // Defines the code     as warning,     error, info, or other
+               */
+
+               #endregion
+
+               #region ISC     Error codes
+
+               public const int isc_facility            = 20;
+               public const int isc_err_base            = 335544320;
+               public const int isc_err_factor          = 1;
+               public const int isc_arg_end             = 0;   // end of argument list
+               public const int isc_arg_gds             = 1;   // generic DSRI status value
+               public const int isc_arg_string          = 2;   // string argument
+               public const int isc_arg_cstring         = 3;   // count & string argument
+               public const int isc_arg_number          = 4;   // numeric argument     (long)
+               public const int isc_arg_interpreted = 5;       // interpreted status code (string)
+               public const int isc_arg_vms             = 6;   // VAX/VMS status code (long)
+               public const int isc_arg_unix            = 7;   // UNIX error code
+               public const int isc_arg_domain          = 8;   // Apollo/Domain error code
+               public const int isc_arg_dos             = 9;   // MSDOS/OS2 error code
+               public const int isc_arg_mpexl           = 10;  // HP MPE/XL error code
+               public const int isc_arg_mpexl_ipc       = 11;  // HP MPE/XL IPC error code
+               public const int isc_arg_next_mach       = 15;  // NeXT/Mach error code
+               public const int isc_arg_netware         = 16;  // NetWare error code
+               public const int isc_arg_win32           = 17;  // Win32 error code
+               public const int isc_arg_warning         = 18;  // warning argument
+
+               public const int isc_arith_except                                         =     335544321;
+               public const int isc_bad_dbkey                                            =     335544322;
+               public const int isc_bad_db_format                                        =     335544323;
+               public const int isc_bad_db_handle                                        =     335544324;
+               public const int isc_bad_dpb_content                              =     335544325;
+               public const int isc_bad_dpb_form                                         =     335544326;
+               public const int isc_bad_req_handle                                       =     335544327;
+               public const int isc_bad_segstr_handle                            =     335544328;
+               public const int isc_bad_segstr_id                                        =     335544329;
+               public const int isc_bad_tpb_content                              =     335544330;
+               public const int isc_bad_tpb_form                                         =     335544331;
+               public const int isc_bad_trans_handle                             =     335544332;
+               public const int isc_bug_check                                            =     335544333;
+               public const int isc_convert_error                                        =     335544334;
+               public const int isc_db_corrupt                                           =     335544335;
+               public const int isc_deadlock                                             =     335544336;
+               public const int isc_excess_trans                                         =     335544337;
+               public const int isc_from_no_match                                        =     335544338;
+               public const int isc_infinap                                              =     335544339;
+               public const int isc_infona                                                       =     335544340;
+               public const int isc_infunk                                                       =     335544341;
+               public const int isc_integ_fail                                           =     335544342;
+               public const int isc_invalid_blr                                          =     335544343;
+               public const int isc_io_error                                             =     335544344;
+               public const int isc_lock_conflict                                        =     335544345;
+               public const int isc_metadata_corrupt                             =     335544346;
+               public const int isc_not_valid                                            =     335544347;
+               public const int isc_no_cur_rec                                           =     335544348;
+               public const int isc_no_dup                                                       =     335544349;
+               public const int isc_no_finish                                            =     335544350;
+               public const int isc_no_meta_update                                       =     335544351;
+               public const int isc_no_priv                                              =     335544352;
+               public const int isc_no_recon                                             =     335544353;
+               public const int isc_no_record                                            =     335544354;
+               public const int isc_no_segstr_close                              =     335544355;
+               public const int isc_obsolete_metadata                            =     335544356;
+               public const int isc_open_trans                                           =     335544357;
+               public const int isc_port_len                                             =     335544358;
+               public const int isc_read_only_field                              =     335544359;
+               public const int isc_read_only_rel                                        =     335544360;
+               public const int isc_read_only_trans                              =     335544361;
+               public const int isc_read_only_view                                       =     335544362;
+               public const int isc_req_no_trans                                         =     335544363;
+               public const int isc_req_sync                                             =     335544364;
+               public const int isc_req_wrong_db                                         =     335544365;
+               public const int isc_segment                                              =     335544366;
+               public const int isc_segstr_eof                                           =     335544367;
+               public const int isc_segstr_no_op                                         =     335544368;
+               public const int isc_segstr_no_read                                       =     335544369;
+               public const int isc_segstr_no_trans                              =     335544370;
+               public const int isc_segstr_no_write                              =     335544371;
+               public const int isc_segstr_wrong_db                              =     335544372;
+               public const int isc_sys_request                                          =     335544373;
+               public const int isc_stream_eof                                           =     335544374;
+               public const int isc_unavailable                                          =     335544375;
+               public const int isc_unres_rel                                            =     335544376;
+               public const int isc_uns_ext                                              =     335544377;
+               public const int isc_wish_list                                            =     335544378;
+               public const int isc_wrong_ods                                            =     335544379;
+               public const int isc_wronumarg                                            =     335544380;
+               public const int isc_imp_exc                                              =     335544381;
+               public const int isc_random                                                       =     335544382;
+               public const int isc_fatal_conflict                                       =     335544383;
+               public const int isc_badblk                                                       =     335544384;
+               public const int isc_invpoolcl                                            =     335544385;
+               public const int isc_nopoolids                                            =     335544386;
+               public const int isc_relbadblk                                            =     335544387;
+               public const int isc_blktoobig                                            =     335544388;
+               public const int isc_bufexh                                                       =     335544389;
+               public const int isc_syntaxerr                                            =     335544390;
+               public const int isc_bufinuse                                             =     335544391;
+               public const int isc_bdbincon                                             =     335544392;
+               public const int isc_reqinuse                                             =     335544393;
+               public const int isc_badodsver                                            =     335544394;
+               public const int isc_relnotdef                                            =     335544395;
+               public const int isc_fldnotdef                                            =     335544396;
+               public const int isc_dirtypage                                            =     335544397;
+               public const int isc_waifortra                                            =     335544398;
+               public const int isc_doubleloc                                            =     335544399;
+               public const int isc_nodnotfnd                                            =     335544400;
+               public const int isc_dupnodfnd                                            =     335544401;
+               public const int isc_locnotmar                                            =     335544402;
+               public const int isc_badpagtyp                                            =     335544403;
+               public const int isc_corrupt                                              =     335544404;
+               public const int isc_badpage                                              =     335544405;
+               public const int isc_badindex                                             =     335544406;
+               public const int isc_dbbnotzer                                            =     335544407;
+               public const int isc_tranotzer                                            =     335544408;
+               public const int isc_trareqmis                                            =     335544409;
+               public const int isc_badhndcnt                                            =     335544410;
+               public const int isc_wrotpbver                                            =     335544411;
+               public const int isc_wroblrver                                            =     335544412;
+               public const int isc_wrodpbver                                            =     335544413;
+               public const int isc_blobnotsup                                           =     335544414;
+               public const int isc_badrelation                                          =     335544415;
+               public const int isc_nodetach                                             =     335544416;
+               public const int isc_notremote                                            =     335544417;
+               public const int isc_trainlim                                             =     335544418;
+               public const int isc_notinlim                                             =     335544419;
+               public const int isc_traoutsta                                            =     335544420;
+               public const int isc_connect_reject                                       =     335544421;
+               public const int isc_dbfile                                                       =     335544422;
+               public const int isc_orphan                                                       =     335544423;
+               public const int isc_no_lock_mgr                                          =     335544424;
+               public const int isc_ctxinuse                                             =     335544425;
+               public const int isc_ctxnotdef                                            =     335544426;
+               public const int isc_datnotsup                                            =     335544427;
+               public const int isc_badmsgnum                                            =     335544428;
+               public const int isc_badparnum                                            =     335544429;
+               public const int isc_virmemexh                                            =     335544430;
+               public const int isc_blocking_signal                              =     335544431;
+               public const int isc_lockmanerr                                           =     335544432;
+               public const int isc_journerr                                             =     335544433;
+               public const int isc_keytoobig                                            =     335544434;
+               public const int isc_nullsegkey                                           =     335544435;
+               public const int isc_sqlerr                                                       =     335544436;
+               public const int isc_wrodynver                                            =     335544437;
+               public const int isc_funnotdef                                            =     335544438;
+               public const int isc_funmismat                                            =     335544439;
+               public const int isc_bad_msg_vec                                          =     335544440;
+               public const int isc_bad_detach                                           =     335544441;
+               public const int isc_noargacc_read                                        =     335544442;
+               public const int isc_noargacc_write                                       =     335544443;
+               public const int isc_read_only                                            =     335544444;
+               public const int isc_ext_err                                              =     335544445;
+               public const int isc_non_updatable                                        =     335544446;
+               public const int isc_no_rollback                                          =     335544447;
+               public const int isc_bad_sec_info                                         =     335544448;
+               public const int isc_invalid_sec_info                             =     335544449;
+               public const int isc_misc_interpreted                             =     335544450;
+               public const int isc_update_conflict                              =     335544451;
+               public const int isc_unlicensed                                           =     335544452;
+               public const int isc_obj_in_use                                           =     335544453;
+               public const int isc_nofilter                                             =     335544454;
+               public const int isc_shadow_accessed                              =     335544455;
+               public const int isc_invalid_sdl                                          =     335544456;
+               public const int isc_out_of_bounds                                        =     335544457;
+               public const int isc_invalid_dimension                            =     335544458;
+               public const int isc_rec_in_limbo                                         =     335544459;
+               public const int isc_shadow_missing                                       =     335544460;
+               public const int isc_cant_validate                                        =     335544461;
+               public const int isc_cant_start_journal                           =     335544462;
+               public const int isc_gennotdef                                            =     335544463;
+               public const int isc_cant_start_logging                           =     335544464;
+               public const int isc_bad_segstr_type                              =     335544465;
+               public const int isc_foreign_key                                          =     335544466;
+               public const int isc_high_minor                                           =     335544467;
+               public const int isc_tra_state                                            =     335544468;
+               public const int isc_trans_invalid                                        =     335544469;
+               public const int isc_buf_invalid                                          =     335544470;
+               public const int isc_indexnotdefined                              =     335544471;
+               public const int isc_login                                                        =     335544472;
+               public const int isc_invalid_bookmark                             =     335544473;
+               public const int isc_bad_lock_level                                       =     335544474;
+               public const int isc_relation_lock                                        =     335544475;
+               public const int isc_record_lock                                          =     335544476;
+               public const int isc_max_idx                                              =     335544477;
+               public const int isc_jrn_enable                                           =     335544478;
+               public const int isc_old_failure                                          =     335544479;
+               public const int isc_old_in_progress                              =     335544480;
+               public const int isc_old_no_space                                         =     335544481;
+               public const int isc_no_wal_no_jrn                                        =     335544482;
+               public const int isc_num_old_files                                        =     335544483;
+               public const int isc_wal_file_open                                        =     335544484;
+               public const int isc_bad_stmt_handle                              =     335544485;
+               public const int isc_wal_failure                                          =     335544486;
+               public const int isc_walw_err                                             =     335544487;
+               public const int isc_logh_small                                           =     335544488;
+               public const int isc_logh_inv_version                             =     335544489;
+               public const int isc_logh_open_flag                                       =     335544490;
+               public const int isc_logh_open_flag2                              =     335544491;
+               public const int isc_logh_diff_dbname                             =     335544492;
+               public const int isc_logf_unexpected_eof                          =     335544493;
+               public const int isc_logr_incomplete                              =     335544494;
+               public const int isc_logr_header_small                            =     335544495;
+               public const int isc_logb_small                                           =     335544496;
+               public const int isc_wal_illegal_attach                           =     335544497;
+               public const int isc_wal_invalid_wpb                              =     335544498;
+               public const int isc_wal_err_rollover                             =     335544499;
+               public const int isc_no_wal                                                       =     335544500;
+               public const int isc_drop_wal                                             =     335544501;
+               public const int isc_stream_not_defined                           =     335544502;
+               public const int isc_wal_subsys_error                             =     335544503;
+               public const int isc_wal_subsys_corrupt                           =     335544504;
+               public const int isc_no_archive                                           =     335544505;
+               public const int isc_shutinprog                                           =     335544506;
+               public const int isc_range_in_use                                         =     335544507;
+               public const int isc_range_not_found                              =     335544508;
+               public const int isc_charset_not_found                            =     335544509;
+               public const int isc_lock_timeout                                         =     335544510;
+               public const int isc_prcnotdef                                            =     335544511;
+               public const int isc_prcmismat                                            =     335544512;
+               public const int isc_wal_bugcheck                                         =     335544513;
+               public const int isc_wal_cant_expand                              =     335544514;
+               public const int isc_codnotdef                                            =     335544515;
+               public const int isc_xcpnotdef                                            =     335544516;
+               public const int isc_except                                                       =     335544517;
+               public const int isc_cache_restart                                        =     335544518;
+               public const int isc_bad_lock_handle                              =     335544519;
+               public const int isc_jrn_present                                          =     335544520;
+               public const int isc_wal_err_rollover2                            =     335544521;
+               public const int isc_wal_err_logwrite                             =     335544522;
+               public const int isc_wal_err_jrn_comm                             =     335544523;
+               public const int isc_wal_err_expansion                            =     335544524;
+               public const int isc_wal_err_setup                                        =     335544525;
+               public const int isc_wal_err_ww_sync                              =     335544526;
+               public const int isc_wal_err_ww_start                             =     335544527;
+               public const int isc_shutdown                                             =     335544528;
+               public const int isc_existing_priv_mod                            =     335544529;
+               public const int isc_primary_key_ref                              =     335544530;
+               public const int isc_primary_key_notnull                          =     335544531;
+               public const int isc_ref_cnstrnt_notfound                         =     335544532;
+               public const int isc_foreign_key_notfound                         =     335544533;
+               public const int isc_ref_cnstrnt_update                           =     335544534;
+               public const int isc_check_cnstrnt_update                         =     335544535;
+               public const int isc_check_cnstrnt_del                            =     335544536;
+               public const int isc_integ_index_seg_del                          =     335544537;
+               public const int isc_integ_index_seg_mod                          =     335544538;
+               public const int isc_integ_index_del                              =     335544539;
+               public const int isc_integ_index_mod                              =     335544540;
+               public const int isc_check_trig_del                                       =     335544541;
+               public const int isc_check_trig_update                            =     335544542;
+               public const int isc_cnstrnt_fld_del                              =     335544543;
+               public const int isc_cnstrnt_fld_rename                           =     335544544;
+               public const int isc_rel_cnstrnt_update                           =     335544545;
+               public const int isc_constaint_on_view                            =     335544546;
+               public const int isc_invld_cnstrnt_type                           =     335544547;
+               public const int isc_primary_key_exists                           =     335544548;
+               public const int isc_systrig_update                                       =     335544549;
+               public const int isc_not_rel_owner                                        =     335544550;
+               public const int isc_grant_obj_notfound                           =     335544551;
+               public const int isc_grant_fld_notfound                           =     335544552;
+               public const int isc_grant_nopriv                                         =     335544553;
+               public const int isc_nonsql_security_rel                          =     335544554;
+               public const int isc_nonsql_security_fld                          =     335544555;
+               public const int isc_wal_cache_err                                        =     335544556;
+               public const int isc_shutfail                                             =     335544557;
+               public const int isc_check_constraint                             =     335544558;
+               public const int isc_bad_svc_handle                                       =     335544559;
+               public const int isc_shutwarn                                             =     335544560;
+               public const int isc_wrospbver                                            =     335544561;
+               public const int isc_bad_spb_form                                         =     335544562;
+               public const int isc_svcnotdef                                            =     335544563;
+               public const int isc_no_jrn                                                       =     335544564;
+               public const int isc_transliteration_failed                       =     335544565;
+               public const int isc_start_cm_for_wal                             =     335544566;
+               public const int isc_wal_ovflow_log_required              =     335544567;
+               public const int isc_text_subtype                                         =     335544568;
+               public const int isc_dsql_error                                           =     335544569;
+               public const int isc_dsql_command_err                             =     335544570;
+               public const int isc_dsql_constant_err                            =     335544571;
+               public const int isc_dsql_cursor_err                              =     335544572;
+               public const int isc_dsql_datatype_err                            =     335544573;
+               public const int isc_dsql_decl_err                                        =     335544574;
+               public const int isc_dsql_cursor_update_err                       =     335544575;
+               public const int isc_dsql_cursor_open_err                         =     335544576;
+               public const int isc_dsql_cursor_close_err                        =     335544577;
+               public const int isc_dsql_field_err                                       =     335544578;
+               public const int isc_dsql_internal_err                            =     335544579;
+               public const int isc_dsql_relation_err                            =     335544580;
+               public const int isc_dsql_procedure_err                           =     335544581;
+               public const int isc_dsql_request_err                             =     335544582;
+               public const int isc_dsql_sqlda_err                                       =     335544583;
+               public const int isc_dsql_var_count_err                           =     335544584;
+               public const int isc_dsql_stmt_handle                             =     335544585;
+               public const int isc_dsql_function_err                            =     335544586;
+               public const int isc_dsql_blob_err                                        =     335544587;
+               public const int isc_collation_not_found                          =     335544588;
+               public const int isc_collation_not_for_charset            =     335544589;
+               public const int isc_dsql_dup_option                              =     335544590;
+               public const int isc_dsql_tran_err                                        =     335544591;
+               public const int isc_dsql_invalid_array                           =     335544592;
+               public const int isc_dsql_max_arr_dim_exceeded            =     335544593;
+               public const int isc_dsql_arr_range_error                         =     335544594;
+               public const int isc_dsql_trigger_err                             =     335544595;
+               public const int isc_dsql_subselect_err                           =     335544596;
+               public const int isc_dsql_crdb_prepare_err                        =     335544597;
+               public const int isc_specify_field_err                            =     335544598;
+               public const int isc_num_field_err                                        =     335544599;
+               public const int isc_col_name_err                                         =     335544600;
+               public const int isc_where_err                                            =     335544601;
+               public const int isc_table_view_err                                       =     335544602;
+               public const int isc_distinct_err                                         =     335544603;
+               public const int isc_key_field_count_err                          =     335544604;
+               public const int isc_subquery_err                                         =     335544605;
+               public const int isc_expression_eval_err                          =     335544606;
+               public const int isc_node_err                                             =     335544607;
+               public const int isc_command_end_err                              =     335544608;
+               public const int isc_index_name                                           =     335544609;
+               public const int isc_exception_name                                       =     335544610;
+               public const int isc_field_name                                           =     335544611;
+               public const int isc_token_err                                            =     335544612;
+               public const int isc_union_err                                            =     335544613;
+               public const int isc_dsql_construct_err                           =     335544614;
+               public const int isc_field_aggregate_err                          =     335544615;
+               public const int isc_field_ref_err                                        =     335544616;
+               public const int isc_order_by_err                                         =     335544617;
+               public const int isc_return_mode_err                              =     335544618;
+               public const int isc_extern_func_err                              =     335544619;
+               public const int isc_alias_conflict_err                           =     335544620;
+               public const int isc_procedure_conflict_error             =     335544621;
+               public const int isc_relation_conflict_err                        =     335544622;
+               public const int isc_dsql_domain_err                              =     335544623;
+               public const int isc_idx_seg_err                                          =     335544624;
+               public const int isc_node_name_err                                        =     335544625;
+               public const int isc_table_name                                           =     335544626;
+               public const int isc_proc_name                                            =     335544627;
+               public const int isc_idx_create_err                                       =     335544628;
+               public const int isc_wal_shadow_err                                       =     335544629;
+               public const int isc_dependency                                           =     335544630;
+               public const int isc_idx_key_err                                          =     335544631;
+               public const int isc_dsql_file_length_err                         =     335544632;
+               public const int isc_dsql_shadow_number_err                       =     335544633;
+               public const int isc_dsql_token_unk_err                           =     335544634;
+               public const int isc_dsql_no_relation_alias                       =     335544635;
+               public const int isc_indexname                                            =     335544636;
+               public const int isc_no_stream_plan                                       =     335544637;
+               public const int isc_stream_twice                                         =     335544638;
+               public const int isc_stream_not_found                             =     335544639;
+               public const int isc_collation_requires_text              =     335544640;
+               public const int isc_dsql_domain_not_found                        =     335544641;
+               public const int isc_index_unused                                         =     335544642;
+               public const int isc_dsql_self_join                                       =     335544643;
+               public const int isc_stream_bof                                           =     335544644;
+               public const int isc_stream_crack                                         =     335544645;
+               public const int isc_db_or_file_exists                            =     335544646;
+               public const int isc_invalid_operator                             =     335544647;
+               public const int isc_conn_lost                                            =     335544648;
+               public const int isc_bad_checksum                                         =     335544649;
+               public const int isc_page_type_err                                        =     335544650;
+               public const int isc_ext_readonly_err                             =     335544651;
+               public const int isc_sing_select_err                              =     335544652;
+               public const int isc_psw_attach                                           =     335544653;
+               public const int isc_psw_start_trans                              =     335544654;
+               public const int isc_invalid_direction                            =     335544655;
+               public const int isc_dsql_var_conflict                            =     335544656;
+               public const int isc_dsql_no_blob_array                           =     335544657;
+               public const int isc_dsql_base_table                              =     335544658;
+               public const int isc_duplicate_base_table                         =     335544659;
+               public const int isc_view_alias                                           =     335544660;
+               public const int isc_index_root_page_full                         =     335544661;
+               public const int isc_dsql_blob_type_unknown                       =     335544662;
+               public const int isc_req_max_clones_exceeded              =     335544663;
+               public const int isc_dsql_duplicate_spec                          =     335544664;
+               public const int isc_unique_key_violation                         =     335544665;
+               public const int isc_srvr_version_too_old                         =     335544666;
+               public const int isc_drdb_completed_with_errs             =     335544667;
+               public const int isc_dsql_procedure_use_err                       =     335544668;
+               public const int isc_dsql_count_mismatch                          =     335544669;
+               public const int isc_blob_idx_err                                         =     335544670;
+               public const int isc_array_idx_err                                        =     335544671;
+               public const int isc_key_field_err                                        =     335544672;
+               public const int isc_no_delete                                            =     335544673;
+               public const int isc_del_last_field                                       =     335544674;
+               public const int isc_sort_err                                             =     335544675;
+               public const int isc_sort_mem_err                                         =     335544676;
+               public const int isc_version_err                                          =     335544677;
+               public const int isc_inval_key_posn                                       =     335544678;
+               public const int isc_no_segments_err                              =     335544679;
+               public const int isc_crrp_data_err                                        =     335544680;
+               public const int isc_rec_size_err                                         =     335544681;
+               public const int isc_dsql_field_ref                                       =     335544682;
+               public const int isc_req_depth_exceeded                           =     335544683;
+               public const int isc_no_field_access                              =     335544684;
+               public const int isc_no_dbkey                                             =     335544685;
+               public const int isc_jrn_format_err                                       =     335544686;
+               public const int isc_jrn_file_full                                        =     335544687;
+               public const int isc_dsql_open_cursor_request             =     335544688;
+               public const int isc_ib_error                                             =     335544689;
+               public const int isc_cache_redef                                          =     335544690;
+               public const int isc_cache_too_small                              =     335544691;
+               public const int isc_log_redef                                            =     335544692;
+               public const int isc_log_too_small                                        =     335544693;
+               public const int isc_partition_too_small                          =     335544694;
+               public const int isc_partition_not_supp                           =     335544695;
+               public const int isc_log_length_spec                              =     335544696;
+               public const int isc_precision_err                                        =     335544697;
+               public const int isc_scale_nogt                                           =     335544698;
+               public const int isc_expec_int                                            =     335544699;
+               public const int isc_expec_long                                           =     335544700;
+               public const int isc_expec_uint                                           =     335544701;
+               public const int isc_like_escape_invalid                          =     335544702;
+               public const int isc_svcnoexe                                             =     335544703;
+               public const int isc_net_lookup_err                                       =     335544704;
+               public const int isc_service_unknown                              =     335544705;
+               public const int isc_host_unknown                                         =     335544706;
+               public const int isc_grant_nopriv_on_base                         =     335544707;
+               public const int isc_dyn_fld_ambiguous                            =     335544708;
+               public const int isc_dsql_agg_ref_err                             =     335544709;
+               public const int isc_complex_view                                         =     335544710;
+               public const int isc_unprepared_stmt                              =     335544711;
+               public const int isc_expec_positive                                       =     335544712;
+               public const int isc_dsql_sqlda_value_err                         =     335544713;
+               public const int isc_invalid_array_id                             =     335544714;
+               public const int isc_extfile_uns_op                                       =     335544715;
+               public const int isc_svc_in_use                                           =     335544716;
+               public const int isc_err_stack_limit                              =     335544717;
+               public const int isc_invalid_key                                          =     335544718;
+               public const int isc_net_init_error                                       =     335544719;
+               public const int isc_loadlib_failure                              =     335544720;
+               public const int isc_network_error                                        =     335544721;
+               public const int isc_net_connect_err                              =     335544722;
+               public const int isc_net_connect_listen_err                       =     335544723;
+               public const int isc_net_event_connect_err                        =     335544724;
+               public const int isc_net_event_listen_err                         =     335544725;
+               public const int isc_net_read_err                                         =     335544726;
+               public const int isc_net_write_err                                        =     335544727;
+               public const int isc_integ_index_deactivate                       =     335544728;
+               public const int isc_integ_deactivate_primary             =     335544729;
+               public const int isc_cse_not_supported                            =     335544730;
+               public const int isc_tra_must_sweep                                       =     335544731;
+               public const int isc_unsupported_network_drive            =     335544732;
+               public const int isc_io_create_err                                        =     335544733;
+               public const int isc_io_open_err                                          =     335544734;
+               public const int isc_io_close_err                                         =     335544735;
+               public const int isc_io_read_err                                          =     335544736;
+               public const int isc_io_write_err                                         =     335544737;
+               public const int isc_io_delete_err                                        =     335544738;
+               public const int isc_io_access_err                                        =     335544739;
+               public const int isc_udf_exception                                        =     335544740;
+               public const int isc_lost_db_connection                           =     335544741;
+               public const int isc_no_write_user_priv                           =     335544742;
+               public const int isc_token_too_long                                       =     335544743;
+               public const int isc_max_att_exceeded                             =     335544744;
+               public const int isc_login_same_as_role_name              =     335544745;
+               public const int isc_reftable_requires_pk                         =     335544746;
+               public const int isc_usrname_too_long                             =     335544747;
+               public const int isc_password_too_long                            =     335544748;
+               public const int isc_usrname_required                             =     335544749;
+               public const int isc_password_required                            =     335544750;
+               public const int isc_bad_protocol                                         =     335544751;
+               public const int isc_dup_usrname_found                            =     335544752;
+               public const int isc_usrname_not_found                            =     335544753;
+               public const int isc_error_adding_sec_record              =     335544754;
+               public const int isc_error_modifying_sec_record           =     335544755;
+               public const int isc_error_deleting_sec_record            =     335544756;
+               public const int isc_error_updating_sec_db                        =     335544757;
+               public const int isc_sort_rec_size_err                            =     335544758;
+               public const int isc_bad_default_value                            =     335544759;
+               public const int isc_invalid_clause                                       =     335544760;
+               public const int isc_too_many_handles                             =     335544761;
+               public const int isc_optimizer_blk_exc                            =     335544762;
+               public const int isc_invalid_string_constant              =     335544763;
+               public const int isc_transitional_date                            =     335544764;
+               public const int isc_read_only_database                           =     335544765;
+               public const int isc_must_be_dialect_2_and_up             =     335544766;
+               public const int isc_blob_filter_exception                        =     335544767;
+               public const int isc_exception_access_violation           =     335544768;
+               public const int isc_exception_datatype_missalignment = 335544769;
+               public const int isc_exception_array_bounds_exceeded  = 335544770;
+               public const int isc_exception_float_denormal_operand = 335544771;
+               public const int isc_exception_float_divide_by_zero       =     335544772;
+               public const int isc_exception_float_inexact_result       =     335544773;
+               public const int isc_exception_float_invalid_operand  = 335544774;
+               public const int isc_exception_float_overflow             =     335544775;
+               public const int isc_exception_float_stack_check          =     335544776;
+               public const int isc_exception_float_underflow            =     335544777;
+               public const int isc_exception_int_divide_by_zero         =     335544778;
+               public const int isc_exception_int_overflow                       =     335544779;
+               public const int isc_exception_unknown                            =     335544780;
+               public const int isc_exception_stack_overflow             =     335544781;
+               public const int isc_exception_sigsegv                            =     335544782;
+               public const int isc_exception_sigill                             =     335544783;
+               public const int isc_exception_sigbus                             =     335544784;
+               public const int isc_exception_sigfpe                             =     335544785;
+               public const int isc_ext_file_delete                              =     335544786;
+               public const int isc_ext_file_modify                              =     335544787;
+               public const int isc_adm_task_denied                              =     335544788;
+               public const int isc_extract_input_mismatch                       =     335544789;
+               public const int isc_insufficient_svc_privileges          =     335544790;
+               public const int isc_file_in_use                                          =     335544791;
+               public const int isc_service_att_err                              =     335544792;
+               public const int isc_ddl_not_allowed_by_db_sql_dial       =     335544793;
+               public const int isc_cancelled                                            =     335544794;
+               public const int isc_unexp_spb_form                                       =     335544795;
+               public const int isc_sql_dialect_datatype_unsupport       =     335544796;
+               public const int isc_svcnouser                                            =     335544797;
+               public const int isc_depend_on_uncommitted_rel            =     335544798;
+               public const int isc_svc_name_missing                             =     335544799;
+               public const int isc_too_many_contexts                            =     335544800;
+               public const int isc_datype_notsup                                        =     335544801;
+               public const int isc_dialect_reset_warning                        =     335544802;
+               public const int isc_dialect_not_changed                          =     335544803;
+               public const int isc_database_create_failed                       =     335544804;
+               public const int isc_inv_dialect_specified                        =     335544805;
+               public const int isc_valid_db_dialects                            =     335544806;
+               public const int isc_sqlwarn                                              =     335544807;
+               public const int isc_dtype_renamed                                        =     335544808;
+               public const int isc_extern_func_dir_error                        =     335544809;
+               public const int isc_date_range_exceeded                          =     335544810;
+               public const int isc_inv_client_dialect_specified         =     335544811;
+               public const int isc_valid_client_dialects                        =     335544812;
+               public const int isc_optimizer_between_err                        =     335544813;
+               public const int isc_service_not_supported                        =     335544814;
+               public const int isc_generator_name                                       =     335544815;
+               public const int isc_udf_name                                             =     335544816;
+               public const int isc_bad_limit_param                              =     335544817;
+               public const int isc_bad_skip_param                                       =     335544818;
+               public const int isc_io_32bit_exceeded_err                        =     335544819;
+               public const int isc_invalid_savepoint                            =     335544820;
+               public const int isc_dsql_column_pos_err                          =     335544821;
+               public const int isc_dsql_agg_where_err                           =     335544822;
+               public const int isc_dsql_agg_group_err                           =     335544823;
+               public const int isc_dsql_agg_column_err                          =     335544824;
+               public const int isc_dsql_agg_having_err                          =     335544825;
+               public const int isc_dsql_agg_nested_err                          =     335544826;
+               public const int isc_exec_sql_invalid_arg                         =     335544827;
+               public const int isc_exec_sql_invalid_req                         =     335544828;
+               public const int isc_exec_sql_invalid_var                         =     335544829;
+               public const int isc_exec_sql_max_call_exceeded           =     335544830;
+               public const int isc_conf_access_denied                           =     335544831;
+               public const int isc_gfix_db_name                                         =     335740929;
+               public const int isc_gfix_invalid_sw                              =     335740930;              
+               public const int isc_gfix_incmp_sw                                        =     335740932;
+               public const int isc_gfix_replay_req                              =     335740933;
+               public const int isc_gfix_pgbuf_req                                       =     335740934;
+               public const int isc_gfix_val_req                                         =     335740935;
+               public const int isc_gfix_pval_req                                        =     335740936;
+               public const int isc_gfix_trn_req                                         =     335740937;
+               public const int isc_gfix_full_req                                        =     335740940;
+               public const int isc_gfix_usrname_req                             =     335740941;
+               public const int isc_gfix_pass_req                                        =     335740942;
+               public const int isc_gfix_subs_name                                       =     335740943;
+               public const int isc_gfix_wal_req                                         =     335740944;
+               public const int isc_gfix_sec_req                                         =     335740945;
+               public const int isc_gfix_nval_req                                        =     335740946;
+               public const int isc_gfix_type_shut                                       =     335740947;
+               public const int isc_gfix_retry                                           =     335740948;
+               public const int isc_gfix_retry_db                                        =     335740951;
+               public const int isc_gfix_exceed_max                              =     335740991;
+               public const int isc_gfix_corrupt_pool                            =     335740992;
+               public const int isc_gfix_mem_exhausted                           =     335740993;
+               public const int isc_gfix_bad_pool                                        =     335740994;
+               public const int isc_gfix_trn_not_valid                           =     335740995;
+               public const int isc_gfix_unexp_eoi                                       =     335741012;
+               public const int isc_gfix_recon_fail                              =     335741018;
+               public const int isc_gfix_trn_unknown                             =     335741036;
+               public const int isc_gfix_mode_req                                        =     335741038;
+               public const int isc_gfix_opt_SQL_dialect                         =     335741039;
+               public const int isc_dsql_dbkey_from_non_table            =     336003074;
+               public const int isc_dsql_transitional_numeric            =     336003075;
+               public const int isc_dsql_dialect_warning_expr            =     336003076;
+               public const int isc_sql_db_dialect_dtype_unsupport       =     336003077;
+               public const int isc_isc_sql_dialect_conflict_num         =     336003079;
+               public const int isc_dsql_warning_number_ambiguous        =     336003080;
+               public const int isc_dsql_warning_number_ambiguous1       =     336003081;
+               public const int isc_dsql_warn_precision_ambiguous        =     336003082;
+               public const int isc_dsql_warn_precision_ambiguous1       =     336003083;
+               public const int isc_dsql_warn_precision_ambiguous2       =     336003084;
+               public const int isc_dyn_role_does_not_exist              =     336068796;
+               public const int isc_dyn_no_grant_admin_opt                       =     336068797;
+               public const int isc_dyn_user_not_role_member             =     336068798;
+               public const int isc_dyn_delete_role_failed                       =     336068799;
+               public const int isc_dyn_grant_role_to_user                       =     336068800;
+               public const int isc_dyn_inv_sql_role_name                        =     336068801;
+               public const int isc_dyn_dup_sql_role                             =     336068802;
+               public const int isc_dyn_kywd_spec_for_role                       =     336068803;
+               public const int isc_dyn_roles_not_supported              =     336068804;
+               public const int isc_dyn_domain_name_exists                       =     336068812;
+               public const int isc_dyn_field_name_exists                        =     336068813;
+               public const int isc_dyn_dependency_exists                        =     336068814;
+               public const int isc_dyn_dtype_invalid                            =     336068815;
+               public const int isc_dyn_char_fld_too_small                       =     336068816;
+               public const int isc_dyn_invalid_dtype_conversion         =     336068817;
+               public const int isc_dyn_dtype_conv_invalid                       =     336068818;
+               public const int isc_gbak_unknown_switch                          =     336330753;
+               public const int isc_gbak_page_size_missing                       =     336330754;
+               public const int isc_gbak_page_size_toobig                        =     336330755;
+               public const int isc_gbak_redir_ouput_missing             =     336330756;
+               public const int isc_gbak_switches_conflict                       =     336330757;
+               public const int isc_gbak_unknown_device                          =     336330758;
+               public const int isc_gbak_no_protection                           =     336330759;
+               public const int isc_gbak_page_size_not_allowed           =     336330760;
+               public const int isc_gbak_multi_source_dest                       =     336330761;
+               public const int isc_gbak_filename_missing                        =     336330762;
+               public const int isc_gbak_dup_inout_names                         =     336330763;
+               public const int isc_gbak_inv_page_size                           =     336330764;
+               public const int isc_gbak_db_specified                            =     336330765;
+               public const int isc_gbak_db_exists                                       =     336330766;
+               public const int isc_gbak_unk_device                              =     336330767;
+               public const int isc_gbak_blob_info_failed                        =     336330772;
+               public const int isc_gbak_unk_blob_item                           =     336330773;
+               public const int isc_gbak_get_seg_failed                          =     336330774;
+               public const int isc_gbak_close_blob_failed                       =     336330775;
+               public const int isc_gbak_open_blob_failed                        =     336330776;
+               public const int isc_gbak_put_blr_gen_id_failed           =     336330777;
+               public const int isc_gbak_unk_type                                        =     336330778;
+               public const int isc_gbak_comp_req_failed                         =     336330779;
+               public const int isc_gbak_start_req_failed                        =     336330780;
+               public const int isc_gbak_rec_failed                              =     336330781;
+               public const int isc_gbak_rel_req_failed                          =     336330782;
+               public const int isc_gbak_db_info_failed                          =     336330783;
+               public const int isc_gbak_no_db_desc                              =     336330784;
+               public const int isc_gbak_db_create_failed                        =     336330785;
+               public const int isc_gbak_decomp_len_error                        =     336330786;
+               public const int isc_gbak_tbl_missing                             =     336330787;
+               public const int isc_gbak_blob_col_missing                        =     336330788;
+               public const int isc_gbak_create_blob_failed              =     336330789;
+               public const int isc_gbak_put_seg_failed                          =     336330790;
+               public const int isc_gbak_rec_len_exp                             =     336330791;
+               public const int isc_gbak_inv_rec_len                             =     336330792;
+               public const int isc_gbak_exp_data_type                           =     336330793;
+               public const int isc_gbak_gen_id_failed                           =     336330794;
+               public const int isc_gbak_unk_rec_type                            =     336330795;
+               public const int isc_gbak_inv_bkup_ver                            =     336330796;
+               public const int isc_gbak_missing_bkup_desc                       =     336330797;
+               public const int isc_gbak_string_trunc                            =     336330798;
+               public const int isc_gbak_cant_rest_record                        =     336330799;
+               public const int isc_gbak_send_failed                             =     336330800;
+               public const int isc_gbak_no_tbl_name                             =     336330801;
+               public const int isc_gbak_unexp_eof                                       =     336330802;
+               public const int isc_gbak_db_format_too_old                       =     336330803;
+               public const int isc_gbak_inv_array_dim                           =     336330804;
+               public const int isc_gbak_xdr_len_expected                        =     336330807;
+               public const int isc_gbak_open_bkup_error                         =     336330817;
+               public const int isc_gbak_open_error                              =     336330818;
+               public const int isc_gbak_missing_block_fac                       =     336330934;
+               public const int isc_gbak_inv_block_fac                           =     336330935;
+               public const int isc_gbak_block_fac_specified             =     336330936;
+               public const int isc_gbak_missing_username                        =     336330940;
+               public const int isc_gbak_missing_password                        =     336330941;
+               public const int isc_gbak_missing_skipped_bytes           =     336330952;
+               public const int isc_gbak_inv_skipped_bytes                       =     336330953;
+               public const int isc_gbak_err_restore_charset             =     336330965;
+               public const int isc_gbak_err_restore_collation           =     336330967;
+               public const int isc_gbak_read_error                              =     336330972;
+               public const int isc_gbak_write_error                             =     336330973;
+               public const int isc_gbak_db_in_use                                       =     336330985;
+               public const int isc_gbak_sysmemex                                        =     336330990;
+               public const int isc_gbak_restore_role_failed             =     336331002;
+               public const int isc_gbak_role_op_missing                         =     336331005;
+               public const int isc_gbak_page_buffers_missing            =     336331010;
+               public const int isc_gbak_page_buffers_wrong_param        =     336331011;
+               public const int isc_gbak_page_buffers_restore            =     336331012;
+               public const int isc_gbak_inv_size                                        =     336331014;
+               public const int isc_gbak_file_outof_sequence             =     336331015;
+               public const int isc_gbak_join_file_missing                       =     336331016;
+               public const int isc_gbak_stdin_not_supptd                        =     336331017;
+               public const int isc_gbak_stdout_not_supptd                       =     336331018;
+               public const int isc_gbak_bkup_corrupt                            =     336331019;
+               public const int isc_gbak_unk_db_file_spec                        =     336331020;
+               public const int isc_gbak_hdr_write_failed                        =     336331021;
+               public const int isc_gbak_disk_space_ex                           =     336331022;
+               public const int isc_gbak_size_lt_min                             =     336331023;
+               public const int isc_gbak_svc_name_missing                        =     336331025;
+               public const int isc_gbak_not_ownr                                        =     336331026;
+               public const int isc_gbak_mode_req                                        =     336331031;
+               public const int isc_gsec_cant_open_db                            =     336723983;
+               public const int isc_gsec_switches_error                          =     336723984;
+               public const int isc_gsec_no_op_spec                              =     336723985;
+               public const int isc_gsec_no_usr_name                             =     336723986;
+               public const int isc_gsec_err_add                                         =     336723987;
+               public const int isc_gsec_err_modify                              =     336723988;
+               public const int isc_gsec_err_find_mod                            =     336723989;
+               public const int isc_gsec_err_rec_not_found                       =     336723990;
+               public const int isc_gsec_err_delete                              =     336723991;
+               public const int isc_gsec_err_find_del                            =     336723992;
+               public const int isc_gsec_err_find_disp                           =     336723996;
+               public const int isc_gsec_inv_param                                       =     336723997;
+               public const int isc_gsec_op_specified                            =     336723998;
+               public const int isc_gsec_pw_specified                            =     336723999;
+               public const int isc_gsec_uid_specified                           =     336724000;
+               public const int isc_gsec_gid_specified                           =     336724001;
+               public const int isc_gsec_proj_specified                          =     336724002;
+               public const int isc_gsec_org_specified                           =     336724003;
+               public const int isc_gsec_fname_specified                         =     336724004;
+               public const int isc_gsec_mname_specified                         =     336724005;
+               public const int isc_gsec_lname_specified                         =     336724006;
+               public const int isc_gsec_inv_switch                              =     336724008;
+               public const int isc_gsec_amb_switch                              =     336724009;
+               public const int isc_gsec_no_op_specified                         =     336724010;
+               public const int isc_gsec_params_not_allowed              =     336724011;
+               public const int isc_gsec_incompat_switch                         =     336724012;
+               public const int isc_gsec_inv_username                            =     336724044;
+               public const int isc_gsec_inv_pw_length                           =     336724045;
+               public const int isc_gsec_db_specified                            =     336724046;
+               public const int isc_gsec_db_admin_specified              =     336724047;
+               public const int isc_gsec_db_admin_pw_specified           =     336724048;
+               public const int isc_gsec_sql_role_specified              =     336724049;
+               public const int isc_license_no_file                              =     336789504;
+               public const int isc_license_op_specified                         =     336789523;
+               public const int isc_license_op_missing                           =     336789524;
+               public const int isc_license_inv_switch                           =     336789525;
+               public const int isc_license_inv_switch_combo             =     336789526;
+               public const int isc_license_inv_op_combo                         =     336789527;
+               public const int isc_license_amb_switch                           =     336789528;
+               public const int isc_license_inv_parameter                        =     336789529;
+               public const int isc_license_param_specified              =     336789530;
+               public const int isc_license_param_req                            =     336789531;
+               public const int isc_license_syntx_error                          =     336789532;
+               public const int isc_license_dup_id                                       =     336789534;
+               public const int isc_license_inv_id_key                           =     336789535;
+               public const int isc_license_err_remove                           =     336789536;
+               public const int isc_license_err_update                           =     336789537;
+               public const int isc_license_err_convert                          =     336789538;
+               public const int isc_license_err_unk                              =     336789539;
+               public const int isc_license_svc_err_add                          =     336789540;
+               public const int isc_license_svc_err_remove                       =     336789541;
+               public const int isc_license_eval_exists                          =     336789563;
+               public const int isc_gstat_unknown_switch                         =     336920577;
+               public const int isc_gstat_retry                                          =     336920578;
+               public const int isc_gstat_wrong_ods                              =     336920579;
+               public const int isc_gstat_unexpected_eof                         =     336920580;
+               public const int isc_gstat_open_err                                       =     336920605;
+               public const int isc_gstat_read_err                                       =     336920606;
+               public const int isc_gstat_sysmemex                                       =     336920607;
+               public const int isc_err_max                                              =     689;
+               
+               #endregion
+
+               #region BLR     Codes
+
+               public const int blr_version5   = 5;
+               public const int blr_begin              = 2;
+               public const int blr_message    = 4;
+               public const int blr_eoc                = 76;
+               public const int blr_end                = 255;  /* note: defined as     -1 in gds.h     */
+
+               public const int blr_text               = 14;
+               public const int blr_text2              = 15;
+               public const int blr_short              = 7;
+               public const int blr_long               = 8;
+               public const int blr_quad               = 9;
+               public const int blr_int64              = 16;
+               public const int blr_float              = 10;
+               public const int blr_double             = 27;
+               public const int blr_d_float    = 11;
+               public const int blr_timestamp  = 35;
+               public const int blr_varying    = 37;
+               public const int blr_varying2   = 38;
+               public const int blr_blob               = 261;
+               public const int blr_cstring    = 40;
+               public const int blr_cstring2   = 41;
+               public const int blr_blob_id    = 45;
+               public const int blr_sql_date   = 12;
+               public const int blr_sql_time   = 13;
+
+               #endregion
+
+               #region DataType Definitions
+
+               public const int SQL_TEXT          = 452;
+               public const int SQL_VARYING   = 448;
+               public const int SQL_SHORT         = 500;
+               public const int SQL_LONG          = 496;
+               public const int SQL_FLOAT         = 482;
+               public const int SQL_DOUBLE        = 480;
+               public const int SQL_D_FLOAT   = 530;
+               public const int SQL_TIMESTAMP = 510;
+               public const int SQL_BLOB          = 520;
+               public const int SQL_ARRAY         = 540;
+               public const int SQL_QUAD          = 550;
+               public const int SQL_TYPE_TIME = 560;
+               public const int SQL_TYPE_DATE = 570;
+               public const int SQL_INT64         = 580;
+               
+               // Historical alias     for     pre     V6 applications
+               public const int SQL_DATE          = SQL_TIMESTAMP;
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscError.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscError.cs
new file mode 100644 (file)
index 0000000..9b158ef
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class IscError
+       {
+               #region Fields
+
+               private string  message;
+               private int             type;
+               private int             errorCode;
+               private string  strParam;
+               
+               #endregion
+
+               #region Properties
+               
+               public string Message
+               {
+                       get     { return this.message; }
+                       set     { this.message = value; }
+               }
+
+               public int ErrorCode
+               {
+                       get     { return this.errorCode; }
+               }
+
+               public string StrParam
+               {
+                       get
+                       {
+                               switch (this.type)
+                               {
+                                       case IscCodes.isc_arg_interpreted:
+                                       case IscCodes.isc_arg_string:
+                                       case IscCodes.isc_arg_cstring:
+                                               return this.strParam;
+
+                                       case IscCodes.isc_arg_number:
+                                               return this.errorCode.ToString(CultureInfo.InvariantCulture);
+
+                                       default:
+                                               return String.Empty;
+                               }
+                       }
+               }
+
+               public int Type
+               {
+                       get     { return this.type;     }
+               }
+
+               public bool     IsArgument
+               {
+                       get
+                       {
+                               switch (this.type)
+                               {
+                                       case IscCodes.isc_arg_interpreted:
+                                       case IscCodes.isc_arg_string:
+                                       case IscCodes.isc_arg_cstring:
+                                       case IscCodes.isc_arg_number:
+                                               return true;
+
+                                       default:
+                                               return false;
+                               }
+                       }
+               }
+
+               public bool     IsWarning
+               {
+                       get     { return this.type == IscCodes.isc_arg_warning; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               internal IscError(int errorCode)
+               {                                               
+                       this.errorCode = errorCode;
+               }
+
+               internal IscError(int type,     string strParam)
+               {
+                       this.type               = type;
+                       this.strParam   = strParam;
+               }
+
+               internal IscError(int type,     int     errorCode)
+               {
+                       this.type               = type;
+                       this.errorCode  = errorCode;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscErrorCollection.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscErrorCollection.cs
new file mode 100644 (file)
index 0000000..c5f0162
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class IscErrorCollection : CollectionBase
+       {
+               #region Indexers
+
+               public IscError this[int index]
+               {
+                       get     { return (IscError)this.List[index]; }
+               }
+
+               #endregion
+
+               #region Methods
+
+               public IscError Add(int type, string strParam)
+               {
+                       return this.Add(new     IscError(type, strParam));
+               }
+
+               public IscError Add(int type, int errorCode)
+               {
+                       return this.Add(new     IscError(type, errorCode));
+               }
+
+               public IscError Add(IscError error)
+               {
+                       this.List.Add(error);
+
+                       return error;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscException.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscException.cs
new file mode 100644 (file)
index 0000000..a754536
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.Text;
+using System.Reflection;
+using System.Resources;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class IscException : Exception
+       {
+               #region Fields
+
+               private IscErrorCollection      errors;
+               private int                                     errorCode;
+               private string                          message;
+
+               #endregion
+
+               #region Properties
+
+               public IscErrorCollection Errors
+               {
+                       get
+                       {
+                               if (this.errors == null)
+                               {
+                                       this.errors     = new IscErrorCollection();
+                               }
+                               return this.errors;
+                       }
+               }
+
+               public new string Message
+               {
+                       get     { return this.message; }
+               }
+
+               public int ErrorCode
+               {
+                       get     { return this.errorCode; }
+               }
+
+               public bool     IsWarning
+               {
+                       get
+                       {
+                               if (this.errors.Count > 0)
+                               {
+                                       return this.errors[0].IsWarning;
+                               }
+                               else
+                               {
+                                       return false;
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public IscException() : base()
+               {
+               }
+
+               public IscException(int errorCode) : base()
+               {
+                       this.Errors.Add(IscCodes.isc_arg_gds, errorCode);
+                       this.BuildExceptionMessage();
+               }
+
+               public IscException(string strParam) : base()
+               {
+                       this.Errors.Add(IscCodes.isc_arg_string, strParam);
+                       this.BuildExceptionMessage();
+               }
+
+               public IscException(int errorCode, int intparam) : base()
+               {
+                       this.Errors.Add(IscCodes.isc_arg_gds, errorCode);
+                       this.Errors.Add(IscCodes.isc_arg_number, intparam);
+                       this.BuildExceptionMessage();
+               }
+
+               public IscException(int type, int errorCode, string     strParam) :     base()
+               {
+                       this.Errors.Add(type, errorCode);
+                       this.Errors.Add(IscCodes.isc_arg_string, strParam);
+                       this.BuildExceptionMessage();
+               }
+
+               public IscException(
+                       int     type, int errorCode, int intParam, string strParam)     : base()
+               {
+                       this.Errors.Add(type, errorCode);
+                       this.Errors.Add(IscCodes.isc_arg_string, strParam);
+                       this.Errors.Add(IscCodes.isc_arg_number, intParam);
+                       this.BuildExceptionMessage();
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void     BuildExceptionMessage()
+               {
+                       string                  resources =     "FirebirdSql.Data.Common.Resources.isc_error_msg";
+                       StringBuilder   builder = new StringBuilder();
+                       ResourceManager rm = new ResourceManager(resources,     Assembly.GetExecutingAssembly());
+
+                       this.errorCode = (this.Errors.Count     != 0) ? this.Errors[0].ErrorCode : 0;
+
+                       for     (int i = 0;     i <     this.Errors.Count; i++)
+                       {
+                               if (this.Errors[i].Type == IscCodes.isc_arg_gds ||
+                                       this.Errors[i].Type     == IscCodes.isc_arg_warning)
+                               {
+                                       int             code    = this.Errors[i].ErrorCode;
+                                       string  message = null;
+
+                                       try
+                                       {
+                                               message = rm.GetString(code.ToString());
+                                       }
+                                       catch
+                                       {
+                                               message = String.Format(CultureInfo.CurrentUICulture, "No message for error     code {0} found.", code);
+                                       }
+
+                                       ArrayList param = new ArrayList();
+
+                                       int     index = i +     1;
+
+                                       while (index < this.Errors.Count &&     this.Errors[index].IsArgument)
+                                       {
+                                               param.Add(this.Errors[index++].StrParam);
+                                               i++;
+                                       }
+
+                                       object[] args = (object[])param.ToArray(typeof(object));
+
+                                       if (code ==     IscCodes.isc_except)
+                                       {
+                                               // Custom exception     add     the     first argument as error code
+                                               this.errorCode = Convert.ToInt32(args[0], CultureInfo.InvariantCulture);
+                                       }
+                                       else
+                                       {
+                                               if (builder.Length > 0)
+                                               {
+                                                       builder.Append("\n");
+                                               }
+
+                                               builder.AppendFormat(CultureInfo.CurrentUICulture, message,     args);
+                                       }
+                               }
+                       }
+
+                       // Update error collection only with the main error
+                       IscError mainError = new IscError(this.errorCode);
+                       mainError.Message =     builder.ToString();
+
+                       this.errors     = new IscErrorCollection();
+                       this.Errors.Add(mainError);
+
+                       // Update exception     message
+                       this.message = builder.ToString();
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscHelper.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscHelper.cs
new file mode 100644 (file)
index 0000000..354a4ee
--- /dev/null
@@ -0,0 +1,331 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.Resources;
+using System.Text;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class IscHelper
+       {
+               #region Constructors
+
+               private IscHelper()
+               {
+               }
+
+               #endregion
+
+               #region General Static Methods
+
+               public static ArrayList ParseDatabaseInfo(byte[] buffer)
+               {
+                       ArrayList info = new ArrayList();
+
+                       int     pos             = 0;
+                       int     length  = 0;
+                       int     type    = 0;
+
+                       while ((type = buffer[pos++]) != IscCodes.isc_info_end)
+                       {
+                               length  = VaxInteger(buffer, pos, 2);
+                               pos             += 2;
+
+                               switch (type) 
+                               {
+                                       //
+                                       // Database     characteristics
+                                       //
+                                       case IscCodes.isc_info_allocation:
+                                               // Number of database pages     allocated
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+
+                                       case IscCodes.isc_info_base_level:
+                                               /* Database     version (level) number:
+                                                *              1 byte containing the number 1
+                                                *              1 byte containing the version number
+                                                */
+                                               info.Add(String.Format(CultureInfo.CurrentUICulture, "{0}.{1}", buffer[pos], buffer[pos + 1]));
+                                               break;
+
+                                       case IscCodes.isc_info_db_id:
+                                               /* Database     file name and site name:
+                                                *              \95 1     byte containing the     number 2
+                                                *              \95 1     byte containing the     length, d, of the database file name in bytes
+                                                *              \95 A     string of d     bytes, containing the database file     name
+                                                *              \95 1     byte containing the     length, l, of the site name     in bytes
+                                                *              \95 A     string of l     bytes, containing the site name
+                                                */
+                                               string dbFile   = Encoding.Default.GetString(buffer, pos + 2, buffer[pos + 1]);
+                                               int     sitePos         = pos + 2 +     buffer[pos + 1];
+                                               int     siteLength      = buffer[sitePos];
+                                               string siteName = Encoding.Default.GetString(buffer, sitePos + 1, siteLength);
+                                               sitePos                 += siteLength + 1;
+                                               siteLength              = buffer[sitePos];                                              
+                                               siteName                += "." + Encoding.Default.GetString(buffer,     sitePos + 1, siteLength);
+                                               
+                                               info.Add(siteName +     ":"     + dbFile);
+                                               break;
+
+                                       case IscCodes.isc_info_implementation:
+                                               /* Database     implementation number:
+                                                *              \95 1     byte containing a 1
+                                                *              \95 1     byte containing the     implementation number
+                                                *              \95 1     byte containing a \93class\94 number, either 1 or 12
+                                                */
+                                               info.Add(String.Format(CultureInfo.CurrentUICulture, "{0}.{1}.{2}",     buffer[pos], buffer[pos + 1], buffer[pos + 2]));
+                                               break;
+
+                                       case IscCodes.isc_info_no_reserve:
+                                               /* 0 or 1
+                                                *              \95 0     indicates space is reserved     on each database page for holding
+                                                *                      backup versions of modified     records [Default]
+                                                *              \95 1     indicates no space is reserved for such records
+                                                */
+                                               info.Add(buffer[pos] == 1 ?     true : false);
+                                               break;
+
+                                       case IscCodes.isc_info_ods_version:
+                                               /* ODS major version number
+                                                *              \95 Databases     with different major version numbers have different
+                                                *                      physical layouts; a     database engine can     only access     databases
+                                                *                      with a particular ODS major     version number
+                                                *              \95 Trying to     attach to a     database with a different ODS number
+                                                *                      results in an error
+                                                */
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+
+                                       case IscCodes.isc_info_ods_minor_version:
+                                               /* On-disk structure (ODS) minor version number; an     increase in     a
+                                                * minor version number indicates a     non-structural change, one that
+                                                * still allows the     database to     be accessed     by database     engines with
+                                                * the same     major version number but possibly different     minor
+                                                * version numbers
+                                                */
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+
+                                       case IscCodes.isc_info_page_size:
+                                               /* Number of bytes per page     of the attached database; use with
+                                                * isc_info_allocation to determine     the     size of the     database
+                                                */
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_isc_version:
+                                               /* Version identification string of     the     database implementation:
+                                                *              \95 1     byte containing the     number 1
+                                                *              \95 1     byte specifying the     length, n, of the following     string
+                                                *              \95 n     bytes containing the version identification     string
+                                                */                                             
+                                               info.Add(Encoding.Default.GetString(buffer,     pos     + 2, buffer[pos + 1]));
+                                               break;
+
+                                       //
+                                       // Environmental characteristics
+                                       //
+
+                                       case IscCodes.isc_info_current_memory:
+                                               // Amount of server     memory (in bytes) currently     in use
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+
+                                       case IscCodes.isc_info_forced_writes:
+                                               /* Number specifying the mode in which database writes are performed
+                                                * (0 for asynchronous, 1 for synchronous)
+                                                */
+                                               info.Add(buffer[pos] == 1 ?     true : false);
+                                               break;
+                                                
+                                       case IscCodes.isc_info_max_memory:
+                                               /* Maximum amount of memory     (in     bytes) used     at one time     since the first
+                                                * process attached     to the database
+                                                */
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+
+                                       case IscCodes.isc_info_num_buffers:
+                                               // Number of memory     buffers currently allocated
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+
+                                       case IscCodes.isc_info_sweep_interval:
+                                               /* Number of transactions that are committed between \93sweeps\94 to
+                                                * remove database record versions that are     no longer needed
+                                                */
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+
+                                               //
+                                               // Performance statistics
+                                               //
+
+                                       case IscCodes.isc_info_fetches:
+                                               // Number of reads from the     memory buffer cache
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_marks:
+                                               // Number of writes     to the memory buffer cache
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                                                                                       
+                                       case IscCodes.isc_info_reads:
+                                               // Number of page reads
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_writes:
+                                               // Number of page writes
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+
+                                       //
+                                       // Database     operation counts
+                                       //
+
+                                       case IscCodes.isc_info_backout_count:
+                                               // Number of removals of a version of a record
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_delete_count:
+                                               // Number of database deletes since     the     database was last attached
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_expunge_count:
+                                               /* Number of removals of a record and all of its ancestors,     for     records
+                                                * whose deletions have been committed
+                                                */
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_insert_count:
+                                               // Number of inserts into the database since the database was last attached     
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_purge_count:
+                                               // Number of removals of old versions of fully mature records
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_read_idx_count:
+                                               // Number of reads done via     an index since the database     was     last attached
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+
+                                       case IscCodes.isc_info_read_seq_count:
+                                               /* Number of sequential sequential table scans (row     reads) done     on each 
+                                                * table since the database     was     last attached
+                                                */
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_update_count:
+                                               // Number of database updates since     the     database was last attached
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       //
+                                       // Misc
+                                       //
+
+                                       case IscCodes.isc_info_firebird_version:
+                                               info.Add(Encoding.Default.GetString(buffer,     pos     + 2, buffer[pos + 1]));
+                                               break;
+
+                                       case IscCodes.isc_info_db_class:
+                                               int     serverClass     = VaxInteger(buffer, pos, length);
+                                               if (serverClass == IscCodes.isc_info_db_class_classic_access)
+                                               {
+                                                       info.Add("CLASSIC SERVER");
+                                               }
+                                               else
+                                               {
+                                                       info.Add("SUPER SERVER");
+                                               }
+                                               break;
+                                                                                       
+                                       case IscCodes.isc_info_db_read_only:
+                                               info.Add(buffer[pos] == 1 ?     true : false);
+                                               break;
+
+                                       case IscCodes.isc_info_db_size_in_pages:
+                                               // Database     size in pages.
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_oldest_transaction:
+                                               // Number of oldest     transaction
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_oldest_active:
+                                               // Number of oldest     active transaction
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_oldest_snapshot:
+                                               // Number of oldest     snapshot transaction
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_next_transaction:
+                                               // Number of next transaction
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                                       
+                                       case IscCodes.isc_info_active_transactions:
+                                               // Number of active     transactions
+                                               info.Add(VaxInteger(buffer,     pos, length));
+                                               break;
+                               }
+                               
+                               pos     += length;
+                       }
+
+                       return info;
+               }
+
+               public static int VaxInteger(byte[]     buffer, int     index, int length) 
+               {
+                       int     newValue;
+                       int     shift;
+
+                       newValue = shift = 0;
+
+                       int     i =     index;
+                       while (--length >= 0) 
+                       {
+                               newValue +=     (buffer[i++] & 0xff) << shift;
+                               shift += 8;
+                       }
+                       
+                       return newValue;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ParameterBuffer.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ParameterBuffer.cs
new file mode 100644 (file)
index 0000000..ebd4372
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using System.Text;
+using System.Net;
+
+namespace FirebirdSql.Data.Common
+{
+       internal abstract class ParameterBuffer
+       {       
+               #region Fields
+
+               private MemoryStream    stream;
+               private bool                    isLittleEndian;
+
+               #endregion
+
+               #region Properties
+               
+               public short Length
+               {
+                       get     { return (short)this.ToArray().Length; }
+               }
+               
+               #endregion
+
+               #region Protected properties
+
+               protected bool IsLittleEndian
+               {
+                       get     { return this.isLittleEndian; }
+               }
+
+               #endregion
+               
+               #region Constructors
+               
+               protected ParameterBuffer()     : this(false)
+               {
+               }
+
+               protected ParameterBuffer(bool isLittleEndian)
+               {
+                       this.stream                     = new MemoryStream();
+                       this.isLittleEndian     = isLittleEndian;
+               }
+               
+               #endregion                      
+               
+               #region Protected Methods
+
+               protected void WriteByte(int value)
+               {
+                       this.WriteByte((byte)value);
+               }
+
+               protected void WriteByte(byte value)
+               {
+                       this.stream.WriteByte(value);
+               }
+
+               protected void Write(short value)
+               {
+                       if (!this.IsLittleEndian)
+                       {
+                               value = (short)IPAddress.NetworkToHostOrder(value);
+                       }
+
+                       byte[] buffer = BitConverter.GetBytes(value);
+
+                       this.stream.Write(buffer, 0, buffer.Length);
+               }
+
+               protected void Write(int value)
+               {
+                       if (!this.IsLittleEndian)
+                       {
+                               value = (int)IPAddress.NetworkToHostOrder(value);
+                       }
+
+                       byte[] buffer = BitConverter.GetBytes(value);
+
+                       this.stream.Write(buffer, 0, buffer.Length);
+               }
+
+               protected void Write(byte[]     buffer)
+               {
+                       this.Write(buffer, 0, buffer.Length);
+               }
+
+               protected void Write(byte[]     buffer, int     offset, int     count)
+               {
+                       this.stream.Write(buffer, offset, count);
+               }
+
+               #endregion
+
+               #region Methods
+                                               
+               public virtual void     Append(int type)
+               {
+                       this.WriteByte(type);
+               }
+
+               public byte[] ToArray()
+               {
+                       return stream.ToArray();
+               }
+                               
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/RemoteEvent.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/RemoteEvent.cs
new file mode 100644 (file)
index 0000000..6d3e9eb
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections.Specialized;
+
+namespace FirebirdSql.Data.Common
+{
+       #region Delegates
+
+       internal delegate void EventCountsCallback();
+
+       #endregion
+
+       internal class RemoteEvent
+       {
+               #region Callbacks
+
+               public EventCountsCallback EventCountsCallback
+               {
+                       get     { return this.eventCountsCallback; }
+                       set     { this.eventCountsCallback = value;     }
+               }
+
+               #endregion
+
+               #region Fields
+
+               private EventCountsCallback     eventCountsCallback;
+
+               private IDatabase                       db;
+               private int                                     localId;
+               private int                                     remoteId;
+               private StringCollection        events;
+               private bool                            initialCounts;
+               private int[]                           previousCounts;
+               private int[]                           actualCounts;
+
+               #endregion
+
+               #region Properties
+
+               public IDatabase Database
+               {
+                       get     { return this.db; }
+               }
+
+               public int LocalId
+               {
+                       get     { return this.localId; }
+                       set     { this.localId = value; }
+               }
+
+               public int RemoteId
+               {
+                       get     { return this.remoteId; }
+                       set     { this.remoteId = value; }
+               }
+
+               public StringCollection Events
+               {
+                       get
+                       {
+                               if (this.events == null)
+                               {
+                                       this.events     = new StringCollection();
+                               }
+
+                               return this.events;
+                       }
+               }
+
+               public bool     HasChanges
+               {
+                       get
+                       {
+                               if (this.actualCounts == null && this.previousCounts == null)
+                               {
+                                       return false;
+                               }
+                               else if (this.actualCounts != null && this.previousCounts == null)
+                               {
+                                       return true;
+                               }
+                               else if (this.actualCounts.Length != this.previousCounts.Length)
+                               {
+                                       return true;
+                               }
+                               
+                               for     (int i = 0;     i <     this.actualCounts.Length; i++)
+                               {
+                                       if (this.actualCounts[i] !=     this.previousCounts[i])
+                                       {
+                                               return true;
+                                       }
+                               }
+
+                               return false;
+                       }
+               }
+
+               public int[] PreviousCounts
+               {
+                       get     { return this.previousCounts; }
+               }
+
+               public int[] ActualCounts
+               {
+                       get     { return this.actualCounts;     }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public RemoteEvent(IDatabase db) : this(db,     0, 0, null)
+               {
+               }
+
+               public RemoteEvent(IDatabase db, int localId, int remoteId,     StringCollection events)
+               {
+                       this.db                 = db;
+                       this.localId    = localId;
+                       this.remoteId   = remoteId;
+                       this.events             = events;
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void     QueueEvents()
+               {
+                       lock (this.db)
+                       {
+                               this.db.QueueEvents(this);
+                       }
+               }
+
+               public void     CancelEvents()
+               {
+                       lock (this.db)
+                       {
+                               this.db.CancelEvents(this);
+                               this.ResetCounts();
+                       }
+               }
+
+               public void     ResetCounts()
+               {
+                       this.initialCounts      = false;
+                       this.actualCounts       = null;
+                       this.previousCounts     = null;
+               }
+
+               public void     EventCounts(byte[] buffer)
+               {
+                       int             pos                             = 1;
+                       Charset charset                 = this.db.Charset;
+
+                       if (buffer != null)
+                       {
+                               if (this.initialCounts)
+                               {
+                                       this.previousCounts     = this.actualCounts;
+                               }
+
+                               this.actualCounts =     new     int[this.events.Count];
+
+                               while (pos < buffer.Length)
+                               {
+                                       int     length = buffer[pos++];
+                                       string eventName = charset.GetString(buffer, pos, length);
+
+                                       pos     += length;
+
+                                       int     index = this.events.IndexOf(eventName);
+                                       if (index != -1)
+                                       {
+                                               this.actualCounts[index] = BitConverter.ToInt32(buffer, pos) - 1;
+                                       }
+
+                                       pos     += 4;
+                               }
+
+                               if (!this.initialCounts)
+                               {
+                                       this.QueueEvents();
+                                       this.initialCounts = true;
+                               }
+                               else
+                               {
+                                       if (this.EventCountsCallback != null)
+                                       {
+                                               this.EventCountsCallback();
+                                       }
+                               }
+                       }
+               }
+
+               public EventParameterBuffer     ToEpb()
+               {
+                       EventParameterBuffer epb = this.db.CreateEventParameterBuffer();
+
+                       epb.Append(IscCodes.EPB_version1);
+
+                       for     (int i = 0;     i <     this.events.Count; i++)
+                       {
+                               if (this.actualCounts != null)
+                               {
+                                       epb.Append(this.events[i], this.actualCounts[i] + 1);
+                               }
+                               else
+                               {
+                                       epb.Append(this.events[i], 0);
+                               }
+                       }
+
+                       return epb;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Resources/isc_error_msg.resources b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Resources/isc_error_msg.resources
new file mode 100644 (file)
index 0000000..3030789
Binary files /dev/null and b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Resources/isc_error_msg.resources differ
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Resources/isc_error_msg.txt b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Resources/isc_error_msg.txt
new file mode 100644 (file)
index 0000000..179963f
--- /dev/null
@@ -0,0 +1,3576 @@
+336265216=This is a modified text message\r
+336330769=cannot set APOLLO tape descriptor attribute for {0}\r
+336330768=cannot create APOLLO tape descriptor file {0}\r
+336330767=device type not specified\r
+336330766=database {0} already exists.  To replace it, use the -R switch\r
+336330765=REPLACE specified, but the first file {0} is a database\r
+336330764=expected page size, encountered "{0}"\r
+336330763=input and output have the same name.  Disallowed.\r
+336330762=requires both input and output filenames\r
+336330761=multiple sources or destinations specified\r
+336330760=page size is allowed only on restore or create\r
+336330759=protection is not there yet\r
+336330758=device type {0} not known\r
+336330757=conflicting switches for backup/restore\r
+336330756=redirect location for output is not specified\r
+336330755=Page size specified ({0}) greater than limit (8192 bytes)\r
+336330754=page size parameter missing\r
+336330753=found unknown switch\r
+336330752=could not locate appropriate error message\r
+336396693=the current position is on a crack\r
+336396692=illegal operation when at beginning of stream\r
+336396691=Preceding file did not specify length, so {0} must include starting page number\r
+336396690=Shadow number must be a positive integer\r
+336396689=node not supported\r
+336396688=sort error: corruption in data structure\r
+336396687=database or file exists\r
+336396684=Illegal array dimension range\r
+336396683=Inappropriate self-reference of column\r
+336396681=This operation is not defined for system tables.\r
+336396673=lock on conflicts with existing lock\r
+336396672=Object is referenced by another object\r
+336396671=Cannot modify object referenced by another object\r
+336396670=Cannot delete object referenced by another object\r
+336396663=The insert failed because a column definition includes validation constraints.\r
+336396651=duplicate specification of {0} - not supported\r
+336592999=Journal server shutdown\r
+336592998=Journal server started\r
+336592997=Journaling enabled\r
+336592996=Process sign_on\r
+336592995=Process sign_off\r
+336592994=Shutdown requested\r
+336592993=Journaling disabled\r
+336592992=Process disconnect\r
+336592991=Console disconnected\r
+336592990=Dump id for recovery\r
+335675736=Please respond with YES or NO.\r
+335675735=NO\r
+335675734=YES\r
+335675733=expected comma or ')', encountered "{0}"\r
+335675732=Overflow log specification required for this configuration\r
+335675731=minimum of {0} cache pages required\r
+335675730=Only one log configuration can be specified.\r
+336592989=Name of recovered database\r
+336592988=recover database ({0})? (y/n)\r
+336592987=enter journal directory name:\r
+336592986=Secondary file name\r
+336592985=Online dump file name\r
+336592984=continue? (y/n)?:\r
+336592983= transaction commit at: {0}\r
+336592982=applying clumps to log page {0}\r
+335675729=Cannot add and drop log file in same statement.\r
+336592981=enter new value:\r
+335675728=Minimum log length should be {0} Kbytes\r
+336592980=do you want to change this? (y/n):\r
+335675727=Total length of the partitioned log {0} must be specified\r
+335675726=log partition size too small for {0}\r
+335675725=Cannot modify log file specification.  Drop and redefine log files\r
+335675724=Partitions not supported in series of log file specification\r
+335675723=Raw devices not supported in series of log file specification\r
+335675722=Only raw devices support partitioned log files\r
+335675721=use CASCADE option to remove log files before archive is done\r
+335675720=error in reading list of log files\r
+336396628=cannot create index\r
+336396625=definition error for index {0}\r
+336396624=key size exceeds implementation restriction for index "{0}"\r
+336592979=  -s <file size>\r
+336592978=  -f <file name>\r
+336592977= <online dump options>\r
+336592976= <restore options>\r
+336592975= <disable options>\r
+336592974= <enable options>\r
+336592973=  -s <command>\r
+336592972= <console options>\r
+335675719=error in getting Write-ahead Log information\r
+336592971= <server options>\r
+335675718=error committing deletion of shared cache file\r
+336592970=error in file seek\r
+335675717=no shared cache file exists to drop\r
+335675716=error committing new shared cache file declaration\r
+335675715=a shared cache file {0} already exists\r
+335675714=a node name is not permitted in a shared cache file name\r
+335675713=error committing new Write-ahead Log declarations\r
+335675712=DYN request size limit exceeded\r
+335675711=Unexpected sort clause\r
+335675710=expected GENERATOR, encountered "{0}"\r
+336396611={0} extension error\r
+336592969=no buffers available\r
+336592968=invalid clumplet record\r
+336592967=invalid secondary database file sequence number\r
+336592966=ms_$mapl -- wrong length map\r
+336592965=invalid clump type\r
+336592964=wrong use count for buffer\r
+336592963=compress: temporary buffer is too small for page\r
+336592962=wrong clump type for transaction inventory page\r
+335675709=expected comma or right bracket, encountered "{0}"\r
+336592961=wrong clump type index root page\r
+335675708=expected ')', encountered "{0}"\r
+336592960=wrong clump type for pointer page\r
+335675707=expected ON or '(', encountered "{0}"\r
+335675706=expected ')', encountered "{0}"\r
+335675705=expected ON or '(', encountered "{0}"\r
+335675704=key length ({0}) for compound index {1} exceeds 202\r
+335675703=Set_generator requires write privilege for RDB$GENERATORS.\r
+335675702=UDF is limited to 10 parameters\r
+335675701=shadow {0} is inactive\r
+335675700=Ceasing processing.\r
+336396603=invalid ARRAY or BLOB operation\r
+336592959=wrong clump type for page inventory page\r
+336592958=wrong clump type for b-tree page\r
+336592957=b-tree node delete. wrong length\r
+336592956=b-tree node delete. wrong delta\r
+336592955=wrong clump type generator page\r
+336592954=wrong clump type for header page\r
+336592953=invalid line offset\r
+336592952=no space for segment in data page\r
+336592951=wrong clump type for data page ({0})\r
+336592950=error in processing log files\r
+335610299=There are no filters defined in any open database.\r
+335610298=Filters are not supported in any open database.\r
+335610297=Filter {0} is not defined in any open database.\r
+335610296=Filter {0} is not defined in database {1}.\r
+335610295=Filters are not supported in database {0}.\r
+335610294=References to array fields like {0} in relation {1} are not supported\r
+335610293=released block overlaps prior free block\r
+335610292=released block overlaps following free block\r
+335610291=block released twice\r
+336592949=no online dump file specified\r
+335610290=memory pool free list is incorrect\r
+336592948=failure in online dump processing\r
+336592947=invalid online dump record in journal database\r
+336592946=no space on header page\r
+336592945=write() failed in writing page\r
+336592944=lseek failed in write page\r
+336592943=unknown log record type: {0}\r
+336592942=end online dump record. file seqno ({0}) offset ({1})\r
+336592941=start online dump record. file seqno ({0}) offset ({1})\r
+336592940=clumplet records for page ({0}) - applied\r
+335610289= array\r
+335610288=Operation unlicensed for database "{0}"\r
+335610287=Could not drop database file "{0}"\r
+335610286=Unlicensed for database "{0}"\r
+335610285=database file name required on DROP DATABASE\r
+335610284=    Argument {0} is\r
+335610283=    Return argument is\r
+335610282=    Function library is {0}\r
+335610281=Function {0} in database "{1}" ({2}):\r
+336592939=clumplet records for page ({0}) - not applied\r
+335610280=Function {0} ({1}) in database "{2}" ({3}):\r
+336592938=full page record (page = {0}) - applied\r
+336592937=full page record (page = {0}) - not applied\r
+336592936=end processing log files\r
+336592935=start processing log files\r
+336592934=end processing online dump files\r
+336592933=start processing online dump files\r
+336592932=log file for recovery: {0}\r
+336592931=database "{0}" ({1}) disabled at {2}\r
+336592930=applying clumps to tip page {0}\r
+335610279=Function {0} is not defined in any open database.\r
+335610278=Function {0} is not defined in database {1}.\r
+335610277=    Function description:\r
+335610276=Functions are not supported in any open database.\r
+335610275=There are no functions defined in any open database.\r
+335610273=Functions are not supported in database {0}.\r
+335610272=Functions in database "{0}" ({1}):\r
+335610271=matching language string too long\r
+336592929=applying clumps to index root page {0}\r
+335610270=Relation {0} is missing or undefined\r
+336592928=applying clumps to pointer page {0}\r
+336592927=applying clumps to page inventory page {0}\r
+336592926=b-tree drop node. offset {0}\r
+336592925=b-tree add segment. expected after length {0}\r
+336592924=b-tree add segment before length: {0}\r
+336592923=valid b-tree btr_length: {0}\r
+336592922=b-tree add node. offset: {0}  length: {1}\r
+336592921=b-tree add node. before offset {0}\r
+336592920=applying clumps to b-tree page {0}\r
+335610269=Incompatible global field {0} already exists in target database\r
+335610268=function {0} not found in database {1}\r
+335610267=Cannot convert "{0}" to a numeric value\r
+335610266=Cannot convert from {0} to {1}\r
+335610265=Could not create QLI$PROCEDURES index\r
+335610264=Database handle {0} conflicts with an established name\r
+335610263=TABLE\r
+335610262=Dynamic DDL buffer exceeded\r
+335610261=ADD or DROP\r
+336592919=applying clumps to gen-id page {0}\r
+335610260=TO\r
+336592918=applying clumps to header page {0}\r
+336592917=applying clumps to data page {0}\r
+336592916=log file for recovery: {0}\r
+336592915=invalid time stamp on -u (use "dd-mmm-yy hh:mm:ss")\r
+336592914=time stamp required with -u (e.g., "dd-mmm-yy hh:mm:ss")\r
+336592913=no log files for recovery\r
+336592912=online dump file size must be greater than zero\r
+336592911=please retry, specifying journal database directory\r
+336592910=please retry, specifying correct journal utility\r
+335610259=FROM\r
+335610258=OPTION\r
+335610257=GRANT\r
+335610256=user name identifier\r
+335610255=table name\r
+335610254=field name\r
+335610253=ON\r
+335610252==\r
+335610251=SELECT\r
+336592909=please retry, giving a database name\r
+335610250=AS\r
+336592908=database file name ({0}) already specified\r
+336592907=  -u <until options>\r
+336592906=  -i  -run utility in interactive mode\r
+336592905=  -a <archive base name>\r
+336592904=  -j <journal directory>\r
+336592903= <utility> : -enable | -disable | -online_dump | -server | -console | -restore\r
+336592902=enter file name or <Ctrl-D> to end input:\r
+336592901=enter file size or <Ctrl-D> to end input:\r
+336592900=reading online dump parameters\r
+335610249=NULL\r
+335610248=Aggregates not allowed in view definition\r
+335610247=GROUP BY not allowed in view definition\r
+335610246=Multiple page size specifications\r
+335610245=INDEX\r
+335610244=FLOAT\r
+335610243=Database filename required in CREATE\r
+335610242=DATABASE, TABLE, or INDEX\r
+335610241= Shadow {0}, File: {1} starting at page {2}\r
+335610240=Too many WITHs\r
+335741041=dialect number required\r
+335741040=database SQL dialect must be one of '{0}'\r
+335610239=sort field\r
+335610238=TOP or BOTTOM\r
+335610237=Trigger for relation {0}:\r
+335610236= Triggers defined for this relation:\r
+335610235=System Trigger for relation {0}\r
+335741039= -sql_dialect set database dialect n\r
+335610234=No system triggers are defined\r
+335741038="read_only" or "read_write" required\r
+335610233= Source for the trigger is not available.  Trigger BLR:\r
+335741037= -mode  read_only or read_write\r
+335610232= Source for the trigger:\r
+335741036=Transaction description item unknown\r
+335610231= Description:\r
+335741035=Transaction {0} was rolled back, but prior ones were committed.\r
+335610230=Inactive\r
+335741034=Transaction {0} was committed, but prior ones were rolled back.\r
+335741033=Warning: Multidatabase transaction is in inconsistent state for recovery.\r
+335741032=  Automated recovery would rollback this transaction.\r
+335741031=  Automated recovery would commit this transaction.\r
+335741030=        Database Path: {0}\r
+335610229=Active\r
+335610228=Post-erase\r
+335610227=Pre-erase\r
+335610226=Post-modify\r
+335610225=Pre-modify\r
+335741029=        Remote Site: {0}\r
+335610224=Post-store\r
+335741028=is not found, assumed to be committed.\r
+335610223=Pre-store\r
+335741027=is not found, assumed not prepared.\r
+335610222=    {0} {1}, Sequence {2}, {3}\r
+335741026=is not available.\r
+335610221=Triggers for relation {0}:\r
+335741025=has been rolled back.\r
+335610220=lost message\r
+335741024=has been committed.\r
+335741023=has been prepared.\r
+335741022=    Transaction {0}\r
+335741021=    Host Site: {0}\r
+335741020=  Multidatabase transaction:\r
+335610219=missing message\r
+335610218=make_descriptor: not yet implemented\r
+335610217=computable: not yet implemented\r
+335610216=not yet implemented (compile_statement)\r
+335610215=compile_expression: not yet implemented\r
+335741019=Transaction {0}:\r
+335610214=cannot find database for BLOB edit\r
+335741018=failed to reconnect to a transaction in database {0}\r
+335610213=relations from multiple databases in single RSE\r
+335741017=Attach unsuccessful.\r
+335610212=EDIT argument must be a BLOB field\r
+335741016=Enter a valid path:\r
+335610211=gen_statistical: not understood\r
+335741015=Original path: {0}\r
+335610210=gen_statement: not yet implemented\r
+335741014=Could not reattach to database for transaction {0}.\r
+335741013=Commit, rollback, or neither (c, r, or n)?\r
+335741012=unexpected end of input\r
+335741011=Either commit or rollback is possible.\r
+335741010=Transaction {0}: All subtransactions have been prepared.\r
+336397085=Ambiguous column reference.\r
+336397084=Undefined name\r
+336397083=column {0} is not defined in table {1}\r
+336397082=Column does not belong to referenced table\r
+336397080=invalid ORDER BY clause\r
+335610209=gen_expression: not understood\r
+335610208=gen_descriptor: dtype not recognized\r
+335610207=Do you want to roll back your updates?\r
+335610206=END PROCEDURE\r
+335610205={0}Base field description for {1}:\r
+335741009=a proper action for transaction {0}.\r
+335610204={0} Based on field {1} of {2}{3}\r
+335741008=Insufficient information is available to determine\r
+335610203=    Edit string:   {0}\r
+335741007=A commit is necessary to preserve the two-phase commit.\r
+335610202=    Edit string:  {0}\r
+335741006=Transaction {0} has been partially committed.\r
+335610201=    Query header:\r
+335741005=A rollback of this transaction will violate two-phase commit.\r
+335610200=    Query name:  {0}\r
+335741004=Transaction {0} has already been partially committed.\r
+335741003=A rollback of transaction {0} is needed to preserve two-phase commit.\r
+335741002=A commit of transaction {0} will violate two-phase commit.\r
+335741001=Unrecognized info item {0}\r
+335741000=More limbo transactions than fit.  Try again\r
+336397069=table {0} is not defined\r
+336397058=WAL Writer error\r
+336397057=Log file header of {0} too small\r
+336397056=Invalid version of log file {0}\r
+336397055=Log file {0} not latest in the chain but open flag still set\r
+336397054=Log file {0} not closed properly; database recovery may be required\r
+336397053=Database name in the log file {0} is different\r
+336397052=Unexpected end of log file {0} at offset {1}\r
+336397051=Incomplete log record at offset {0} in log file {1}\r
+336397050=Log record header too small at offset {0} in log file {1}\r
+336397049=Cache or Log size too small\r
+336397048=Illegal attempt to attach to an uninitialized WAL segment for {0}\r
+336397047=Invalid WAL parameter block option {0}\r
+336397046=Cannot roll over to the next log file {0}\r
+336397045=database does not use Write-ahead Log\r
+336397044=WAL subsystem encountered error\r
+336397043=WAL subsystem corrupted\r
+336397042=Database {0}: WAL subsystem bug for pid {1}n{2}\r
+336397041=Could not expand the WAL segment for database {0}\r
+336397040=Unable to roll over; please see Firebird log.\r
+336397039=WAL I/O error.  Please see Firebird log.\r
+336397038=WAL writer - Journal server communication error.  Please see Firebird log.\r
+336397037=WAL buffers cannot be increased.  Please see Firebird log.\r
+336397036=WAL setup error.  Please see Firebird log.\r
+336397035=WAL writer synchronization error for the database {0}\r
+336397034=Cannot start WAL writer for the database {0}\r
+336397033=Write-ahead Log without shared cache configuration not allowed\r
+336397031=WAL defined; Cache Manager must be started first\r
+336397030=Overflow log specification required for round-robin log\r
+336397029=Write-ahead Log with shadowing configuration not allowed\r
+336397028=Cache or Log redefined\r
+336397027=Log file specification partition error\r
+336397007=table {0} is not referenced in plan\r
+336397006=the table {0} is referenced twice; use aliases to differentiate\r
+336397005=table {0} is referenced in the plan but not the from list\r
+336397004=index {0} cannot be used in the specified plan\r
+335675699=Ceasing processing because of errors.\r
+335675698=expected end_trigger or description keyword, encountered "{0}"\r
+335675697=expected trigger action, encountered "{0}"\r
+335675696=expected message keyword, encountered "{0}"\r
+335675695=A relation or view may not be defined and then deleted in a single execution of GDEF\r
+335675694=Modify data type of array {0} requires complete field specification\r
+335675693=Array indexes and size cannot be modified\r
+335675692=table {0} already exists\r
+335675691=A node name is not permitted in an external file name\r
+335675690=A non-Decnet node name is not permitted in an external file name\r
+336396599=wrong page type\r
+336789563=The evaluation license has already been used on this server.  You need to purchase a non-evaluation license.\r
+336396598=segments not allowed in expression index {0}\r
+336789562=Customized license entry created by means other than entering a certificate ID/key.\r
+336396597=new record size of {0} bytes is too big\r
+336789561=Evaluation InterBase Server license and simultaneous user license for five (5) users.\r
+336396596=maximum indexes per table ({0}) exceeded\r
+336789560=Precompiler license for Pascal.\r
+336396595=Too many concurrent executions of the same request\r
+336396594=cannot access column {0} in view {1}\r
+335675689=A node name is not permitted in a shadow, secondary, or log file name\r
+335675688=symbol {0} is too long, truncating it to {1} characters\r
+335675687=Functions cannot return arrays.\r
+335675686=unexpected end of file, semicolon missing?\r
+335675685=argument mode 'by value' requires a return mode\r
+335675684=argument mode of a return_argument must be 'by reference'\r
+335675683=nn/* Index Definitions */\r
+335675682=nn/* Generator Definitions */\r
+335675681=BLR request size limit exceeded\r
+336789559=Precompiler license for Cobol.\r
+335675680=shadow file must be AUTO or MANUAL\r
+336789558=Precompiler license for Fortran.\r
+336789557=Precompiler license for Ada.\r
+336789556=Precompiler license for C and C++.\r
+336789555=Simultaneous user license for unlimited users.\r
+336789554=Internet access license with unlimited users.\r
+336789553=InterBase server activation license and simultaneous user license for unlimited users.\r
+336789552=InterBase server activation license and simultaneous user license for five (5) users.\r
+336789551=Firebird Server: Metadata capability.\r
+336789550=Firebird Server: Remote access capability.\r
+335675679=inappropriate self-reference of field\r
+335675678=\r
+335675677=internal error during DYN pretty print\r
+335675676=internal error during DYN pretty print\r
+335675675=internal error during DYN pretty print\r
+335675674=action not implemented yet\r
+335675673=gdef: cannot open DYN output file: {0}\r
+335675672=HSH_remove failed\r
+335675671=line too long\r
+336789549=Firebird Server: Client capability\r
+335675670= unterminated quoted string\r
+336789548=InterBase Server activation license and simultaneous user licnese for one (1) user.\r
+336789547=Local InterBase activation license.\r
+336789546=Simultaneous user license for twenty (20) users.\r
+336789545=Simultaneous user license for ten (10) users.\r
+336789544=Simultaneous user license for five (5) users.\r
+336789543=Simultaneous user license for four (4) users.\r
+336789542=Simultaneous user license for one (1) user.\r
+336789541=Remove license operation failed, KEY: {0}\r
+336789540=Add license operation failed, KEY: {0} ID: {1}\r
+335675669=gds_$put_segment failed\r
+335675668=could not open scratch file\r
+335675667=fseek failed\r
+335675666=expected generator name, encountered "{0}"\r
+335675665=database version is too old for the new syntax: generators\r
+335675664=gds_$close_blob failed\r
+335675663=gds_$get_segment failed\r
+335675662=*****  BLOB option not understood ****\r
+335675661=gds_$open_blob failed\r
+336789539=Operation failed.  An unknown error occurred.\r
+335675660=***** ACL not understood *****\r
+336789538=The certificate could not be validated based on the information given.  Please recheck the ID and key information.\r
+336789537=An error occurred updating the license file.  Operation cancelled.\r
+336789536=The certificate was not removed.  The key does not exist or corresponds to a temporary evaluation license.\r
+336789535=The certificate was not added.  Invalid certificate ID / Key combination.\r
+336789534=The certificate was not added.  A duplicate ID exists in the license file.\r
+336789533=The operation was completed successfully.  Please restart the server for the changes to take effect.\r
+336789532=syntax error in command line\r
+336789531=switch requires a parameter\r
+336789530=switch does not take any parameter\r
+335675659=**** view definition {0} must be recreated ****\r
+335675658=nn/* View Definitions */\r
+335675657=**** erase trigger source for relation {0} must be recreated ****\r
+335675656=**** modify trigger source for relation {0} must be recreated ****\r
+335675655=**** store trigger source for relation {0} must be recreated ****\r
+335675654=****  trigger source for trigger {0} must be recreated ****\r
+335675653=*****  trigger type not understood ****\r
+335675652=nn/* Trigger Definitions */\r
+335675651=n/* Add Security Classes to Defined Objects */\r
+336789529=invalid parameter, no switch specified\r
+335675650=nn/* Relation Definitions */\r
+336789528=ambiguous switch\r
+336789527=illegal operation/switch combination\r
+336789526=invalid switch combination\r
+336789525=invalid switch\r
+336789524=no operation specified\r
+336789523=operation already specified\r
+336789522=InterBase License Utility Version:\r
+336789521=\r
+336789520=Copyright (c) 1985, 1994 by Borland International, Inc.\r
+335675649=nn/* Function Definitions */\r
+335675648=nn/* Filter Definitions */\r
+335675647=nn/* Global Field Definitions */\r
+335675646=n***gds_$database_info failed***\r
+335675645=\r
+335675644=**** field {0} cannot be extracted, computed source missing ***\r
+335675643=nn/* Security Class Definitions / GRANT statements */\r
+335675642=**** unable to decompile missing value ***\r
+335675641=    Version(s) for database "{0}"\r
+336789519=        Software theft is a civil and criminal offense.\r
+335675640=ddl: cannot open {0}\r
+336789518=    Processing will continue in {0} seconds.\r
+336789517=        Your {0}         {1}\r
+336789516=        Your version is "{0}"\r
+336789515=    Be prepared to provide the following information.\r
+336789514=    Pacific time (GMT + 8 hours).\r
+336789513=    between 9 am and 8 pm, Monday through Friday,\r
+336789512=    from outside the United States and Canada call (408) 431-5400,\r
+336789511=    To register this node for InterBase, call (800) 437-7367,\r
+336789510=\r
+336592899=gjrn [-z] <utility> [-debug] [-verbose] [<options>] [<database name>]\r
+336592898=Journal utility version: {0}\r
+335544839=Foreign key references are present for the record\r
+336592897=exiting journal utility due to errors\r
+335544838=Foreign key reference target does not exist\r
+336592896=gjrn::\r
+335544837=Invalid {0} parameter to SUBSTRING. Only positive integers are allowed.\r
+335544836=Concatenation overflow. Resulting string cannot exceed 32K in length.\r
+335544835=Target shutdown mode is invalid for database "{0}"\r
+335544834=Invalid cursor state: {0}\r
+335675639=action not implemented yet\r
+335544833=Physical backup is not allowed while Write-Ahead Log is in use\r
+335675638=expected OF, encountered "{0}"\r
+335544832=Cannot change difference file name while database is in backup mode\r
+335675637=expected relational operator, encountered "{0}"\r
+335544831=Access to {0} "{1}" is denied by server administrator\r
+335675636=expected IN, encountered "{0}"\r
+335544830=Too many recursion levels of EXECUTE STATEMENT\r
+335675635=expected right parenthesis, encountered "{0}"\r
+335675634=expected value expression, encountered "{0}"\r
+335675633=expected left parenthesis, encountered "{0}"\r
+335675632=expected comma or right parenthesis, encountered "{0}"\r
+335675631=expected FROM RSE clause, encountered "{0}"\r
+336789509=    by closing this window.\r
+335675630=unrecognized character in numeric string\r
+336789508=    the registered node is temporarily unavailable, you may continue\r
+336789507=    If you are using this node to demonstrate software, or because\r
+336789506=    Your node is not registered to run InterBase.n    {0}\r
+336789504=The license file does not exist or could not be opened for read\r
+335544829=Variable type (position {0}) in EXECUTE STATEMENT '{1}' INTO does not match returned column type\r
+335544828=Wrong request type in EXECUTE STATEMENT '{0}'\r
+335544827=Invalid argument in EXECUTE STATEMENT - cannot convert to string\r
+335544826=Nested aggregate functions are not allowed\r
+335544825=Invalid expression in the {0} (neither an aggregate function nor a part of the GROUP BY clause)\r
+335544824=Invalid expression in the {0} (not contained in either an aggregate function or the GROUP BY clause)\r
+335675629=too many decimal points\r
+335544823=Cannot use an aggregate function in a GROUP BY clause\r
+335675628=expected =, encountered "{0}"\r
+335544822=Cannot use an aggregate function in a WHERE clause, use HAVING instead\r
+335675627=abort code cannot exceed 255\r
+335544821=Invalid column position used in the {0} clause\r
+335675626=OVER can only be used in CROSS expressions\r
+335544820=Unable to find savepoint with name {0} in transaction context\r
+335675625=action not implemented yet\r
+335675624=action not implemented yet\r
+335675623=action not implemented yet\r
+335675622=global field {0} is not defined\r
+335675621=segment length is valid only for BLOBS\r
+335675620=subtypes are valid only for BLOBS and text\r
+335544819=File exceeded maximum size of 2GB.  Add another database file or use a 64 bit I/O version of Firebird.\r
+335544818=Invalid parameter to SKIP.  Only integers >= 0 are allowed.\r
+335544817=Invalid parameter to FIRST.  Only integers >= 0 are allowed.\r
+335544816=UDF {0}\r
+335544815=GENERATOR {0}\r
+335544814=Services functionality will be supported in a later version  of the product\r
+335675619=computed fields need data types\r
+335544813=Unsupported field type specified in BETWEEN predicate.\r
+335675618={0} is a global, not local, attribute\r
+335544812=Valid client dialects are {0}.\r
+335675617=segment_length\r
+335544811=passed client dialect {0} is not a valid dialect.\r
+335675616=sub type\r
+335544810=value exceeds the range for valid dates\r
+335675615=data type\r
+335675614=missing value\r
+335675613=valid if\r
+335675612=Attempt to change trigger type from ERASE to STORE\r
+335675611=Attempt change trigger type from MODIFY to ERASE\r
+335675610=Attempt change trigger type from MODIFY to STORE\r
+335544809=Function {0} is in {1}, which is not in a permitted directory for external functions.\r
+335544808=DATE data type is now called TIMESTAMP\r
+335544807=SQL warning code = {0}\r
+335544806=Valid database dialects are {0}.\r
+335544805=Database dialect {0} is not a valid dialect.\r
+335544804=Unable to create database {0}\r
+335675609=Attempt change trigger type from STORE to ERASE\r
+335544803=Database dialect not changed.\r
+335675608=expected FROM, encountered "{0}"\r
+335544802=Database dialect being changed from 3 to 1\r
+335675607=REVOKE privilege was not specified\r
+335544801=data type not supported for arithmetic\r
+335675606=expected ON, encountered "{0}"\r
+335544800=Too many Contexts of Relation/Procedure/Views. Maximum allowed is 127\r
+335675605=database version is too old for the new syntax: REVOKE\r
+335675604=Unrecognized privilege "{0}" or unrecognized identifier\r
+335675603=PAGE_SIZE specified ({0}) was rounded up to {1} bytes\r
+335675602=PAGE_SIZE specified ({0}) longer than limit of {1} bytes\r
+335675601=no database declared\r
+335675600=expected trailing bracket, encountered "{0}"\r
+335610199=    Query name:  {0}\r
+335610198=    Field validation:\r
+335610197=    Field is computed from:\r
+335610196=    Datatype information\r
+335610195=    Field description:\r
+335610194=    Global field {0}\r
+335610193=Field {0} in {1} {2} of database {3}\r
+335610192= {0} in relation {1}\r
+335610191=    Global field {0} is used in database {1} as :\r
+335610190=, subtype fixed\r
+335610189=, scale {0}\r
+335610188=date\r
+335610187=long floating\r
+335610186=short floating\r
+335610185=quadword binary\r
+335610184=long binary\r
+335610183=short binary\r
+335610182=null terminated text, length {0}\r
+335610181=varying text, length {0}\r
+335610180=text, length {0}\r
+336724058=z (interactive only)\r
+336724057=displaying version number:\r
+336724056=-z\r
+336724055=-database <security database>\r
+336724054=-role <database administrator SQL role name>\r
+336724053=-password <database administrator password>\r
+336724052=-user <database administrator name>\r
+336724051=available options:\r
+336724050=[ <options> ... ]\r
+335610179=, subtype {0}\r
+335610178=, subtype ACL\r
+335610177=, subtype BLR\r
+335610176=, subtype text\r
+335610175=, segment length {0}\r
+335610174=BLOB\r
+335610173=    {0} comprised of:\r
+335610172=Views in database {0}:\r
+335610171=    {0} comprised of :\r
+336724049=SQL role name already specified\r
+335610170=Views in database {0}:\r
+336724048=database administrator password already specified\r
+336724047=database administrator name already specified\r
+336724046=database already specified\r
+336724045=Warning - maximum 8 significant bytes of password used\r
+336724044=Invalid user name (maximum 31 bytes allowed)\r
+336724043=gsec error\r
+336724042=gsec - memory allocation error\r
+336724041=-lname <lastname>\r
+336724040=-mname <middlename>\r
+335610169=n    Relation {0} is a view defined as:\r
+335610168=n    View source for relation {0} is not available.  View BLR:\r
+335610167=OBSOLETE -    Store trigger for relation {0}:\r
+335610166=OBSOLETE -    Source for the store trigger is not available.  Trigger BLR:\r
+335610165=OBSOLETE -    Modify trigger for relation {0}:\r
+335610164=OBSOLETE -    Source for the modify trigger is not available.  Trigger BLR:\r
+335610163=OBSOLETE -    Erase trigger for relation {0}:\r
+335610162=OBSOLETE -    Source for the erase trigger is not available.  Trigger BLR:\r
+335610161=OBSOLETE -    Triggers for relation {0}:\r
+335610160=OBSOLETE -    Store trigger for relation {0}:\r
+336724039=-fname <firstname>\r
+336724038=-org <organizationname>\r
+336724037=-proj <projectname>\r
+336724036=-gid <uid>\r
+336724035=-uid <uid>\r
+336724034=-pw <password>\r
+336724033=available parameters:\r
+336724032=quit (interactive only)\r
+336724031=quit interactive session:\r
+336724030=help\r
+335610159=OBSOLETE -    Source for the store trigger is not available.  Trigger BLR:\r
+335610158=OBSOLETE -    Modify trigger for relation {0}:\r
+335610157=OBSOLETE -    Source for the modify trigger is not available.  Trigger BLR:\r
+335610156=OBSOLETE -    Erase trigger for relation {0}:\r
+335610155=OBSOLETE -    Source for the erase trigger is not available.  Trigger BLR:\r
+335610154=OBSOLETE - Triggers for relation {0}:\r
+335610153=    Security classes for database {0}\r
+335610152=OBSOLETE -        A store trigger is defined for {0}\r
+335610151=OBSOLETE -        A modify trigger is defined for {0}\r
+335610150=OBSOLETE -        An erase trigger is defined for {0}\r
+336724029=? (interactive only)\r
+336724028=help:\r
+336724027=modify <name> <parameter> [ <parameter> ... ]\r
+336724026=modifying a user's parameters:\r
+336724025=display <name>\r
+336724024=displaying one user:\r
+336724023=display\r
+336724022=displaying all users:\r
+336724021=delete <name>\r
+336724020=deleting a current user:\r
+335610149=    Stored in external file {0}\r
+335610148=    Security class {0}\r
+335610147=    Description:\r
+335610146=        Index {0}{1}\r
+335610145=            index {0} is NOT active\r
+335610144=        Index {0}{1}\r
+335610143=    Field description:\r
+335610142=Global fields for database {0}:\r
+335610141=Forms in database {0}\r
+335610140=    {0} is not used in any relations in database {1}\r
+336724019=add <name> [ <parameter> ... ]\r
+336724018=adding a new user:\r
+336724017=available commands:\r
+336724016=interactive usage:\r
+336724015=<command> [ <parameter> ... ]\r
+336724014=command line usage:\r
+336724013=gsec utility - maintains user password database\r
+336724012=incompatible switches specified\r
+336724011=no parameters allowed for this operation\r
+336724010=no operation specified for parameters\r
+335610139=    Query header:\r
+335610138=    Edit string:  {0}\r
+335610137=    Query name:  {0}\r
+335610136=    Field validation:\r
+335610135=    Field is computed from:\r
+335610134=    Datatype information:\r
+335610133=    Field description:\r
+335610132=Global field {0} in database {1}\r
+335610131=    Query header:\r
+335610130=    Edit string:  {0}\r
+336724009=ambiguous switch specified\r
+336724008=invalid switch specified\r
+336724007=gsec version\r
+336724006=last name already specified\r
+336724005=middle name already specified\r
+336724004=first name already specified\r
+336724003=organization already specified\r
+336724002=project already specified\r
+336724001=gid already specified\r
+336331035=closing file, committing, and finishing. {0} bytes written\r
+336724000=uid already specified\r
+336331034=restoring data only ignoring foreign key, unique, not null & other constraints\r
+336331033=just data ignore all constraints etc.\r
+336331032=setting database to read-only access\r
+336331031="read_only" or "read_write" required\r
+336331030= {0}MO(DE) <access>      "read_only" or "read_write" access\r
+335610129=    Edit string:  {0}\r
+335610128=    Query name:  {0}\r
+335610127=    Query name:  {0}\r
+335610126=    Security class {0}\r
+335610125=    Field validation:\r
+335610124=    Field is computed from:\r
+335610123=    Datatype information:\r
+335610122=    Field description:\r
+335610121=    Global field {0}\r
+335610120=Field {0} in {1} {2} of database {3}\r
+336331029=        {0}SE(RVICE)            use services manager\r
+336331028= {0}USE_(ALL_SPACE)      do not reserve space for record versions\r
+336331027=\r
+336331026=Cannot restore over current database, must be SYSDBA or owner of the existing database.\r
+336331025=service name parameter missing\r
+336331024=Warning -- free disk space exhausted for file {0}, the rest of the bytes ({1}) will be written to file {2}\r
+336331023=file size given ({0}) is less than minimum allowed ({1})\r
+336331022=free disk space exhausted\r
+336331021=can't write a header record to file {0}\r
+336331020=database file specification missing\r
+335610119= File: {0} starting at page {1}\r
+335610118=    Database description:\r
+335610117=    Database description:\r
+335610116=    Security class for database {0}\r
+335610115=Operation unlicensed for database "{0}"\r
+335610114=do not understand BLR operator {0}\r
+335610113=database info call failed\r
+335610112=No data type specified for field {0}\r
+335610111=Data type conflict with existing global field {0}\r
+335610110=field {0} not found in relation {1}\r
+336331019=backup file {0} might be corrupt\r
+336331018=standard output is not supported when using split operation\r
+336331017= standard input is not supported when using join operation\r
+336331016=can't join -- one of the files missing\r
+336331015=file {0} out of sequence\r
+336331014=size specification either missing or incorrect for file {0}\r
+336331013=Starting with volume #{0}, "{1}"\r
+336331012=page buffers is allowed only on restore or create\r
+336331011=expected page buffers, encountered "{0}"\r
+336331010=page buffers parameter missing\r
+335610109=global field {0} does not exist\r
+335610108=data type cannot be changed locally\r
+335610107=Field {0} already exists in relation {1}\r
+335610106=Unlicensed for database "{0}"\r
+335610105=Interactive metadata updates are not available on Rdb\r
+335610104=no active database for operation\r
+335610103=field {0} does not exist\r
+335610102=Index {0} does not exist in database {1}\r
+335610101=global field {0} is not defined\r
+335610100=Interactive metadata updates are not available on Rdb\r
+336331009= {0}BU(FFERS)            override page buffers default\r
+336331008=gbak: ERROR:\r
+336331007=gbak: WARNING:\r
+336331006=        {0}CO(NVERT)            backup external files as tables\r
+336331005=SQL role parameter missing\r
+336331004=        {0}RO(LE)               Firebird SQL role\r
+336331003=restoring SQL role: {0}\r
+336331002=Bad attributes for restoring SQL role\r
+336331001=writing sql role: {0}\r
+336331000=writing SQL roles\r
+336462436=Duplicate column or domain name found.\r
+335544799=The service name was not specified.\r
+335544798=You created an indirect dependency on uncommitted metadata. You must roll back the current transaction.\r
+335544797=user name and password are required while attaching to the services manager\r
+335544796=Client SQL dialect {0} does not support reference to {1} datatype\r
+335544795=unexpected item in service parameter block, expected {0}\r
+335544794=operation was cancelled\r
+335675599=expected comma between group and user ID, encountered "{0}"\r
+335544793=Metadata update statement is not allowed by the current database SQL dialect {0}\r
+335675598=expected number, encountered "{0}"\r
+335544792=Cannot attach to services manager\r
+335675597=return mode must be return_value or return_argument\r
+335544791=The file {0} is currently in use by another process.  Try again later.\r
+335675596=argument mode is by value, or by reference\r
+335544790=Service {0} requires SYSDBA permissions.  Reattach to the Service Manager using the SYSDBA account.\r
+335675595=argument mode by value not allowed for this data type\r
+335675594=expected "]", encountered "{0}"\r
+335675593=character field length must be positive\r
+335675592=expected "[", encountered "{0}"\r
+335675591=expected field sub_type, encountered "{0}"\r
+335675590=expected field sub_type, encountered "{0}"\r
+335544789=Specified EXTRACT part does not exist in input datatype\r
+335544788=Unable to perform operation.  You must be either SYSDBA or owner of the database\r
+335544787=Cannot update rows in external files.\r
+335544786=Cannot delete rows from external files.\r
+335544785=Floating Point Error. The Code caused an Arithmetic Exception or a floating point exception.\r
+335544784=Bus Error. The Code caused a system bus error.\r
+335675589=segment length must be positive\r
+335544783=Illegal Instruction. The Code attempted to perfrom an illegal operation.\r
+335675588=validation expression must be parenthesized\r
+335544782=Segmentation Fault. The code attempted to access memory without priviledges.\r
+335675587=unmatched parenthesis\r
+335544781=Stack overflow.  The resource requirements of the runtime stack have exceeded the memory available to it.\r
+335675586=COMPUTED BY expression must be parenthesized\r
+335544780=An exception occurred that does not have a description.  Exception number {0}.\r
+335675585=expected DESCRIPTION, EDIT_STRING, MISSING VALUE, SECURITY_CLASS or VALID_IF, encountered "{0}"\r
+335675584=expected field clause, encountered "{0}"\r
+335675583=data type cstring not supported for fields\r
+335675582=expected semicolon, encountered "{0}"\r
+335675581=expected comma, encountered "{0}"\r
+335675580=array size must be positive\r
+336396486=Arithmetic overflow or division by zero has occurred.\r
+336396485=Invalid insert or update value(s): object columns arenconstrained - no 2 table rows can have duplicate column values\r
+336396484=An error was found in the application program input parameters for the SQL statement.\r
+336396482=Only simple column names permitted for VIEW WITH CHECK OPTION\r
+336396481=No WHERE clause for VIEW WITH CHECK OPTION\r
+336396480=Only one table allowed for VIEW WITH CHECK OPTION\r
+335544779=Integer overflow.  The result of an integer operation caused the most significant bit of the result to carry.\r
+335544778=Integer divide by zero.  The code attempted to divide an integer value by an integer divisor of zero.\r
+335544777=Floating-point underflow.  The exponent of a floating-point operation is less than the magnitude allowed.\r
+335544776=Floating-point stack check.  The stack overflowed or underflowed as the result of a floating-point operation.\r
+335544775=Floating-point overflow.  The exponent of a floating-point operation is greater than the magnitude allowed.\r
+335544774=Floating-point invalid operand.  An indeterminant error occurred during a floating-point operation.\r
+335675579=database version is too old for the new syntax: array\r
+335544773=Floating-point inexact result.  The result of a floating-point operation cannot be represented as a deciaml fraction.\r
+335675578=expected command, encountered "{0}"\r
+335544772=Floating-point divide by zero.  The code attempted to divide a floating-point value by zero.\r
+335675577=expected object for DROP, encountered "{0}"\r
+335544771=Float denormal operand.  One of the floating-point operands is too small to represent a standard float value.\r
+335544770=Array bounds exceeded.  The code attempted to access an array element that is out of bounds.\r
+335675575=expected object for DEFINE, encountered "{0}"\r
+335675574=expected drop/modify of field or security class, encountered "{0}"\r
+335675573=A computed expression cannot be changed or added\r
+335675572=database version is too old for the new syntax: types\r
+335675571=expected message modification keyword, encountered "{0}"\r
+335675570=message number {0} exceeds 255\r
+336396479=DISTINCT, GROUP or HAVING not permitted for VIEW WITH CHECK OPTION\r
+336396478=No subqueries permitted for VIEW WITH CHECK OPTION\r
+336396477=multiple rows in singleton select\r
+336396472=external file could not be opened for output\r
+336396471=The insert, update, delete, ddl or authorization statement cannotn be executed because the transaction is inquiry only\r
+335544769=Datatype misalignment.  The attempted to read or write a value that was not stored on a memory boundary.\r
+335544768=Access violation.  The code attempted to access a virtual address without privilege to do so.\r
+335544767=A fatal exception occurred during the execution of a blob filter.\r
+335544766=SQL dialect {0} is not supported in this database\r
+335544765=attempted update on read-only database\r
+335544764=DATE must be changed to TIMESTAMP\r
+335675569=Unsuccessful attempt to modify trigger relation\r
+335544763=a string constant is delimited by double quotes\r
+335675568=expected trigger name, encountered "{0}"\r
+335544762=size of optimizer block exceeded\r
+335675567=database version is too old for the new trigger syntax\r
+335544761=too many open handles to database\r
+335675566=expected field action, encountered "{0}"\r
+335544760=invalid clause --- '{0}'\r
+335675565=A computed expression cannot be changed or added\r
+335675564=expected DESCRIPTION, encountered "{0}"\r
+335675563=database version is too old for the new syntax: ASC/DESC\r
+335675562=Security class can appear only on local field references\r
+335675561= A computed expression cannot be changed or added\r
+335675560=data type cstring not supported for fields\r
+336396468=wrong or obsolete version\r
+336396465=invalid bookmark handle\r
+336396464=invalid lock level {0}\r
+336396463=invalid lock handle\r
+336396462=Invalid statement handle\r
+336396461=invalid direction for find operation\r
+336396460=invalid key position\r
+335544759=can not define a not null column with NULL as default value\r
+335544758=sort record size of {0} bytes is too big\r
+335544757=An error occurred while updating the security database.\r
+335544756=An error occurred while attempting to delete the user record.\r
+335544755=An error occurred while attempting to modify the user record.\r
+335544754=An error occurred while attempting to add the user.\r
+335675559=expected global field name, encountered "{0}"\r
+335544753=The user name specified was not found in the security database\r
+335675558=Trigger {0} does not exist\r
+335544752=A duplicate user name was found in the security database\r
+335675557=expected STORE, MODIFY, ERASE, END_TRIGGER, encountered "{0}"\r
+335544751=The network protocol specified is invalid\r
+335675556=global field {0} already exists\r
+335544750=A password is required for this operation\r
+335675555=expected OPTION, encountered "{0}"\r
+335675554=expected GRANT, encountered "{0}"\r
+335675553=expected TO, encountered "{0}"\r
+335675552=GRANT privilege was not specified\r
+335675551=expected ON, encountered "{0}"\r
+335675550=database version is too old for the new syntax: GRANT\r
+336396459=invalid column reference\r
+336396458=column used with aggregate\r
+336396457=Attempt to define a second PRIMARY KEY for the same table\r
+336396456=FOREIGN KEY column count does not match PRIMARY KEY\r
+336396455=expression evaluation not supported\r
+336396454=refresh range number {0} not found\r
+336396453=bad checksum\r
+336396452=exception {0}\r
+336396451=restart shared cache manager\r
+336396450=database {0} shutdown in {1} seconds\r
+335544749=A username is required for this operation.\r
+335544748=The password specified is too long.  Maximum length is 8 bytes.\r
+335544747=The username entered is too long.  Maximum length is 31 bytes.\r
+335544746="REFERENCES table" without "(column)" requires PRIMARY KEY on referenced table\r
+335544745=Your login {0} is same as one of the SQL role name. Ask your database administrator to set up a valid Firebird login.\r
+335544744=Maximum user count exceeded.  Contact your database administrator.\r
+335675549=System flag value of 1 is reserved for system relations\r
+335544743=token size exceeds limit\r
+335675548=gen_trigger_name: invalid trigger type\r
+335544742=User cannot write to RDB$USER_PRIVILEGES\r
+335675547=database version is too old for the new syntax: types\r
+335544741=connection lost to database\r
+335675546=database version is too old for the new trigger syntax\r
+335544740=A fatal exception occurred during the execution of a user defined function.\r
+335675545=expected STORE, MODIFY, ERASE, or END_TRIGGER, encountered "{0}"\r
+335675544=database version is too old for the new syntax: functions\r
+335675543=database version is too old for the new syntax: filters\r
+335675542=expected FROM, COMPUTED, or qualified field, encountered "{0}"\r
+335675541=unmatched parenthesis\r
+335675540=computed by expression must be parenthesized\r
+336396449=journal file wrong format\r
+336396448=intermediate journal file full\r
+336396447=too many versions\r
+336396446=Wrong numeric type\r
+335544739=Error while trying to access file\r
+335544738=Error while trying to delete file\r
+335544737=Error while trying to write to file\r
+335544736=Error while trying to read from file\r
+335544735=Error while trying to close file\r
+335544734=Error while trying to open file\r
+335675539=data type cstring not supported for fields\r
+335544733=Error while trying to create file\r
+335675538=expected period, encountered "{0}"\r
+335544732=Access to databases on file servers is not supported.\r
+335675537=expected qualified field name, encountered "{0}"\r
+335544731=\r
+335675536=expected period, encountered "{0}"\r
+335544730=Client/Server Express not supported in this release\r
+335675535=database version is too old for the new syntax: types\r
+335675534=message number {0} exceeds 255\r
+335675533=expected STORE, MODIFY, ERASE, encountered "{0}"\r
+335675532=database version is too old for the new trigger syntax\r
+335675531=shadow number must be a positive integer\r
+335675530=expected comma or semicolon, encountered "{0}"\r
+335544729=Cannot deactivate primary index\r
+335544728=Cannot deactivate index used by an Integrity Constraint\r
+335544727=Error writing data to the connection.\r
+335544726=Error reading data from the connection.\r
+335544725=Error while listening for an incoming event connection request.\r
+335544724=Failed to establish a secondary connection for event processing.\r
+335675529=table {0} already exists\r
+335544723=Error while listening for an incoming connection.\r
+335675528=expected STORE, MODIFY, ERASE, END_TRIGGER, encountered "{0}"\r
+335544722=Failed to establish a connection.\r
+335675527=expected comma or semicolon, encountered "{0}"\r
+335544721=Unable to complete network request to host "{0}".\r
+335675526=database version is too old for the new syntax: ASC/DESC\r
+335544720=Unable to load required library {0}.\r
+335675525=database version is too old for the new syntax: ASC/DESC\r
+335675524=expected comma or semicolon, encountered "{0}"\r
+335675523=Function module name must be specified\r
+335675522=Function entry point must be specified\r
+335675521=database version is too old for the new syntax: functions\r
+335675520=Filter module name must be specified\r
+335544719=Error initializing the network software.\r
+335544718=Invalid key for find operation\r
+335544717=stack size insufficent to execute current request\r
+335544715=Operation not supported for EXTERNAL FILE table {0}\r
+335675519=Filter entry point must be specified\r
+335544714=invalid blob id\r
+335675518=expected filter name, encountered "{0}"\r
+335544713=Incorrect values within SQLDA structure\r
+335675517=database version is too old for the new syntax: filters\r
+335544712=Positive value expected\r
+335675516=Security class can appear only on local field references\r
+335544711=Attempt to execute an unprepared dynamic SQL statement.\r
+335544710=navigational stream {0} references a view with more than one base table\r
+335675515=data type required for global field\r
+335675514=PAGE_SIZE cannot be modified\r
+335675513=only SECURITY_CLASS, DESCRIPTION, and CACHE can be dropped\r
+335675512=GDEF processes only one database at a time\r
+335675511=expected symbol, encountered "{0}"\r
+335675510=expected quoted string, encountered "{0}"\r
+335544709=Invalid aggregate reference\r
+335544708=Ambiguous column reference.\r
+335544707=user does not have GRANT privileges on base table/view for operation\r
+335544706=The specified name was not found in the hosts file or Domain Name Services.\r
+335544705=Undefined service {0}/{1}.\r
+335675509=expected identifier, encountered "{0}"\r
+335544704=Failed to locate host machine.\r
+335675508=expected table name, encountered "{0}"\r
+335544703=service {0} does not have an associated executable\r
+335675507=expected number, encountered "{0}"\r
+335544702=Invalid ESCAPE sequence\r
+335675506=expected function, encountered "{0}"\r
+335544701=Unsigned short integer expected\r
+335675505=expected function, encountered "{0}"\r
+335544700=Long integer expected\r
+335675504=u0008ceasing processing\r
+335675503=no database declared\r
+335675502=relation {0} is not defined\r
+335675501=Cannot resolve field "{0}"\r
+335675500=context {0} is not defined\r
+335610099=no active database for operation\r
+335610098=metadata operation failed\r
+335610097=Index {0} is not defined in database "{1}"\r
+335610096=Field {0} is not defined in database "{1}"\r
+335610095=Field {0} is in use in database "{1}"\r
+335610094=Field {0} is in use in the following relations:\r
+335610093=Table {0} already exists\r
+335610092=Column {0} does not occur in table {1}\r
+335610091=Index {0} already exists\r
+335610090=Cannot define an index in a view\r
+335610089=global field {0} already exists\r
+335610088=show_fields: dtype not done\r
+335610087=database block not found for removal\r
+335610086=SET\r
+335610085=database handle\r
+335610084=OF\r
+335610083=left parenthesis\r
+335610082=COUNT (*)\r
+335610081=AVG, MAX, MIN, SUM, or COUNT\r
+335610080=FROM clause\r
+335610079=table name\r
+335610078=table name\r
+335610077=database name\r
+335610076=table name\r
+335610075=database name\r
+335610074=table name\r
+335610073=database name\r
+335610072=table name\r
+336461925=segment buffer length shorter than expected\r
+335610071=RELATIONS or TRIGGERS\r
+335610070=set option\r
+336461924=Row not found for fetch, update or delete, or the result of a query is an empty table.\r
+335610069=report item\r
+335610068=report writer SET option\r
+335610067=TOP or BOTTOM\r
+335610066=PROCEDURE\r
+335610065=table name\r
+335610064=expected "table_name", encountered "{0}"\r
+335610063=a database has not been readied\r
+335610062=relational operator\r
+335610061=EXISTS (SELECT * <sql rse>)\r
+335610060=database file name required on READY\r
+335610059={0} is not a table in database {1}\r
+335610058=period in qualified table name\r
+335610057=FORM\r
+335610056=positive number\r
+335610055=identifier\r
+335610054=comma between field definitions\r
+335610053=ADD, MODIFY, or DROP\r
+335610052=table name\r
+335610051=index state option\r
+335610050=quoted string\r
+336068826=Database is not in the physical backup mode\r
+336068825=Database is already in the physical backup mode\r
+336068824=Difference file is already defined\r
+335610049=ENTREE or END\r
+336068823=Difference file is not defined\r
+335610048=quoted string\r
+336068822=Generator not found\r
+335610047=right parenthesis\r
+336068821=ERASE RDB$GENERATORS failed\r
+335610046=value expression\r
+336068820=Zero length identifiers are not allowed\r
+335610045=the number of values do not match the number of fields\r
+335610044=VALUES list or SELECT clause\r
+335610043=left parenthesis\r
+335610042=comma or terminating right parenthesis\r
+335610041=left parenthesis\r
+335610040=quoted header segment\r
+336068819=unable to allocate memory from the operating system\r
+336068818=Cannot change datatype for column {0} from a character type to a non-character type.\r
+336068817=Cannot change datatype for {0}.  Conversion from base type {1} to {2} is not supported.\r
+336068816=New size specified for column {0} must be at least {1} characters.\r
+336068815=Cannot change datatype for column {0}.  Changing datatype is not supported for BLOB or ARRAY columns.\r
+336068814=Column {0} from table {1} is referenced in {2}\r
+335610039=comma\r
+336068813=Cannot rename column {0} to {1}.  A column with that name already exists in table {2}.\r
+335610038=FROM RSE clause\r
+336068812=Cannot rename domain {0} to {1}.  A domain with that name already exists.\r
+335610037=field name or asterisk expression\r
+335610036=global fields may not be based on other fields\r
+335610035=column definition clause\r
+335610034=quoted edit string\r
+335610033=ON or TO\r
+335610032=No statements issued yet\r
+335610031=]\r
+335610030=[\r
+336068804=SQL roles are not supported in on older versions of the database.  A backup and restore of the database is required.\r
+335610029=table or view name\r
+336068803=keyword {0} can not be used as a SQL role name\r
+335610028=FROM\r
+336068802=SQL role {0} already exists\r
+335610027=comma between field definitions\r
+336068801=user name {0} could not be used for SQL role\r
+335610026=table name\r
+336068800={0} is a SQL role and not a user\r
+335610025=object type for DEFINE\r
+335610024=no data type may be specified for a variable based on a field\r
+335610023=variable data type\r
+335610022={0} is not a table in database {1}\r
+335610021={0} is not a database\r
+335610020=variable definition clause\r
+335610019=quoted edit string\r
+335610018=end of command\r
+335610017=end of statement\r
+335610016=BLOB variables are not supported\r
+335610015=no databases are ready\r
+335610014=period in qualified name\r
+335610013=Expected PROCEDURE encountered "{0}"\r
+335610012=expected statement, encountered "{0}"\r
+335610011=field referenced in BASED ON cannot be resolved against readied databases\r
+335610010=unrecognized context\r
+335610009=asterisk expressions require exactly one qualifying context\r
+335610008=invalid ORDER BY ordinal\r
+335610007=No items in print list\r
+335610006=No items in print list\r
+335610005=field list required for modify\r
+335610004=no context for modify\r
+335610003=field {0} is not defined in form {1}\r
+335610002=no context for form ACCEPT statement\r
+335610001=form {0} is not defined in database "{1}"\r
+335610000=No database for form {0}\r
+336593136=Restart archiving for database {0}.\r
+336593135= {0}: restart archive for database\r
+336593134=Archive process unable to close log and/or archive files.\r
+336593133=Archive process unable to create archive file.\r
+336593132=Archive process unable to open log file.\r
+336593131=Archive process unable to attach to journal server.\r
+336593130=Error in reading page from disk.\r
+336593129=Error in closing database files. Retry recover.\r
+336593128=Error in creating or opening secondary database file.\r
+336593127=Known databases and connections:\r
+336593126=Output files queued:\r
+336593125=current output file: {0}\r
+336593124=Journaling suspended\r
+336593123=no output file\r
+336593122=unsupported journal sub-system version (expected {0}, encountered {1}) -- connection rejected\r
+336593121=Journal file sequence number {0} does not exist\r
+336593120=Optional close argument is a journal file sequence number\r
+335544699=Short integer expected\r
+335544698=Scale must be between zero and precision\r
+335544697=Precision must be from 1 to 18\r
+335544696=Total length of a partitioned log must be specified\r
+335544695=Partitions not supported in series of log file specification\r
+335544694=Log partition size too small\r
+335675499=relation {0} is not defined\r
+335544693=Log size too small\r
+335675498=bugcheck\r
+335544692=Log redefined\r
+335675497=trigger {0} is not defined\r
+335544691=Insufficient memory to allocate page buffer cache\r
+335675496=relation {0} is not defined\r
+335544690=Cache redefined\r
+335675495=global field {0} is not defined\r
+335675494=field {0} is not defined in relation {1}\r
+335675493=field {0} cannot be resolved\r
+335675492=field {0} does not exist\r
+335675491=field {0} does not exist in relation {1}\r
+335675490=Global field {0} is not defined\r
+336593119=Journal file "{0}" opened\r
+336593118=could not open journal file "{0}"-\r
+336593117=Journal server version {0}\r
+336593116=enter backup directory name: \r
+336593115=enter database name: \r
+336593114=enter journal option: \r
+336593113=Cannot open mailbox {0}\r
+336593112=unexpected end of file from server\r
+336593111=Journal server console program\r
+336593110=Checksum error in log record when reading from log file.\r
+335544689=Firebird error\r
+335544688=The prepare statement identifies a prepare statement with an open cursor\r
+335544687=intermediate journal file full\r
+335544686=journal file wrong format\r
+335544685=dbkey not available for multi-table views\r
+335544684=cannot access column {0} in view {1}\r
+335675489=object cannot be resolved\r
+335544683=request depth exceeded. (Recursive definition?)\r
+335675488=GENERATE_blr: node not supported\r
+335544682=Inappropriate self-reference of column\r
+335675487=GENERATE_blr: dtype not supported\r
+335544681=new record size of {0} bytes is too big\r
+335675486=(EXE) string_length: No defined length for BLOBS\r
+335544680=sort error: corruption in data structure\r
+335675485=gds_$put_segment failed\r
+335675484=gds_$put_segment failed\r
+335675483=symbol {0} is too long\r
+335675482=Type {0} for field {1} does not exist\r
+335675481=Trigger {0} does not exist\r
+335675480=Invalid attempt to assign trigger {0} to a new relation\r
+336593109=Journal server required for recovery to complete.\r
+336593108=Windows NT error {0}\r
+336593107=Windows NT error {0}\r
+336396387=Unsuccessful execution caused by system error that does not preclude successful execution of subsequent statements\r
+336593106=Error in updating log_transfer_status relation.\r
+336396386=Unsuccessful execution caused by a system error that precludesnsuccessful execution of subsequent statements\r
+336593105=Skipping online dumps files during a trace.\r
+336593104= {0} {1}  {2}\r
+336396384=Unsuccessful execution caused by an unavailable resource.\r
+336593103= Record Type  Number of records Total bytes\r
+336593102=Analysis of log records.\r
+336396382=the SQL statement cannot be executed\r
+336593101=Index root split.  For index ({0}) new root page {1}.\r
+336593100=Generator offset {0}.  New value {1}.\r
+335544679=segments not allowed in expression index {0}\r
+335544678=invalid key position\r
+335544677=too many versions\r
+335544676=sort error: not enough memory\r
+335544675=sort error\r
+335544674=last column in a table cannot be deleted\r
+335675479=table {0} does not exist\r
+335544673=cannot delete\r
+335675478=relation {0} is not external\r
+335544672=too few key columns found for index {0} (incorrect column name?)\r
+335675477=index {0} does not exist\r
+335544671=attempt to index array column in index {0}\r
+335675476=field {0} does not exist\r
+335544670=attempt to index BLOB column in index {0}\r
+335675475=Unauthorized attempt to change field {0} to or from BLOB\r
+335675474=field {0} does not exist\r
+335675473=(EXE) make_desc: do not understand node type\r
+335675472=TOTAL of date not supported\r
+335675471=relation {0} is used in trigger {1} but not defined\r
+335675470=field {0} is unknown in relation {1}\r
+336658541=    SET HEADING            -- toggle display of query column titles\r
+336658540=    SET PLANONLY           -- toggle display of query plan without executing\r
+336396379=operation completed with errors\r
+336396377=record from transaction {0} is stuck in limbo\r
+336396376=Unsuccessful execution caused by deadlock.\r
+336396375=deadlock\r
+335544669=count of column list and variable list do not match\r
+335544668=procedure {0} does not return any values\r
+335544667=drop database completed with errors\r
+335544666=server version too old to support all CREATE DATABASE options\r
+335544665=violation of PRIMARY or UNIQUE KEY constraint "{0}" on table "{1}"\r
+335544664=duplicate specification of {0} - not supported\r
+335675469=User privilege {0} on relation {1} for user {2} does not exist\r
+335544663=Too many concurrent executions of the same request\r
+335675468=User privilege {0} on field {1} in relation {2} nfor user {3} does not exist\r
+335544662=BLOB SUB_TYPE {0} is not defined\r
+335675467=Type {0} for field {1} does not exist\r
+335544661=cannot add index, index root page is full.\r
+335675466=Trigger message number {0} for trigger {1} does not exist\r
+336658539=There is no privilege granted in this database\r
+335544660=view {0} has more than one base table; use aliases to distinguish\r
+335675465=Trigger {0} does not exist\r
+336658538=    SET SQL DIALECT <n>    -- set sql dialect to <n>\r
+335675464=error committing deletion of shadow\r
+336658537=Incomplete string in {0}\r
+335675463=shadow {0} does not exist\r
+336658536=     [-r <rolename>] [-c <num cache buffers>] [-z] -nowarnings -noautocommit\r
+335675462=security class {0} does not exist\r
+336658535=There is no role {0} in this database\r
+335675461=table {0} does not exist\r
+336658534=               TRIGGER, VERSION, VIEW\r
+335675460=cannot drop system relation {0}\r
+336658533=Bad TIME: {0}\r
+336658530=Expected end of statement, encountered EOF\r
+336396366=Connection authorization failure.\r
+336396365=Connection not established\r
+336396364=Connection error\r
+336396362=Rollback not performed\r
+335544659=table {0} is referenced twice in view; use an alias to distinguish\r
+335544658={0} is not a valid base table of the specified view\r
+335544657=Array/BLOB/DATE data types not allowed in arithmetic\r
+335544656=variable {0} conflicts with parameter in same procedure\r
+335544655=invalid direction for find operation\r
+335544654=cannot start transaction for password database\r
+335675459={0} referenced by view {1}\r
+335544653=cannot attach to password database\r
+335675458=index {0} does not exist\r
+335544652=multiple rows in singleton select\r
+335675457=field {0} does not exist\r
+335544651=Cannot insert because the file is readonly or is on a read only medium.\r
+335675456=field {0} is used in relation {1} (local name {2}) and cannot be dropped\r
+336658529=There is no membership privilege granted on {0} in this database\r
+335544650=wrong page type\r
+335675455=function {0} does not exist\r
+336658528=There is no table, stored procedure, or role {0} in this database\r
+335675454=filter {0} does not exist\r
+336658527=There are no roles in this database\r
+335675453=field {0} does not exist in relation {1}\r
+336658526=Single isql command exceeded maximum buffer size\r
+335675452=field {0} from relation {1} is referenced in view {2}\r
+336658525=Buffers = !bnReads = !rnWrites !wnFetches = !f\r
+335675451=gds_$create_blob failed\r
+336658524=There are no check constraints on table {0} in this database\r
+335675450=gds_$close_blob failed\r
+336658523=There are no triggers in this database\r
+336658522=There is no table or trigger {0} in this database\r
+336658521=There are no triggers on table {0} in this database\r
+336658520=There are no stored procedures in this database\r
+335544649=bad checksum\r
+335544648=Connection lost to pipe server\r
+335544647=invalid comparison operator for find operation\r
+335544646=database or file exists\r
+335544645=the current position is on a crack\r
+335544644=illegal operation when at beginning of stream\r
+335675449=field {0} does not exist in relation {1} as referenced in view field {2}\r
+335544643=the table {0} is referenced twice; use aliases to differentiate\r
+335675448=field {0} already exists in relation {1}\r
+335544642=index {0} cannot be used in the specified plan\r
+335675447=table {0} already exists\r
+335544641=Specified domain or source column {0} does not exist\r
+335675446=table {0} does not exist\r
+336658519=There is no stored procedure {0} in this database\r
+335544640=Invalid use of CHARACTER SET or COLLATE\r
+335675445=Erase trigger already exists for {0}\r
+335740999=Transaction {0} is in limbo.\r
+336658518=There is no table or stored procedure {0} in this database\r
+335675444=Modify trigger already exists for {0}\r
+335740998= succeeded\r
+336658517=There is no privilege granted on stored procedure {0} in this database\r
+335675443=Store trigger already exists for {0}\r
+335740997= failed\r
+336658516=There is no privilege granted on table {0} in this database\r
+335675442=security class {0} already exists\r
+335740996=ATTACH_DATABASE: attempted attach of {0},\r
+336658515=There are no generators in this database\r
+335675441=table {0} already exists\r
+335740995=Transaction state {0} not in valid range.\r
+336658514=There is no generator {0} in this database\r
+335675440=error creating index {0}\r
+335740994=bad pool id\r
+336658513=There are no user-defined functions in this database\r
+335740993=virtual memory exhausted\r
+336658512=There is no user-defined function {0} in this database\r
+335740992=corrupt pool\r
+336658511=There are no filters in this database\r
+335740991=internal block exceeds maximum size\r
+336658510=There is no filter {0} in this database\r
+335740990=bad block type\r
+335544639=table {0} is referenced in the plan but not the from list\r
+335544638=table {0} is referenced more than once in plan; use aliases to distinguish\r
+335544637=table {0} is not referenced in plan\r
+335544636=there is no index {0} for table {1}\r
+335544635=there is no alias or table named {0} at this scope level\r
+335544634=Token unknown - line {0}, char {1}\r
+335675439=index {0} already exists\r
+335544633=Shadow number must be a positive integer\r
+335675438=combined key length ({0}) for index {1} is > 254 bytes\r
+335544632=Preceding file did not specify length, so {0} must include starting page number\r
+335675437=index {0}: field {1} in {2} is computed and cannot be a key\r
+335544631=too many keys defined for index {0}\r
+335675436=index {0}: field {1} does not exist in relation {2}\r
+336658509=There are no exceptions in this database\r
+335544630=there are {0} dependencies\r
+335675435=table {0} does not exist\r
+335740989= Number of database page errors : {0}\r
+336658508=There is no exception {0} in this database\r
+335675434={0} is a view and cannot be indexed\r
+335740988= Number of transaction page errors : {0}\r
+336658507=There are no domains in this database\r
+335675433=function {0} already exists\r
+335740987= Number of pointer page errors : {0}\r
+336658506=There is no domain {0} in this database\r
+335675432=error committing new file declarations\r
+335740986= Number of index page errors : {0}\r
+336658505=There are no indices in this database\r
+335675431=Preceding file did not specify length, so {0} must include starting page number\r
+335740985= Number of data page errors : {0}\r
+336658504=There is no table or index {0} in this database\r
+335675430=gds_$database_info failed\r
+335740984= Number of Blob page errors : {0}\r
+336658503=There are no indices on table {0} in this database\r
+335740983=n Number of record level errors : {0}\r
+336658502=There is no view {0} in this database\r
+335740982= -z  print software version number\r
+336658501=There are no views in this database\r
+335740981= -x  set debug on\r
+336658500=There is no table {0} in this database\r
+335740980= -write  write synchronously or asynchronously\r
+335544629=Write-ahead Log with shadowing configuration not allowed\r
+335544628=cannot create index {0}\r
+335544627=PROCEDURE {0}\r
+335544626=TABLE {0}\r
+335544625=A node name is not permitted in a secondary, shadow, cache or log file name\r
+335544624=segment count of 0 defined for index {0}\r
+335675429=field {0} already exists in relation {1}\r
+335544623=Illegal use of keyword VALUE\r
+335675428=error committing metadata changes\r
+335544622=alias {0} conflicts with a table in the same statement\r
+335675427=error rolling back metadata changes\r
+335544621=alias {0} conflicts with a procedure in the same statement\r
+335675426=action not implemented yet\r
+335544620=alias {0} conflicts with an alias in the same statement\r
+335675425=no database specified\r
+335740979= -validate validate database structure\r
+335675424=database version is too old to modify: use GBAK first\r
+335740978= -user  default user name\r
+335675423=GDEF unlicensed\r
+335740977= -use  use full or reserve space for versions\r
+335675422=    Version(s) for database "{0}"\r
+335740976= -tran  shutdown transaction startup\r
+335675421=Could not attach database "{0}"\r
+335740975= -two_phase perform automated two-phase recovery\r
+335675420=Could not delete file {0}\r
+335740974= -shut  shutdown <full / single / multi>\r
+335740973= -sweep  force garbage collection\r
+335740972= -rollback rollback transaction <tr / all>\r
+335740971= -quit_log quit logging for replay utility\r
+335740970= -password default password\r
+335544619= External functions cannot have more than 10 parameters\r
+335544618=Return mode by value not allowed for this data type\r
+335544617=invalid ORDER BY clause\r
+335544616=invalid column reference\r
+335544615=column used with aggregate\r
+335544614=Unsupported DSQL construct\r
+335675419=Could not release database\r
+335544613=union not supported\r
+335675418=error committing metadata changes\r
+335544612=Token unknown\r
+335675417=Could not locate database\r
+335544611=COLUMN {0}\r
+335675416=GDEF unlicensed\r
+335544610=EXCEPTION {0}\r
+335675415=    Version(s) for database "{0}"\r
+335740969= -prompt  prompt for commit/rollback (-l)\r
+335675414=    Version(s) for database "{0}"\r
+335740968= -online  database online <single / multi / normal>\r
+335675413=Could not create database "{0}"\r
+335740967= -no_update read-only validation (-v)\r
+335675412=Database "{0}" exists but cannot be opened\r
+335740966= -mend  prepare corrupt database for backup\r
+335675411=Do you want to replace it?\r
+335740965= -list  show limbo transactions\r
+335675410=Database "{0}" already exists\r
+335740964= -kill  kill all unavailable shadow files\r
+336068799={0} is not the owner of SQL role {1}\r
+335740963= -ignore  ignore checksum errors\r
+336068798=user {0} is not a member of SQL role {1}\r
+335740962= -housekeeping set sweep interval <n>\r
+336068797=user {0} has no grant admin option on SQL role {1}\r
+335740961= -force  force database shutdown\r
+336068796=SQL role {0} does not exist\r
+335740960= -full  validate record fragments (-v)\r
+336068795=column {0} from table {1} is referenced in index {2}\r
+336068794=SELECT RDB$VIEW_RELATIONS/RDB$RELATION_FIELDS/... failed in grant\r
+336068793=SELECT RDB$USER_PRIVILEGES failed in grant\r
+336068792=SELECT RDB$RELATIONS/RDB$OWNER_NAME failed in grant\r
+336068791=SELECT RDB$RELATION_FIELDS failed in grant\r
+336068790=SELECT RDB$RELATIONS failed in grant\r
+335544609=INDEX {0}\r
+335544608=Unexpected end of command\r
+335544607=gen.c: node not supported\r
+335544606=expression evaluation not supported\r
+335544605=No subqueries permitted for VIEW WITH CHECK OPTION\r
+335544604=FOREIGN KEY column count does not match PRIMARY KEY\r
+335675409=what we have here is a failure to communicate!\r
+335544603=DISTINCT, GROUP or HAVING not permitted for VIEW WITH CHECK OPTION\r
+335675408=error count exceeds limit ({0})\r
+335544602=Only one table allowed for VIEW WITH CHECK OPTION\r
+335675407={0}:{1}:\r
+335544601=No WHERE clause for VIEW WITH CHECK OPTION\r
+335675406=memory exhausted\r
+335544600=Only simple column names permitted for VIEW WITH CHECK OPTION\r
+335675405=you told me to.\r
+335740959= -disable disable WAL\r
+335675404=of errors.\r
+335740958= -cache  shutdown cache manager\r
+335675403=Ceasing processing because\r
+335740957= -commit  commit transaction <tr / all>\r
+335675402=Save changes before exiting?\r
+335740956= -buffers set page buffers <n>\r
+335675401=n1 error during input.\r
+335740955= -begin_log begin logging for replay utility\r
+335675400=nNo errors.\r
+335740954= -attach  shutdown new database attachments\r
+336068789=attempt to index a view\r
+335740953= -activate activate shadow file for database usage\r
+336068788=Table Name lookup failed\r
+335740952=Summary of validation errors\r
+335740951=please retry, giving a database name\r
+336068786=EXTERNAL FILE table not supported in this context\r
+335740950=n    qualifiers show the major option in parenthesis\r
+336068785=Can not alter a view\r
+336068784=column {0} does not exist in table/view {1}\r
+336068783=table/view {0} does not exist\r
+336068782=no {0} privilege with grant option on table/view {1}\r
+336068781=no grant option for privilege {0} on table/view {1}\r
+336068780=no {0} privilege with grant option on base table/view {1} (for column {2})\r
+335740949=plausible options are:\r
+335740948=please retry, specifying an option\r
+335740947=must specify type of shutdown\r
+335740946=numeric value between 0 and 32767 inclusive required\r
+335740945=number of seconds required\r
+335740944="wal" required\r
+336068779=no {0} privilege with grant option on table/view {1} (for column {2})\r
+335740943=subsystem name\r
+336068778=no grant option for privilege {0} on base table/view {1} (for column {2})\r
+335740942=password required\r
+336068777=no grant option for privilege {0} on table/view {1} (for column {2})\r
+335740941=user name required\r
+336068776=no grant option for privilege {0} on column {1} of base table/view {2}\r
+335740940="full" or "reserve" required\r
+336068775=no grant option for privilege {0} on column {1} of table/view {2}\r
+336068774=Cannot add file with the same name as the database or added files\r
+336068773=Shadow {0} already exists\r
+336068772=Shadow lookup failed\r
+336068771=A node name is not permitted in a table with external file definition\r
+336068770=Looking up column position failed\r
+335740939="sync" or "async" required\r
+335740938=transaction number or "all" required\r
+335740937=number of transactions per sweep required\r
+335740936=positive numeric value required\r
+335740935=numeric value required\r
+335740934=number of page buffers for cache required\r
+335740933=replay log pathname required\r
+336068768="Only one constraint allowed for a domain"\r
+335740932=incompatible switch combination\r
+336068767=Name longer than database column size\r
+335740931=gfix version {0}\r
+336068766=MODIFY DATABASE failed\r
+335740930=invalid switch {0}\r
+336068765=DEFINE SHADOW failed\r
+336068764=Shared cache lookup failed\r
+336068763=Write-ahead Log lookup failed\r
+336068762=STORE RDB$LOG_FILES failed\r
+336068761=ERASE RDB$LOG_FILES failed\r
+336068760=Write-ahead Log not found\r
+335740929=data base file name ({0}) already given\r
+336068759=Write-ahead Log already exists\r
+336068758=STORE RDB$FILES failed\r
+336068757=Shared cache file not found\r
+336068756=Shared cache file already exists\r
+336068755=Trigger {0} not found\r
+336068754=Parameter {0} in procedure {1} not found\r
+336068753=MODIFY EXCEPTION failed\r
+336068752=Exception not found\r
+336068751=ERASE EXCEPTION failed\r
+336068750=DEFINE EXCEPTION failed\r
+336396997=Column used in a PRIMARY/UNIQUE constraint must be NOT NULL.\r
+336396996=Cannot update constraints (RDB$REF_CONSTRAINTS).\r
+336396995=Cannot update constraints (RDB$CHECK_CONSTRAINTS).\r
+336396994=Cannot delete CHECK constraint entry (RDB$CHECK_CONSTRAINTS)\r
+336396993=Cannot update constraints (RDB$RELATION_CONSTRAINTS).\r
+336396992=internal gds software consistency check (invalid RDB$CONSTRAINT_TYPE)\r
+336396991=Operation violates CHECK constraint {0} on view or table\r
+336068749=MODIFY RDB$PROCEDURES failed\r
+336068748=Procedure {0} not found\r
+336068747=ERASE RDB$PROCEDURES failed\r
+336068746=ERASE RDB$PROCEDURE_PARAMETERS failed\r
+336068745=Store into system table {0} failed\r
+336068744=STORE RDB$PROCEDURE_PARAMETERS failed\r
+336068743=Procedure {0} already exists\r
+336068742=STORE RDB$PROCEDURES failed\r
+336068741=Number of referencing columns do not equal number of referenced columns\r
+336068740=Table {0} already exists\r
+336396985=Incompatible column/host variable data type\r
+336068739=Generation of constraint name failed\r
+336068738=CONSTRAINT {0} does not exist.\r
+336068737=ERASE RDB$RELATION_CONSTRAINTS failed\r
+336068736=No table specified in delete_constraint\r
+336068735=STORE RDB$REF_CONSTRAINTS failed\r
+336068734=Same set of columns cannot be used in more than one PRIMARY KEY and/or UNIQUE constraint definition\r
+336068733=Integrity Constraint lookup failed\r
+336068732=A column name is repeated in the definition of constraint: {0}\r
+336068731=Column: {0} not defined as NOT NULL - cannot be used in PRIMARY KEY/UNIQUE constraint definition\r
+336068730=STORE RDB$CHECK_CONSTRAINTS failed\r
+336396975=count of column list and variable list do not match\r
+336396974=Cannot transliterate character between character sets\r
+336068729=STORE RDB$RELATION_CONSTRAINTS failed\r
+336068728=Unknown columns in index {0}\r
+336068727=no keys for index {0}\r
+336068726=key size too big for index {0}\r
+336068725= attempt to index array column in index {0}\r
+336068724= attempt to index BLOB column in INDEX {0}\r
+336068723=CREATE VIEW failed\r
+336068722=Access to RDB$USER_PRIVILEGES failed in revoke (4)\r
+336068721=ERASE RDB$USER_PRIVILEGES failed in revoke (3)\r
+336068720=Access to RDB$USER_PRIVILEGES failed in revoke(2)\r
+336068719=ERASE RDB$USER_PRIVILEGES failed in revoke(1)\r
+336068718=unsupported DYN verb\r
+336068717=Create metadata BLOB failed\r
+336068716=Close metadata BLOB failed\r
+336068715=Write metadata BLOB failed\r
+336068714=Create metadata BLOB failed\r
+336068713=MODIFY TRIGGER MESSAGE failed\r
+336068712=unsupported DYN verb\r
+336068711=TRIGGER NAME expected\r
+336068710=MODIFY TRIGGER failed\r
+336068709=Table column not found\r
+336068708=MODIFY RDB$RELATIONS failed\r
+336068707=MODIFY RDB$RELATIONS failed\r
+336068706=drop EXTERNAL FILE not allowed\r
+336068705=add EXTERNAL FILE not allowed\r
+336068704=Local column not found\r
+336068703=MODIFY RDB$RELATION_FIELDS failed\r
+336068702=MODIFY RDB$FIELDS failed\r
+336068701=Index column not found\r
+336068700=MODIFY RDB$INDICES failed\r
+336593099=Next transaction {0}. Oldest active {1}. Oldest Interesting {2}.\r
+336593098=Next tip page {0} allocated.\r
+336593097=Continuing partial rebuild for database {0}.\r
+336593096=Starting partial rebuild for database {0}.\r
+336593095=Error in creating or opening database file.\r
+336593094=Invalid database for partial recovery.\r
+336593093=  -p <database name for partial recovery>\r
+336593092=  -a  -activate partially recovered database\r
+336593091=Target database name not specified.\r
+336593090=Error in modifying relation partial_rebuilds.\r
+336593089=Database exists or in use.\r
+336593088=Overwrite database ({0}) last log seqno ({1})? (y/n):\r
+336593087=Processing online dump file {0}.\r
+336593086=Recovering database "{0}" page size {1}.\r
+336593085=Enter full name of original database:\r
+336593084=reading log file names\r
+336593083=Online dump specified does not belong to database being recovered.\r
+336593082=Only one journal server can be active per journal database.\r
+336593081=Database not found in journal database\r
+336593080=Free slot {0} of pip page {1}\r
+336593079=Allocate slot {0} of pip page {1}\r
+336593078=Processing records for page {0}.  seqno {1}.  offset {2}.\r
+336593077=Commit transaction {0}.\r
+336593076=Secondary File: {0}.  Sequence: {1}.\r
+336593075=Error in archiving file. (id = {0}).\r
+336593074= Log archive complete.  File "{0}" (id = {1}).\r
+336593073=Database (id = {0}) not enabled with this journal server.\r
+336593072={0} ({1}/{2})\r
+336593071=Do not understand mailbox message type {0}\r
+336593070=Dos error {0}\r
+336593069=Dos error {0}\r
+336593068= {0}: display software version number\r
+336593067= {0}: display status of journal server\r
+336593066= {0}: shut down journal server\r
+336593065= {0}: set delete flag for database\r
+336593064= {0}: reset delete flag for database\r
+336593063= {0}: display help menu\r
+336593062= {0}: exit journal console program\r
+336593061= {0}: drop all files for non active database\r
+336593060= {0}: drop all files for an active database\r
+336593059= {0}: disable database\r
+336593058=Drop records for database (id = {0}).\r
+336593057=Database (id = {0}) is currently in use.\r
+336593056=Database "{0}" not enabled with this journal server.\r
+336593055=Mark database "{0}" as disabled for long-term journaling.\r
+336593054= Elapsed time = {0} seconds.\r
+336593053= Bytes applied = {0}\r
+336593052= Bytes processed = {0}\r
+336593051=Rebuild Statistics.\r
+336593050=Log file name\r
+336658499=There are no tables in this database\r
+336658497=    SET BLOB               -- turn off BLOB display\r
+336658496=               GRANT, INDEX, PROCEDURE, ROLE, SQL DIALECT, SYSTEM, TABLE,\r
+336658495=    SET NAMES <csname>     -- set name of runtime character set\r
+336658494=OUTput                     -- return output to stdout\r
+336658493=EDIT                       -- edit current command buffer and execute\r
+336658492=    SET TIME               -- toggle display of timestamp with DATE values\r
+336658491=    SET PLAN               -- toggle display of query access plan\r
+336658490=    SET WIDTH <col> [<n>]  -- set/unset print width to <n> for column <col>\r
+336593049=Error in attaching to recovered database.  Retry recovery.\r
+336593048=Error in attaching to journal database.\r
+336593047=Reset delete flag for database "{0}".\r
+336593046=Ensure files are archived for full recovery.\r
+336593045=Encountered records for files not yet archived.\r
+336593044=Must recover to a point in time after the end of online dump.\r
+336593043=Error in unlink() for file "{0}".\r
+336593042=Console connected.\r
+336593041=Removing file "{0}".\r
+336593040=:Error while erasing records for database "{0}".\r
+336658489=Unlicensed for database "{0}"\r
+336658488=Records affected: {0}\r
+336658487=Server version too old to support the isql command\r
+336658486=Errors occurred (possibly duplicate domains) in creating {0} in {1}\r
+336658485={0} not found\r
+336658484=    SET LIST               -- toggle column or table display format\r
+336658483=CON> \r
+336658482=Bad date {0}\r
+336658481=Enter {0}>\r
+336593039=Database "{0}" not enabled with this journal server.\r
+336658480=Enter {0} as M/D/Y>\r
+336593038=  -m <output message file>\r
+336593037=Error in opening output message file.\r
+336593036=out of sequence log record encountered.\r
+336593035=DOS error code {0}\r
+336593034=Failure in modifying journal files record\r
+336593033= Resetting database "{0}" ({1})\r
+336593032=Journal not properly closed\r
+336593031=Error in store for databases table\r
+336593030=Error in modify for databases table\r
+336658479=BLOB: {0}, type 'edit' or filename to load>\r
+336658478=BLOB display set to subtype {0}. This BLOB: subtype = {1}\r
+336658477=Cpu = !u secnBuffers = !bnReads = !rnWrites = !wnFetches = !f\r
+336658476=Current memory = !cnDelta memory = !dnMax memory = !xnElapsed time= !e sec\r
+336593029= No Databases with journaling enabled.\r
+336658470=    <object> = CHECK, DATABASE, DOMAIN, EXCEPTION, FILTER, FUNCTION, GENERATOR,\r
+336593028= {0} (db id = {1}), connections: {2}\r
+336593027=Journaling Enabled for:\r
+336593026=nJournal Server Status.\r
+336593025=Error in modify journal files table\r
+336593024=Close log file: ({0})\r
+336593023=Open log file: ({0})\r
+336593022=Error in storing journal files record\r
+336593021=Start Online Dump. dump_id: {0}\r
+336593020=Error in storing online dump record\r
+335544599=number of columns does not match select list\r
+335544598=must specify column name for view select expression\r
+335544597=Cannot prepare a CREATE DATABASE/SCHEMA statement\r
+335544596=Subselect illegal in this context\r
+335544595=Trigger unknown\r
+335675399=n{0} errors during input.\r
+335544594=Illegal array dimension range\r
+335675398=gdef: cannot open {0} or {1}\r
+335544593=Array declared with too many dimensions\r
+335675397=gdef: cannot open {0}\r
+335544592=Invalid array reference\r
+335675396=gdef: Database name is required for extract\r
+335544591=Unknown transaction option\r
+336527664=RDB$FLAGS for trigger {0} in RDB$TRIGGERS is corrupted\r
+335675395={0}{1}\r
+335544590=Option specified more than once\r
+336527663=Invalid expression for evaluation\r
+335675394= legal switches are:\r
+335675393=gdef: unknown switch {0}\r
+335675392=gdef version {0}\r
+336527660=can't find shared latch\r
+336658461=Set commands:\r
+336593019=Do not recognize journal message {0}\r
+336658460=HELP                       -- display this menu\r
+336593018=End Online Dump. dump id: {0}\r
+336593017=Error in modifying online_dump table\r
+336593016=Online Dump file. dump id: {0}. name: ({1})\r
+336593015=Error in writing record to online_dump_files table\r
+336593014=Error is updating delete flag.\r
+336593013=Control Point. Seqno: {0}  Offset: {1}\r
+336593012=Do not understand command "{0}"\r
+336593011=Set delete flag for database "{0}".\r
+336593010=Drop records for database "{0}"\r
+335544589=COLLATION {0} is not valid for specified CHARACTER SET\r
+335544588=COLLATION {0} is not defined\r
+335544587=Column is not a BLOB\r
+335544586=Function unknown\r
+336527659=exceeded maximum number of shared latches on a bdb\r
+335544585=Invalid statement handle\r
+336527658=missing exclusive latch\r
+335544584=Count of read-write columns does not equal count of values\r
+336527657=bdb is unexpectedly marked\r
+335544583=SQLDA missing or incorrect version, or incorrect number/type of variables\r
+336527656=inconsistent latch downgrade call\r
+335544582=Request unknown\r
+336527655=inconsistent LATCH_mark call\r
+335544581=Procedure unknown\r
+336658459=SHELL    <command>         -- execute Operating System command in sub-shell\r
+336527654=inconsistent LATCH_mark release\r
+335544580=Table unknown\r
+336527653=bad ACL\r
+336527652=Illegal user_type.\r
+336527651=cannot find record back version\r
+336527650=error during savepoint backout\r
+336658453=Frontend commands:n\r
+336658452=Transaction in limbo = {0}\r
+336658451=Base level = {0}\r
+336593009=Journal utility version {0}\r
+336658450=Wal group commit wait = {0}\r
+336396289=Firebird error\r
+336593008=Commands are:\r
+336593007=Error occurred during "{0}"\r
+336593006=Child process completed\r
+336593005=Error on writing disable record\r
+336593004=Release connection failed.\r
+336593003=Archiving log file. id: {0} name: {1}\r
+336593002=Forking backup process failed\r
+336593001=Failure before forking back up process\r
+336593000= Number of archives running concurrently exceeds limit.\r
+335544579=Internal error\r
+335544578=Column unknown\r
+335544577=Attempt to reclose a closed cursor\r
+335544576=Attempt to reopen an open cursor\r
+336527649=Unknown BLOB FILTER ACTION_\r
+335544575=Cursor not updatable\r
+336527648=garbage collect record disappeared\r
+335544574=Declared cursor already exists\r
+336527647=Too many savepoints\r
+335544573=Data type unknown\r
+336527646=size of opt block exceeded\r
+335544572=Cursor {0} {1}\r
+336527645=lock not found in internal lock manager\r
+335544571=Data type for constant unknown\r
+336658449=Check point interval = {0}\r
+336527644=cannot restore singleton select data\r
+335544570=Invalid command\r
+336658448=Check point length = {0}\r
+336527643=checksum error in log record when reading from log file\r
+336658447=Wal buffer size = {0}\r
+336527642=journal server cannot archive to specified archive directory\r
+336658446=Number of wal buffers = {0}\r
+336527641=error in recovery! unknown record type\r
+336527640=error in recovery! unknown page type\r
+336658444=Number of DB pages allocated = {0}\r
+336723999=password already specified\r
+336658443=     [-x|-a] [-d <target db>] [-u <user>] [-p <password>]n     [-page <pagelength>] [-n] [-m] [-q] [-s <sql_dialect>]\r
+336723998=operation already specified\r
+336658442=ISQL Version: {0}\r
+336723997=invalid parameter, no switch defined\r
+336658441=Enter data or NULL for each column.  RETURN to end.\r
+336723996=find/display record error\r
+336658440=Command error: {0}\r
+336723995=------------------------------------------------------------------------------------------\r
+336723994=     user name                      uid   gid     full name\r
+336723993=users defined for node\r
+336723992=find/delete record error\r
+336723991=delete record error\r
+336723990=record not found for user: {0}\r
+335544569=Dynamic SQL Error\r
+335544568=Implementation of text subtype {0} not located.\r
+335544567=Overflow log specification required for round-robin log\r
+335544566=WAL defined; Cache Manager must be started first\r
+336527639=error in recovery! out of sequence log record encountered\r
+335544565=Cannot transliterate character between character sets\r
+336527638=error in recovery! wrong transaction page record\r
+335544564=long-term journaling not enabled\r
+336527637=error in recovery! wrong index root page record\r
+335544563=service {0} is not defined\r
+336527636=error in recovery! wrong pointer page record\r
+335544562=unrecognized service parameter block\r
+336527635=error in recovery! wrong page inventory page record\r
+335544561=wrong version of service parameter block\r
+336658439=Rolling back work.\r
+336527634=error in recovery! wrong b-tree page record\r
+335544560=database {0} shutdown in {1} seconds\r
+336658438=Committing.\r
+336527633=error in recovery! wrong generator page record\r
+336658437=Commit current transaction (y/n)?\r
+336527632=error in recovery! wrong header page record\r
+336658436=Unable to open {0}\r
+336527631=error in recovery! no space on data page\r
+336658435=Use CONNECT or CREATE DATABASE to specify a database\r
+336527630=error in recovery! wrong data page record\r
+336658434=Unknown switch: {0}\r
+336723989=find/modify record error\r
+336658433=isql [<database>] [-e] [-t <terminator>] [-i <inputfile>] [-o <outputfile>]\r
+336723988=modify record error\r
+336658432=Statement failed, SQLCODE = {0}\r
+336723987=add record error\r
+336723986=no user name specified\r
+336723985=no operation specified\r
+336723984=error in switch specifications\r
+336723983=unable to open database\r
+336723982=LNAME          user's last name\r
+336723981=MNAME          user's middle name/initial\r
+336723980=FNAME          user's first name\r
+335544559=invalid service handle\r
+335544558=Operation violates CHECK constraint {0} on view or table {1}\r
+335544557=database shutdown unsuccessful\r
+335544556=Write-ahead Log without shared cache configuration not allowed\r
+336527629=error in recovery! database corrupted\r
+335544555=column has non-SQL security class defined\r
+336527628=buffer marked during cache unwind\r
+335544554=table/procedure has non-SQL security class defined\r
+336527627=next transaction older than oldest transaction\r
+335544553=user does not have GRANT privileges for operation\r
+336527626=next transaction older than oldest active transaction\r
+335544552=could not find column for GRANT\r
+336527625=in an ill-defined state\r
+335544551=could not find table/procedure for GRANT\r
+336527624=rolled back\r
+335544550=only the owner of a table may reassign ownership\r
+336527623=committed\r
+336527622=active\r
+336527621=scalar operator used on field which is not an array\r
+336527620=index unexpectedly deleted\r
+336723979=ORG            user's organization name\r
+336723978=PROJ           user's project name\r
+336723977=GID            user's group ID\r
+336723976=UID            user's ID\r
+336723975=PW             user's password\r
+336723974=MODIFY         modify user\r
+336723973=DISPLAY        display user(s)\r
+336723972=DELETE         delete user\r
+335609999=no default form name\r
+336723971=ADD            add user\r
+335609998="{0}" is undefined or used out of context\r
+336723970=gsec\r
+335609997={0}.* cannot be used when a single element is required\r
+335609996=cannot erase from a join\r
+335609995=no context for ERASE\r
+335609994=cannot perform assignment to computed field {0}\r
+335609993=variables may not be based on BLOB fields\r
+335609992=expand_statement: not yet implemented\r
+335609991=expand_expression: not yet implemented\r
+335609990=    Version(s) for database "{0}"\r
+335544549=cannot modify or erase a system trigger\r
+335544548=Attempt to define a second PRIMARY KEY for the same table\r
+335544547=internal gds software consistency check (invalid RDB$CONSTRAINT_TYPE)\r
+335544546=Cannot define constraints on views\r
+336527619=bad pointer page\r
+335544545=Cannot update constraints (RDB$RELATION_CONSTRAINTS).\r
+336527618=page slot not empty\r
+335544544=Cannot rename column being used in an Integrity Constraint.\r
+336527617=bad record in RDB$PAGES\r
+335544543=Cannot delete column being used in an Integrity Constraint.\r
+336527616=pointer page vanished from mark_full\r
+335544542=Cannot update trigger used by a CHECK Constraint\r
+336527615=cannot find free space\r
+335544541=Cannot delete trigger used by a CHECK Constraint\r
+336527614=pointer page vanished from relation list in locate_space\r
+335544540=Cannot modify index used by an Integrity Constraint\r
+336527613=pointer page vanished from extend_relation\r
+336527612=header fragment length changed\r
+336527611=damaged data page\r
+336527610=temporary page buffer too small\r
+336723969=GSEC>\r
+336330999=Run gfix -online to bring database online without active indices.\r
+336330998=Database is not online due to failure to activate one or more indices.\r
+336330997=  Set the TMP environment variable to a directory on a filesystem that does have enough space, and activate index with\r
+336330996=  Not enough disk space to create the sort file for an index.\r
+335609989=    QLI, version "{0}"\r
+336330995=  ALTER INDEX "{0}" ACTIVE;\r
+335609988=Variables:\r
+336330994=  Delete or Update duplicate values or NULLs, and activate index with\r
+335609987=No triggers are defined in database {0}\r
+336330993=  The unique index has duplicate values or NULLs.\r
+335609986=No triggers are defined in database {0}\r
+335609985=No triggers are defined for table {0}\r
+336330992=Index "{0}" failed to activate because:\r
+336330991= {0}NT                   Non-Transportable backup file format\r
+335609984=Procedures in database "{0}" ({1}):\r
+336330990=System memory exhausted\r
+335609983=Procedure {0} not found\r
+335609982=Procedure {0} not found in database {1}\r
+335609981=There are no fields defined in any open database\r
+335609980=There are no fields defined for database {0}\r
+335544539=Cannot delete index used by an Integrity Constraint\r
+335544538=Cannot update index segment used by an Integrity Constraint\r
+335544537=Cannot delete index segment used by an Integrity Constraint\r
+335544536=Cannot delete CHECK constraint entry (RDB$CHECK_CONSTRAINTS)\r
+336527609=pointer page vanished from DPM_next\r
+335544535=Cannot update constraints (RDB$CHECK_CONSTRAINTS).\r
+336527608=cannot find record fragment\r
+335544534=Cannot update constraints (RDB$REF_CONSTRAINTS).\r
+336527607=missing pointer page in DPM_dump\r
+335544533=Non-existent PRIMARY or UNIQUE KEY specified for FOREIGN KEY.\r
+336527606=pointer page lost from DPM_delete_relation\r
+335544532=Name of Referential Constraint not defined in constraints table.\r
+336527605=pointer page disappeared in DPM_delete\r
+335544531=Column used in a PRIMARY/UNIQUE constraint must be NOT NULL.\r
+336527604=Fragment does not exist\r
+335544530=Cannot delete PRIMARY KEY being used in FOREIGN KEY definition.\r
+336527603=missing pointer page in DPM_data_pages\r
+336527602=unimplemented FAO directive\r
+336527601=error parsing RDB FAO message string\r
+336527600=Firebird/RdB message parameter inconsistency\r
+336330989=Converted V3 scale: {0} to character_set_id: {1} and callate_id: {2}.\r
+336330988=Converted V3 sub_type: {0} to character_set_id: {1} and collate_id: {2}.\r
+336330987=Unknown V3 SUB_TYPE: {0} in FIELD: {1}.\r
+336330986=Skipped bad security class entry: {0}\r
+335609979=Global field {0} does not exist in any open database\r
+335609978=Global field {0} does not exist in database {1}\r
+336330985=could not drop database {0} (database might be in use)\r
+335609977=There are no forms defined in any open database\r
+336330984=Expected volume number {0}, found volume {1}\r
+335609976=There are no forms defined for database {0}\r
+336330983=Expected backup database {0}, found {1}\r
+335609975= (computed expression)\r
+336330982=Expected backup start time {0}, found {1}\r
+335609974=Field {0} does not exist in any open database\r
+336330981=nnERROR: Backup incomplete\r
+335609973=Field {0} does not exist in database {1}\r
+336330980=  Name: \r
+335609972=    Page size is {0} bytes.  Current allocation is {1} pages.\r
+335609971=No databases are currently ready\r
+335609970=Database "{0}"\r
+335544529=cannot modify an existing user privilege\r
+335544528=database {0} shutdown\r
+335544527=Cannot start WAL writer for the database {0}\r
+335544526=WAL writer synchronization error for the database {0}\r
+335544525=WAL setup error.  Please see Firebird log.\r
+335544524=WAL buffers cannot be increased.  Please see Firebird log.\r
+335544523=WAL writer - Journal server communication error.  Please see Firebird log.\r
+335544522=WAL I/O error.  Please see Firebird log.\r
+335544521=Unable to roll over please see Firebird log.\r
+335544520=long-term journaling already enabled\r
+336330979=Type a file name to open and hit return\r
+336330978= Press return to reopen that file, or type a newn name followed by return to open a different file.\r
+336330977=Done with volume #{0}, "{1}"\r
+335609969=Database "{0}" readied as {1}\r
+336330976=nnCould not read from file "{0}"\r
+335609968=, subtype fixed\r
+336330975=nnCould not write to file "{0}"\r
+335609967=, scale {0}\r
+336330974=nnCould not open file name "{0}"\r
+335609966=date\r
+336330973=Unexpected I/O error while writing to backup file\r
+335609965=, subtype ACL\r
+336330972=Unexpected I/O error while reading from backup file\r
+335609964=, subtype BLR\r
+335609963=, subtype {0}\r
+335609962=, segment length {0}\r
+335609961=BLOB\r
+335609960=long floating\r
+335544519=invalid lock handle\r
+335544518=restart shared cache manager\r
+335544517=exception {0}\r
+335544516=exception {0} not defined\r
+335544515=status code {0} unknown\r
+335544514=Could not expand the WAL segment for database {0}\r
+335544513=Database {0}: WAL subsystem bug for pid {1}n{2}\r
+335544512=parameter mismatch for procedure {0}\r
+335544511=procedure {0} is not defined\r
+335544510=lock time-out on wait transaction\r
+336068699=MODIFY RDB$INDICESS failed\r
+336068698=unsupported DYN verb\r
+336068697=Domain not found\r
+336068696=MODIFY RDB$FIELDS failed\r
+336068695=MODIFY RDB$FIELDS failed\r
+336068694=MODIFY DATABASE failed\r
+336330968=Writing collation {0}\r
+336068693=MODIFY DATABASE failed\r
+336330967=Bad attribute for RDB$COLLATIONS\r
+335609959=short floating\r
+336068692=MODIFY DATABASE failed\r
+336330966=Writing character set {0}\r
+335609958=quad\r
+336068691=Generation of trigger name failed\r
+336330965=Bad attribute for RDB$CHARACTER_SETS\r
+335609957=long binary\r
+336068690=Generation of index name failed\r
+336330964=writing Collations\r
+335609956=short binary\r
+336330963=writing Character Sets\r
+335609955=null terminated text, length {0}\r
+336330962=writing check constraints\r
+335609954=varying text, length {0}\r
+336330961=writing referential constraints\r
+335609953=text, length {0}\r
+336330960=Bad attribute for table constraint\r
+335609952=Procedure {0} in database "{1}" ({2})\r
+335609951=No databases are currently ready\r
+335609950= No indexes defined\r
+335544509=CHARACTER SET {0} is not defined\r
+335544508=refresh range number {0} not found\r
+335544507=refresh range number {0} already in use\r
+335544506=database {0} shutdown in progress\r
+335544505=must specify archive file when enabling long term journal for databases with round-robin log files\r
+335544504=WAL subsystem corrupted\r
+335544503=WAL subsystem encountered error\r
+335544502=reference to invalid stream number\r
+335544501=cannot drop log file when journaling is enabled\r
+335544500=database does not use Write-ahead Log\r
+336068689=Generation of column name failed\r
+336068688= Specified domain or source column does not exist\r
+336068687=STORE RDB$USER_PRIVILEGES failed in grant\r
+336068686=SELECT RDB$USER_PRIVILEGES failed in grant\r
+336068685=SELECT RDB$USER_PRIVILEGES failed in grant\r
+336330959=writing constraint {0}\r
+336068684=unsupported DYN verb\r
+336330958=writing table constraints\r
+336068683=Security class not found\r
+336330957=skipped {0} bytes looking for next valid attribute, encountered attribute {1}\r
+335609949= No indexes defined\r
+336068682=ERASE RDB$SECURITY_CLASSES failed\r
+336330956= {0}S(KIP_BAD_DATA)      skip number of bytes after reading bad data\r
+335609948= No views defined\r
+336068681=unsupported DYN verb\r
+336330955=skipped {0} bytes after reading a bad attribute {1}\r
+335609947= Security class {0} is not defined\r
+336068680=Trigger Message not found\r
+336330954=adjusting an invalid decompression length from {0} to {1}\r
+335609946=No security classes defined\r
+336330953=expected number of bytes to be skipped, encountered "{0}"\r
+335609945=Procedure {0} not found in database {1}\r
+336330952= missing parameter for the number of bytes to be skipped\r
+335609944=Procedure {0} not found in database {1}\r
+336330951=restoring exception {0}\r
+335609943=substitute prompt string too long\r
+336330950=writing exception {0}\r
+335609942=substitute prompt string too long\r
+335609941=Procedure {0} not found in database {1}\r
+335609940=Procedures can not be renamed across databases. Try COPY\r
+336068679=ERASE TRIGGER MESSAGE failed\r
+336068678=TRIGGER NAME expected\r
+336068677=unsupported DYN verb\r
+336068676=MODIFY RDB$VIEW_RELATIONS failed\r
+336068675=Trigger not found\r
+336330949=writing exceptions\r
+336068674=ERASE RDB$TRIGGERS failed\r
+336330948=restoring parameter {0} for stored procedure\r
+336068673=ERASE RDB$TRIGGER_MESSAGES failed\r
+336330947=restoring stored procedure {0}\r
+335609939=nSub-topics available for {0} are:\r
+336068672=unsupported DYN verb\r
+336330946=writing parameter {0} for stored procedure\r
+335609938=nNo help is available for {0} {1}\r
+336068671=ERASE RDB$FILES failed\r
+336330945=writing stored procedure {0}\r
+335609937=n{0}Sub-topics available:\r
+336068670=ERASE RDB$USER_PRIVILEGES failed\r
+336330944=writing stored procedures\r
+335609936= [{0} topics matched {1}]\r
+336330943= {0}USER                 Firebird user name\r
+335609935=procedure name over 31 characters\r
+336330942= {0}PAS(SWORD)           Firebird password\r
+335609934=QLI$PROCEDURES table must be created with RDO in Rdb/VMS databases\r
+336330941=password parameter missing\r
+335609933=database handle required\r
+336330940=user name parameter missing\r
+335609932=procedure name "{0}" in use in database {1}\r
+335609931=Could not create QLI$PROCEDURES table\r
+335609930=Could not create QLI$PROCEDURE field\r
+336068669=Table not found\r
+336068668=ERASE RDB$RELATIONS failed\r
+336068667=ERASE RDB$VIEW_RELATIONS failed\r
+336068666=ERASE RDB$RELATION_FIELDS failed\r
+336068665=ERASE RDB$INDICES failed\r
+336330939= {0}N(O_VALIDITY)        do not restore database validity conditions\r
+336068664=ERASE RDB$INDEX_SEGMENTS failed\r
+336330938= {0}OL(D_DESCRIPTIONS)   save old style metadata descriptions\r
+336068663=Column not found for table\r
+336330937=restoring generator {0} value: {1}\r
+335609929=Could not create QLI$PROCEDURE_NAME field\r
+336068662=ERASE RDB$RELATION_FIELDS failed\r
+336330936=a blocking factor may not be used in conjunction with device CT\r
+335609928=procedure "{0}" is undefined\r
+336068661=ERASE RDB$RELATION_FIELDS failed\r
+336330935=expected blocking factor, encountered "{0}"\r
+335609927=procedure "{0}" is undefined in database {1}\r
+336068660=Column {0} from table {1} is referenced in view {2}\r
+336330934=blocking factor parameter missing\r
+335609926=procedure "{0}" is undefined\r
+336330933= {0}FA(CTOR)             blocking factor\r
+335609925=conversion error\r
+336330932=index {0} omitted because {1} of the expected {2} keys were found\r
+335609924=PIC_edit: class not yet implemented\r
+336330931= column {0} used in index {1} seems to have vanished\r
+335609923=cannot open command file "{0}"\r
+336330930= {0}IG(NORE)             ignore bad checksums\r
+335609922=unexpected eof\r
+335609921=unexpected end of file in file {0}\r
+335609920=unexpected end of procedure in procedure {0}\r
+336068659=No table specified in ERASE RFR\r
+336068658=No segments found for index\r
+336068657=ERASE RDB$INDEX_SEGMENTS failed\r
+336068656=Index not found\r
+336068655=ERASE RDB$INDICES failed\r
+336330929= {0}G(ARBAGE_COLLECT)    inhibit garbage collection\r
+336068654=Column not found\r
+336330928=closing file, committing, and finishing. {0} bytes written\r
+336068653=ERASE RDB$FIELDS failed\r
+336330927= {0}T(RANSPORTABLE)      transportable backup -- data in XDR format\r
+335609919=unterminated quoted string\r
+336068652=ERASE RDB$FIELDS failed\r
+336330926=cannot commit files\r
+335609918=fseek failed\r
+336068651=column {0} is used in table {1} (local name {2}) and cannot be dropped\r
+336330925=cannot commit index {0}\r
+335609917=could not open scratch file\r
+336068650=unsupported DYN verb\r
+336330924= {0}K(ILL)               restore without creating shadows\r
+335609916=unterminated quoted string\r
+336330923= error committing metadata for table {0}\r
+335609915=fseek failed\r
+336330922=committing metadata for table {0}\r
+335609914=gds_$put_segment failed\r
+336330921=gbak:\r
+335609913=overflow during conversion\r
+336330920=type\r
+335609912=Error converting string "{0}" to date\r
+335609911=BLOB conversion is not supported\r
+335609910=conversion error\r
+336068649=Function not found\r
+336068648=ERASE RDB$FUNCTIONS failed\r
+336068647=ERASE RDB$FUNCTION_ARGUMENTS failed\r
+336068646=unsupported DYN verb\r
+336068645=BLOB Filter not found\r
+336330919=restoring table {0}\r
+336068644=ERASE BLOB FILTER failed\r
+336330918=readied database {0} for backup\r
+336068643=ERASE RDB$FIELDS failed\r
+336330917=    writing generator {0} value {1}\r
+335609909=conversion error\r
+336068642=STORE RDB$VIEW_RELATIONS failed\r
+336330916=writing id generators\r
+335609908=conversion error\r
+336068641=DEFINE TRIGGER MESSAGE failed\r
+336330915=    writing shadow file {0}\r
+335609907=conversion error\r
+336068640=unsupported DYN verb\r
+336330914=writing shadow files\r
+335609906=conversion error\r
+336330913=writing types\r
+336396887=invalid comparison operator for find operation\r
+335609905=conversion error\r
+336330912=    writing type {0} for column {1}\r
+336396886=data operation not supported\r
+335609904=BLOB conversion is not supported\r
+336330911=writing triggers\r
+335609903=MOVQ_move: conversion not done\r
+336330910=writing trigger messages\r
+335609902=conversion not implemented\r
+335609901=conversion not implemented\r
+336396882=subscript out of bounds\r
+335609900=comparison not done\r
+336396881=null segment of UNIQUE KEY\r
+336068639=DEFINE TRIGGER failed\r
+336068638=unsupported DYN verb\r
+336068637=STORE RDB$RELATION_FIELDS failed\r
+336068636=STORE RDB$FIELDS failed\r
+336068635=STORE RDB$RELATIONS failed\r
+336330909=    writing trigger message for {0}\r
+336068634=unsupported DYN verb\r
+336330908=    writing trigger {0}\r
+336068633=STORE RDB$USER_PRIVILEGES failed defining a table\r
+336330907=    writing security class {0}\r
+336068632=STORE RDB$RELATIONS failed\r
+336330906=writing tables\r
+336068631=STORE RDB$RELATION_FIELDS failed\r
+336330905=    writing table {0}\r
+336068630=STORE RDB$FIELDS failed\r
+336330904=    writing privilege for user {0}\r
+336330903=    writing index {0}\r
+336330902=writing domains\r
+336330901=    writing domain {0}\r
+336330900=writing functions\r
+336396875=Overflow occurred during data type conversion.\r
+336068629=STORE RDB$INDICES failed\r
+336068628=could not find PRIMARY KEY index in specified table\r
+336068627=PRIMARY KEY lookup failed\r
+336068626=could not find UNIQUE INDEX with specified columns\r
+336068625=PRIMARY KEY column lookup failed\r
+336068624=unsupported DYN verb\r
+336068623=STORE RDB$INDICES failed\r
+336068622=No table specified for index\r
+336068621=STORE RDB$FIELDS failed\r
+336068620=DEFINE FUNCTION ARGUMENT failed\r
+336068619=unsupported DYN verb\r
+336068618=DEFINE FUNCTION failed\r
+336068617=DEFINE GENERATOR unexpected DYN verb\r
+336068616=DEFINE GENERATOR failed\r
+336068615=DEFINE BLOB FILTER failed\r
+336068614=unsupported DYN verb\r
+336068613={0}\r
+336068612=unsupported DYN verb\r
+336068611=STORE RDB$FIELD_DIMENSIONS failed\r
+336068610=unsupported DYN verb\r
+336068609=ODS version not supported by DYN\r
+336527599=Firebird status vector inconsistent\r
+336527598=unknown parameter in RdB status vector\r
+336527597=Error parsing RDB FAO msg str\r
+336527596=Error parsing RDB FAO msg string\r
+336527595=Unimplemented conversion, FAO directive X,U\r
+336527594=Unimplemented conversion, FAO directive O,Z,S\r
+336527593=eval_statistical: invalid operation\r
+336527592=EVL_expt: invalid operation\r
+336527591=EVL_boolean: invalid operation\r
+336527590=EVL_bitmap: invalid operation\r
+336855113=Not enough disk space remaining\r
+336855112=A sweep must be performed on this database before it can be started.  Sweep?\r
+336855111=Beginning database sweep, which can take a long time.  This can be controlled by varying the sweep interval.  Sweep?\r
+336855110=The server disconnected from the other end of the pipe.\r
+336527589=EVL_assign_to: invalid operation\r
+336527588=cannot access field in view {0}\r
+336527587=cannot access field {0} in view {1}\r
+336527586=request size limit exceeded\r
+336855109=A write fault occurred on the network.\r
+336527585=data type not supported for arithmetic\r
+336855108=The network request was not accepted.\r
+336527584=quad word arithmetic not supported\r
+336855107=The network BIOS session limit was exceeded.\r
+336527583=argument of scalar operation must be an array\r
+336855106=The name limit for the local computer network adapter card was exceeded.\r
+336527582=bad BLR -- invalid stream\r
+336855105=The network name cannot be found.\r
+336527581=(CMP) copy: cannot remap\r
+336855104=The network resource type is not correct.\r
+336527580=release of unknown resource\r
+336855103=Network access is denied.\r
+336855102=The specified network name is no longer available.\r
+336855101=The remote adapter is not compatible.\r
+336855100=An unexpected network error occurred.\r
+336527579=request of unknown resource\r
+336527578=CCH: {0}, status = {1} (218)\r
+336527577=buffer marked for update\r
+336527576=page {0}, page type {1} lock denied\r
+336527575=page {0}, page type {1} lock conversion denied\r
+336527574=no cache buffers available for reuse\r
+336527573=insufficient cache size\r
+336527572=CCH_precedence: block marked\r
+336527571=attempt to remove page from dirty page list when not there\r
+336527570=page in use during flush\r
+336462125=Datatype needs modification\r
+335544499=Cannot roll over to the next log file {0}\r
+335544498=Invalid WAL parameter block option {0}\r
+335544497=Illegal attempt to attach to an uninitialized WAL segment for {0}\r
+335544496=Log block too small at offset {0} in log file {1}\r
+336527569=attempt to release page not acquired\r
+335544495=Log record header too small at offset {0} in log file {1}\r
+336527568=page not accessed for write\r
+335544494=Incomplete log record at offset {0} in log file {1}\r
+336527567=page already in use\r
+335544493=Unexpected end of log file {0} at offset {1}\r
+336527566=exceeded index level\r
+335544492=Database name in the log file {0} is different\r
+336527565=index bucket overfilled\r
+335544491=Log file {0} not closed properly; database recovery may be required\r
+336527564=index inconsistent\r
+335544490=Log file {0} not latest in the chain but open flag still set\r
+336527563=shadow block not found for extend file\r
+336527562=unknown data type\r
+336527561=cannot find BLOB page\r
+336527560=invalid BLOB ID\r
+335544489=Invalid version of log file {0}\r
+335544488=Log file header of {0} too small\r
+335544487=WAL Writer error\r
+335544486=Write-ahead log subsystem failure\r
+336527559=expected field node\r
+335544485=invalid statement handle\r
+336527558=array subscript computation error\r
+335544484=error in opening Write-ahead Log file during recovery\r
+336527557=field for array not known\r
+335544483=maximum number of online dump files that can be specified is 16\r
+336527556=relation for array not known\r
+335544482=journaling allowed only if database has Write-ahead Log\r
+336527555=cannot update old BLOB\r
+335544481=no more disk/tape space.  Cannot continue online dump\r
+336527554=BLOB not found\r
+335544480=an online dump is already in progress\r
+336527553=null or invalid array\r
+336527552=overflow during conversion\r
+336527551=conversion error\r
+336527550=conversion not supported for specified data types\r
+335544479=online dump failure. Retry dump\r
+335544478=enable journal for database before starting online dump\r
+335544477=maximum indexes per table ({0}) exceeded\r
+335544476=requested record lock conflicts with existing lock\r
+336527549=comparison not supported for specified data types\r
+335544475=lock on table {0} conflicts with existing lock\r
+336527548=cannot update erased record\r
+335544474=invalid lock level {0}\r
+336527547=cannot delete system tables\r
+335544473=invalid bookmark handle\r
+336527546=record disappeared\r
+335544472=Your user name and password are not defined. Ask your database administrator to set up a Firebird login.\r
+336527545=wrong record version\r
+335544471=there is no index in table {0} with id {1}\r
+336527544=limbo impossible\r
+335544470=cache buffer for page {0} invalid\r
+336527543=wrong record length\r
+336527542=differences record too long\r
+336527541=external access type not implemented\r
+336527540=cannot reposition for update after sort for RMS\r
+336920611=    -t      tablename\r
+336920610=    -r      analyze average record and version length\r
+335544469=transaction marked invalid by I/O error\r
+335544468=transaction {0} is {1}\r
+335544467=minor version too high found {0} expected {1}\r
+335544466=violation of FOREIGN KEY constraint "{0}" on table "{1}"\r
+336527539=decompression overran buffer\r
+335544465=invalid BLOB type for operation\r
+336527538=record length inconsistent\r
+335544464=secondary server attachments cannot start logging\r
+336527537=applied differences will not fit in record\r
+335544463=generator {0} is not defined\r
+336527536=bad difference record\r
+335544462=secondary server attachments cannot start journaling\r
+336527535=partner index description not found\r
+335544461=secondary server attachments cannot validate databases\r
+336527534=index key too big\r
+335544460=a file in manual shadow {0} is unavailable\r
+336527533=referenced index description not found\r
+336527532=journal server refused connection\r
+336527531=journal server is incompatible version\r
+336920609=    -p      password\r
+336527530=unexpected reply from journal server\r
+336920608=    -u      username\r
+336920607=System memory exhausted\r
+336920606=Can't read a database page\r
+336920605=Can't open database file {0}\r
+336920604=    -z      display version number\r
+336920603=    -s      analyze system relations\r
+336920602=    -l      analyze log page\r
+336920601=    -i      analyze index leaf pages\r
+336920600=    -h      analyze header page\r
+335544459=record from transaction {0} is stuck in limbo\r
+335544458=column not array or invalid dimensions (expected {0}, encountered {1})\r
+335544457=subscript out of bounds\r
+335544456=invalid slice description language at offset {0}\r
+336527529=return data type not supported\r
+335544455=cannot attach active shadow file\r
+336527528=looper: action not yet implemented\r
+335544454=filter not found to convert type {0} to type {1}\r
+336527527=invalid SEND request\r
+335544453=object {0} is in use\r
+336527526=invalid rsb type\r
+335544452=product {0} is not licensed\r
+336527525=cannot find tip page\r
+335544451=update conflicts with concurrent update\r
+336527524=failed to remove symbol from hash table\r
+335544450={0}\r
+336527523=root file name not listed for shadow\r
+336527522=shadow lock not synchronized properly\r
+336527521=shadow block not found\r
+336527520=wrong ACL version\r
+335609899=Could not run "{0}"\r
+335609898=Cannot open output file "{0}"\r
+335609897=Request terminated by statement\r
+335609896=Request terminated by statement: {0}\r
+335609895=field validation error\r
+335609894=execution terminated by signal\r
+335609893=fdopen failed\r
+335609892=could not create pipe\r
+335609891=output pipe is not supported on VMS\r
+335544449=\r
+335609890=print_blob: expected field node\r
+335544448=\r
+335544447=no rollback performed\r
+335544446=not updatable\r
+336527519=cannot assert logical lock\r
+335544445={0} extension error\r
+336527518=database file not available\r
+335544444=operation not supported\r
+336527517=cannot sort on a field that does not exist\r
+335544443=database system cannot write argument {0}\r
+336527516=attempt to release block overlapping prior free block\r
+335544442=database system cannot read argument {0}\r
+336527515=attempt to release block overlapping following free block\r
+335544441=database detach completed with errors\r
+336527514=attempt to release free block\r
+335544440=\r
+336527513=invalid pool id encountered\r
+336527512=memory pool free list is invalid\r
+336527511=request to allocate block type larger than maximum size\r
+336527510=request to allocate invalid block type\r
+336330899=    writing function {0}\r
+336330898=writing filters\r
+336330897=    writing filter {0}\r
+336330896=         writing column {0}\r
+335609889=EXEC_execute: not implemented\r
+336330895=     writing gen id of: {0}\r
+335609888=Input value is too long\r
+336330894=    writing data for table {0}\r
+335609887=user name is supported in RSEs temporarily\r
+336330893=    writing argument for function {0}\r
+335609886=data type not supported for arithmetic\r
+336330892=view\r
+335609885=EVAL_value: not finished\r
+336330891=    Version(s) for database "{0}"\r
+335609884=EVAL_boolean: not finished\r
+336330890=validation error on column in table {0}\r
+335609883=HSH_remove failed\r
+335609882=nStatistics for database "{0}"n{1}\r
+335609881=qli version {0}\r
+335544439=function {0} could not be matched\r
+335609880=Welcome to QLInQuery Language Interpreter\r
+335544438=function {0} is not defined\r
+335544437=wrong DYN version\r
+335544436=SQL error code = {0}\r
+336527509=cannot map page\r
+335544435=null segment of UNIQUE KEY\r
+336527508=wrong packet type\r
+335544434=key size exceeds implementation restriction for index "{0}"\r
+336527507=invalid block type encountered\r
+335544433=communication error with journal "{0}"\r
+335544432=lock manager error\r
+335544431=blocking signal has been received\r
+335544430=unable to allocate memory from operating system\r
+336330889=unknown switch "{0}"\r
+336330888=trigger type\r
+336330887=trigger message\r
+336330886=trigger\r
+335609879=Please retry, supplying an application script file name\r
+336330885=transportable backup -- data in XDR format\r
+335609878=illegal instruction or address, recovering...\r
+336330884=switches can be abbreviated to the unparenthesized characters\r
+335609877=arithmetic exception\r
+336330883=security class\r
+335609876=floating underflow fault\r
+336330882=starting transaction\r
+335609875=floating overflow fault\r
+336330881=started transaction\r
+335609874=floating underflow trap\r
+336330880=    restoring type {0} for column {1}\r
+335609873=floating division by zero\r
+335609872=floating overflow trap\r
+335609871=integer division by zero\r
+335544429=bad parameter number\r
+335609870=integer overflow\r
+335544428=undefined message number\r
+335544427=data operation not supported\r
+335544426=context not defined (BLR error)\r
+335544425=context already in use (BLR error)\r
+335544424=no lock manager available\r
+335544423=internal error\r
+335544422=internal error\r
+335544421=connection rejected by remote interface\r
+335544420=transaction outstanding\r
+336330879=    restoring trigger message for {0}\r
+336330878=    restoring trigger {0}\r
+336330877=restoring security class {0}\r
+336330876=restoring data for table {0}\r
+335609869=expected {0}, encountered "{1}"\r
+336330875=    restoring privilege for user {0}\r
+335609868=** QLI error: {0} **\r
+336330874=    restoring index {0}\r
+335609867=** QLI error from database **\r
+336330873=restoring domain {0}\r
+335609866=** QLI error from database "{0}" **\r
+336330872=     restoring gen id value of: {0}\r
+335609865=INTERNAL: {0}\r
+336330871=    restoring argument for function {0}\r
+335609864=show_fields: dtype not done\r
+336330870=restoring function {0}\r
+335609863=show option not implemented\r
+335609862=set option not implemented\r
+335609861=memory exhausted\r
+335544419=transaction not in limbo\r
+335609860=bad pool ID\r
+335544418=transaction in limbo\r
+335544417=internal error\r
+335544416=internal error\r
+335544415=database corrupted\r
+335544414=BLOB and array data types are not supported for {0} operation\r
+335544413=wrong version of database parameter block\r
+335544412=unsupported BLR version (expected {0}, encountered {1})\r
+335544411=wrong version of transaction parameter block\r
+335544410=bad handle count\r
+336397204=non-SQL security class defined\r
+336397203=An error occurred while trying to update the security database\r
+336330869=    restoring filter {0}\r
+336330868=    restoring file {0}\r
+336330867=    restoring column {0}\r
+336330866=restore failed for record in table {0}\r
+335609859=corrupt pool\r
+336330865= {0}V(ERIFY)             report each action taken\r
+335609858=bad block size\r
+336330864= {0}R(EPLACE_DATABASE)   replace database from backup file\r
+335609857=bad block type\r
+336330863=table\r
+335609856=expected type\r
+336330862=Reducing the database page size from {0} bytes to {1} bytes\r
+336330861= {0}Y  <path>            redirect/suppress status message output\r
+336330860={0} records written\r
+335544409=transaction--request mismatch (synchronization error)\r
+335544408=transaction handle not zero\r
+335544407=database handle not zero\r
+335544406=index is broken\r
+335544405=checksum error on database page {0}\r
+335544404=database corrupted\r
+335544403=page {0} is of wrong type (expected {1}, found {2})\r
+335544402=internal error\r
+335544401=internal error\r
+335544400=internal error\r
+336330859=   {0} records restored\r
+336330858=     {0} records ignored\r
+336330857=privilege\r
+336330856= {0}Z                    print version number\r
+336330855=page size specified ({0} bytes) rounded up to {1} bytes\r
+336330854=page size\r
+336330853= {0}P(AGE_SIZE)          override default page size\r
+336330852=opened file {0}\r
+336330851= {0}O(NE_AT_A_TIME)      restore one table at a time\r
+336330850= {0}L(IMBO)              ignore transactions in limbo\r
+336330849= {0}E(XPAND)             no data compression\r
+336330848=length given for initial file ({0}) is less than minimum ({1})\r
+336330847=legal switches are:\r
+336330846=trigger {0} is invalid\r
+336330845=index\r
+336330844=domain\r
+336330843=gbak version {0}\r
+336330842=function argument\r
+336330841=function\r
+336330840=finishing, closing, and going home\r
+336330839=filter\r
+336330838=file length\r
+336330837=file\r
+336330836=column\r
+336330835=Exiting before completion due to errors\r
+336330834=Exiting before completion due to errors\r
+336330833=error accessing BLOB column {0} -- continuing\r
+336330832=do not recognize {0} attribute {1} -- continuing\r
+336330831=do not understand BLOB INFO item {0}\r
+336330830= {0}I(NACTIVE)           deactivate indexes during restore\r
+336330829=database {0} has a page size of {1} bytes.\r
+336330828=creating indexes\r
+336330827=creating file {0}\r
+336330826=created database {0}, page_size {1} bytes\r
+336330825= {0}C(REATE_DATABASE)    create database from backup file\r
+336330824=committing data for table {0}\r
+336330823=creating index {0}\r
+336330822=committing secondary files\r
+336330821=commit failed on table {0}\r
+336330820=    committing metadata\r
+336330819=closing file, committing, and finishing\r
+336330818=cannot open status and error output file {0}\r
+336330817=cannot open backup file {0}\r
+336330816=blob\r
+336330815= {0}M(ETA_DATA)          backup metadata only\r
+336330814= {0}D(EVICE)             backup file device type on APOLLO (CT or MT)\r
+336330813=  backup file is compressed\r
+336330812= {0}B(ACKUP_DATABASE)    backup database to file\r
+336396787=The cursor identified in a FETCH or CLOSE statement is not open.\r
+336330811=backup\r
+336396786=The cursor identified in an OPEN statement is already open.\r
+336330810=array\r
+336396784=Unknown cursor\r
+336396780= The cursor identified in the update or delete statement is not positioned on a row.\r
+336330809=adding file {0}, starting at page {1}\r
+336330808=Unexpected I/O error while {0} backup file\r
+336330807=Expected XDR record length\r
+336330806=expected array dimension {0} but instead found {1}\r
+336330805=expected array version number {0} but instead found {1}\r
+336330804=array dimension for column {0} is invalid\r
+336330803=database format {0} is too old to restore to\r
+336396778=Attempt to update non-updatable cursor\r
+336330802=unexpected end of file on backup file\r
+336330801=no table name for data\r
+336330800=gds_$send failed\r
+336396770=Unknown statement or request\r
+336396769=The prepare statement identifies a prepare statement with an open cursor\r
+336396758=violation of FOREIGN KEY constraint "{0}"\r
+336396757=Cannot prepare a CREATE DATABASE/SCHEMA statement\r
+336396756=transaction marked invalid by I/O error\r
+336396737=This user does not have privilege to perform this operation on this object.\r
+336396736=user does not have the privilege to perform operation\r
+336396735=cannot modify an existing user privilege\r
+336003088=Datatypes {0}are not comparable in expression {1}\r
+336003087=Label {0} {1} in the current scope\r
+336003086=External function should have return position between 1 and {0}\r
+336003085=Ambiguous field name between {0} and {1}\r
+336003084=integers in SQL dialect 3.\r
+336003083=as approximate floating-point values in SQL dialect 1, but as 64-bit\r
+336003082=WARNING: NUMERIC and DECIMAL fields with precision 10 or greater are stored\r
+336003081=value in SQL dialect 1, but as an exact numeric value in SQL dialect 3.\r
+336003080=WARNING: Numeric literal {0} is interpreted as a floating-point\r
+336855099=The specified server cannot perform the requested operation.\r
+336855098=A network adapter hardware error occurred.\r
+336855097=The network BIOS command limit has been reached.\r
+336855096=The network path was not found.\r
+336855095=A duplicate name exists on the network.\r
+336855094=The remote computer not available.\r
+336855093=The IPX/SPX software is already initialized.\r
+336855092=The request exceeds the maximum IPX/SPX resource limits.\r
+336855091=Lock on network resources failed.\r
+336855090=Not enough event control blocks free.\r
+336003079=DB dialect {0} and client dialect {1} conflict with respect to numeric precision {2}.\r
+336003078=\r
+336003077=Database SQL dialect {0} does not support reference to {1} datatype\r
+336003076=Use of {0} expression that returns different results in dialect 1 and dialect 3\r
+336003075=Precision 10 to 18 changed from DOUBLE PRECISION in SQL dialect 1 to 64-bit scaled integer in SQL dialect 3\r
+336003074=Cannot SELECT RDB$DB_KEY from a stored procedure.\r
+336855089=Not enough DOS memory available.\r
+336855088=The specified network resource or device is no longer available.\r
+336855087=The named pipe is busy.\r
+336855086=The specified path was not found.\r
+336855085=The remote host is not responding or you may lack proper security to access network resources.\r
+336855084=No process slots are available.\r
+336855083=The Network is busy.\r
+336855082=The input buffer is too small.\r
+336855081=Pipe has been closed or is not being read.\r
+336855080=Bad length in command.\r
+336855079=There is not enough available memory.\r
+336855078=Pipe does not exist or is no longer valid.\r
+336855077=SPX is not installed or the specified socket is not open.\r
+336855076=Malformed or overflow packet.\r
+336855075=The socket has already been closed.\r
+336855074=The SPX connection table is full.\r
+336855073=Specified connection is not valid.\r
+336855072=The Firebird server is not responding or has closed the connection.\r
+336855071=The Firebird server is not responding or has closed the connection.\r
+336855070=The IPX/SPX software is not initialized.\r
+336855069=The host was not found or is unreachable over the specified network protocol.\r
+336855068=Windows sockets have not been initialized properly.\r
+336855067=The version of winsock.dll is not usable by this application.\r
+336855066=The network subsystem is unusable.\r
+336855065=The request would cause the non-blocking socket to block.\r
+336855064=A blocking winsock request is already in progress.\r
+336855063=Operation already in progress.\r
+336855062=No route to the requested host.\r
+336855061=The requested host is down.\r
+336855060=Request timed out without establishing a connection.\r
+336855059=Cannot send or receive data on a socket which has been shutdown.\r
+336855058=The socket is not connected.\r
+336855057=The socket is already connected.\r
+336855056=Insufficient buffer space or sockets are available.\r
+336855055=The connection was reset by the remote host.\r
+336855054=The connection was aborted due to a timeout or other failure.\r
+336855053=The network dropped the connection on reset.\r
+336855052=The network cannot be reached from this host at this time.\r
+336855051=The winsock implemenation has detected that the network subsystem has failed.\r
+336855050=The specified address is not available from the local machine.\r
+336855049=The specified address is already in use.\r
+336855048=The requested address family is not supported by this protocol family.\r
+336855047=The requested protocol family is not supported.\r
+336855046=The TCP operation is not supported.\r
+336855045=The TCP socket type is not supported in the requested address family.\r
+336920599=    -d      analyze data pages\r
+336855044=The requested winsock protocol is not supported by the TCP implemenation.\r
+336920598=    -a      analyze data and index pages\r
+336855043=The packet was too large for the buffer and was truncated.\r
+336920597=Available switches:\r
+336855042=There are too many open files.  No more file descriptors are available.\r
+336920596=unknown switch "{0}"\r
+336855041=The request was canceled before completing.\r
+336920595=    Expected b-tree bucket on page {0} from {1}\r
+336855040=The connection request was refused.  This can occur if the Firebird server is not started on the host machine.\r
+336920594=    Expected data on page {0}\r
+336920593= Fill distribution:\r
+336920592= Average data length: {0}, total dup: {1}, max dup: {2}\r
+336920591= Depth: {0}, leaf buckets: {1}, nodes: {2}\r
+336920590=    Index {0} ({1})\r
+335610364={0} Based on field {1} of view {2}\r
+335610363={0} Based on field {1} of relation {2}\r
+335610362=    elapsed = !e cpu = !u system = !s mem = !x buffers = !b\r
+335610361=    reads = !r writes = !w fetches = !f marks = !m\r
+335610360=unknown data type {0}\r
+336920589=    Fill distribution:\r
+336920588=    Data pages: {0}, data page slots: {1}, average fill: {2}\r
+336920587=    Primary pointer page: {0}, Index root page: {1}\r
+336920586=nAnalyzing database pages ...\r
+336920585=File {0} is the {1} file\r
+336920584=File {0} continues as file {1}\r
+336920583=nnDatabase file sequence:\r
+336920582=nDatabase "{0}"\r
+336920581=gstat version {0}\r
+336920580=Unexpected end of database file.\r
+335610359=ntype <cr> for next topic or <EOF> to stop: \r
+335610358=Subtopic? \r
+335610357=bad kanji found while formatting output\r
+335610356=Enter\r
+335610355=Re-enter\r
+335610354=NO\r
+335610353=YES\r
+335610352=Field {0} in relation {1} of database {2}\r
+335610351=Field {0} in view {1} of database {2}\r
+336920579=Wrong ODS version, expected {0}, encountered {1}\r
+336920578=please retry, giving a database name\r
+336920577=found unknown switch\r
+335610345=JOIN\r
+335610344=SINGULAR (SELECT * <sql rse>)\r
+335610343=Invalid argument for UDF\r
+335610341= Expression index BLR:\r
+335610340=FORMs not supported\r
+335610339=Relation {0} does not exist\r
+335610338=field width ({0}) * header segments ({1}) greater than 60,000 characters\r
+335610337=unsuccessful attempt to extend pool beyond 64KB\r
+335610336=cannot format unsubscripted array {0}\r
+335610335= ({0})\r
+335610334=number > 0\r
+335610333=input line too long\r
+335610332=input line too long\r
+335610331=    Datatype information:\r
+335610330=Variable {0} has not been declared\r
+335610329=    Edit string:  {0}\r
+335610328=    Query name:  {0}\r
+335610327=Variable {0}\r
+335610326=literal string  <MAXSYMLEN> characters or longer\r
+335610325=qli: ignoring unknown switch -{0}\r
+335610324=Data type of field {0} may not be changed to or from BLOB\r
+335610323="{0}" is not a field and so may not be subscripted\r
+335610322=Only fields may be subscripted\r
+335610321=Error during two phase commit on database {0}nroll back all databases or commit databases individually\r
+335610320=no filters are defined for database {0}\r
+335610319=filters are not supported in database {0}\r
+335610318=no functions are defined in database {0}\r
+335610317=functions are not supported in database {0}\r
+335610316=Do you want to rollback updates for {0}?\r
+335610315=Unable to create form window\r
+335610314=Connection to database {0} lostn Please FINISH the database!\r
+335544399=internal error\r
+335610313=    message {0}:  {1}\r
+335544398=internal error\r
+335610312=Messages associated with {0}:\r
+335544397=internal error\r
+335610311=source relation {0} does not exist\r
+335544396=column {0} is not defined in table {1}\r
+335610310=could not resolve context for aggregate expression\r
+335544395=table {0} is not defined\r
+335544394=incompatible version of on-disk structure\r
+335544393=request in use\r
+335544392=internal error\r
+335544391=buffer in use\r
+335544390=BLR syntax error: expected {0} at offset {1}, encountered {2}\r
+336397185=Invalid numeric literal\r
+336397184=Invalid token\r
+336397183=Invalid String\r
+335610309=output pipe is not supported on MPE/XL\r
+335610308=prompting not allowed in select field list\r
+335610307=simple field reference not allowed in global aggregates\r
+335610306= Index {0}{1}{2}{3}\r
+335610305=Filters in database {0} ({1}):\r
+335610304=    Filter description:\r
+335544389=buffer exhausted\r
+335610303=    Output sub-type is {0}\r
+335544388=block size exceeds implementation restriction\r
+335610302=    Input sub-type is {0}\r
+335544387=internal error\r
+335610301=    Filter library is {0}\r
+335544386=too many requests\r
+335610300=Filter {0} in database "{1}" ({2}):\r
+335544385=internal error\r
+335544384=internal error\r
+335544383=unrecoverable conflict with limbo transaction {0}\r
+335544382={0}\r
+335544381=Implementation limit exceeded\r
+335544380=wrong number of arguments on call\r
+335544379=unsupported on-disk structure for file {0}; found {1} type {2}, support {3} type {4}\r
+335544378=feature is not supported\r
+335544377=request includes a DSRI extension not supported in this implementation\r
+335544376=table {0} was omitted from the transaction reserving list\r
+335544375=unavailable database\r
+335544374=attempt to fetch past the last record in a record stream\r
+335544373=operating system directive {0} failed\r
+335544372=attempted reference to BLOB in unavailable database\r
+335544371=attempted write to read-only BLOB\r
+335544370=attempted action on blob outside transaction\r
+335544369=attempted read of a new, open BLOB\r
+335544368=attempted invalid operation on a BLOB\r
+335544367=attempted retrieval of more segments than exist\r
+335544366=segment buffer length shorter than expected\r
+335544365=request referenced an unavailable database\r
+335544364=request synchronization error\r
+335544363=no transaction for request\r
+335544362=cannot update read-only view {0}\r
+335544361=attempted update during read-only transaction\r
+335544360=attempted update of read-only table\r
+335544359=attempted update of read-only column\r
+335544358=message length error (encountered {0}, expected {1})\r
+335544357=cannot disconnect database with open transactions ({0} active)\r
+335544356=metadata is obsolete\r
+335544355=BLOB was not closed\r
+335544354=invalid database key\r
+335544353=transaction is not in limbo\r
+335544352=no permission for {0} access to {1} {2}\r
+335544351=unsuccessful metadata update\r
+335544350=program attempted to exit without finishing database\r
+335544349=attempt to store duplicate value (visible to active transactions) in unique index "{0}"\r
+335544348=no current record for fetch operation\r
+335544347=validation error for column {0}, value "{1}"\r
+335544346=corrupt system table\r
+335544345=lock conflict on no wait transaction\r
+335544344=I/O error for file {0} "{1}"\r
+335544343=invalid request BLR at offset {0}\r
+335544342=action cancelled by trigger ({0}) to preserve data integrity\r
+335544341=unknown information item\r
+335544340=no information of this type available for object specified\r
+336397138=The object of the insert, delete or update statement is a view for which the requested operation is not permitted.\r
+336397137=This column cannot be updated because it is derived from an SQL function or expression.\r
+336330799= warning -- record could not be restored\r
+336397133={0} is not a valid base table of the specified view\r
+336330798=string truncated\r
+336330797=expected backup description record\r
+336397131=must specify column name for view select expression\r
+336330796=Expected backup version 1, 2, or 3.  Found {0}\r
+336397130=number of columns does not match select list\r
+336330795=do not recognize record type {0}\r
+336330794=Failed in store_blr_gen_id\r
+336330793=expected data attribute\r
+336330792=wrong length record, expected {0} encountered {1}\r
+336330791=expected record length\r
+336330790=gds_$put_segment failed\r
+335544339=information type inappropriate for object specified\r
+335544338=no match for first value expression\r
+335544337=attempt to start more than {0} transactions\r
+335544336=deadlock\r
+335544335=database file appears corrupt ({0})\r
+335544334=conversion error from string "{0}"\r
+335544333=internal gds software consistency check ({0})\r
+335544332=invalid transaction handle (expecting explicit transaction start)\r
+335544331=invalid format for transaction parameter block\r
+335544330=invalid parameter in transaction parameter block\r
+336397126=dbkey not available for multi-table views\r
+336330789=gds_$create_blob failed\r
+336330788=Cannot find column for BLOB\r
+336330787=cannot find table {0}\r
+336330786=RESTORE: decompression length error\r
+336330785=failed to create database {0}\r
+336330784=Expected database description record\r
+336330783= gds_$database_info failed\r
+336330782=gds_$release_request failed\r
+336330781= gds_$receive failed\r
+336330780=gds_$start_request failed\r
+335544329=invalid BLOB ID\r
+335544328=invalid BLOB handle\r
+335544327=invalid request handle\r
+335544326=unrecognized database parameter block\r
+335544325=bad parameters on attach or create database\r
+335544324=invalid database handle (no active connection)\r
+335544323=file {0} is not a valid database\r
+335544322=invalid database key\r
+335544321=arithmetic exception, numeric overflow, or string truncation\r
+335544320=\r
+336397118=Invalid number of arguments\r
+336397117=Invalid data type, length, or value\r
+336397116=function {0} is not defined\r
+336330779=gds_$compile_request failed\r
+336330778=data type {0} not understood\r
+336330777=Failed in put_blr_gen_id\r
+336330776=gds_$open_blob failed\r
+336330775=gds_$close_blob failed\r
+336330774=gds_$get_segment failed\r
+336330773=do not understand BLOB INFO item {0}\r
+336330772=gds_$blob_info failed\r
+336330771=cannot close APOLLO tape descriptor file {0}\r
+336330770=cannot create APOLLO cartridge descriptor file {0}\r
+336265219=This is a test message\r
+1=arithmetic exception, numeric overflow, or string truncation\r
+2=invalid database key\r
+3=file {0} is not a valid database\r
+4=invalid database handle (no active connection)\r
+5=bad parameters on attach or create database\r
+6=unrecognized database parameter block\r
+7=invalid request handle\r
+8=invalid BLOB handle\r
+9=invalid BLOB ID\r
+10=invalid parameter in transaction parameter block\r
+11=invalid format for transaction parameter block\r
+12=invalid transaction handle (expecting explicit transaction start)\r
+13=internal gds software consistency check ({0})\r
+15=database file appears corrupt ({0})\r
+16=deadlock\r
+17=attempt to start more than {0} transactions\r
+18=no match for first value expression\r
+19=information type inappropriate for object specified\r
+20=no information of this type available for object specified\r
+21=unknown information item\r
+22=action cancelled by trigger ({0}) to preserve data integrity\r
+23=invalid request BLR at offset {0}\r
+25=lock conflict on no wait transaction\r
+26=corrupt system table\r
+28=no current record for fetch operation\r
+30=program attempted to exit without finishing database\r
+31=unsuccessful metadata update\r
+32=no permission for {0} access to {1} {2}\r
+33=transaction is not in limbo\r
+34=invalid database key\r
+35=BLOB was not closed\r
+36=metadata is obsolete\r
+37=cannot disconnect database with open transactions ({0} active)\r
+38=message length error (encountered {0}, expected {1})\r
+39=attempted update of read-only column\r
+40=attempted update of read-only table\r
+41=attempted update during read-only transaction\r
+42=cannot update read-only view {0}\r
+43=no transaction for request\r
+44=request synchronization error\r
+45=request referenced an unavailable database\r
+46=segment buffer length shorter than expected\r
+47=attempted retrieval of more segments than exist\r
+48=attempted invalid operation on a BLOB\r
+49=attempted read of a new, open BLOB\r
+50=attempted action on blob outside transaction\r
+51=attempted write to read-only BLOB\r
+52=attempted reference to BLOB in unavailable database\r
+53=operating system directive {0} failed\r
+54=attempt to fetch past the last record in a record stream\r
+55=unavailable database\r
+56=table {0} was omitted from the transaction reserving list\r
+57=request includes a DSRI extension not supported in this implementation\r
+58=feature is not supported\r
+59=unsupported on-disk structure for file {0}; found {1}, support {2}\r
+60=wrong number of arguments on call\r
+61=Implementation limit exceeded\r
+62={0}\r
+63=unrecoverable conflict with limbo transaction {0}\r
+64=internal error\r
+65=internal error\r
+66=too many requests\r
+67=internal error\r
+68=block size exceeds implementation restriction\r
+69=buffer exhausted\r
+70=BLR syntax error: expected {0} at offset {1}, encountered {2}\r
+71=buffer in use\r
+72=internal error\r
+73=request in use\r
+74=incompatible version of on-disk structure\r
+75=table {0} is not defined\r
+76=column {0} is not defined in table {1}\r
+77=internal error\r
+78=internal error\r
+79=internal error\r
+80=internal error\r
+81=internal error\r
+82=internal error\r
+83=page {0} is of wrong type (expected {1}, found {2})\r
+84=database corrupted\r
+85=checksum error on database page {0}\r
+86=index is broken\r
+87=database handle not zero\r
+88=transaction handle not zero\r
+89=transaction--request mismatch (synchronization error)\r
+90=bad handle count\r
+91=wrong version of transaction parameter block\r
+92=unsupported BLR version (expected {0}, encountered {1})\r
+93=wrong version of database parameter block\r
+94=BLOB and array data types are not supported for {0} operation\r
+95=database corrupted\r
+96=internal error\r
+97=internal error\r
+98=transaction in limbo\r
+99=transaction not in limbo\r
+100=transaction outstanding\r
+101=connection rejected by remote interface\r
+102=internal error\r
+103=internal error\r
+104=no lock manager available\r
+105=context already in use (BLR error)\r
+106=context not defined (BLR error)\r
+107=data operation not supported\r
+108=undefined message number\r
+109=bad parameter number\r
+110=unable to allocate memory from operating system\r
+111=blocking signal has been received\r
+112=lock manager error\r
+115=null segment of UNIQUE KEY\r
+116=SQL error code = {0}\r
+117=wrong DYN version\r
+118=function {0} is not defined\r
+119=function {0} could not be matched\r
+121=database detach completed with errors\r
+122=database system cannot read argument {0}\r
+123=database system cannot write argument {0}\r
+124=operation not supported\r
+125={0} extension error\r
+126=not updatable\r
+127=no rollback performed\r
+130={0}\r
+131=update conflicts with concurrent update\r
+132=product {0} is not licensed\r
+133=object {0} is in use\r
+134=filter not found to convert type {0} to type {1}\r
+135=cannot attach active shadow file\r
+136=invalid slice description language at offset {0}\r
+137=subscript out of bounds\r
+138=column not array or invalid dimensions (expected {0}, encountered {1})\r
+139=record from transaction {0} is stuck in limbo\r
+140=a file in manual shadow {0} is unavailable\r
+141=secondary server attachments cannot validate databases\r
+142=secondary server attachments cannot start journaling\r
+143=generator {0} is not defined\r
+144=secondary server attachments cannot start logging\r
+145=invalid BLOB type for operation\r
+147=minor version too high found {0} expected {1}\r
+148=transaction {0} is {1}\r
+149=transaction marked invalid by I/O error\r
+150=cache buffer for page {0} invalid\r
+151=there is no index in table {0} with id {1}\r
+152=Your user name and password are not defined. Ask your database administrator to set up a Firebird login.\r
+153=invalid bookmark handle\r
+154=invalid lock level {0}\r
+155=lock on table {0} conflicts with existing lock\r
+156=requested record lock conflicts with existing lock\r
+157=maximum indexes per table ({0}) exceeded\r
+158=enable journal for database before starting online dump\r
+159=online dump failure. Retry dump\r
+160=an online dump is already in progress\r
+161=no more disk/tape space.  Cannot continue online dump\r
+162=journaling allowed only if database has Write-ahead Log\r
+163=maximum number of online dump files that can be specified is 16\r
+164=error in opening Write-ahead Log file during recovery\r
+165=invalid statement handle\r
+166=Write-ahead log subsystem failure\r
+167=WAL Writer error\r
+168=Log file header of {0} too small\r
+169=Invalid version of log file {0}\r
+170=Log file {0} not latest in the chain but open flag still set\r
+171=Log file {0} not closed properly; database recovery may be required\r
+172=Database name in the log file {0} is different\r
+173=Unexpected end of log file {0} at offset {1}\r
+174=Incomplete log record at offset {0} in log file {1}\r
+175=Log record header too small at offset {0} in log file {1}\r
+176=Log block too small at offset {0} in log file {1}\r
+177=Illegal attempt to attach to an uninitialized WAL segment for {0}\r
+178=Invalid WAL parameter block option {0}\r
+179=Cannot roll over to the next log file {0}\r
+180=database does not use Write-ahead Log\r
+181=cannot drop log file when journaling is enabled\r
+182=reference to invalid stream number\r
+183=WAL subsystem encountered error\r
+184=WAL subsystem corrupted\r
+185=must specify archive file when enabling long term journal for databases with round-robin log files\r
+186=database {0} shutdown in progress\r
+187=refresh range number {0} already in use\r
+188=refresh range number {0} not found\r
+189=CHARACTER SET {0} is not defined\r
+190=lock time-out on wait transaction\r
+191=procedure {0} is not defined\r
+192=parameter mismatch for procedure {0}\r
+194=Could not expand the WAL segment for database {0}\r
+195=status code {0} unknown\r
+196=exception {0} not defined\r
+197=exception {0}\r
+198=restart shared cache manager\r
+199=invalid lock handle\r
+200=long-term journaling already enabled\r
+201=Unable to roll over please see Firebird log.\r
+202=WAL I/O error.  Please see Firebird log.\r
+203=WAL writer - Journal server communication error.  Please see Firebird log.\r
+204=WAL buffers cannot be increased.  Please see Firebird log.\r
+205=WAL setup error.  Please see Firebird log.\r
+206=WAL writer synchronization error for the database {0}\r
+207=Cannot start WAL writer for the database {0}\r
+208=database {0} shutdown\r
+209=cannot modify an existing user privilege\r
+210=Cannot delete PRIMARY KEY being used in FOREIGN KEY definition.\r
+211=Column used in a PRIMARY KEY constraint must be NOT NULL.\r
+212=Name of Referential Constraint not defined in constraints table.\r
+213=Non-existent PRIMARY or UNIQUE KEY specified for FOREIGN KEY.\r
+214=Cannot update constraints (RDB$REF_CONSTRAINTS).\r
+215=Cannot update constraints (RDB$CHECK_CONSTRAINTS).\r
+216=Cannot delete CHECK constraint entry (RDB$CHECK_CONSTRAINTS)\r
+217=Cannot delete index segment used by an Integrity Constraint\r
+218=Cannot update index segment used by an Integrity Constraint\r
+219=Cannot delete index used by an Integrity Constraint\r
+220=Cannot modify index used by an Integrity Constraint\r
+221=Cannot delete trigger used by a CHECK Constraint\r
+222=Cannot update trigger used by a CHECK Constraint\r
+223=Cannot delete column being used in an Integrity Constraint.\r
+224=Cannot rename column being used in an Integrity Constraint.\r
+225=Cannot update constraints (RDB$RELATION_CONSTRAINTS).\r
+226=Cannot define constraints on views\r
+227=internal gds software consistency check (invalid RDB$CONSTRAINT_TYPE)\r
+228=Attempt to define a second PRIMARY KEY for the same table\r
+229=cannot modify or erase a system trigger\r
+230=only the owner of a table may reassign ownership\r
+231=could not find table/procedure for GRANT\r
+232=could not find column for GRANT\r
+233=user does not have GRANT privileges for operation\r
+234=table/procedure has non-SQL security class defined\r
+235=column has non-SQL security class defined\r
+236=Write-ahead Log without shared cache configuration not allowed\r
+237=database shutdown unsuccessful\r
+238=Operation violates CHECK constraint {0} on view or table {1}\r
+239=invalid service handle\r
+240=database {0} shutdown in {1} seconds\r
+241=wrong version of service parameter block\r
+242=unrecognized service parameter block\r
+243=service {0} is not defined\r
+244=long-term journaling not enabled\r
+245=Cannot transliterate character between character sets\r
+246=WAL defined; Cache Manager must be started first\r
+247=Overflow log specification required for round-robin log\r
+248=Implementation of text subtype {0} not located.\r
+249=Dynamic SQL Error\r
+250=Invalid command\r
+251=Data type for constant unknown\r
+252=Cursor unknown\r
+253=Data type unknown\r
+254=Declared cursor already exists\r
+255=Cursor not updatable\r
+256=Attempt to reopen an open cursor\r
+257=Attempt to reclose a closed cursor\r
+258=Column unknown\r
+259=Internal error\r
+260=Table unknown\r
+261=Procedure unknown\r
+262=Request unknown\r
+263=SQLDA missing or incorrect version, or incorrect number/type of variables\r
+264=Count of read-write columns does not equal count of values\r
+265=Invalid statement handle\r
+266=Function unknown\r
+267=Column is not a BLOB\r
+268=COLLATION {0} is not defined\r
+269=COLLATION {0} is not valid for specified CHARACTER SET\r
+270=Option specified more than once\r
+271=Unknown transaction option\r
+272=Invalid array reference\r
+273=Array declared with too many dimensions\r
+274=Illegal array dimension range\r
+275=Trigger unknown\r
+276=Subselect illegal in this context\r
+277=Cannot prepare a CREATE DATABASE/SCHEMA statement\r
+278=must specify column name for view select expression\r
+279=number of columns does not match select list\r
+280=Only simple column names permitted for VIEW WITH CHECK OPTION\r
+281=No WHERE clause for VIEW WITH CHECK OPTION\r
+282=Only one table allowed for VIEW WITH CHECK OPTION\r
+283=DISTINCT, GROUP or HAVING not permitted for VIEW WITH CHECK OPTION\r
+284=FOREIGN KEY column count does not match PRIMARY KEY\r
+285=No subqueries permitted for VIEW WITH CHECK OPTION\r
+286=expression evaluation not supported\r
+287=gen.c: node not supported\r
+288=Unexpected end of command\r
+289=INDEX {0}\r
+290=EXCEPTION {0}\r
+291=COLUMN {0}\r
+292=Token unknown\r
+293=union not supported\r
+294=Unsupported DSQL construct\r
+295=column used with aggregate\r
+296=invalid column reference\r
+297=invalid ORDER BY clause\r
+298=Return mode by value not allowed for this data type\r
+299= External functions cannot have more than 10 parameters\r
+300=alias {0} conflicts with an alias in the same statement\r
+301=alias {0} conflicts with a procedure in the same statement\r
+302=alias {0} conflicts with a table in the same statement\r
+303=Illegal use of keyword VALUE\r
+304=segment count of 0 defined for index {0}\r
+305=A node name is not permitted in a secondary, shadow, cache or log file name\r
+306=TABLE {0}\r
+307=PROCEDURE {0}\r
+308=cannot create index {0}\r
+309=Write-ahead Log with shadowing configuration not allowed\r
+310=there are {0} dependencies\r
+311=too many keys defined for index {0}\r
+312=Preceding file did not specify length, so {0} must include starting page number\r
+313=Shadow number must be a positive integer\r
+314=Token unknown - line {0}, char {1}\r
+315=there is no alias or table named {0} at this scope level\r
+316=there is no index {0} for table {1}\r
+317=table {0} is not referenced in plan\r
+318=table {0} is referenced more than once in plan; use aliases to distinguish\r
+319=table {0} is referenced in the plan but not the from list\r
+320=Invalid use of CHARACTER SET or COLLATE\r
+321=Specified domain or source column {0} does not exist\r
+322=index {0} cannot be used in the specified plan\r
+323=the table {0} is referenced twice; use aliases to differentiate\r
+324=illegal operation when at beginning of stream\r
+325=the current position is on a crack\r
+326=database or file exists\r
+327=invalid comparison operator for find operation\r
+328=Connection lost to pipe server\r
+329=bad checksum\r
+330=wrong page type\r
+331=Cannot insert because the file is readonly or is on a read only medium.\r
+332=multiple rows in singleton select\r
+333=cannot attach to password database\r
+334=cannot start transaction for password database\r
+335=invalid direction for find operation\r
+336=variable {0} conflicts with parameter in same procedure\r
+337=Array/BLOB/DATE data types not allowed in arithmetic\r
+338={0} is not a valid base table of the specified view\r
+339=table {0} is referenced twice in view; use an alias to distinguish\r
+340=view {0} has more than one base table; use aliases to distinguish\r
+341=cannot add index, index root page is full.\r
+342=BLOB SUB_TYPE {0} is not defined\r
+343=Too many concurrent executions of the same request\r
+344=duplicate specification of {0} - not supported\r
+346=server version too old to support all CREATE DATABASE options\r
+347=drop database completed with errors\r
+348=procedure {0} does not return any values\r
+349=count of column list and variable list do not match\r
+350=attempt to index BLOB column in index {0}\r
+351=attempt to index array column in index {0}\r
+352=too few key columns found for index {0} (incorrect column name?)\r
+353=cannot delete\r
+354=last column in a table cannot be deleted\r
+355=sort error\r
+356=sort error: not enough memory\r
+357=too many versions\r
+358=invalid key position\r
+359=segments not allowed in expression index {0}\r
+360=sort error: corruption in data structure\r
+361=new record size of {0} bytes is too big\r
+362=Inappropriate self-reference of column\r
+363=request depth exceeded. (Recursive definition?)\r
+364=cannot access column {0} in view {1}\r
+365=dbkey not available for multi-table views\r
+366=journal file wrong format\r
+367=intermediate journal file full\r
+368=The prepare statement identifies a prepare statement with an open cursor\r
+369=Firebird error\r
+370=Cache redefined\r
+371=Insufficient memory to allocate page buffer cache\r
+372=Log redefined\r
+373=Log size too small\r
+374=Log partition size too small\r
+375=Partitions not supported in series of log file specification\r
+376=Total length of a partitioned log must be specified\r
+377=Precision must be from 1 to 18\r
+378=Scale must be between zero and precision\r
+379=Short integer expected\r
+380=Long integer expected\r
+381=Unsigned short integer expected\r
+382=Invalid ESCAPE sequence\r
+383=service {0} does not have an associated executable\r
+384=Failed to locate host machine.\r
+385=Undefined service {0}/{1}.\r
+386=The specified name was not found in the hosts file or Domain Name Services.\r
+387=user does not have GRANT privileges on base table/view for operation\r
+388=Ambiguous column reference.\r
+389=Invalid aggregate reference\r
+390=navigational stream {0} references a view with more than one base table\r
+391=Attempt to execute an unprepared dynamic SQL statement.\r
+392=Positive value expected\r
+393=Incorrect values within SQLDA structure\r
+394=invalid blob id\r
+395=Operation not supported for EXTERNAL FILE table {0}\r
+396=Service is currently busy: {0}\r
+397=stack size insufficent to execute current request\r
+398=Invalid key for find operation\r
+399=Error initializing the network software.\r
+400=Unable to load required library {0}.\r
+402=Failed to establish a connection.\r
+403=Error while listening for an incoming connection.\r
+404=Failed to establish a secondary connection for event processing.\r
+405=Error while listening for an incoming event connection request.\r
+406=Error reading data from the connection.\r
+407=Error writing data to the connection.\r
+408=Cannot deactivate index used by an Integrity Constraint\r
+409=Cannot deactivate primary index\r
+410=Client/Server Express not supported in this release\r
+412=Access to databases on file servers is not supported.\r
+413=Error while trying to create file\r
+414=Error while trying to open file\r
+415=Error while trying to close file\r
+416=Error while trying to read from file\r
+417=Error while trying to write to file\r
+418=Error while trying to delete file\r
+419=Error while trying to access file\r
+420=A fatal exception occurred during the execution of a user defined function.\r
+421=connection lost to database\r
+422=User cannot write to RDB$USER_PRIVILEGES\r
+423=token size exceeds limit\r
+424=Maximum user count exceeded.  Contact your database administrator.\r
+425=Your login {0} is same as one of the SQL role name. Ask your database administrator to set up a valid Firebird login.\r
+427=The username entered is too long.  Maximum length is 31 bytes.\r
+428=The password specified is too long.  Maximum length is 8 bytes.\r
+429=A username is required for this operation.\r
+430=A password is required for this operation\r
+431=The network protocol specified is invalid\r
+432=A duplicate user name was found in the security database\r
+433=The user name specified was not found in the security database\r
+434=An error occurred while attempting to add the user.\r
+435=An error occurred while attempting to modify the user record.\r
+436=An error occurred while attempting to delete the user record.\r
+437=An error occurred while updating the security database.\r
+438=sort record size of {0} bytes is too big\r
+439=can not define a not null column with NULL as default value\r
+440=invalid clause --- '{0}'\r
+441=too many open handles to database\r
+442=size of optimizer block exceeded\r
+443=a string constant is delimited by double quotes\r
+444=DATE must be changed to TIMESTAMP\r
+445=attempted update on read-only database\r
+446=SQL dialect {0} is not supported in this database\r
+447=A fatal exception occurred during the execution of a blob filter.\r
+448=Access violation.  The code attempted to access a virtual address without privilege to do so.\r
+449=Datatype misalignment.  The attempted to read or write a value that was not stored on a memory boundary.\r
+450=Array bounds exceeded.  The code attempted to access an array element that is out of bounds.\r
+451=Float denormal operand.  One of the floating-point operands is too small to represent a standard float value.\r
+452=Floating-point divide by zero.  The code attempted to divide a floating-point value by zero.\r
+453=Floating-point inexact result.  The result of a floating-point operation cannot be represented as a deciaml fraction.\r
+454=Floating-point invalid operand.  An indeterminant error occurred during a floating-point operation.\r
+455=Floating-point overflow.  The exponent of a floating-point operation is greater than the magnitude allowed.\r
+456=Floating-point stack check.  The stack overflowed or underflowed as the result of a floating-point operation.\r
+457=Floating-point underflow.  The exponent of a floating-point operation is less than the magnitude allowed.\r
+458=Integer divide by zero.  The code attempted to divide an integer value by an integer divisor of zero.\r
+459=Integer overflow.  The result of an integer operation caused the most significant bit of the result to carry.\r
+460=An exception occurred that does not have a description.  Exception number {0}.\r
+461=Stack overflow.  The resource requirements of the runtime stack have exceeded the memory available to it.\r
+462=Segmentation Fault. The code attempted to access memory without priviledges.\r
+463=Illegal Instruction. The Code attempted to perfrom an illegal operation.\r
+464=Bus Error. The Code caused a system bus error.\r
+465=Floating Point Error. The Code caused an Arithmetic Exception or a floating point exception.\r
+466=Cannot delete rows from external files.\r
+467=Cannot update rows in external files.\r
+468=Unable to perform operation.  You must be either SYSDBA or owner of the database\r
+469=Specified EXTRACT part does not exist in input datatype\r
+470=Service {0} requires SYSDBA permissions.  Reattach to the Service Manager using the SYSDBA account.\r
+471=The file {0} is currently in use by another process.  Try again later.\r
+472=Cannot attach to services manager\r
+473=Metadata update statement is not allowed by the current database SQL dialect {0}\r
+474=operation was cancelled\r
+475=unexpected item in service parameter block, expected {0}\r
+476=Client SQL dialect {0} does not support reference to {1} datatype\r
+477=user name and password are required while attaching to the services manager\r
+478=You created an indirect dependency on uncommitted metadata. You must roll back the current transaction.\r
+479=The service name was not specified.\r
+480=Too many Contexts of Relation/Procedure/Views. Maximum allowed is 127\r
+481=data type not supported for arithmetic\r
+482=Database dialect being changed from 3 to 1\r
+483=Database dialect not changed.\r
+484=Unable to create database {0}\r
+485=Database dialect {0} is not a valid dialect.\r
+486=Valid database dialects are {0}.\r
+487=SQL warning code = {0}\r
+488=DATE data type is now called TIMESTAMP\r
+489=Function {0} is in {1}, which is not in a permitted directory for external functions.\r
+490=value exceeds the range for valid dates\r
+491=passed client dialect {0} is not a valid dialect.\r
+492=Valid client dialects are {0}.\r
+493=Unsupported field type specified in BETWEEN predicate.\r
+494=Services functionality will be supported in a later version  of the product\r
+495=GENERATOR {0}\r
+496=UDF {0}\r
+497=Invalid parameter to FIRST.  Only integers >= 0 are allowed.\r
+498=Invalid parameter to SKIP.  Only integers >= 0 are allowed.\r
+499=File exceeded maximum size of 2GB.  Add another database file or use a 64 bit I/O version of Firebird.\r
+500=Unable to find savepoint with name {0} in transaction context\r
+501=Invalid column position used in the {0} clause\r
+502=Cannot use an aggregate function in a WHERE clause, use HAVING instead\r
+503=Cannot use an aggregate function in a GROUP BY clause\r
+504=Invalid expression in the {0} (not contained in either an aggregate function or the GROUP BY clause)\r
+505=Invalid expression in the {0} (neither an aggregate function nor a part of the GROUP BY clause)\r
+506=Nested aggregate functions are not allowed\r
+507=Invalid argument in EXECUTE STATEMENT - cannot convert to string\r
+508=Wrong request type in EXECUTE STATEMENT '{0}'\r
+509=Variable type (position {0}) in EXECUTE STATEMENT '{1}' INTO does not match returned column type\r
+510=Too many recursion levels of EXECUTE STATEMENT\r
+512=data base file name ({0}) already given\r
+513=invalid switch {0}\r
+514=incompatible switch combination\r
+515=replay log pathname required\r
+516=number of page buffers for cache required\r
+517=numeric value required\r
+518=positive numeric value required\r
+519=number of transactions per sweep required\r
+521=user name required\r
+522=password required\r
+523=subsystem name\r
+525=number of seconds required\r
+526=numeric value between 0 and 32767 inclusive required\r
+527=must specify type of shutdown\r
+528=please retry, specifying an option\r
+529=please retry, giving a database name\r
+530=internal block exceeds maximum size\r
+531=corrupt pool\r
+532=virtual memory exhausted\r
+533=bad pool id\r
+534=Transaction state {0} not in valid range.\r
+535=unexpected end of input\r
+536=failed to reconnect to a transaction in database {0}\r
+537=Transaction description item unknown\r
+539=   -sql_dialect    set database dialect n\r
+540=Cannot SELECT RDB$DB_KEY from a stored procedure.\r
+541=Precision 10 to 18 changed from DOUBLE PRECISION in SQL dialect 1 to 64-bit scaled integer in SQL dialect 3\r
+542=Use of {0} expression that returns different results in dialect 1 and dialect 3\r
+543=Database SQL dialect {0} does not support reference to {1} datatype\r
+544=DB dialect {0} and client dialect {1} conflict with respect to numeric precision {2}.\r
+545=WARNING: Numeric literal {0} is interpreted as a floating-point\r
+546=value in SQL dialect 1, but as an exact numeric value in SQL dialect 3.\r
+547=WARNING: NUMERIC and DECIMAL fields with precision 10 or greater are stored\r
+548=as approximate floating-point values in SQL dialect 1, but as 64-bit\r
+549=integers in SQL dialect 3.\r
+550=Ambiguous field name between {0} and {1}\r
+551=External function should have return position between 1 and {0}\r
+552=Label {0} {1} in the current scope\r
+553=Datatypes {0} not comparable in expression {1}\r
+554=SQL role {0} does not exist\r
+555=user {0} has no grant admin option on SQL role {1}\r
+556=user {0} is not a member of SQL role {1}\r
+557={0} is not the owner of SQL role {1}\r
+558={0} is a SQL role and not a user\r
+559=user name {0} could not be used for SQL role\r
+560=SQL role {0} already exists\r
+561=keyword {0} can not be used as a SQL role name\r
+562=SQL roles are not supported in on older versions of the database.  A backup and restore of the database is required.\r
+563=Cannot rename domain {0} to {1}.  A domain with that name already exists.\r
+564=Cannot rename column {0} to {1}.  A column with that name already exists in table {2}.\r
+565=Column {0} from table {1} is referenced in {2}\r
+566=Cannot change datatype for column {0}.  Changing datatype is not supported for BLOB or ARRAY columns.\r
+567=New size specified for column {0} must be at least {1} characters.\r
+568=Cannot change datatype for {0}.  Conversion from base type {1} to {2} is not supported.\r
+569=Cannot change datatype for column {0} from a character type to a non-character type.\r
+570=Zero length identifiers are not allowed\r
+571=found unknown switch\r
+572=page size parameter missing\r
+573=Page size specified ({0}) greater than limit (8192 bytes)\r
+574=redirect location for output is not specified\r
+575=conflicting switches for backup/restore\r
+576=device type {0} not known\r
+577=protection is not there yet\r
+578=page size is allowed only on restore or create\r
+579=multiple sources or destinations specified\r
+580=requires both input and output filenames\r
+581=input and output have the same name.  Disallowed.\r
+583=REPLACE specified, but the first file {0} is a database\r
+584=database {0} already exists.  To replace it, use the -R switch\r
+585=device type not specified\r
+586=gds_$blob_info failed\r
+587=do not understand BLOB INFO item {0}\r
+588=gds_$get_segment failed\r
+589=gds_$close_blob failed\r
+590=gds_$open_blob failed\r
+591=Failed in put_blr_gen_id\r
+592=data type {0} not understood\r
+593=gds_$compile_request failed\r
+594=gds_$start_request failed\r
+595= gds_$receive failed\r
+596=gds_$release_request failed\r
+597= gds_$database_info failed\r
+598=Expected database description record\r
+599=failed to create database {0}\r
+600=RESTORE: decompression length error\r
+601=cannot find table {0}\r
+602=Cannot find column for BLOB\r
+603=gds_$create_blob failed\r
+604=gds_$put_segment failed\r
+605=expected record length\r
+606=wrong length record, expected {0} encountered {1}\r
+607=expected data attribute\r
+608=Failed in store_blr_gen_id\r
+609=do not recognize record type {0}\r
+610=Expected backup version 1, 2, or 3.  Found {0}\r
+611=expected backup description record\r
+612=string truncated\r
+613= warning -- record could not be restored\r
+614=gds_$send failed\r
+615=no table name for data\r
+616=unexpected end of file on backup file\r
+617=database format {0} is too old to restore to\r
+618=array dimension for column {0} is invalid\r
+619=Expected XDR record length\r
+620=cannot open backup file {0}\r
+621=cannot open status and error output file {0}\r
+622=blocking factor parameter missing\r
+624=a blocking factor may not be used in conjunction with device CT\r
+625=user name parameter missing\r
+626=password parameter missing\r
+627= missing parameter for the number of bytes to be skipped\r
+629=Bad attribute for RDB$CHARACTER_SETS\r
+630=Bad attribute for RDB$COLLATIONS\r
+631=Unexpected I/O error while reading from backup file\r
+632=Unexpected I/O error while writing to backup file\r
+633=could not drop database {0} (database might be in use)\r
+634=System memory exhausted\r
+635=Bad attributes for restoring SQL role\r
+636=SQL role parameter missing\r
+637=page buffers parameter missing\r
+639=page buffers is allowed only on restore or create\r
+640=size specification either missing or incorrect for file {0}\r
+641=file {0} out of sequence\r
+642=can't join -- one of the files missing\r
+643= standard input is not supported when using join operation\r
+644=standard output is not supported when using split operation\r
+645=backup file {0} might be corrupt\r
+646=database file specification missing\r
+647=can't write a header record to file {0}\r
+648=free disk space exhausted\r
+649=file size given ({0}) is less than minimum allowed ({1})\r
+650=service name parameter missing\r
+651=Cannot restore over current database, must be SYSDBA or owner of the existing database.\r
+653=just data ignore all constraints etc.\r
+654=restoring data only ignoring foreign key, unique, not null & other constraints\r
+655=unable to open database\r
+656=error in switch specifications\r
+657=no operation specified\r
+658=no user name specified\r
+659=add record error\r
+660=modify record error\r
+661=find/modify record error\r
+662=record not found for user: {0}\r
+663=delete record error\r
+664=find/delete record error\r
+665=find/display record error\r
+666=invalid parameter, no switch defined\r
+667=operation already specified\r
+668=password already specified\r
+669=uid already specified\r
+670=gid already specified\r
+671=project already specified\r
+672=organization already specified\r
+673=first name already specified\r
+674=middle name already specified\r
+675=last name already specified\r
+676=invalid switch specified\r
+677=ambiguous switch specified\r
+678=no operation specified for parameters\r
+679=no parameters allowed for this operation\r
+680=incompatible switches specified\r
+681=Invalid user name (maximum 31 bytes allowed)\r
+682=Warning - maximum 8 significant bytes of password used\r
+683=database already specified\r
+684=database administrator name already specified\r
+685=database administrator password already specified\r
+686=SQL role name already specified\r
+687=The license file does not exist or could not be opened for read\r
+688=operation already specified\r
+689=no operation specified\r
+690=invalid switch\r
+691=invalid switch combination\r
+692=illegal operation/switch combination\r
+693=ambiguous switch\r
+694=invalid parameter, no switch specified\r
+695=switch does not take any parameter\r
+696=switch requires a parameter\r
+697=syntax error in command line\r
+698=The certificate was not added.  A duplicate ID exists in the license file.\r
+699=The certificate was not added.  Invalid certificate ID / Key combination.\r
+700=The certificate was not removed.  The key does not exist or corresponds to a temporary evaluation license.\r
+701=An error occurred updating the license file.  Operation cancelled.\r
+702=The certificate could not be validated based on the information given.  Please recheck the ID and key information.\r
+703=Operation failed.  An unknown error occurred.\r
+704=Add license operation failed, KEY: {0} ID: {1}\r
+705=Remove license operation failed, KEY: {0}\r
+706=The evaluation license has already been used on this server.  You need to purchase a non-evaluation license.\r
+707=found unknown switch\r
+708=please retry, giving a database name\r
+709=Wrong ODS version, expected {0}, encountered {1}\r
+710=Unexpected end of database file.\r
+711=Can't open database file {0}\r
+712=Can't read a database page\r
+713=System memory exhausted
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ServiceParameterBuffer.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ServiceParameterBuffer.cs
new file mode 100644 (file)
index 0000000..6a35777
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class ServiceParameterBuffer : ParameterBuffer
+       {
+               #region Constructors
+                               
+               public ServiceParameterBuffer() : base(true)
+               {
+               }
+
+               #endregion
+               
+               #region Methods
+
+               public void     Append(int type, byte value)
+               {                                               
+                       this.WriteByte(type);
+                       this.WriteByte(value);
+               }
+
+               public void     Append(int type, int value)
+               {                                               
+                       this.WriteByte(type);
+                       this.Write(value);                      
+               }
+
+               public void     Append(int type, string value)
+               {
+                       this.Append(type, Encoding.Default.GetBytes(value));
+               }
+
+               public void     Append(byte     type, string value)
+               {
+                       this.Append(type, Encoding.Default.GetBytes(value));
+               }
+
+               public void     Append(int type, byte[] value)
+               {
+                       this.WriteByte((byte)type);
+                       this.Write((short)value.Length);
+                       this.Write(value);
+               }
+
+               public void     Append(byte     type, byte[] value)
+               {
+                       this.WriteByte(type);
+                       this.WriteByte((byte)value.Length);
+                       this.Write(value);
+               }
+                               
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/StatementBase.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/StatementBase.cs
new file mode 100644 (file)
index 0000000..de6eb13
--- /dev/null
@@ -0,0 +1,411 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Text;
+using System.Data;
+
+namespace FirebirdSql.Data.Common
+{
+       #region Enumerations
+
+       internal enum StatementState
+       {
+               Deallocated,
+               Allocated,
+               Prepared,
+               Executed,
+               Closed,
+               Error
+       }
+
+       #endregion
+
+       internal abstract class StatementBase : IDisposable
+       {
+               #region Protected Static Fields
+
+               // Plan information     items
+               protected static byte[] DescribePlanInfoItems = new     byte[] 
+               { 
+                       IscCodes.isc_info_sql_get_plan
+               };
+
+               // Records affected     items
+               protected static byte[] RecordsAffectedInfoItems = new byte[]
+               {
+                       IscCodes.isc_info_sql_records
+               };
+
+               // Describe     information     items
+               protected static byte[] DescribeInfoItems =     new     byte[] 
+               { 
+                       IscCodes.isc_info_sql_select,
+                       IscCodes.isc_info_sql_describe_vars,
+                       IscCodes.isc_info_sql_sqlda_seq,
+                       IscCodes.isc_info_sql_type,
+                       IscCodes.isc_info_sql_sub_type,
+                       IscCodes.isc_info_sql_length,
+                       IscCodes.isc_info_sql_scale,
+                       IscCodes.isc_info_sql_field,
+                       IscCodes.isc_info_sql_relation,
+                       // IscCodes.isc_info_sql_owner,
+                       IscCodes.isc_info_sql_alias,
+                       IscCodes.isc_info_sql_describe_end
+               };
+
+               protected static byte[] DescribeBindInfoItems = new     byte[] 
+               { 
+                       IscCodes.isc_info_sql_bind,
+                       IscCodes.isc_info_sql_describe_vars,
+                       IscCodes.isc_info_sql_sqlda_seq,
+                       IscCodes.isc_info_sql_type,
+                       IscCodes.isc_info_sql_sub_type,
+                       IscCodes.isc_info_sql_length,
+                       IscCodes.isc_info_sql_scale,
+                       IscCodes.isc_info_sql_field,
+                       IscCodes.isc_info_sql_relation,
+                       // IscCodes.isc_info_sql_owner,
+                       IscCodes.isc_info_sql_alias,
+                       IscCodes.isc_info_sql_describe_end 
+               };
+
+               protected static byte[] StatementTypeInfoItems = new byte[]
+               {
+                       IscCodes.isc_info_sql_stmt_type
+               };
+
+               #endregion
+
+               #region Fields
+
+               private bool disposed;
+
+               #endregion
+
+               #region Abstract Properties
+
+               public abstract IDatabase DB
+               {
+                       get;
+                       set;
+               }
+
+               public abstract ITransaction Transaction
+               {
+                       get;
+                       set;
+               }
+
+               public abstract Descriptor Parameters
+               {
+                       get;
+                       set;
+               }
+
+               public abstract Descriptor Fields
+               {
+                       get;
+               }
+
+               public abstract int     RecordsAffected
+               {
+                       get;
+               }
+
+               public abstract bool IsPrepared
+               {
+                       get;
+               }
+
+               public abstract DbStatementType StatementType
+               {
+                       get;
+                       set;
+               }
+
+               public abstract StatementState State
+               {
+                       get;
+                       set;
+               }
+
+               public abstract int     FetchSize
+               {
+                       get;
+                       set;
+               }
+
+               #endregion
+
+               #region Protected Properties
+
+               protected bool IsDisposed
+               {
+                       get     { return this.disposed; }
+               }
+
+               #endregion
+
+               #region Protected Fields
+
+               protected TransactionUpdateEventHandler TransactionUpdate;
+
+               #endregion
+
+               #region Abstract Methods
+
+               public abstract void Describe();
+               public abstract void DescribeParameters();
+               public abstract void Prepare(string     commandText);
+               public abstract void Execute();
+               public abstract DbValue[] Fetch();
+               public abstract DbValue[] GetOuputParameters();
+               public abstract byte[] GetSqlInfo(byte[] items, int     bufferLength);
+
+               public abstract BlobBase CreateBlob();
+               public abstract BlobBase CreateBlob(long handle);
+
+               public abstract ArrayBase CreateArray(ArrayDesc descriptor);
+               public abstract ArrayBase CreateArray(string tableName, string fieldName);
+               public abstract ArrayBase CreateArray(long handle, string tableName, string     fieldName);
+
+               #endregion
+
+               #region Finalizer
+
+               ~StatementBase()
+               {
+                       this.Dispose(false);
+               }
+
+               #endregion
+
+               #region IDisposable     methods
+
+               public void     Dispose()
+               {
+                       this.Dispose(true);
+                       GC.SuppressFinalize(this);
+               }
+
+               protected virtual void Dispose(bool     disposing)
+               {
+                       lock (this)
+                       {
+                               if (!this.disposed)
+                               {
+                                       this.disposed = true;
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Protected Abstract Methods
+
+               protected abstract void TransactionUpdated(object sender, EventArgs     e);
+               protected abstract void Free(int option);
+
+               #endregion
+
+               #region Methods
+
+               public string GetExecutionPlan()
+               {
+                       string  plan            = String.Empty;
+                       int             count           = 0;
+                       int             bufferSize      = IscCodes.MAX_BUFFER_SIZE;
+                       byte[]  buffer          = this.GetSqlInfo(DescribePlanInfoItems, bufferSize);
+
+                       while (buffer[0] ==     IscCodes.isc_info_truncated     && count < 4)
+                       {
+                               bufferSize *= 2;
+                               buffer = this.GetSqlInfo(DescribePlanInfoItems, bufferSize);
+                               count++;
+                       }
+
+                       if (count >     3)
+                       {
+                               return null;
+                       }
+
+                       int     len     = buffer[1];
+                       len     += buffer[2] << 8;
+
+                       if (len > 0)
+                       {
+                               plan = this.DB.Charset.GetString(buffer, 4,     --len);
+                       }
+
+                       return plan;
+               }
+
+               public virtual void     Close()
+               {
+                       if (this.State == StatementState.Executed ||
+                               this.State == StatementState.Error)
+                       {
+                               if (this.StatementType == DbStatementType.Select ||
+                                       this.StatementType == DbStatementType.SelectForUpdate ||
+                                       this.StatementType == DbStatementType.StoredProcedure)
+                               {
+                                       this.Free(IscCodes.DSQL_close);
+                                       this.ClearArrayHandles();
+                                       this.State = StatementState.Closed;
+                               }
+                       }
+               }
+
+               public virtual void     Release()
+               {
+                       if (this.Transaction != null &&
+                               this.TransactionUpdate != null)
+                       {
+                               this.Transaction.Update -= this.TransactionUpdate;
+                               this.TransactionUpdate = null;
+                       }
+
+                       this.Free(IscCodes.DSQL_drop);
+
+                       this.State                      = StatementState.Deallocated;
+                       this.StatementType      = DbStatementType.None;
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected byte[] GetSqlInfo(byte[] items)
+               {
+                       return this.GetSqlInfo(items, IscCodes.MAX_BUFFER_SIZE);
+               }
+
+               protected int GetRecordsAffected()
+               {
+                       byte[] buffer = this.GetSqlInfo(RecordsAffectedInfoItems, IscCodes.ROWS_AFFECTED_BUFFER_SIZE);
+
+                       return this.ProcessRecordsAffectedBuffer(buffer);
+               }
+
+               protected int ProcessRecordsAffectedBuffer(byte[] buffer)
+               {
+                       int     insertCount     = 0;
+                       int     updateCount     = 0;
+                       int     deleteCount     = 0;
+                       int     selectCount     = 0;
+                       int     pos                     = 0;
+                       int     length          = 0;
+                       int     type            = 0;
+
+                       while ((type = buffer[pos++]) != IscCodes.isc_info_end)
+                       {
+                               length = IscHelper.VaxInteger(buffer, pos, 2);
+                               pos     += 2;
+                               switch (type)
+                               {
+                                       case IscCodes.isc_info_sql_records:
+                                               int     l;
+                                               int     t;
+                                               while ((t =     buffer[pos++]) != IscCodes.isc_info_end)
+                                               {
+                                                       l =     IscHelper.VaxInteger(buffer, pos, 2);
+                                                       pos     += 2;
+                                                       switch (t)
+                                                       {
+                                                               case IscCodes.isc_info_req_insert_count:
+                                                                       insertCount     = IscHelper.VaxInteger(
+                                                                               buffer, pos, l);
+                                                                       break;
+
+                                                               case IscCodes.isc_info_req_update_count:
+                                                                       updateCount     = IscHelper.VaxInteger(
+                                                                               buffer, pos, l);
+                                                                       break;
+
+                                                               case IscCodes.isc_info_req_delete_count:
+                                                                       deleteCount     = IscHelper.VaxInteger(
+                                                                               buffer, pos, l);
+                                                                       break;
+
+                                                               case IscCodes.isc_info_req_select_count:
+                                                                       selectCount     = IscHelper.VaxInteger(
+                                                                               buffer, pos, l);
+                                                                       break;
+                                                       }
+                                                       pos     += l;
+                                               }
+                                               break;
+
+                                       default:
+                                               pos     += length;
+                                               break;
+                               }
+                       }
+
+                       return insertCount + updateCount + deleteCount;
+               }
+
+               protected DbStatementType GetStatementType()
+               {
+                       byte[] buffer = this.GetSqlInfo(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE);
+
+                       return this.ParseStatementTypeInfo(buffer);
+               }
+
+               protected DbStatementType ParseStatementTypeInfo(byte[] buffer)
+               {
+                       DbStatementType stmtType = DbStatementType.None;
+                       int     pos     = 0;
+                       int     length = 0;
+                       int     type = 0;
+
+                       while ((type = buffer[pos++]) != IscCodes.isc_info_end)
+                       {
+                               length = IscHelper.VaxInteger(buffer, pos, 2);
+                               pos     += 2;
+                               switch (type)
+                               {
+                                       case IscCodes.isc_info_sql_stmt_type:
+                                               stmtType = (DbStatementType)IscHelper.VaxInteger(buffer, pos, length);
+                                               pos     += length;
+                                               break;
+
+                                       default:
+                                               pos     += length;
+                                               break;
+                               }
+                       }
+
+                       return stmtType;
+               }
+
+               protected void ClearArrayHandles()
+               {
+                       if (this.Fields != null && this.Fields.Count > 0)
+                       {
+                               for     (int i = 0;     i <     this.Fields.Count; i++)
+                               {
+                                       this.Fields[i].ArrayHandle = null;
+                               }
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/StringCollection.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/StringCollection.cs
new file mode 100644 (file)
index 0000000..a12f899
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+#if    (NETCF)
+
+using System;
+using System.Collections;
+
+namespace System.Collections.Specialized
+{
+       public class StringCollection : CollectionBase
+       {
+               #region Indexers
+
+               public string this[int index]
+               {
+                       get     { return ((string)base.List[index]); }
+                       set     { base.List[index] = value;     }
+               }
+
+               #endregion
+
+               #region Methods
+
+               public int Add(string value)
+               {
+                       return (base.List.Add(value));
+               }
+
+               public void     CopyTo(string[] array, int index)
+               {
+                       if (array == null)
+                       {
+                               throw new ArgumentNullException("array is null.");
+                       }
+                       if (index <     0)
+                       {
+                               throw new ArgumentOutOfRangeException("index is less than zero.");
+                       }
+                       if (array.Rank > 1)
+                       {
+                               throw new ArgumentException("array is multidimensional.");
+                       }
+                       if (index >= array.Length)
+                       {
+                               throw new ArgumentException("index is equal     to or greater than the length of array.");
+                       }
+                       if ((array.Length -     index) < this.List.Count)
+                       {
+                               throw new ArgumentException("The number of elements     in the source StringCollection is greater than the available space from index to the end of     the     destination     array.");
+                       }
+
+                       foreach (string value in this.List)
+                       {
+                               if (index <     array.Length)
+                               {
+                                       array[index++] = value;
+                               }
+                       }
+               }
+
+               public int IndexOf(string value)
+               {
+                       return (base.List.IndexOf(value));
+               }
+
+               public void     Insert(int index, string value)
+               {
+                       base.List.Insert(index, value);
+               }
+
+               public void     Remove(string value)
+               {
+                       base.List.Remove(value);
+               }
+
+               public bool     Contains(string value)
+               {
+                       // If value     is not of type String, this     will return     false.
+                       return (base.List.Contains(value));
+               }
+
+               #endregion
+
+               #region Protected MEthods
+                        
+               protected override void OnValidate(Object value)
+               {
+                       if (value.GetType()     != Type.GetType("System.String"))
+                       {
+                               throw new ArgumentException("value must be of type String.", "value");
+                       }
+               }
+
+               #endregion
+       }
+}
+
+#endif
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TransactionParameterBuffer.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TransactionParameterBuffer.cs
new file mode 100644 (file)
index 0000000..950afa3
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+
+using System;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class TransactionParameterBuffer : ParameterBuffer
+       {
+               #region Constructors
+
+               public TransactionParameterBuffer()     : base()
+               {
+               }
+
+               public TransactionParameterBuffer(bool isLittleEndian) : base(isLittleEndian)
+               {
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeDecoder.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeDecoder.cs
new file mode 100644 (file)
index 0000000..b924df3
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class TypeDecoder
+       {
+               #region Constructors
+
+               private TypeDecoder()
+               {
+               }
+
+               #endregion
+
+               #region Static Methods
+
+               public static decimal DecodeDecimal(object value, int scale, int sqltype)
+               {
+                       long divisor = 1;
+                       decimal returnValue     = Convert.ToDecimal(value, CultureInfo.InvariantCulture);
+
+                       if (scale <     0)
+                       {
+                               divisor = (long)System.Math.Pow(10,     scale * (-1));
+                       }
+
+                       switch (sqltype & ~1)
+                       {
+                               case IscCodes.SQL_SHORT:
+                               case IscCodes.SQL_LONG:
+                               case IscCodes.SQL_QUAD:
+                               case IscCodes.SQL_INT64:
+                                       returnValue     = returnValue / divisor;
+                                       break;
+                       }
+
+                       return returnValue;
+               }
+
+               public static DateTime DecodeTime(int sql_time)
+               {
+                       GregorianCalendar calendar = new GregorianCalendar();
+
+                       int     millisInDay     = sql_time / 10;
+                       int     hour            = millisInDay / 3600000;
+                       int     minute          = (millisInDay - hour * 3600000) / 60000;
+                       int     second          = (millisInDay - hour * 3600000 - minute * 60000) /     1000;
+                       int     millisecond     = millisInDay - hour * 3600000 - minute * 60000 - second * 1000;
+
+                       return new DateTime(1970, 1, 1, hour, minute, second, millisecond, calendar);
+               }
+
+               public static DateTime DecodeDate(int sql_date)
+               {
+                       int     year, month, day, century;
+
+                       sql_date        -= 1721119 - 2400001;
+                       century         = (4 * sql_date - 1) / 146097;
+                       sql_date        = 4     * sql_date - 1 - 146097 * century;
+                       day                     = sql_date / 4;
+
+                       sql_date        = (4 * day + 3) / 1461;
+                       day                     = 4     * day + 3 -     1461 * sql_date;
+                       day                     = (day + 4)     / 4;
+
+                       month           =       (5 * day - 3) / 153;
+                       day                     = 5     * day - 3 -     153     * month;
+                       day                     = (day + 5)     / 5;
+
+                       year            = 100 * century + sql_date;
+
+                       if (month <     10)
+                       {
+                               month   += 3;
+                       }
+                       else
+                       {
+                               month   -= 9;
+                               year    += 1;
+                       }
+
+                       DateTime date = new     System.DateTime(year, month, day);
+
+                       return date.Date;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeEncoder.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeEncoder.cs
new file mode 100644 (file)
index 0000000..66bf1ed
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class TypeEncoder
+       {
+               #region Constructors
+
+               private TypeEncoder()
+               {
+               }
+
+               #endregion
+
+               #region Static Methods
+
+               public static object EncodeDecimal(decimal d, int scale, int sqltype)
+               {
+                       long multiplier = 1;
+
+                       if (scale < 0)
+                       {
+                               multiplier = (long)System.Math.Pow(10, scale * (-1));
+                       }
+
+                       switch (sqltype & ~1)
+                       {
+                               case IscCodes.SQL_SHORT:
+                                       return (short)(d * multiplier);
+
+                               case IscCodes.SQL_LONG:
+                                       return (int)(d * multiplier);
+
+                               case IscCodes.SQL_QUAD:
+                               case IscCodes.SQL_INT64:
+                                       return (long)(d * multiplier);
+
+                               case IscCodes.SQL_DOUBLE:
+                               default:
+                                       return d;
+                       }
+               }
+
+               public static int EncodeTime(DateTime d)
+               {
+                       GregorianCalendar calendar = new GregorianCalendar();
+
+                       int millisInDay =
+                               (int)(calendar.GetHour(d) * 3600000 +
+                               calendar.GetMinute(d) * 60000 +
+                               calendar.GetSecond(d) * 1000 +
+                               calendar.GetMilliseconds(d)) * 10;
+
+                       return millisInDay;
+               }
+
+               public static int EncodeDate(DateTime d)
+               {
+                       int day, month, year;
+                       int c, ya;
+
+                       GregorianCalendar calendar = new GregorianCalendar();
+
+                       day = calendar.GetDayOfMonth(d);
+                       month = calendar.GetMonth(d);
+                       year = calendar.GetYear(d);
+
+                       if (month > 2)
+                       {
+                               month -= 3;
+                       }
+                       else
+                       {
+                               month += 9;
+                               year -= 1;
+                       }
+
+                       c = year / 100;
+                       ya = year - 100 * c;
+
+                       return ((146097 * c) / 4 +
+                               (1461 * ya) / 4 +
+                               (153 * month + 2) / 5 +
+                               day + 1721119 - 2400001);
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeHelper.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeHelper.cs
new file mode 100644 (file)
index 0000000..1782c91
--- /dev/null
@@ -0,0 +1,433 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+
+namespace FirebirdSql.Data.Common
+{
+       internal sealed class TypeHelper
+       {
+               #region Constructors
+
+               private TypeHelper()
+               {
+               }
+
+               #endregion
+
+               #region Static Methods
+
+               public static short     GetSize(DbDataType dataType)
+               {
+                       switch (dataType)
+                       {
+                               case DbDataType.Array:
+                               case DbDataType.Binary:
+                               case DbDataType.Text:
+                                       return 8;
+
+                               case DbDataType.SmallInt:
+                                       return 2;
+
+                               case DbDataType.Integer:
+                               case DbDataType.Float:
+                               case DbDataType.Date:
+                               case DbDataType.Time:
+                                       return 4;
+
+                               case DbDataType.BigInt:
+                               case DbDataType.Double:
+                               case DbDataType.TimeStamp:
+                                       return 8;
+
+                               case DbDataType.Guid:
+                                       return 16;
+
+                               default:
+                                       return 0;
+                       }
+               }
+
+               public static int GetFbType(DbDataType dataType, bool isNullable)
+               {
+                       int     sqltype = 0;
+
+                       switch (dataType)
+                       {
+                               case DbDataType.Array:
+                                       sqltype = IscCodes.SQL_ARRAY;
+                                       break;
+
+                               case DbDataType.Binary:
+                               case DbDataType.Text:
+                                       sqltype = IscCodes.SQL_BLOB;
+                                       break;
+
+                               case DbDataType.Char:
+                                       sqltype = IscCodes.SQL_TEXT;
+                                       break;
+
+                               case DbDataType.VarChar:
+                                       sqltype = IscCodes.SQL_VARYING;
+                                       break;
+
+                               case DbDataType.SmallInt:
+                                       sqltype = IscCodes.SQL_SHORT;
+                                       break;
+
+                               case DbDataType.Integer:
+                                       sqltype = IscCodes.SQL_LONG;
+                                       break;
+
+                               case DbDataType.BigInt:
+                                       sqltype = IscCodes.SQL_INT64;
+                                       break;
+
+                               case DbDataType.Float:
+                                       sqltype = IscCodes.SQL_FLOAT;
+                                       break;
+
+                               case DbDataType.Guid:
+                                       sqltype = IscCodes.SQL_TEXT;
+                                       break;
+
+                               case DbDataType.Double:
+                                       sqltype = IscCodes.SQL_DOUBLE;
+                                       break;
+
+                               case DbDataType.Date:
+                                       sqltype = IscCodes.SQL_TYPE_DATE;
+                                       break;
+
+                               case DbDataType.Time:
+                                       sqltype = IscCodes.SQL_TYPE_TIME;
+                                       break;
+
+                               case DbDataType.TimeStamp:
+                                       sqltype = IscCodes.SQL_TIMESTAMP;
+                                       break;
+                               
+                               default:
+                                       throw new ArgumentException("Invalid data type");
+                       }
+
+                       if (isNullable)
+                       {
+                               sqltype++;
+                       }
+
+                       return sqltype;
+               }
+
+               public static int GetFbType(int blrType)
+               {
+                       switch (blrType)
+                       {
+                               case IscCodes.blr_varying:
+                               case IscCodes.blr_varying2:
+                                       return IscCodes.SQL_VARYING;
+
+                               case IscCodes.blr_text:
+                               case IscCodes.blr_text2:
+                               case IscCodes.blr_cstring:
+                               case IscCodes.blr_cstring2:
+                                       return IscCodes.SQL_TEXT;
+
+                               case IscCodes.blr_short:
+                                       return IscCodes.SQL_SHORT;
+
+                               case IscCodes.blr_long:
+                                       return IscCodes.SQL_LONG;
+
+                               case IscCodes.blr_quad:
+                                       return IscCodes.SQL_QUAD;
+
+                               case IscCodes.blr_int64:
+                               case IscCodes.blr_blob_id:
+                                       return IscCodes.SQL_INT64;
+
+                               case IscCodes.blr_double:
+                                       return IscCodes.SQL_DOUBLE;
+
+                               case IscCodes.blr_d_float:
+                                       return IscCodes.SQL_D_FLOAT;
+
+                               case IscCodes.blr_float:
+                                       return IscCodes.SQL_FLOAT;
+
+                               case IscCodes.blr_sql_date:
+                                       return IscCodes.SQL_TYPE_DATE;
+
+                               case IscCodes.blr_sql_time:
+                                       return IscCodes.SQL_TYPE_TIME;
+
+                               case IscCodes.blr_timestamp:
+                                       return IscCodes.SQL_TIMESTAMP;
+                               
+                               case IscCodes.blr_blob:
+                                       return IscCodes.SQL_BLOB;
+
+                               default:
+                                       throw new ArgumentException("Invalid data type");
+                       }
+               }
+
+               public static DbDataType GetDbDataType(int blrType,     int     subType, int scale)
+               {
+                       switch (blrType)
+                       {
+                               case IscCodes.blr_varying:
+                               case IscCodes.blr_varying2:
+                                       return DbDataType.VarChar;
+
+                               case IscCodes.blr_text:
+                               case IscCodes.blr_text2:
+                                       return DbDataType.Char;
+
+                               case IscCodes.blr_cstring:
+                               case IscCodes.blr_cstring2:
+                                       return DbDataType.Text;
+
+                               case IscCodes.blr_short:
+                                       if (scale <     0)
+                                       {
+                                               return DbDataType.Decimal;
+                                       }
+                                       else
+                                       {
+                                               return DbDataType.SmallInt;
+                                       }                                       
+
+                               case IscCodes.blr_long:
+                                       if (scale <     0)
+                                       {
+                                               return DbDataType.Decimal;
+                                       }
+                                       else
+                                       {
+                                               return DbDataType.Integer;
+                                       }
+
+                               case IscCodes.blr_quad:
+                               case IscCodes.blr_int64:
+                               case IscCodes.blr_blob_id:
+                                       if (scale <     0)
+                                       {
+                                               return DbDataType.Decimal;
+                                       }
+                                       else
+                                       {
+                                               return DbDataType.BigInt;
+                                       }
+
+                               case IscCodes.blr_double:
+                               case IscCodes.blr_d_float:
+                                       return DbDataType.Double;
+
+                               case IscCodes.blr_float:
+                                       return DbDataType.Float;
+
+                               case IscCodes.blr_sql_date:
+                                       return DbDataType.Date;
+
+                               case IscCodes.blr_sql_time:
+                                       return DbDataType.Time;
+
+                               case IscCodes.blr_timestamp:
+                                       return DbDataType.TimeStamp;                    
+
+                               case IscCodes.blr_blob:
+                                       if (subType     == 1)
+                                       {
+                                               return DbDataType.Text;
+                                       }
+                                       else
+                                       {
+                                               return DbDataType.Binary;
+                                       }
+
+                               default:
+                                       throw new ArgumentException("Invalid data type");
+                       }
+               }
+
+               public static string GetDataTypeName(DbDataType dataType)
+               {                        
+                       switch (dataType)
+                       {
+                               case DbDataType.Array:
+                                       return "ARRAY";
+                               
+                               case DbDataType.Binary:
+                                       return "BLOB";
+
+                               case DbDataType.Text:
+                                       return "BLOB SUB_TYPE 1";
+
+                               case DbDataType.Char:
+                               case DbDataType.Guid:
+                                       return "CHAR";
+
+                               case DbDataType.VarChar:
+                                       return "VARCHAR";
+                               
+                               case DbDataType.SmallInt:
+                                       return "SMALLINT";
+
+                               case DbDataType.Integer:
+                                       return "INTEGER";
+                               
+                               case DbDataType.Float:
+                                       return "FLOAT";
+                               
+                               case DbDataType.Double:
+                                       return "DOUBLE PRECISION";
+                                                               
+                               case DbDataType.BigInt:
+                                       return "BIGINT";
+
+                               case DbDataType.Numeric:
+                                       return "NUMERIC";
+
+                               case DbDataType.Decimal:
+                                       return "DECIMAL";
+
+                               case DbDataType.Date:
+                                       return "DATE";
+
+                               case DbDataType.Time:
+                                       return "TIME";
+                               
+                               case DbDataType.TimeStamp:
+                                       return "TIMESTAMP";
+
+                               default:
+                                       return null;
+                       }
+               }
+
+               public static DbType GetDbType(DbDataType type)
+               {
+                       switch (type)
+                       {
+                               case DbDataType.Array:
+                               case DbDataType.Binary:
+                                       return DbType.Binary;
+
+                               case DbDataType.Text:
+                               case DbDataType.VarChar:
+                               case DbDataType.Char:
+                                       return DbType.String;
+
+                               case DbDataType.SmallInt:
+                                       return DbType.Int16;
+
+                               case DbDataType.Integer:
+                                       return DbType.Int32;
+
+                               case DbDataType.BigInt:
+                                       return DbType.Int64;
+
+                               case DbDataType.Date:
+                                       return DbType.Date;
+
+                               case DbDataType.Time:
+                                       return DbType.Time;
+
+                               case DbDataType.TimeStamp:
+                                       return DbType.DateTime;
+
+                               case DbDataType.Numeric:
+                               case DbDataType.Decimal:
+                                       return DbType.Decimal;
+
+                               case DbDataType.Float:
+                                       return DbType.Single;
+
+                               case DbDataType.Double:
+                                       return DbType.Double;
+
+                               case DbDataType.Guid:
+                                       return DbType.Guid;
+
+                               default:
+                                       throw new ArgumentException("Invalid data type");
+                       }
+               }
+
+               public static DbDataType GetDbDataType(DbType dbType)
+               {
+                       switch (dbType)
+                       {
+                               case DbType.String:
+                               case DbType.AnsiString:
+                                       return DbDataType.VarChar;
+
+                               case DbType.StringFixedLength:
+                               case DbType.AnsiStringFixedLength:
+                                       return DbDataType.Char;
+
+                               case DbType.Boolean:
+                               case DbType.Byte:
+                               case DbType.SByte:
+                               case DbType.Int16:
+                               case DbType.UInt16:
+                                       return DbDataType.SmallInt;
+
+                               case DbType.Int32:
+                               case DbType.UInt32:
+                                       return DbDataType.Integer;
+
+                               case DbType.Int64:
+                               case DbType.UInt64:
+                                       return DbDataType.BigInt;
+
+                               case DbType.Date:
+                                       return DbDataType.Date;
+
+                               case DbType.Time:
+                                       return DbDataType.Time;
+
+                               case DbType.DateTime:
+                                       return DbDataType.TimeStamp;
+
+                               case DbType.Object:
+                               case DbType.Binary:
+                                       return DbDataType.Binary;
+
+                               case DbType.Decimal:
+                                       return DbDataType.Decimal;
+
+                               case DbType.Double:
+                                       return DbDataType.Double;
+
+                               case DbType.Single:
+                                       return DbDataType.Float;
+
+                               case DbType.Guid:
+                                       return DbDataType.Guid;
+
+                               default:
+                                       throw new ArgumentException("Invalid data type");
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/ArrayDescMarshal.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/ArrayDescMarshal.cs
new file mode 100644 (file)
index 0000000..3837024
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Embedded
+{
+       #region Structures
+
+       [StructLayout(LayoutKind.Sequential)]
+       internal struct ArrayDescMarshal
+       {
+               public byte             DataType;
+               public byte             Scale;
+               public short    Length;
+               [MarshalAs(UnmanagedType.ByValTStr,     SizeConst=32)]
+               public string   FieldName;
+               [MarshalAs(UnmanagedType.ByValTStr,     SizeConst=32)] 
+               public string   RelationName;
+               public short    Dimensions;
+               public short    Flags;
+
+               #region Static Methods
+
+               public static int ComputeLength(int     n)
+               {
+                       return (Marshal.SizeOf(typeof(ArrayDescMarshal)) + n * Marshal.SizeOf(typeof(ArrayBoundMarshal)));
+               }
+
+               #endregion
+       }
+
+       [StructLayout(LayoutKind.Sequential)]
+       internal struct ArrayBoundMarshal
+       {
+               public short LowerBound;
+               public short UpperBound;
+       }
+
+       #endregion
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/ArrayDescMarshaler.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/ArrayDescMarshaler.cs
new file mode 100644 (file)
index 0000000..3d63250
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Embedded
+{
+       internal class ArrayDescMarshaler
+       {
+               #region Static Fields
+
+               private static ArrayDescMarshaler instance;
+
+               #endregion
+
+               #region Constructors
+
+               private ArrayDescMarshaler()
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public static ArrayDescMarshaler GetInstance()
+               {
+                       if (ArrayDescMarshaler.instance == null)
+                       {
+                               ArrayDescMarshaler.instance     = new ArrayDescMarshaler();
+                       }
+
+                       return ArrayDescMarshaler.instance;
+               }
+
+               public void     CleanUpNativeData(ref IntPtr pNativeData)
+               {
+                       if (pNativeData != IntPtr.Zero)
+                       {
+                               // Destroy ArrayDescMarshal     structure
+                               Marshal.DestroyStructure(pNativeData, typeof(ArrayDescMarshal));
+
+                               // Destroy ArrayBound structures
+                               for     (int i = 0;     i <     16;     i++)
+                               {
+                                       Marshal.DestroyStructure(
+                                               (IntPtr)(pNativeData.ToInt32() + ArrayDescMarshal.ComputeLength(i)),
+                                               typeof(ArrayBoundMarshal));
+                               }
+
+                               // Free pointer memory
+                               Marshal.FreeHGlobal(pNativeData);
+
+                               pNativeData     = IntPtr.Zero;
+                       }
+               }
+
+               public IntPtr MarshalManagedToNative(ArrayDesc descriptor)
+               {
+                       ArrayDescMarshal arrayDesc = new ArrayDescMarshal();
+                       
+                       arrayDesc.DataType              = descriptor.DataType;
+                       arrayDesc.Scale                 = (byte)descriptor.Scale;
+                       arrayDesc.Length                = descriptor.Length;
+                       arrayDesc.FieldName             = descriptor.FieldName;         
+                       arrayDesc.RelationName  = descriptor.RelationName;
+                       arrayDesc.Dimensions    = descriptor.Dimensions;
+                       arrayDesc.Flags                 = descriptor.Flags;
+
+                       ArrayBoundMarshal[]     arrayBounds     = new ArrayBoundMarshal[descriptor.Bounds.Length];
+
+                       for     (int i = 0;     i <     descriptor.Dimensions; i++)
+                       {
+                               arrayBounds[i].LowerBound =     
+                                       (short)descriptor.Bounds[i].LowerBound;
+                               arrayBounds[i].UpperBound =     
+                                       (short)descriptor.Bounds[i].UpperBound;
+                       }
+
+                       return this.MarshalManagedToNative(arrayDesc, arrayBounds);
+               }
+
+               public IntPtr MarshalManagedToNative(
+                       ArrayDescMarshal        arrayDesc,
+                       ArrayBoundMarshal[]     arrayBounds)
+               {
+                       int             size    = ArrayDescMarshal.ComputeLength(arrayBounds.Length);
+                       IntPtr  ptr             = Marshal.AllocHGlobal(size);
+
+                       Marshal.StructureToPtr(arrayDesc, ptr, true);
+                       for     (int i = 0;     i <     arrayBounds.Length;     i++)
+                       {
+                               Marshal.StructureToPtr(
+                                       arrayBounds[i],
+                                       (IntPtr)(ptr.ToInt32() + ArrayDescMarshal.ComputeLength(i)),
+                                       true);
+                       }
+
+                       return ptr;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FbClient.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FbClient.cs
new file mode 100644 (file)
index 0000000..d491170
--- /dev/null
@@ -0,0 +1,468 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Security;
+
+namespace FirebirdSql.Data.Embedded
+{
+       [SuppressUnmanagedCodeSecurity]
+       internal sealed class FbClient
+       {
+               #region Conditional     directives
+
+#if    (LINUX)
+       #if     (FBCLIENT)
+               public const string     DllPath = "libfbclient";
+       #elif (GDS32)
+               public const string     DllPath = "libgds";
+       #elif (VULCAN)
+               public const string     DllPath = "libfirebird32";
+       #elif (FYRACLE)
+               public const string     DllPath = "fyracle";
+       #else
+               public const string     DllPath = "libfbembed";
+       #endif
+#else
+       #if     (FBCLIENT)
+               public const string     DllPath = "fbclient";
+       #elif (GDS32)
+               public const string     DllPath = "gds32";
+       #elif (VULCAN)
+               public const string     DllPath = "firebird32";
+       #elif (FYRACLE)
+               public const string     DllPath = "fyracle";
+       #else
+               public const string     DllPath = "fbembed";
+       #endif
+#endif
+               
+               #endregion
+
+               #region Constructors
+
+               private FbClient()
+               {
+               }
+
+               #endregion
+
+               #region Array Functions
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_array_get_slice(
+                       [In, Out] int[] statusVector,
+                       ref     int             dbHandle,
+                       ref     int             trHandle,
+                       ref     long    arrayId,
+                       IntPtr          desc,
+                       byte[]          destArray,
+                       ref     int             sliceLength);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_array_lookup_bounds(
+                       [In, Out] int[] statusVector,
+                       ref     int             dbHandle,
+                       ref     int             trHandle,
+                       string          tableName,
+                       string          columnName,
+                       IntPtr          desc);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_array_lookup_desc(
+                       [In, Out] int[] statusVector,
+                       ref     int             dbHandle,
+                       ref     int             trHandle,
+                       string          tableName,
+                       string          columnName,
+                       IntPtr          desc);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_array_put_slice(
+                       [In, Out] int[] statusVector,
+                       ref     int             dbHandle,
+                       ref     int             trHandle,
+                       ref     long    arrayId,
+                       IntPtr          desc,
+                       byte[]          sourceArray,
+                       ref     int             sliceLength);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_array_get_slice(
+                       [In, Out] int[] statusVector,
+                       string          tableName,
+                       string          columnName,
+                       ref     short   sqlDtype,
+                       ref     short   sqlLength,
+                       ref     short   dimensions,
+                       IntPtr          desc);
+
+               #endregion
+
+               #region Blob functions
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_blob_info(
+                       [In, Out] int[] statusVector,
+                       ref     int             blobHandle,
+                       short           itemListBufferLength,
+                       byte[]          itemListBuffer,
+                       short           resultBufferLength,
+                       byte[]          resultBuffer);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_cancel_blob(
+                       [In, Out] int[] statusVector,
+                       ref     int     blobHandle);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_close_blob(
+                       [In, Out] int[] statusVector,
+                       ref     int     blobHandle);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_create_blob2(
+                       [In, Out] int[] statusVector,
+                       ref     int             dbHandle,
+                       ref     int             trHandle,
+                       ref     int             blobHandle,
+                       ref     long    blobId,
+                       short           bpbLength,
+                       byte[]          bpbAddress);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_get_segment(
+                       [In, Out] int[] statusVector,
+                       ref     int             blobHandle,
+                       ref     short   actualSegLength,
+                       short   segBufferLength,
+                       byte[]          segBuffer);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_open_blob2(
+                       [In, Out] int[] statusVector,
+                       ref     int             dbHandle,
+                       ref     int             trHandle,
+                       ref     int             blobHandle,
+                       ref     long    blobId,
+                       short           bpbLength,
+                       byte[]          bpbAddress);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_put_segment(
+                       [In, Out] int[] statusVector,
+                       ref     int     blobHandle,
+                       short   segBufferLength,
+                       byte[]  segBuffer);
+
+               #endregion
+
+               #region Database functions
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_attach_database(
+                       [In, Out] int[] statusVector,
+                       short   dbNameLength,
+                       string  dbName,
+                       ref     int     dbHandle,
+                       short   parmBufferLength,
+                       byte[]  parmBuffer);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_detach_database(
+                       [In, Out] int[] statusVector,
+                       ref     int     dbHandle);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_database_info(
+                       [In, Out] int[] statusVector,
+                       ref     int     dbHandle,
+                       short   itemListBufferLength,
+                       byte[]  itemListBuffer,
+                       short   resultBufferLength,
+                       byte[]  resultBuffer);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_create_database(
+                       [In, Out] int[] statusVector,
+                       short   dbNameLength,
+                       string  dbName,
+                       ref     int     dbHandle,
+                       short   parmBufferLength,
+                       byte[]  parmBuffer,
+                       short   dbType);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_drop_database(
+                       [In, Out] int[] statusVector,
+                       ref     int     dbHandle);
+
+               #endregion
+               
+               #region Events functions
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_event_block(
+                               ref     byte[]  event_buffer,
+                               ref     byte[]  result_buffer,
+                               short   id_count,
+                               string  eventName);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern void isc_event_counts(
+                       [In, Out] int[] statusVector,
+                       short   bufferLength,
+                       byte[]  eventBuffer,
+                       byte[]  resultBuffer);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_que_events(
+                       [In, Out] int[] statusVector,
+                       ref     int     dbHandle,
+                       ref     int     eventId,
+                       short   length,
+                       byte[]  eventBuffer,
+                       IntPtr  eventFunction,
+                       IntPtr  eventFunctionArg);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_cancel_events(
+                       [In, Out] int[] statusVector,
+                       ref     int     dbHandle,
+                       ref     int     eventId);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_wait_for_event(
+                       [In, Out] int[] statusVector,
+                       ref     int     dbHandle,
+                       short   length,
+                       byte[]  eventBuffer,
+                       byte[]  resultBuffer);
+
+               #endregion
+
+               #region Transaction     functions
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_commit_retaining(
+                       [In, Out] int[] statusVector,
+                       ref     int     trHandle);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_commit_transaction(
+                       [In, Out] int[] statusVector,
+                       ref     int     trHandle);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_rollback_retaining(
+                       [In, Out] int[] statusVector,
+                       ref     int     trHandle);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_rollback_transaction(
+                       [In, Out] int[] statusVector,
+                       ref     int     trHandle);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_start_transaction(
+                       [In, Out] int[] statusVector,
+                       ref     int     trHandle,
+                       short   dbHandleCount,                  
+                       ref     int     dbHandle,
+                       short   tpbLength,
+                       byte[]  tpbAddress);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_start_multiple(
+                       [In, Out]       int[] statusVector,
+                       ref     int             trHandle,
+                       short           dbHandleCount,
+                       IntPtr          tebVectorAddress);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_prepare_transaction(
+                       [In, Out] int[] statusVector,
+                       ref     int     trHandle);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_prepare_transaction2(
+                       [In, Out] int[] statusVector,
+                       ref     int     trHandle,
+                       short msgLength,
+                       byte[] message);
+
+               #endregion
+
+               #region DSQL functions
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_allocate_statement(
+                       [In, Out] int[] statusVector,
+                       ref     int     dbHandle,
+                       ref     int     stmtHandle);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_describe(
+                       [In, Out] int[] statusVector,
+                       ref     int     stmtHandle,
+                       short   daVersion,
+                       IntPtr  xsqlda);
+                       
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_describe_bind(
+                       [In, Out] int[] statusVector,
+                       ref     int     stmtHandle,
+                       short   daVersion,
+                       IntPtr  xsqlda);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_execute(
+                       [In, Out] int[] statusVector,
+                       ref     int     trHandle,
+                       ref     int     stmtHandle,
+                       short   daVersion,
+                       IntPtr  xsqlda);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_execute2(
+                       [In, Out] int[] statusVector,
+                       ref     int     trHandle,
+                       ref     int     stmtHandle,
+                       short   da_version,
+                       IntPtr  inXsqlda,
+                       IntPtr  outXsqlda);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_execute_immediate(
+                       [In, Out] int[] statusVector,
+                       ref     int     dbHandle,
+                       ref     int     trHandle,
+                       short   length,
+                       string  statement,
+                       short   dialect,
+                       IntPtr  xsqlda);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_exec_immed2(
+                       [In, Out] int[] statusVector,
+                       ref     int     dbHandle,
+                       ref     int     trHandle,
+                       short   length,
+                       string  statement,
+                       short   dialect,
+                       IntPtr  inXsqlda,
+                       IntPtr  outXsqlda);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_fetch(
+                       [In, Out] int[] statusVector,
+                       ref     int     stmtHandle,
+                       short   daVersion,
+                       IntPtr  xsqlda);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_free_statement(
+                       [In, Out] int[] statusVector,
+                       ref     int     stmtHandle,
+                       short   option);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_prepare(
+                       [In, Out] int[] statusVector,
+                       ref     int     trHandle,
+                       ref     int     stmtHandle,
+                       short   length,
+                       byte[]  statement,
+                       short   dialect,
+                       IntPtr  xsqlda);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_sql_info(
+                       [In, Out] int[] statusVector,
+                       ref     int     stmtHandle,
+                       short   itemsLength,
+                       byte[]  items,
+                       short   bufferLength,
+                       byte[]  buffer);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_vax_integer(
+                       byte[] buffer,
+                       short length);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_dsql_set_cursor_name(
+                       [In, Out] int[] statusVector,
+                       ref     int     stmtHandle,
+                       string  cursorName,
+                       short   type);
+
+               #endregion
+
+               #region Services functions
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_service_attach(
+                       [In, Out] int[] statusVector,
+                       short   serviceLength,
+                       string  service,
+                       ref     int     svcHandle,
+                       short   spbLength,
+                       byte[]  spb);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_service_detach(
+                       [In, Out] int[] statusVector,
+                       ref     int     svcHandle);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_service_query(
+                       [In, Out] int[] statusVector,
+                       ref     int     svcHandle,
+                       ref     int     reserved,
+                       short   sendSpbLength,
+                       byte[]  sendSpb,
+                       short   requestSpbLength,
+                       byte[]  requestSpb,
+                       short   bufferLength,
+                       byte[]  buffer);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_service_start(
+                       [In, Out] int[] statusVector,
+                       ref     int     svcHandle,
+                       ref     int     reserved,
+                       short   spbLength,
+                       byte[]  spb);
+
+               #endregion
+
+               #region Error handling
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_interprete(
+                       byte[] buffer,
+                       ref     int[] statusVector);
+
+               [DllImport(FbClient.DllPath)]
+               public static extern int isc_sqlcode(ref int[] statusVector);
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesArray.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesArray.cs
new file mode 100644 (file)
index 0000000..ff96829
--- /dev/null
@@ -0,0 +1,456 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.IO;
+using System.Net;
+using System.Runtime.InteropServices;
+using System.Text;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Embedded
+{
+       internal sealed class FesArray : ArrayBase
+       {
+               #region Fields
+
+               private long                    handle;
+               private FesDatabase             db;
+               private FesTransaction  transaction;
+
+               #endregion
+
+               #region Properties
+
+               public override long Handle
+               {
+                       get     { return this.handle; }
+                       set     { this.handle = value; }
+               }
+
+               public override IDatabase DB
+               {
+                       get     { return this.db; }
+                       set     { this.db =     (FesDatabase)value;     }
+               }
+
+               public override ITransaction Transaction
+               {
+                       get     { return this.transaction; }
+                       set     { this.transaction = (FesTransaction)value;     }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public FesArray(ArrayDesc descriptor) : base(descriptor)
+               {
+               }
+
+               public FesArray(
+                       IDatabase               db,
+                       ITransaction    transaction,
+                       string                  tableName, 
+                       string                  fieldName) : this(db, transaction, -1, tableName, fieldName)
+               {
+               }
+
+               public FesArray(
+                       IDatabase               db,
+                       ITransaction    transaction,
+                       long                    handle, 
+                       string                  tableName, 
+                       string                  fieldName)      : base(tableName, fieldName)
+               {
+                       if (!(db is     FesDatabase))
+                       {
+                               throw new ArgumentException("Specified argument is not of GdsDatabase type.");
+                       }
+                       if (!(transaction is FesTransaction))
+                       {
+                               throw new ArgumentException("Specified argument is not of GdsTransaction type.");
+                       }
+                       this.db                         = (FesDatabase)db;
+                       this.transaction        = (FesTransaction)transaction;
+                       this.handle                     = handle;
+
+                       this.LookupBounds();
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override byte[] GetSlice(int     sliceLength)
+               {
+                       int[] statusVector = FesConnection.GetNewStatusVector();
+
+                       int     dbHandle = this.db.Handle;
+                       int     trHandle = this.transaction.Handle;
+
+                       ArrayDescMarshaler marshaler = ArrayDescMarshaler.GetInstance();
+
+                       IntPtr arrayDesc = marshaler.MarshalManagedToNative(this.Descriptor);
+
+                       byte[] buffer = new     byte[sliceLength];
+
+                       FbClient.isc_array_get_slice(
+                               statusVector,
+                               ref     dbHandle,
+                               ref     trHandle,
+                               ref     this.handle,
+                               arrayDesc,
+                               buffer,
+                               ref     sliceLength);
+                       
+                       // Free memory
+                       marshaler.CleanUpNativeData(ref arrayDesc);
+
+                       FesConnection.ParseStatusVector(statusVector);
+
+                       return buffer;
+               }
+
+               public override void PutSlice(System.Array sourceArray, int     sliceLength)
+               {
+                       int[] statusVector = FesConnection.GetNewStatusVector();
+
+                       int     dbHandle = this.db.Handle;
+                       int     trHandle = this.transaction.Handle;
+
+                       ArrayDescMarshaler marshaler = ArrayDescMarshaler.GetInstance();
+
+                       IntPtr arrayDesc = marshaler.MarshalManagedToNative(this.Descriptor);
+
+                       // Obtain the System of type of Array elements and
+                       // Fill buffer
+                       Type systemType = this.GetSystemType();
+
+                       byte[] buffer = new     byte[sliceLength];
+                       if (systemType.IsPrimitive)
+                       {
+                               Buffer.BlockCopy(sourceArray, 0, buffer, 0,     buffer.Length);
+                       }
+                       else
+                       {
+                               buffer = this.EncodeSlice(this.Descriptor, sourceArray, sliceLength);
+                       }
+
+                       FbClient.isc_array_put_slice(
+                               statusVector,
+                               ref     dbHandle,
+                               ref     trHandle,
+                               ref     this.handle,
+                               arrayDesc,
+                               buffer,
+                               ref     sliceLength);
+                       
+                       // Free memory
+                       marshaler.CleanUpNativeData(ref arrayDesc);
+
+                       FesConnection.ParseStatusVector(statusVector);
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override System.Array DecodeSlice(byte[] slice)
+               {
+                       Array           sliceData               = null;
+                       int                     slicePosition   = 0;
+                       int                     type                    = 0;
+                       DbDataType      dbType                  = DbDataType.Array;
+                       Type            systemType              = this.GetSystemType();
+                       Charset         charset                 = this.db.Charset;
+                       int[]           lengths                 = new int[this.Descriptor.Dimensions];
+                       int[]           lowerBounds             = new int[this.Descriptor.Dimensions];                  
+
+                       // Get upper and lower bounds of each dimension
+                       for     (int i = 0;     i <     this.Descriptor.Dimensions;     i++)
+                       {
+                               lowerBounds[i]  = this.Descriptor.Bounds[i].LowerBound;
+                               lengths[i]              = this.Descriptor.Bounds[i].UpperBound;
+                       }
+                       
+                       // Create slice arrays
+                       sliceData =     Array.CreateInstance(systemType, lengths, lowerBounds);
+
+                       Array tempData = Array.CreateInstance(systemType, sliceData.Length);
+
+                       // Infer data types
+                       type    = TypeHelper.GetFbType(this.Descriptor.DataType);
+                       dbType  = TypeHelper.GetDbDataType(this.Descriptor.DataType, 0, this.Descriptor.Scale);
+
+                       int     itemLength = this.Descriptor.Length;
+
+                       for     (int i = 0;     i <     tempData.Length; i++)
+                       {
+                               if (slicePosition >= slice.Length)
+                               {
+                                       break;
+                               }
+                                                               
+                               switch(dbType)
+                               {                                                       
+                                       case DbDataType.Char:
+                                               tempData.SetValue(charset.GetString(slice, slicePosition, itemLength), i);
+                                               break;
+
+                                       case DbDataType.VarChar:
+                                       {
+                                               int     index = slicePosition;
+                                               int     count = 0;
+                                               while (slice[index++] != 0)
+                                               {
+                                                       count ++;
+                                               }
+                                               tempData.SetValue(charset.GetString(slice, slicePosition, count), i);
+
+                                               slicePosition += 2;
+                                       }
+                                       break;
+                                       
+                                       case DbDataType.SmallInt:
+                                               tempData.SetValue(BitConverter.ToInt16(slice, slicePosition), i);
+                                               break;
+       
+                                       case DbDataType.Integer:
+                                               tempData.SetValue(BitConverter.ToInt32(slice, slicePosition), i);
+                                               break;
+       
+                                       case DbDataType.BigInt:
+                                               tempData.SetValue(BitConverter.ToInt64(slice, slicePosition), i);
+                                               break;
+                                       
+                                       case DbDataType.Decimal:
+                                       case DbDataType.Numeric:
+                                       {
+                                               object evalue = null;
+
+                                               switch (type)
+                                               {
+                                                       case IscCodes.SQL_SHORT:
+                                                               evalue = BitConverter.ToInt16(slice, slicePosition);
+                                                               break;
+
+                                                       case IscCodes.SQL_LONG:
+                                                               evalue = BitConverter.ToInt32(slice, slicePosition);
+                                                               break;
+
+                                                       case IscCodes.SQL_QUAD:
+                                                       case IscCodes.SQL_INT64:
+                                                               evalue = BitConverter.ToInt64(slice, slicePosition);
+                                                               break;
+                                               }
+
+                                               decimal dvalue = TypeDecoder.DecodeDecimal(evalue, this.Descriptor.Scale, type);
+
+                                               tempData.SetValue(dvalue, i);
+                                       }
+                                       break;
+
+                                       case DbDataType.Double: 
+                                               tempData.SetValue(BitConverter.ToDouble(slice, slicePosition), i);
+                                               break;
+       
+                                       case DbDataType.Float:
+                                               tempData.SetValue(BitConverter.ToSingle(slice, slicePosition), i);
+                                               break;
+
+                                       case DbDataType.Date:
+                                       {
+                                               int     idate = BitConverter.ToInt32(slice,     slicePosition);
+
+                                               DateTime date = TypeDecoder.DecodeDate(idate);
+                                               
+                                               tempData.SetValue(date, i);
+                                       }
+                                       break;
+                                       
+                                       case DbDataType.Time:
+                                       {
+                                               int     itime = BitConverter.ToInt32(slice,     slicePosition);
+                                       
+                                               DateTime time = TypeDecoder.DecodeTime(itime);                                  
+                                               
+                                               tempData.SetValue(time, i);
+                                       }
+                                       break;
+                                                                               
+                                       case DbDataType.TimeStamp:
+                                       {
+                                               int     idate = BitConverter.ToInt32(slice,     slicePosition);
+                                               int     itime = BitConverter.ToInt32(slice,     slicePosition + 4);
+                                       
+                                               DateTime date = TypeDecoder.DecodeDate(idate);
+                                               DateTime time = TypeDecoder.DecodeTime(itime);
+
+                                               DateTime timestamp = new System.DateTime(
+                                                       date.Year, date.Month, date.Day,
+                                                       time.Hour,time.Minute, time.Second,     time.Millisecond);
+                                                                                       
+                                               tempData.SetValue(timestamp, i);
+                                       }
+                                       break;
+                               }
+                               
+                               slicePosition += itemLength;
+                       }
+                       
+                       if (systemType.IsPrimitive)
+                       {
+                               // For primitive types we can use System.Buffer to copy generated data to destination array
+                               Buffer.BlockCopy(tempData, 0, sliceData, 0,     Buffer.ByteLength(tempData));
+                       }
+                       else
+                       {
+                               sliceData =     tempData;       
+                       }
+                       
+                       return sliceData;
+               }
+
+               #endregion
+
+               #region Private Metods
+
+               private byte[] EncodeSlice(ArrayDesc desc, Array sourceArray, int length)
+               {
+                       BinaryWriter    writer  = new BinaryWriter(new MemoryStream());
+                       IEnumerator             i               = sourceArray.GetEnumerator();
+                       Charset                 charset = this.db.Charset;
+                       DbDataType              dbType  = DbDataType.Array;
+                       int                             type    = 0;
+
+                       // Infer data types
+                       type    = TypeHelper.GetFbType(this.Descriptor.DataType);
+                       dbType  = TypeHelper.GetDbDataType(this.Descriptor.DataType, 0, this.Descriptor.Scale);
+
+                       while (i.MoveNext())
+                       {
+                               switch (dbType)
+                               {
+                                       case DbDataType.Char:
+                                       {
+                                               string value  = i.Current != null ?     (string)i.Current :     String.Empty;
+                                               byte[] buffer = charset.GetBytes(value);
+
+                                               writer.Write(buffer);
+
+                                               if (desc.Length > buffer.Length)
+                                               {
+                                                       for     (int j = buffer.Length; j <     desc.Length; j++)
+                                                       {
+                                                               writer.Write((byte)32);
+                                                       }
+                                               }
+                                       }
+                                       break;
+
+                                       case DbDataType.VarChar:
+                                       {
+                                               string value = i.Current !=     null ? (string)i.Current : String.Empty;
+
+                                               value = value.TrimEnd();
+
+                                               byte[] buffer = charset.GetBytes(value);
+                                               writer.Write(buffer);
+
+                                               if (desc.Length > buffer.Length)
+                                               {
+                                                       for     (int j = buffer.Length; j <     desc.Length; j++)
+                                                       {
+                                                               writer.Write((byte)0);
+                                                       }
+                                               }
+                                               writer.Write((short)0);
+                                       }
+                                       break;
+       
+                                       case DbDataType.SmallInt:
+                                               writer.Write((short)i.Current);
+                                               break;
+       
+                                       case DbDataType.Integer:
+                                               writer.Write((int)i.Current);
+                                               break;
+
+                                       case DbDataType.BigInt:
+                                               writer.Write((long)i.Current);
+                                               break;
+                                       
+                                       case DbDataType.Float:
+                                               writer.Write((float)i.Current);
+                                               break;
+                                                                               
+                                       case DbDataType.Double:
+                                               writer.Write((double)i.Current);
+                                               break;
+                                       
+                                       case DbDataType.Numeric:
+                                       case DbDataType.Decimal:
+                                       {
+                                               object numeric = TypeEncoder.EncodeDecimal((decimal)i.Current, desc.Scale, type);
+
+                                               switch (type)
+                                               {
+                                                       case IscCodes.SQL_SHORT:
+                                                               writer.Write((short)numeric);
+                                                               break;
+
+                                                       case IscCodes.SQL_LONG:
+                                                               writer.Write((int)numeric);
+                                                               break;
+
+                                                       case IscCodes.SQL_QUAD:
+                                                       case IscCodes.SQL_INT64:
+                                                               writer.Write((long)numeric);
+                                                               break;
+                                               }
+                                       }
+                                       break;
+
+                                       case DbDataType.Date:
+                                               writer.Write(TypeEncoder.EncodeDate(Convert.ToDateTime(i.Current, CultureInfo.CurrentUICulture.DateTimeFormat)));
+                                               break;
+                                       
+                                       case DbDataType.Time:
+                                               writer.Write(TypeEncoder.EncodeTime(Convert.ToDateTime(i.Current, CultureInfo.CurrentUICulture.DateTimeFormat)));
+                                               break;
+
+                                       case DbDataType.TimeStamp:
+                                               writer.Write(TypeEncoder.EncodeDate(Convert.ToDateTime(i.Current, CultureInfo.CurrentUICulture.DateTimeFormat)));
+                                               writer.Write(TypeEncoder.EncodeTime(Convert.ToDateTime(i.Current, CultureInfo.CurrentUICulture.DateTimeFormat)));
+                                               break;
+                                       
+                                       default:
+                                               throw new NotSupportedException("Unknown data type");
+                               }
+                       }
+
+                       return ((MemoryStream)writer.BaseStream).ToArray();
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesBlob.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesBlob.cs
new file mode 100644 (file)
index 0000000..833aacb
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Embedded
+{
+       internal sealed class FesBlob : BlobBase
+       {
+               #region Fields
+
+               private FesDatabase     db;
+
+               #endregion
+
+               #region Properties
+
+               public override IDatabase DB
+               {
+                       get     { return this.db; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public FesBlob(IDatabase db, ITransaction transaction) 
+                       : this(db, transaction, 0)
+               {
+               }
+       
+               public FesBlob(IDatabase db, ITransaction transaction, long     blobId) : base(db)
+               {
+                       if (!(db is     FesDatabase))
+                       {
+                               throw new ArgumentException("Specified argument is not of FesDatabase type.");
+                       }
+                       if (!(transaction is FesTransaction))
+                       {
+                               throw new ArgumentException("Specified argument is not of FesTransaction type.");
+                       }
+                       this.db                         = (FesDatabase)db;
+                       this.transaction        = (FesTransaction)transaction;
+                       this.position           = 0;
+                       this.blobHandle         = 0;
+                       this.blobId                     = blobId;
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void Create()
+               {
+                       lock (this.db) 
+                       {
+                               int[] statusVector = FesConnection.GetNewStatusVector();
+
+                               int     dbHandle = this.db.Handle;
+                               int     trHandle = this.transaction.Handle;
+
+                               FbClient.isc_create_blob2(
+                                       statusVector,
+                                       ref     dbHandle,
+                                       ref     trHandle,
+                                       ref     this.blobHandle,
+                                       ref     this.blobId,                                    
+                                       0,
+                                       new     byte[0]);
+
+                               FesConnection.ParseStatusVector(statusVector);
+
+                               this.RblAddValue(IscCodes.RBL_create);
+                       }
+               }
+
+               protected override void Open()
+               {
+                       lock (this.db) 
+                       {
+                               int[] statusVector = FesConnection.GetNewStatusVector();
+
+                               int     dbHandle = this.db.Handle;
+                               int     trHandle = this.transaction.Handle;
+
+                               FbClient.isc_open_blob2(
+                                       statusVector,
+                                       ref     dbHandle,
+                                       ref     trHandle,
+                                       ref     this.blobHandle,
+                                       ref     this.blobId,
+                                       0,
+                                       new     byte[0]);
+
+                               FesConnection.ParseStatusVector(statusVector);
+                       }
+               }
+
+               protected override byte[] GetSegment()
+               {
+                       short   requested               = (short)this.SegmentSize;
+                       short   segmentLength   = 0;
+                                               
+                       lock (this.db) 
+                       {
+                               int[] statusVector = FesConnection.GetNewStatusVector();
+                       
+                               MemoryStream    segment = new MemoryStream();
+                               byte[]                  tmp             = new byte[requested];
+                                                                                                                                       
+                               int     status = FbClient.isc_get_segment(
+                                       statusVector,
+                                       ref     this.blobHandle,
+                                       ref     segmentLength,
+                                       requested,
+                                       tmp);
+
+                               if (segmentLength >     0)
+                               {
+                                       segment.Write(tmp, 0, segmentLength     > requested     ? requested     : segmentLength);
+                               }
+
+                               this.RblRemoveValue(IscCodes.RBL_segment);
+                               if (statusVector[1]     == IscCodes.isc_segstr_eof)
+                               {
+                                       segment.SetLength(0);
+                                       this.RblAddValue(IscCodes.RBL_eof_pending);
+                               }
+                               else
+                               {
+                                       if (status == 0 || statusVector[1] == IscCodes.isc_segment)
+                                       {
+                                               this.RblAddValue(IscCodes.RBL_segment);
+                                       }
+                                       else
+                                       {
+                                               this.db.ParseStatusVector(statusVector);
+                                       }
+                               }
+
+                               return segment.ToArray();
+                       }
+               }
+
+               protected override void PutSegment(byte[] buffer)
+               {
+                       lock (this.db) 
+                       {
+                               int[] statusVector = FesConnection.GetNewStatusVector();
+
+                               FbClient.isc_put_segment(
+                                       statusVector,
+                                       ref     this.blobHandle,
+                                       (short)buffer.Length,
+                                       buffer);
+
+                               FesConnection.ParseStatusVector(statusVector);
+                       }
+               }
+
+               protected override void Seek(int position)
+               {
+                       throw new NotSupportedException();
+               }
+
+               protected override void GetBlobInfo()
+               {
+                       throw new NotSupportedException();
+               }
+
+               protected override void Close()
+               {       
+                       lock (this.db)
+                       {
+                               int[] statusVector = FesConnection.GetNewStatusVector();
+
+                               FbClient.isc_close_blob(statusVector, ref this.blobHandle);
+
+                               FesConnection.ParseStatusVector(statusVector);
+                       }
+               }               
+
+               protected override void Cancel()
+               {       
+                       lock (this.db)
+                       {
+                               int[] statusVector = FesConnection.GetNewStatusVector();
+
+                               FbClient.isc_cancel_blob(statusVector, ref this.blobHandle);
+
+                               FesConnection.ParseStatusVector(statusVector);
+                       }
+               }               
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesConnection.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesConnection.cs
new file mode 100644 (file)
index 0000000..2d7a5ef
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Embedded
+{
+       internal sealed class FesConnection
+       {
+               #region Constructors
+
+               private FesConnection()
+               {
+               }
+
+               #endregion
+
+               #region Static Methods
+
+               public static int[]     GetNewStatusVector()
+               {
+                       return new int[IscCodes.ISC_STATUS_LENGTH];
+               }
+
+               public static IscException ParseStatusVector(int[] statusVector)
+               {
+                       IscException    exception       = null;
+                       bool                    eof                     = false;
+
+                       for     (int i = 0;     i <     statusVector.Length;)
+                       {
+                               int     arg     = statusVector[i++];
+
+                               switch (arg) 
+                               {
+                                       case IscCodes.isc_arg_gds: 
+                                               int     er = statusVector[i++];
+                                               if (er != 0) 
+                                               {
+                                                       if (exception == null)
+                                                       {
+                                                               exception =     new     IscException();
+                                                       }
+                                                       exception.Errors.Add(arg, er);
+                                               }
+                                               break;
+
+                                       case IscCodes.isc_arg_end:
+                                               if (exception != null && exception.Errors.Count != 0) 
+                                               {
+                                                       exception.BuildExceptionMessage();
+                                               }
+                                               eof     = true;
+                                               break;
+                                       
+                                       case IscCodes.isc_arg_interpreted:                                              
+                                       case IscCodes.isc_arg_string:
+                                       {
+                                               IntPtr ptr = new IntPtr(statusVector[i++]);
+                                               string arg_value = Marshal.PtrToStringAnsi(ptr);
+                                               exception.Errors.Add(arg, arg_value);
+                                       }
+                                       break;
+
+                                       case IscCodes.isc_arg_cstring:
+                                       {
+                                               i++;
+
+                                               IntPtr ptr = new IntPtr(statusVector[i++]);
+                                               string arg_value = Marshal.PtrToStringAnsi(ptr);
+                                               exception.Errors.Add(arg, arg_value);
+                                       }
+                                       break;
+                                       
+                                       case IscCodes.isc_arg_win32:
+                                       case IscCodes.isc_arg_number:
+                                               exception.Errors.Add(arg, statusVector[i++]);
+                                               break;
+                                       
+                                       default:
+                                       {
+                                               int     e =     statusVector[i++];
+                                               if (e != 0)     
+                                               {
+                                                       if (exception == null)
+                                                       {
+                                                               exception =     new     IscException();
+                                                       }
+                                                       exception.Errors.Add(arg, e);
+                                               }
+                                       }
+                                       break;
+                               }
+
+                               if (eof)
+                               {
+                                       break;
+                               }
+                       }
+
+                       return exception;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesDatabase.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesDatabase.cs
new file mode 100644 (file)
index 0000000..faa4818
--- /dev/null
@@ -0,0 +1,400 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Data;
+using System.Text;
+using System.Runtime.InteropServices;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Embedded
+{
+       internal sealed class FesDatabase :     IDatabase
+       {
+               #region Callbacks
+
+               public WarningMessageCallback WarningMessage
+               {
+                       get     { return this.warningMessage; }
+                       set     { this.warningMessage = value; }
+               }
+
+               #endregion
+
+               #region Fields
+               
+               private WarningMessageCallback warningMessage;
+
+               private int             handle;
+               private int             transactionCount;
+               private string  serverVersion;
+               private Charset charset;
+               private short   packetSize;
+               private short   dialect;
+               private bool    disposed;
+
+               #endregion
+
+               #region Properties
+
+               public int Handle
+               {
+                       get     { return this.handle; }
+               }
+
+               public int TransactionCount
+               {
+                       get     { return this.transactionCount; }
+                       set     { this.transactionCount = value; }
+               }
+
+               public string ServerVersion
+               {
+                       get     { return this.serverVersion; }
+               }
+
+               public Charset Charset
+               {
+                       get     { return this.charset; }
+                       set     { this.charset = value; }
+               }
+
+               public short PacketSize
+               {
+                       get     { return this.packetSize; }
+                       set     { this.packetSize =     value; }
+               }
+
+               public short Dialect
+               {
+                       get     { return this.dialect; }
+                       set     { this.dialect = value; }
+               }
+
+               public bool     HasRemoteEventSupport
+               {
+                       get     { return false; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public FesDatabase()
+               {
+                       this.charset    = Charset.DefaultCharset;
+                       this.dialect    = 3;
+                       this.packetSize = 8192;
+
+                       GC.SuppressFinalize(this);
+               }
+
+               #endregion
+
+               #region Finalizer
+
+               ~FesDatabase()
+               {
+                       this.Dispose(false);
+               }
+
+               #endregion
+
+               #region IDisposable     methods
+
+               public void     Dispose()
+               {
+                       this.Dispose(true);
+                       GC.SuppressFinalize(this);
+               }
+
+               private void Dispose(bool disposing)
+               {
+                       lock (this)
+                       {
+                               if (!this.disposed)
+                               {
+                                       try
+                                       {
+                                               // release any unmanaged resources
+                                               this.Detach();
+
+                                               // release any managed resources
+                                               if (disposing)
+                                               {
+                                                       this.charset            = null;
+                                                       this.serverVersion      = null;
+                                                       this.dialect            = 0;
+                                                       this.handle                     = 0;
+                                                       this.packetSize         = 0;
+                                                       this.transactionCount = 0;
+                                                       this.warningMessage     = null;
+                                               }
+                                       }
+                                       finally
+                                       {
+                                               this.disposed = true;
+                                       }
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Database Methods
+
+               public void     CreateDatabase(DatabaseParameterBuffer dpb,     string dataSource, int port, string     database)
+               {
+                       lock (this)
+                       {
+                               int[]   statusVector = FesConnection.GetNewStatusVector();
+                               int             dbHandle         = this.Handle;
+
+                               FbClient.isc_create_database(
+                                       statusVector,
+                                       (short)database.Length,
+                                       database,
+                                       ref     dbHandle,
+                                       (short)dpb.Length,
+                                       dpb.ToArray(),
+                                       0);
+
+                               this.ParseStatusVector(statusVector);
+
+                               this.handle     = dbHandle;
+
+                               this.Detach();
+                       }
+               }
+
+               public void     DropDatabase()
+               {
+                       lock (this)
+                       {
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             dbHandle                = this.Handle;
+
+                               FbClient.isc_drop_database(statusVector, ref dbHandle);
+
+                               this.ParseStatusVector(statusVector);
+
+                               this.handle     = 0;
+                       }
+               }
+
+               #endregion
+
+               #region Remote Events Methods
+
+               void IDatabase.CloseEventManager()
+               {
+                       throw new NotSupportedException();
+               }
+
+               RemoteEvent     IDatabase.CreateEvent()
+               {
+                       throw new NotSupportedException();
+               }
+
+               void IDatabase.QueueEvents(RemoteEvent events)
+               {
+                       throw new NotSupportedException();
+               }
+
+               void IDatabase.CancelEvents(RemoteEvent events)
+               {
+                       throw new NotSupportedException();
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void     Attach(DatabaseParameterBuffer dpb,     string dataSource, int port, string     database)
+               {
+                       lock (this)
+                       {
+                               int[]   statusVector = FesConnection.GetNewStatusVector();
+                               int             dbHandle         = 0;
+                               
+                               FbClient.isc_attach_database(
+                                       statusVector,
+                                       (short)database.Length,
+                                       database,
+                                       ref     dbHandle,
+                                       (short)dpb.Length,
+                                       dpb.ToArray());
+
+                               this.handle     = dbHandle;
+                                       
+                               this.ParseStatusVector(statusVector);
+
+                               // Get server version
+                               this.serverVersion = this.GetServerVersion();
+                       }                       
+               }
+
+               public void     Detach()
+               {
+                       lock (this)     
+                       {
+                               if (this.TransactionCount >     0) 
+                               {
+                                       throw new IscException(IscCodes.isc_open_trans, this.TransactionCount);
+                               }
+
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             dbHandle                = this.Handle;
+
+                               FbClient.isc_detach_database(statusVector, ref dbHandle);
+
+                               this.handle     = dbHandle;
+                                       
+                               FesConnection.ParseStatusVector(statusVector);                  
+                       }
+               }
+
+               #endregion
+
+               #region Transaction     methods
+
+               public ITransaction     BeginTransaction(TransactionParameterBuffer     tpb)
+               {
+                       FesTransaction transaction = new FesTransaction(this);
+                       transaction.BeginTransaction(tpb);
+
+                       return transaction;
+               }
+
+               #endregion
+
+               #region Statement creation methods
+
+               public StatementBase CreateStatement()
+               {
+                       return new FesStatement(this);
+               }
+
+               public StatementBase CreateStatement(ITransaction transaction)
+               {
+                       return new FesStatement(this, transaction as FesTransaction);
+               }
+
+               #endregion
+
+               #region Parameter Buffer Creation methods
+
+               public BlobParameterBuffer CreateBlobParameterBuffer()
+               {
+                       return new BlobParameterBuffer(BitConverter.IsLittleEndian);
+               }
+
+               public DatabaseParameterBuffer CreateDatabaseParameterBuffer()
+               {
+                       return new DatabaseParameterBuffer(BitConverter.IsLittleEndian);
+               }
+
+               public EventParameterBuffer     CreateEventParameterBuffer()
+               {
+                       return new EventParameterBuffer();
+               }
+
+               public TransactionParameterBuffer CreateTransactionParameterBuffer()
+               {
+                       return new TransactionParameterBuffer(BitConverter.IsLittleEndian);
+               }
+
+               #endregion
+
+               #region Database information methods
+
+               public string GetServerVersion()
+               {
+                       byte[] items = new byte[]
+                       {
+                               IscCodes.isc_info_isc_version,
+                               IscCodes.isc_info_end
+                       };
+
+                       return this.GetDatabaseInfo(items, 50)[0].ToString();
+               }
+
+               public ArrayList GetDatabaseInfo(byte[] items)
+               {
+                       return this.GetDatabaseInfo(items, IscCodes.MAX_BUFFER_SIZE);
+               }
+
+               public ArrayList GetDatabaseInfo(byte[] items, int bufferLength)
+               {
+                       byte[] buffer = new     byte[bufferLength];
+
+                       this.DatabaseInfo(items, buffer, buffer.Length);
+
+                       return IscHelper.ParseDatabaseInfo(buffer);
+               }
+
+               #endregion
+
+               #region Internal methods
+
+               internal void ParseStatusVector(int[] statusVector)
+               {
+                       IscException ex = FesConnection.ParseStatusVector(statusVector);
+
+                       if (ex != null)
+                       {
+                               if (ex.IsWarning)
+                               {
+                                       this.warningMessage(ex);
+                               }
+                               else
+                               {
+                                       throw ex;
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void DatabaseInfo(byte[] items, byte[] buffer, int bufferLength)
+               {               
+                       lock (this)     
+                       {                       
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             dbHandle                = this.Handle;
+
+                               FbClient.isc_database_info(
+                                       statusVector,
+                                       ref     dbHandle,
+                                       (short)items.Length,
+                                       items,
+                                       (short)bufferLength,
+                                       buffer);
+                                       
+                               this.ParseStatusVector(statusVector);
+                       }
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesServiceManager.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesServiceManager.cs
new file mode 100644 (file)
index 0000000..c09183e
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Embedded
+{
+       internal sealed class FesServiceManager : IServiceManager
+       {
+               #region Fields
+
+               private int     handle;
+
+               #endregion
+
+               #region Properties
+
+               public int Handle
+               {
+                       get     { return this.handle; }
+               }
+
+               public bool     IsLittleEndian
+               {
+                       get     { return BitConverter.IsLittleEndian; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public FesServiceManager()
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void     Attach(ServiceParameterBuffer spb, string dataSource, int port, string service)
+               {
+                       int[]   statusVector    = FesConnection.GetNewStatusVector();
+                       int             svcHandle               = this.Handle;
+
+                       FbClient.isc_service_attach(
+                               statusVector,
+                               (short) service.Length,
+                               service,
+                               ref     svcHandle,
+                               (short) spb.Length,
+                               spb.ToArray());
+
+                       // Parse status vector
+                       this.ParseStatusVector(statusVector);
+
+                       // Update status vector
+                       this.handle     = svcHandle;
+               }
+
+               public void     Detach()
+               {
+                       int[]   statusVector    = FesConnection.GetNewStatusVector();
+                       int             svcHandle               = this.Handle;
+
+                       FbClient.isc_service_detach(statusVector, ref svcHandle);
+
+                       // Parse status vector
+                       this.ParseStatusVector(statusVector);
+
+                       // Update status vector
+                       this.handle     = svcHandle;
+               }                               
+
+               public void     Start(ServiceParameterBuffer spb)
+               {
+                       int[]   statusVector    = FesConnection.GetNewStatusVector();
+                       int             svcHandle               = this.Handle;
+                       int             reserved                = 0;
+
+                       FbClient.isc_service_start(
+                               statusVector,
+                               ref     svcHandle,
+                               ref     reserved,
+                               (short) spb.Length,
+                               spb.ToArray());
+
+                       // Parse status vector
+                       this.ParseStatusVector(statusVector);
+               }
+
+               public void     Query(
+                       ServiceParameterBuffer spb,
+                       int                     requestLength,
+                       byte[]          requestBuffer,
+                       int                     bufferLength,
+                       byte[]          buffer)
+               {
+                       int[]   statusVector    = FesConnection.GetNewStatusVector();
+                       int             svcHandle               = this.Handle;
+                       int             reserved                = 0;
+
+                       FbClient.isc_service_query(
+                               statusVector,
+                               ref     svcHandle,
+                               ref     reserved,
+                               (short) spb.Length,
+                               spb.ToArray(), 
+                               (short) requestLength,
+                               requestBuffer,
+                               (short) buffer.Length,
+                               buffer);
+
+                       // Parse status vector
+                       this.ParseStatusVector(statusVector);
+               }
+               
+               #endregion
+
+               #region Buffer Creation methods
+
+               public ServiceParameterBuffer CreateParameterBuffer()
+               {
+                       return new ServiceParameterBuffer();
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void ParseStatusVector(int[] statusVector)
+               {
+                       IscException ex = FesConnection.ParseStatusVector(statusVector);
+
+                       if (ex != null && !ex.IsWarning)
+                       {
+                               throw ex;
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesStatement.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesStatement.cs
new file mode 100644 (file)
index 0000000..bf4eb63
--- /dev/null
@@ -0,0 +1,679 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.Text;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Embedded
+{
+       internal sealed class FesStatement : StatementBase
+       {
+               #region Fields
+
+               private int                             handle;
+               private FesDatabase             db;
+               private FesTransaction  transaction;
+               private Descriptor              parameters;
+               private Descriptor              fields;
+               private StatementState  state;
+               private DbStatementType statementType;
+               private bool                    allRowsFetched;
+               private Queue                   outputParams;
+               private int                             recordsAffected;
+               
+               #endregion
+
+               #region Properties
+
+               public override IDatabase DB
+               {
+                       get     { return this.db; }
+                       set     { this.db =     (FesDatabase)value;     }
+               }
+
+               public override ITransaction Transaction
+               {
+                       get     { return this.transaction; }
+                       set
+                       {
+                               if (value == null)
+                               {
+                                       this.transaction = null;
+                               }
+                               else
+                               {
+                                       bool addHandler = false;
+                                       if (this.transaction != value)
+                                       {
+                                               if (this.TransactionUpdate != null && this.Transaction != null)
+                                               {
+                                                       this.Transaction.Update -= this.TransactionUpdate ;
+                                                       this.TransactionUpdate  = null;
+                                               }
+                                       
+                                               // Add event handler for transaction updates
+                                               this.TransactionUpdate = new TransactionUpdateEventHandler(this.TransactionUpdated);
+
+                                               addHandler = true;
+                                       }
+
+                                       this.transaction = (FesTransaction)value;
+
+                                       if (addHandler)
+                                       {
+                                               this.transaction.Update += this.TransactionUpdate;
+                                       }
+                               }
+                       }
+               }
+               
+               public override Descriptor Parameters
+               {
+                       get     { return this.parameters; }
+                       set     { this.parameters =     value; }
+               }
+
+               public override Descriptor Fields
+               {
+                       get     { return this.fields; }
+               }
+
+               public override int     RecordsAffected
+               {
+                       get     { return this.recordsAffected; }
+               }
+
+               public override bool IsPrepared
+               {
+                       get     
+                       {
+                               if (this.state == StatementState.Deallocated ||
+                                       this.state == StatementState.Error)
+                               {
+                                       return false;
+                               }
+                               else
+                               {
+                                       return true;
+                               }
+                       }
+               }
+
+               public override DbStatementType StatementType
+               {
+                       get     { return this.statementType; }
+                       set     { this.statementType = value; }
+               }
+
+               public override StatementState State
+               {
+                       get     { return this.state; }
+                       set     { this.state = value; }
+               }
+
+               public override int     FetchSize
+               {
+                       get     { return 200; }
+                       set     { ;     }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public FesStatement(IDatabase db) :     this(db, null)
+               {
+               }
+
+               public FesStatement(IDatabase db, ITransaction transaction)
+               {
+                       if (!(db is     FesDatabase))
+                       {
+                               throw new ArgumentException("Specified argument is not of FesDatabase type.");
+                       }
+
+                       this.recordsAffected = -1;
+                       this.db                          = (FesDatabase)db;
+                       this.outputParams        = new Queue();
+
+                       if (transaction != null)
+                       {
+                               this.Transaction = transaction;
+                       }
+
+                       GC.SuppressFinalize(this);
+               }
+
+               #endregion
+
+               #region IDisposable     Methods
+
+               protected override void Dispose(bool disposing)
+               {
+                       if (!this.IsDisposed)
+                       {
+                               try
+                               {
+                                       // release any unmanaged resources
+                                       this.Release();
+
+                                       // release any managed resources
+                                       if (disposing)
+                                       {
+                                               this.Clear();
+                                               this.db                                 = null;
+                                               this.fields                             = null;
+                                               this.parameters                 = null;
+                                               this.transaction                = null;
+                                               this.outputParams               = null;
+                                               this.allRowsFetched             = false;
+                                               this.recordsAffected    = 0;
+                                               this.state                              = StatementState.Deallocated;
+                                               this.handle                             = 0;
+                                       }
+                               }
+                               finally
+                               {
+                                       base.Dispose(disposing);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Blob Creation Metods
+
+               public override BlobBase CreateBlob()
+               {
+                       return new FesBlob(this.db,     this.transaction);
+               }
+
+               public override BlobBase CreateBlob(long blobId)
+               {
+                       return new FesBlob(this.db,     this.transaction, blobId);
+               }
+
+               #endregion
+
+               #region Array Creation Methods
+
+               public override ArrayBase CreateArray(ArrayDesc descriptor)
+               {
+                       return new FesArray(descriptor);
+               }
+
+               public override ArrayBase CreateArray(string tableName, string fieldName)
+               {
+                       return new FesArray(this.db, this.transaction, tableName, fieldName);
+               }
+
+               public override ArrayBase CreateArray(long handle, string tableName, string     fieldName)
+               {
+                       return new FesArray(this.db, this.transaction, handle, tableName, fieldName);
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Prepare(string     commandText)
+               {
+                       // Clear data
+                       this.Clear();
+                       this.parameters         = null;
+                       this.fields                     = null;
+
+                       lock (this.db)
+                       {
+                               if (this.state == StatementState.Deallocated)
+                               {
+                                       // Allocate     statement
+                                       this.Allocate();
+                               }
+
+                               // Marshal structures to pointer
+                               XsqldaMarshaler marshaler =     XsqldaMarshaler.GetInstance();
+
+                               // Setup fields structure
+                               this.fields     = new Descriptor(1);
+
+                               IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, this.fields);
+
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             trHandle                = this.transaction.Handle;
+                               int             stmtHandle              = this.handle;
+
+                               byte[] buffer = this.db.Charset.GetBytes(commandText);
+
+                               FbClient.isc_dsql_prepare(
+                                       statusVector,
+                                       ref     trHandle,
+                                       ref     stmtHandle,
+                                       (short)buffer.Length,
+                                       buffer,
+                                       this.db.Dialect,
+                                       sqlda);
+
+                               // Marshal Pointer
+                               Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);
+
+                               // Free memory
+                               marshaler.CleanUpNativeData(ref sqlda);
+
+                               // Parse status vector
+                               this.db.ParseStatusVector(statusVector);
+
+                               // Describe     fields
+                               this.fields     = descriptor;
+                               if (this.fields.ActualCount     > 0     &&
+                                       this.fields.ActualCount != this.fields.Count)
+                               {
+                                       this.Describe();
+                               }
+                               else
+                               {
+                                       if (this.fields.ActualCount     == 0)
+                                       {
+                                               this.fields     = new Descriptor(0);
+                                       }
+                               }
+
+                               // Reset actual field values
+                               this.fields.ResetValues();
+
+                               // Get Statement type
+                               this.statementType = this.GetStatementType();
+
+                               // Update state
+                               this.state = StatementState.Prepared;
+                       }
+               }
+
+               public override void Execute()
+               {
+                       if (this.state == StatementState.Deallocated)
+                       {
+                               throw new InvalidOperationException("Statment is not correctly created.");
+                       }
+                       
+                       lock (this.db) 
+                       {
+                               // Marshal structures to pointer
+                               XsqldaMarshaler marshaler =     XsqldaMarshaler.GetInstance();
+
+                               IntPtr inSqlda  = IntPtr.Zero;
+                               IntPtr outSqlda = IntPtr.Zero;
+
+                               if (this.parameters     != null)
+                               {
+                                       inSqlda = marshaler.MarshalManagedToNative(this.db.Charset,     this.parameters);
+                               }
+                               if (this.statementType == DbStatementType.StoredProcedure)
+                               {
+                                       this.Fields.ResetValues();
+                                       outSqlda = marshaler.MarshalManagedToNative(this.db.Charset, this.fields);
+                               }
+
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             trHandle                = this.transaction.Handle;
+                               int             stmtHandle              = this.handle;
+
+                               FbClient.isc_dsql_execute2(
+                                       statusVector,
+                                       ref     trHandle,
+                                       ref     stmtHandle,
+                                       IscCodes.SQLDA_VERSION1,
+                                       inSqlda,
+                                       outSqlda);
+
+                               if (outSqlda != IntPtr.Zero)
+                               {
+                                       Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, outSqlda);
+
+                                       // This would be an     Execute procedure
+                                       DbValue[] values = new DbValue[descriptor.Count];
+
+                                       for     (int i = 0;     i <     values.Length; i++)
+                                       {
+                                               values[i] =     new     DbValue(this, descriptor[i]);
+                                       }
+
+                                       this.outputParams.Enqueue(values);
+                               }
+
+                               // Free memory
+                               marshaler.CleanUpNativeData(ref inSqlda);
+                               marshaler.CleanUpNativeData(ref outSqlda);
+
+                               this.db.ParseStatusVector(statusVector);
+
+                               this.UpdateRecordsAffected();
+
+                               this.state = StatementState.Executed;
+                       }
+               }
+
+               public override DbValue[] Fetch()
+               {
+                       DbValue[] row = null;
+
+                       if (this.state == StatementState.Deallocated)
+                       {
+                               throw new InvalidOperationException("Statment is not correctly created.");
+                       }
+                       if (this.statementType != DbStatementType.Select                 &&
+                               this.statementType != DbStatementType.SelectForUpdate)
+                       {
+                               return null;
+                       }
+
+                       lock (this.db)
+                       {
+                               if (!this.allRowsFetched)
+                               {
+                                       // Marshal structures to pointer
+                                       XsqldaMarshaler marshaler =     XsqldaMarshaler.GetInstance();
+
+                                       // Reset actual field values
+                                       this.fields.ResetValues();
+
+                                       IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, fields);
+
+                                       int[]   statusVector    = FesConnection.GetNewStatusVector();
+                                       int             stmtHandle              = this.handle;
+
+                                       int     status = FbClient.isc_dsql_fetch(
+                                               statusVector,
+                                               ref     stmtHandle,
+                                               IscCodes.SQLDA_VERSION1,
+                                               sqlda);
+
+                                       // Obtain values
+                                       this.fields     = marshaler.MarshalNativeToManaged(this.db.Charset,     sqlda);
+
+                                       // Free memory
+                                       marshaler.CleanUpNativeData(ref sqlda);
+                       
+                                       // Parse status vector
+                                       this.db.ParseStatusVector(statusVector);
+                       
+                                       if (status == 100)
+                                       {
+                                               this.allRowsFetched     = true;
+                                       }
+                                       else
+                                       {
+                                               // set row values
+                                               row     = new DbValue[this.fields.ActualCount];
+                                               for     (int i = 0;     i <     row.Length;     i++)
+                                               {
+                                                       row[i] = new DbValue(this, this.fields[i]);
+                                               }
+                                       }
+                               }
+                       }
+
+                       return row;
+               }
+
+               public override DbValue[] GetOuputParameters()
+               {
+                       if (this.outputParams != null && this.outputParams.Count > 0)
+                       {
+                               return (DbValue[])this.outputParams.Dequeue();
+                       }
+                       
+                       return null;
+               }
+
+               public override void Describe()
+               {
+                       lock (this.db) 
+                       {
+                               // Update structure
+                               this.fields     = new Descriptor(this.fields.ActualCount);
+
+                               // Marshal structures to pointer
+                               XsqldaMarshaler marshaler =     XsqldaMarshaler.GetInstance();
+
+                               IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, fields);
+
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             stmtHandle              = this.handle;
+
+                               FbClient.isc_dsql_describe(
+                                       statusVector,
+                                       ref     stmtHandle,
+                                       IscCodes.SQLDA_VERSION1,
+                                       sqlda);
+
+                               // Marshal Pointer
+                               Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);
+
+                               // Free memory
+                               marshaler.CleanUpNativeData(ref sqlda);
+
+                               // Parse status vector
+                               this.db.ParseStatusVector(statusVector);
+
+                               // Update field descriptor
+                               this.fields     = descriptor;
+                       }
+               }
+
+               public override void DescribeParameters()
+               {
+                       lock (this.db) 
+                       {
+                               // Marshal structures to pointer
+                               XsqldaMarshaler marshaler =     XsqldaMarshaler.GetInstance();
+
+                               this.parameters = new Descriptor(1);
+
+                               IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, parameters);
+
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             stmtHandle              = this.handle;
+
+                               FbClient.isc_dsql_describe_bind(
+                                       statusVector,
+                                       ref     stmtHandle,
+                                       IscCodes.SQLDA_VERSION1,
+                                       sqlda);
+
+                               Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);
+
+                               // Parse status vector
+                               this.db.ParseStatusVector(statusVector);
+                               
+                               if (descriptor.ActualCount != 0 &&
+                                       descriptor.Count !=     descriptor.ActualCount)
+                               {
+                                       short n = descriptor.ActualCount;
+                                       descriptor = new Descriptor(n);
+
+                                       // Fre memory
+                                       marshaler.CleanUpNativeData(ref sqlda);
+
+                                       // Marshal new structure
+                                       sqlda = marshaler.MarshalManagedToNative(this.db.Charset, descriptor);
+
+                                       FbClient.isc_dsql_describe_bind(
+                                               statusVector,
+                                               ref     stmtHandle,
+                                               IscCodes.SQLDA_VERSION1,
+                                               sqlda);
+
+                                       descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);
+
+                                       // Free memory
+                                       marshaler.CleanUpNativeData(ref sqlda);
+
+                                       // Parse status vector
+                                       this.db.ParseStatusVector(statusVector);
+                               }
+                               else
+                               {
+                                       if (descriptor.ActualCount == 0)
+                                       {
+                                               descriptor = new Descriptor(0);
+                                       }
+                               }
+
+                               // Free memory
+                               if (sqlda != IntPtr.Zero)
+                               {
+                                       marshaler.CleanUpNativeData(ref sqlda);
+                               }
+
+                               // Update parameter     descriptor
+                               this.parameters = descriptor;
+                       }
+               }
+
+               public override byte[] GetSqlInfo(byte[] items, int     bufferLength)
+               {
+                       lock (this.db) 
+                       {
+                               byte[]  buffer                  = new byte[bufferLength];
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             stmtHandle              = this.handle;
+
+                               FbClient.isc_dsql_sql_info(
+                                       statusVector,
+                                       ref     stmtHandle,
+                                       (short)items.Length,
+                                       items,
+                                       (short)bufferLength,
+                                       buffer);
+
+                               this.db.ParseStatusVector(statusVector);
+
+                               return buffer;
+                       }
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void Free(int option)
+               {
+                       // Does not     seem to be possible     or necessary to close
+                       // an execute procedure statement.
+                       if (this.StatementType == DbStatementType.StoredProcedure && 
+                               option == IscCodes.DSQL_close) 
+                       {
+                               return;            
+                       }
+                       
+                       lock (this.db) 
+                       {
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             stmtHandle              = this.handle;
+
+                               FbClient.isc_dsql_free_statement(
+                                       statusVector,
+                                       ref     stmtHandle,
+                                       (short)option);
+
+                               this.handle     = stmtHandle;
+
+                               // Reset statement information
+                               if (option == IscCodes.DSQL_drop) 
+                               {
+                                       this.parameters = null;
+                                       this.fields             = null;
+                               }
+
+                               this.Clear();
+                               this.allRowsFetched     = false;
+
+                               this.db.ParseStatusVector(statusVector);
+                       }
+               }
+
+               protected override void TransactionUpdated(object sender, EventArgs     e)
+               {
+                       lock (this)
+                       {
+                               if (this.Transaction != null && this.TransactionUpdate != null)
+                               {
+                                       this.Transaction.Update -= this.TransactionUpdate;
+                               }
+                               this.Clear();
+                               this.State                              = StatementState.Closed;
+                               this.TransactionUpdate  = null;
+                               this.allRowsFetched             = false;
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void Clear()
+               {
+                       if (this.outputParams != null && this.outputParams.Count > 0)
+                       {
+                               this.outputParams.Clear();
+                       }
+               }
+
+               private void Allocate()
+               {
+                       lock (this.db) 
+                       {
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             dbHandle                = this.db.Handle;
+                               int             stmtHandle              = this.handle;
+
+                               FbClient.isc_dsql_allocate_statement(
+                                       statusVector,
+                                       ref     dbHandle,
+                                       ref     stmtHandle);
+
+                               this.db.ParseStatusVector(statusVector);
+
+                               this.handle                     = stmtHandle;
+                               this.allRowsFetched     = false;                                
+                               this.state                      = StatementState.Allocated;
+                               this.statementType      = DbStatementType.None;
+                       }
+               }
+
+               private void UpdateRecordsAffected()
+               {
+                       if (this.StatementType == DbStatementType.Insert ||
+                               this.StatementType == DbStatementType.Delete ||
+                               this.StatementType == DbStatementType.Update)
+                       {
+                               this.recordsAffected = this.GetRecordsAffected();
+                       }
+                       else
+                       {
+                               this.recordsAffected = -1;
+                       }
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesTransaction.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesTransaction.cs
new file mode 100644 (file)
index 0000000..76c06b8
--- /dev/null
@@ -0,0 +1,401 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using System.Data;
+
+using System.Runtime.InteropServices;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Embedded
+{
+       #region Structures
+
+       [StructLayout(LayoutKind.Sequential)]
+       internal struct IscTeb
+       {
+               public IntPtr   dbb_ptr;
+               public int              tpb_len;
+               public IntPtr   tpb_ptr;
+       }
+
+       #endregion
+
+       internal sealed class FesTransaction : ITransaction, IDisposable
+       {
+               #region Events
+
+               public event TransactionUpdateEventHandler Update;
+
+               #endregion
+
+               #region Fields
+
+               private int                                     handle;
+               private FesDatabase                     db;
+               private TransactionState        state;
+               private bool                            disposed;
+
+               #endregion
+
+               #region Properties
+
+               public int Handle
+               {
+                       get     { return this.handle; }
+               }
+
+               public TransactionState State
+               {
+                       get     { return this.state; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public FesTransaction(IDatabase db)
+               {
+                       if (!(db is     FesDatabase))
+                       {
+                               throw new ArgumentException("Specified argument is not of FesDatabase type.");
+                       }
+
+                       this.db         = (FesDatabase)db;
+                       this.state      = TransactionState.NoTransaction;
+
+                       GC.SuppressFinalize(this);
+               }
+
+               #endregion
+
+               #region Finalizer
+
+               ~FesTransaction()
+               {
+                       this.Dispose(false);
+               }
+
+               #endregion
+
+               #region IDisposable     methods
+
+               public void     Dispose()
+               {
+                       this.Dispose(true);
+                       GC.SuppressFinalize(this);
+               }
+
+               private void Dispose(bool disposing)
+               {
+                       lock (this)
+                       {
+                               if (!this.disposed)
+                               {
+                                       try
+                                       {
+                                               // release any unmanaged resources
+                                               this.Rollback();
+
+                                               // release any managed resources
+                                               if (disposing)
+                                               {
+                                                       this.db         = null;
+                                                       this.handle     = 0;
+                                                       this.state      = TransactionState.NoTransaction;
+                                               }
+                                       }
+                                       finally
+                                       {
+                                               this.disposed = true;
+                                       }
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void     BeginTransaction(TransactionParameterBuffer     tpb)
+               {                       
+                       lock (this.db) 
+                       {
+                               if (this.state != TransactionState.NoTransaction)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds, 
+                                               IscCodes.isc_tra_state, 
+                                               this.handle,
+                                               "no     valid");
+                               }
+                               
+                               IscTeb teb              = new IscTeb();
+                               IntPtr tebData  = IntPtr.Zero;
+                               
+                               try
+                               {
+                                       this.state = TransactionState.TrasactionStarting;
+                                                                                                                                                       
+                                       // Set db handle
+                                       teb.dbb_ptr     = Marshal.AllocHGlobal(4);
+                                       Marshal.WriteInt32(teb.dbb_ptr, this.db.Handle);
+
+                                       // Set tpb length
+                                       teb.tpb_len     = tpb.Length;
+
+                                       // Set TPB data
+                                       teb.tpb_ptr     = Marshal.AllocHGlobal(tpb.Length);
+                                       Marshal.Copy(tpb.ToArray(),     0, teb.tpb_ptr, tpb.Length);
+
+                                       // Alloc memory for     the     IscTeb structure
+                                       int     size = Marshal.SizeOf(typeof(IscTeb));
+                                       tebData = Marshal.AllocHGlobal(size);
+
+                                       Marshal.StructureToPtr(teb,     tebData, true);
+
+                                       int[]   statusVector    = FesConnection.GetNewStatusVector();
+                                       int             trHandle                = this.handle;
+
+                                       FbClient.isc_start_multiple(
+                                               statusVector,
+                                               ref     trHandle,
+                                               1,
+                                               tebData);
+
+                                       this.handle     = trHandle;
+
+                                       // Parse status vector
+                                       this.db.ParseStatusVector(statusVector);
+
+                                       // Update transaction state
+                                       this.state = TransactionState.TransactionStarted;
+
+                                       // Update transaction count
+                                       this.db.TransactionCount++;
+                               }
+                               catch (Exception)
+                               {
+                                       throw;
+                               }
+                               finally
+                               {
+                                       // Free memory
+                                       if (teb.dbb_ptr != IntPtr.Zero)
+                                       {
+                                               Marshal.FreeHGlobal(teb.dbb_ptr);
+                                       }
+                                       if (teb.tpb_ptr != IntPtr.Zero)
+                                       {
+                                               Marshal.FreeHGlobal(teb.tpb_ptr);
+                                       }
+                                       if (tebData     != IntPtr.Zero)
+                                       {
+                                               Marshal.DestroyStructure(tebData, typeof(IscTeb));
+                                               Marshal.FreeHGlobal(tebData);
+                                       }
+                               }
+                       }
+               }
+
+               public void     Commit()
+               {
+                       lock (this.db) 
+                       {
+                               if (this.state != TransactionState.TransactionStarted && 
+                                       this.state != TransactionState.TransactionPrepared)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds, 
+                                               IscCodes.isc_tra_state, 
+                                               this.handle,
+                                               "no     valid");
+                               }
+                               
+                               this.state = TransactionState.TransactionCommiting;
+
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             trHandle                = this.handle;
+
+                               FbClient.isc_commit_transaction(statusVector, ref trHandle);
+
+                               this.handle     = trHandle;
+
+                               this.db.ParseStatusVector(statusVector);
+
+                               this.db.TransactionCount--;
+
+                               if (this.Update != null)
+                               {
+                                       this.Update(this, new EventArgs());
+                               }
+
+                               this.state = TransactionState.NoTransaction;
+                       }
+               }
+
+               public void     Rollback()
+               {
+                       lock (this.db)
+                       {
+                               if (this.state == TransactionState.NoTransaction)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds, 
+                                               IscCodes.isc_tra_state, 
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TransactionRollbacking;
+
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             trHandle                = this.handle;
+
+                               FbClient.isc_rollback_transaction(statusVector, ref     trHandle);
+
+                               this.handle     = trHandle;
+
+                               this.db.ParseStatusVector(statusVector);
+
+                               this.db.TransactionCount--;
+
+                               if (this.Update != null)
+                               {
+                                       this.Update(this, new EventArgs());
+                               }
+                       
+                               this.state = TransactionState.NoTransaction;
+                       }
+               }
+
+               public void     CommitRetaining()
+               {
+                       lock (this.db) 
+                       {
+                               if (this.state != TransactionState.TransactionStarted && 
+                                       this.state != TransactionState.TransactionPrepared)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds, 
+                                               IscCodes.isc_tra_state, 
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TransactionCommiting;
+
+                               int[] statusVector      = FesConnection.GetNewStatusVector();
+                               int       trHandle              = this.handle;
+
+                               FbClient.isc_commit_retaining(statusVector,     ref     trHandle);
+
+                               this.db.ParseStatusVector(statusVector);
+
+                               this.state = TransactionState.TransactionStarted;
+                       }
+               }
+
+               public void     RollbackRetaining()
+               {
+                       lock (this.db) 
+                       {
+                               if (this.state != TransactionState.TransactionStarted && 
+                                       this.state != TransactionState.TransactionPrepared)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds, 
+                                               IscCodes.isc_tra_state, 
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TransactionRollbacking;
+
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             trHandle                = this.handle;
+
+                               FbClient.isc_rollback_retaining(statusVector, ref trHandle);
+
+                               this.db.ParseStatusVector(statusVector);
+
+                               this.state = TransactionState.TransactionStarted;
+                       }
+               }
+
+               public void     Prepare()
+               {
+                       lock (this.db)
+                       {
+                               if (this.state != TransactionState.TransactionStarted) 
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds, 
+                                               IscCodes.isc_tra_state, 
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TransactionPreparing;
+
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             trHandle                = this.handle;
+
+                               FbClient.isc_prepare_transaction(statusVector, ref trHandle);
+
+                               this.handle     = trHandle;
+
+                               this.db.ParseStatusVector(statusVector);
+                       }
+               }
+
+               public void     Prepare(byte[] buffer)
+               {
+                       lock (this.db) 
+                       {
+                               if (this.state != TransactionState.TransactionStarted) 
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds, 
+                                               IscCodes.isc_tra_state, 
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TransactionPreparing;
+
+                               int[]   statusVector    = FesConnection.GetNewStatusVector();
+                               int             trHandle                = this.handle;
+
+                               FbClient.isc_prepare_transaction2(
+                                       statusVector,
+                                       ref     trHandle,
+                                       (short)buffer.Length,
+                                       buffer);
+
+                               this.handle     = trHandle;
+
+                               this.db.ParseStatusVector(statusVector);
+                       }
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/XSQLDA.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/XSQLDA.cs
new file mode 100644 (file)
index 0000000..86d22d6
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace FirebirdSql.Data.Embedded
+{
+       [StructLayout(LayoutKind.Sequential)]
+       internal struct XSQLDA
+       {
+               public short            version;
+               [MarshalAs(UnmanagedType.ByValTStr,     SizeConst=8)] 
+               public string           sqldaid;
+               public int                      sqldabc;
+               public short            sqln;
+               public short            sqld;
+       }
+
+       [StructLayout(LayoutKind.Sequential)] 
+       internal struct XSQLVAR
+       {
+               public short    sqltype;        
+               public short    sqlscale;
+               public short    sqlsubtype;     
+               public short    sqllen;
+               public IntPtr   sqldata;
+               public IntPtr   sqlind;
+               public short    sqlname_length;
+               [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
+               public byte[]   sqlname;
+               public short    relname_length;
+               [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
+               public byte[]   relname;
+               public short    ownername_length;
+               [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
+               public byte[]   ownername;
+               public short    aliasname_length;
+               [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
+               public byte[]   aliasname;
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/XsqldaMarshaler.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/XsqldaMarshaler.cs
new file mode 100644 (file)
index 0000000..837ec1c
--- /dev/null
@@ -0,0 +1,433 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Embedded
+{
+       internal sealed class XsqldaMarshaler
+       {
+               #region Static Fields
+
+               private static XsqldaMarshaler instance;
+
+               #endregion
+
+               #region Constructors
+
+               private XsqldaMarshaler()
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public static XsqldaMarshaler GetInstance()
+               {
+                       if (XsqldaMarshaler.instance == null)
+                       {
+                               XsqldaMarshaler.instance = new XsqldaMarshaler();
+                       }
+
+                       return XsqldaMarshaler.instance;
+               }
+
+               public void     CleanUpNativeData(ref IntPtr pNativeData)
+               {
+                       if (pNativeData != IntPtr.Zero)
+                       {
+                               // Obtain XSQLDA information
+                               XSQLDA xsqlda = new     XSQLDA();
+                       
+                               xsqlda = (XSQLDA)Marshal.PtrToStructure(pNativeData, typeof(XSQLDA));
+
+                               // Destroy XSQLDA structure
+                               Marshal.DestroyStructure(pNativeData, typeof(XSQLDA));
+
+                               // Destroy XSQLVAR structures
+                               for     (int i = 0;     i <     xsqlda.sqln; i++)
+                               {
+                                       // Free sqldata and     sqlind pointers if needed
+                                       XSQLVAR sqlvar = (XSQLVAR)Marshal.PtrToStructure(
+                                               this.GetIntPtr(pNativeData,     this.ComputeLength(i)), typeof(XSQLVAR));
+
+                                       if (sqlvar.sqldata != IntPtr.Zero)
+                                       {
+                                               Marshal.FreeHGlobal(sqlvar.sqldata);
+                                               sqlvar.sqldata = IntPtr.Zero;
+                                       }
+                                       if (sqlvar.sqlind != IntPtr.Zero)
+                                       {
+                                               Marshal.FreeHGlobal(sqlvar.sqlind);
+                                               sqlvar.sqlind = IntPtr.Zero;
+                                       }
+
+                                       Marshal.DestroyStructure(
+                                               this.GetIntPtr(pNativeData,     this.ComputeLength(i)), typeof(XSQLVAR));
+                               }
+
+                               // Free pointer memory
+                               Marshal.FreeHGlobal(pNativeData);
+
+                               pNativeData     = IntPtr.Zero;
+                       }
+               }
+
+               public IntPtr MarshalManagedToNative(Charset charset, Descriptor descriptor)
+               {
+                       // Set up XSQLDA structure
+                       XSQLDA xsqlda   = new XSQLDA();
+
+                       xsqlda.version  = descriptor.Version;
+                       xsqlda.sqln             = descriptor.Count;
+                       xsqlda.sqld             = descriptor.ActualCount;
+                       
+                       XSQLVAR[] xsqlvar =     new     XSQLVAR[descriptor.Count];
+
+                       for     (int i = 0;     i <     xsqlvar.Length; i++)
+                       {
+                               // Create a     new     XSQLVAR structure and fill it
+                               xsqlvar[i] = new XSQLVAR();
+
+                               xsqlvar[i].sqltype              = descriptor[i].DataType;
+                               xsqlvar[i].sqlscale             = descriptor[i].NumericScale;
+                               xsqlvar[i].sqlsubtype   = descriptor[i].SubType;
+                               xsqlvar[i].sqllen               = descriptor[i].Length;
+
+                               // Create a     new     pointer for     the     xsqlvar data
+                               byte[] buffer = this.GetBytes(descriptor[i]);
+                               if (buffer.Length >     0)
+                               {
+                                       xsqlvar[i].sqldata = Marshal.AllocHGlobal(buffer.Length);
+                                       Marshal.Copy(buffer, 0, xsqlvar[i].sqldata,     buffer.Length);
+                               }
+
+                               // Create a     new     pointer for     the     sqlind value
+                               xsqlvar[i].sqlind =     Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int16)));
+                               Marshal.WriteInt16(xsqlvar[i].sqlind, descriptor[i].NullFlag);                            
+
+                               // Name
+                               xsqlvar[i].sqlname                      = this.GetStringBuffer(charset, descriptor[i].Name);
+                               xsqlvar[i].sqlname_length       = (short)xsqlvar[i].sqlname.Length;
+
+                               // Relation     Name
+                               xsqlvar[i].relname                      = this.GetStringBuffer(charset, descriptor[i].Relation);
+                               xsqlvar[i].relname_length       = (short)xsqlvar[i].relname.Length;
+
+                               // Owner name
+                               xsqlvar[i].ownername            = this.GetStringBuffer(charset, descriptor[i].Owner);
+                               xsqlvar[i].ownername_length     = (short)xsqlvar[i].ownername.Length;
+
+                               // Alias name
+                               xsqlvar[i].aliasname            = this.GetStringBuffer(charset, descriptor[i].Alias);
+                               xsqlvar[i].aliasname_length     = (short)xsqlvar[i].aliasname.Length;
+                       }
+
+                       return this.MarshalManagedToNative(xsqlda, xsqlvar);
+               }
+
+               public IntPtr MarshalManagedToNative(XSQLDA     xsqlda, XSQLVAR[] xsqlvar)
+               {
+                       int             size = this.ComputeLength(xsqlda.sqln);
+                       IntPtr  ptr      = Marshal.AllocHGlobal(size);
+
+                       Marshal.StructureToPtr(xsqlda, ptr,     true);
+
+                       for     (int i = 0;     i <     xsqlvar.Length; i++)
+                       {
+                               int     offset = this.ComputeLength(i);
+                               Marshal.StructureToPtr(xsqlvar[i], this.GetIntPtr(ptr, offset), true);
+                       }
+
+                       return ptr;
+               }
+
+               public Descriptor MarshalNativeToManaged(Charset charset, IntPtr pNativeData)
+               {
+                       // Obtain XSQLDA information
+                       XSQLDA xsqlda = new     XSQLDA();
+                       
+                       xsqlda = (XSQLDA)Marshal.PtrToStructure(pNativeData, typeof(XSQLDA));
+
+                       // Create a     new     Descriptor
+                       Descriptor descriptor   = new Descriptor(xsqlda.sqln);
+                       descriptor.ActualCount  = xsqlda.sqld;
+                       
+                       // Obtain XSQLVAR members information
+                       XSQLVAR[] xsqlvar =     new     XSQLVAR[xsqlda.sqln];
+                       
+                       for     (int i = 0;     i <     xsqlvar.Length; i++)
+                       {
+                               xsqlvar[i] = (XSQLVAR)Marshal.PtrToStructure(
+                                       this.GetIntPtr(pNativeData,     this.ComputeLength(i)), typeof(XSQLVAR));
+
+                               // Map XSQLVAR information to Descriptor
+                               descriptor[i].DataType          = xsqlvar[i].sqltype;
+                               descriptor[i].NumericScale      = xsqlvar[i].sqlscale;
+                               descriptor[i].SubType           = xsqlvar[i].sqlsubtype;
+                               descriptor[i].Length            = xsqlvar[i].sqllen;
+
+                               // Decode sqlind value
+                               if (xsqlvar[i].sqlind == IntPtr.Zero)
+                               {
+                                       descriptor[i].NullFlag = 0;
+                               }
+                               else
+                               {
+                                       descriptor[i].NullFlag = Marshal.ReadInt16(xsqlvar[i].sqlind);
+                               }
+                               
+                               // Set value
+                               if (descriptor[i].NullFlag != -1)
+                               {
+                                       descriptor[i].SetValue(this.GetBytes(xsqlvar[i]));
+                               }
+                               
+                               descriptor[i].Name              = this.GetString(charset, xsqlvar[i].sqlname);
+                               descriptor[i].Relation  = this.GetString(charset, xsqlvar[i].relname);
+                               descriptor[i].Owner             = this.GetString(charset, xsqlvar[i].ownername);
+                               descriptor[i].Alias             = this.GetString(charset, xsqlvar[i].aliasname);
+                       }
+
+                       return descriptor;
+               }
+
+               #endregion
+
+               #region Private methods
+
+               private IntPtr GetIntPtr(IntPtr ptr, int offset)
+               {
+                       return (IntPtr)(ptr.ToInt32() + offset);
+               }
+
+               private int     ComputeLength(int n)
+               {
+                       return (Marshal.SizeOf(typeof(XSQLDA)) + n * Marshal.SizeOf(typeof(XSQLVAR)));
+               }
+
+               private byte[] GetBytes(XSQLVAR xsqlvar)
+               {
+                       if (xsqlvar.sqllen == 0 || xsqlvar.sqldata == IntPtr.Zero)
+                       {
+                               return null;
+                       }
+
+                       byte[] buffer = new     byte[xsqlvar.sqllen];
+
+                       switch (xsqlvar.sqltype & ~1)
+                       {
+                               case IscCodes.SQL_VARYING:
+                                       short length = Marshal.ReadInt16(xsqlvar.sqldata);
+
+                                       buffer = new byte[length];
+
+                                       IntPtr tmp = this.GetIntPtr(xsqlvar.sqldata, 2);
+
+                                       Marshal.Copy(tmp, buffer, 0, buffer.Length);
+
+                                       return buffer;
+
+                               case IscCodes.SQL_TEXT: 
+                               case IscCodes.SQL_SHORT:
+                               case IscCodes.SQL_LONG:
+                               case IscCodes.SQL_FLOAT:
+                               case IscCodes.SQL_DOUBLE:
+                               case IscCodes.SQL_D_FLOAT:
+                               case IscCodes.SQL_QUAD:
+                               case IscCodes.SQL_INT64:
+                               case IscCodes.SQL_BLOB:
+                               case IscCodes.SQL_ARRAY:        
+                               case IscCodes.SQL_TIMESTAMP:
+                               case IscCodes.SQL_TYPE_TIME:
+                               case IscCodes.SQL_TYPE_DATE:
+                                       Marshal.Copy(xsqlvar.sqldata, buffer, 0, buffer.Length);
+
+                                       return buffer;
+
+                               default:
+                                       throw new NotSupportedException("Unknown data type");
+                       }
+               }
+
+               private byte[] GetBytes(DbField field)
+               {
+                       if (field.DbValue.IsDBNull())
+                       {
+                               int     length = field.Length;
+                               
+                               if (field.SqlType == IscCodes.SQL_VARYING)
+                               {
+                                       // Add two bytes more for store value length
+                                       length += 2;
+                               }
+
+                               return new byte[length];
+                       }
+
+                       switch (field.DbDataType)
+                       {
+                               case DbDataType.Char:
+                               {
+                                       string svalue = field.DbValue.GetString();
+
+                                       if ((field.Length %     field.Charset.BytesPerCharacter) ==     0 &&
+                                               svalue.Length > field.CharCount)
+                                       {        
+                                               throw new IscException(335544321);       
+                                       }
+
+                                       byte[] buffer = new     byte[field.Length];
+                                       for     (int i = 0;     i <     buffer.Length; i++)
+                                       {
+                                               buffer[i] =     32;
+                                       }
+
+                                       byte[] bytes = field.Charset.GetBytes(svalue);
+
+                                       Buffer.BlockCopy(bytes, 0, buffer, 0, bytes.Length);
+
+                                       return buffer;
+                               }
+                               
+                               case DbDataType.VarChar:
+                               {
+                                       string svalue = field.Value.ToString();
+
+                                       if ((field.Length %     field.Charset.BytesPerCharacter) ==     0 &&
+                                               svalue.Length > field.CharCount)
+                                       {        
+                                               throw new IscException(335544321);       
+                                       }
+
+                                       byte[] sbuffer = field.Charset.GetBytes(svalue);
+
+                                       byte[] buffer = new     byte[field.Length +     2];
+
+                                       // Copy length
+                                       Buffer.BlockCopy(
+                                               BitConverter.GetBytes((short)sbuffer.Length), 
+                                               0, buffer, 0, 2);
+                                       
+                                       // Copy string value
+                                       Buffer.BlockCopy(sbuffer, 0, buffer, 2, sbuffer.Length);
+
+                                       return buffer;
+                               }
+
+                               case DbDataType.Numeric:
+                               case DbDataType.Decimal:
+                                       return this.GetNumericBytes(field);
+
+                               case DbDataType.SmallInt:
+                                       return BitConverter.GetBytes(field.DbValue.GetInt16());
+
+                               case DbDataType.Integer:
+                                       return BitConverter.GetBytes(field.DbValue.GetInt32());
+
+                               case DbDataType.Array:
+                               case DbDataType.Binary:
+                               case DbDataType.Text:
+                               case DbDataType.BigInt:
+                                       return BitConverter.GetBytes(field.DbValue.GetInt64());
+
+                               case DbDataType.Float:
+                                       return BitConverter.GetBytes(field.DbValue.GetFloat());
+                                                                       
+                               case DbDataType.Double:
+                                       return BitConverter.GetBytes(field.DbValue.GetDouble());
+
+                               case DbDataType.Date:
+                                       return BitConverter.GetBytes(
+                                               TypeEncoder.EncodeDate(field.DbValue.GetDateTime()));
+                               
+                               case DbDataType.Time:
+                                       return BitConverter.GetBytes(
+                                               TypeEncoder.EncodeTime(field.DbValue.GetDateTime()));
+                               
+                               case DbDataType.TimeStamp:
+                                       byte[] date     = BitConverter.GetBytes(
+                                               TypeEncoder.EncodeDate(field.DbValue.GetDateTime()));
+                                       
+                                       byte[] time     = BitConverter.GetBytes(
+                                               TypeEncoder.EncodeTime(field.DbValue.GetDateTime()));
+                                       
+                                       byte[] result = new     byte[8];
+
+                                       Buffer.BlockCopy(date, 0, result, 0, date.Length);
+                                       Buffer.BlockCopy(time, 0, result, 4, time.Length);
+
+                                       return result;
+
+                               case DbDataType.Guid:
+                                       return field.DbValue.GetGuid().ToByteArray();
+
+                               default:
+                                       throw new NotSupportedException("Unknown data type");
+                       }
+               }
+
+               private byte[] GetNumericBytes(DbField field)
+               {
+                       decimal value   = field.DbValue.GetDecimal();
+                       object  numeric = TypeEncoder.EncodeDecimal(value, field.NumericScale, field.DataType);
+
+                       switch (field.SqlType)
+                       {
+                               case IscCodes.SQL_SHORT:
+                                       return BitConverter.GetBytes((short)numeric);
+
+                               case IscCodes.SQL_LONG:
+                                       return BitConverter.GetBytes((int)numeric);
+
+                               case IscCodes.SQL_INT64:
+                               case IscCodes.SQL_QUAD:
+                                       return BitConverter.GetBytes((long)numeric);
+
+                               case IscCodes.SQL_DOUBLE:
+                                       return BitConverter.GetBytes(field.DbValue.GetDouble());
+
+                               default:
+                                       return null;
+                       }
+               }
+
+               private byte[] GetStringBuffer(Charset charset, string value)
+               {
+                       byte[] buffer = new     byte[32];
+                       
+                       charset.GetBytes(value, 0, value.Length, buffer, 0);
+
+                       return buffer;
+               }
+
+               private string GetString(Charset charset, byte[] buffer)
+               {
+                       string value = charset.GetString(buffer);
+
+                       return value.Replace('\0', ' ').Trim();
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.dll.resources b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.dll.resources
new file mode 100644 (file)
index 0000000..52dcc93
--- /dev/null
@@ -0,0 +1 @@
+-resource:FirebirdSql.Data.Common/Resources/isc_error_msg.resources
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.dll.sources b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.dll.sources
new file mode 100644 (file)
index 0000000..c72e0dd
--- /dev/null
@@ -0,0 +1,136 @@
+Assembly/AssemblyInfo.cs
+FirebirdSql.Data.Common/ArrayBase.cs
+FirebirdSql.Data.Common/ArrayDesc.cs
+FirebirdSql.Data.Common/BinaryEncoding.cs
+FirebirdSql.Data.Common/BlobBase.cs
+FirebirdSql.Data.Common/BlobParameterBuffer.cs
+FirebirdSql.Data.Common/Charset.cs
+FirebirdSql.Data.Common/CharsetCollection.cs
+FirebirdSql.Data.Common/DatabaseParameterBuffer.cs
+FirebirdSql.Data.Common/DbDataType.cs
+FirebirdSql.Data.Common/DbField.cs
+FirebirdSql.Data.Common/DbStatementType.cs
+FirebirdSql.Data.Common/DbValue.cs
+FirebirdSql.Data.Common/Descriptor.cs
+FirebirdSql.Data.Common/EventParameterBuffer.cs
+FirebirdSql.Data.Common/GlobalizationHelper.cs
+FirebirdSql.Data.Common/IDatabase.cs
+FirebirdSql.Data.Common/IscCodes.cs
+FirebirdSql.Data.Common/IscError.cs
+FirebirdSql.Data.Common/IscErrorCollection.cs
+FirebirdSql.Data.Common/IscException.cs
+FirebirdSql.Data.Common/IscHelper.cs
+FirebirdSql.Data.Common/IServiceManager.cs
+FirebirdSql.Data.Common/ITransaction.cs
+FirebirdSql.Data.Common/ParameterBuffer.cs
+FirebirdSql.Data.Common/RemoteEvent.cs
+FirebirdSql.Data.Common/ServiceParameterBuffer.cs
+FirebirdSql.Data.Common/StatementBase.cs
+FirebirdSql.Data.Common/StringCollection.cs
+FirebirdSql.Data.Common/TransactionParameterBuffer.cs
+FirebirdSql.Data.Common/TypeDecoder.cs
+FirebirdSql.Data.Common/TypeEncoder.cs
+FirebirdSql.Data.Common/TypeHelper.cs
+FirebirdSql.Data.Embedded/ArrayDescMarshal.cs
+FirebirdSql.Data.Embedded/ArrayDescMarshaler.cs
+FirebirdSql.Data.Embedded/FbClient.cs
+FirebirdSql.Data.Embedded/FesArray.cs
+FirebirdSql.Data.Embedded/FesBlob.cs
+FirebirdSql.Data.Embedded/FesConnection.cs
+FirebirdSql.Data.Embedded/FesDatabase.cs
+FirebirdSql.Data.Embedded/FesServiceManager.cs
+FirebirdSql.Data.Embedded/FesStatement.cs
+FirebirdSql.Data.Embedded/FesTransaction.cs
+FirebirdSql.Data.Embedded/XSQLDA.cs
+FirebirdSql.Data.Embedded/XsqldaMarshaler.cs
+FirebirdSql.Data.Firebird/ClientFactory.cs
+FirebirdSql.Data.Firebird/DbSchema/FbCharacterSets.cs
+FirebirdSql.Data.Firebird/DbSchema/FbCheckConstraints.cs
+FirebirdSql.Data.Firebird/DbSchema/FbChecksByTable.cs
+FirebirdSql.Data.Firebird/DbSchema/FbCollations.cs
+FirebirdSql.Data.Firebird/DbSchema/FbColumnPrivileges.cs
+FirebirdSql.Data.Firebird/DbSchema/FbColumns.cs
+FirebirdSql.Data.Firebird/DbSchema/FbDataTypes.cs
+FirebirdSql.Data.Firebird/DbSchema/FbDbSchema.cs
+FirebirdSql.Data.Firebird/DbSchema/FbDbSchemaFactory.cs
+FirebirdSql.Data.Firebird/DbSchema/FbDomains.cs
+FirebirdSql.Data.Firebird/DbSchema/FbForeignKeys.cs
+FirebirdSql.Data.Firebird/DbSchema/FbFunctions.cs
+FirebirdSql.Data.Firebird/DbSchema/FbGenerators.cs
+FirebirdSql.Data.Firebird/DbSchema/FbIndexes.cs
+FirebirdSql.Data.Firebird/DbSchema/FbMetaDataCollections.cs
+FirebirdSql.Data.Firebird/DbSchema/FbPrimaryKeys.cs
+FirebirdSql.Data.Firebird/DbSchema/FbProcedureParameters.cs
+FirebirdSql.Data.Firebird/DbSchema/FbProcedurePrivileges.cs
+FirebirdSql.Data.Firebird/DbSchema/FbProcedures.cs
+FirebirdSql.Data.Firebird/DbSchema/FbRestrictions.cs
+FirebirdSql.Data.Firebird/DbSchema/FbRoles.cs
+FirebirdSql.Data.Firebird/DbSchema/FbTableConstraints.cs
+FirebirdSql.Data.Firebird/DbSchema/FbTablePrivileges.cs
+FirebirdSql.Data.Firebird/DbSchema/FbTables.cs
+FirebirdSql.Data.Firebird/DbSchema/FbTriggers.cs
+FirebirdSql.Data.Firebird/DbSchema/FbUniqueKeys.cs
+FirebirdSql.Data.Firebird/DbSchema/FbViewColumnUsage.cs
+FirebirdSql.Data.Firebird/DbSchema/FbViewPrivileges.cs
+FirebirdSql.Data.Firebird/DbSchema/FbViews.cs
+FirebirdSql.Data.Firebird/FbCharset.cs
+FirebirdSql.Data.Firebird/FbCommand.cs
+FirebirdSql.Data.Firebird/FbCommandBuilder.cs
+FirebirdSql.Data.Firebird/FbCommandBuilderBehavior.cs
+FirebirdSql.Data.Firebird/FbConnection.cs
+FirebirdSql.Data.Firebird/FbConnectionInternal.cs
+FirebirdSql.Data.Firebird/FbConnectionPool.cs
+FirebirdSql.Data.Firebird/FbConnectionString.cs
+FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs
+FirebirdSql.Data.Firebird/FbDataAdapter.cs
+FirebirdSql.Data.Firebird/FbDatabaseInfo.cs
+FirebirdSql.Data.Firebird/FbDataReader.cs
+FirebirdSql.Data.Firebird/FbDbSchemaType.cs
+FirebirdSql.Data.Firebird/FbDbType.cs
+FirebirdSql.Data.Firebird/FbError.cs
+FirebirdSql.Data.Firebird/FbErrorCollection.cs
+FirebirdSql.Data.Firebird/FbException.cs
+FirebirdSql.Data.Firebird/FbInfoMessageEventArgs.cs
+FirebirdSql.Data.Firebird/FbParameter.cs
+FirebirdSql.Data.Firebird/FbParameterCollection.cs
+FirebirdSql.Data.Firebird/FbRemoteEvent.cs
+FirebirdSql.Data.Firebird/FbRemoteEventEventArgs.cs
+FirebirdSql.Data.Firebird/FbRowUpdatedEventArgs.cs
+FirebirdSql.Data.Firebird/FbRowUpdatingEventArgs.cs
+FirebirdSql.Data.Firebird/FbTransaction.cs
+FirebirdSql.Data.Firebird/FbTransactionOptions.cs
+FirebirdSql.Data.Firebird/Isql/CommandExecutedEventArgs.cs
+FirebirdSql.Data.Firebird/Isql/CommandExecutingEventArgs.cs
+FirebirdSql.Data.Firebird/Isql/FbBatchExecution.cs
+FirebirdSql.Data.Firebird/Isql/FbScript.cs
+FirebirdSql.Data.Firebird/Isql/StringParser.cs
+FirebirdSql.Data.Firebird/Services/FbBackup.cs
+FirebirdSql.Data.Firebird/Services/FbBackupFile.cs
+FirebirdSql.Data.Firebird/Services/FbBackupFlags.cs
+FirebirdSql.Data.Firebird/Services/FbConfiguration.cs
+FirebirdSql.Data.Firebird/Services/FbDatabasesInfo.cs
+FirebirdSql.Data.Firebird/Services/FbLog.cs
+FirebirdSql.Data.Firebird/Services/FbRestore.cs
+FirebirdSql.Data.Firebird/Services/FbRestoreFlags.cs
+FirebirdSql.Data.Firebird/Services/FbSecurity.cs
+FirebirdSql.Data.Firebird/Services/FbServerConfig.cs
+FirebirdSql.Data.Firebird/Services/FbServerProperties.cs
+FirebirdSql.Data.Firebird/Services/FbService.cs
+FirebirdSql.Data.Firebird/Services/FbServiceState.cs
+FirebirdSql.Data.Firebird/Services/FbShutdownMode.cs
+FirebirdSql.Data.Firebird/Services/FbStatistical.cs
+FirebirdSql.Data.Firebird/Services/FbStatisticalFlags.cs
+FirebirdSql.Data.Firebird/Services/FbUserData.cs
+FirebirdSql.Data.Firebird/Services/FbValidation.cs
+FirebirdSql.Data.Firebird/Services/FbValidationFlags.cs
+FirebirdSql.Data.Firebird/Services/ServiceOutputEventArgs.cs
+FirebirdSql.Data.Gds/GdsArray.cs
+FirebirdSql.Data.Gds/GdsBlob.cs
+FirebirdSql.Data.Gds/GdsConnection.cs
+FirebirdSql.Data.Gds/GdsDatabase.cs
+FirebirdSql.Data.Gds/GdsEventManager.cs
+FirebirdSql.Data.Gds/GdsResponse.cs
+FirebirdSql.Data.Gds/GdsServiceManager.cs
+FirebirdSql.Data.Gds/GdsStatement.cs
+FirebirdSql.Data.Gds/GdsTransaction.cs
+FirebirdSql.Data.Gds/XdrStream.cs
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.snk b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.snk
new file mode 100644 (file)
index 0000000..eb807f4
Binary files /dev/null and b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.snk differ
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/ClientFactory.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/ClientFactory.cs
new file mode 100644 (file)
index 0000000..e68b8ec
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       internal sealed class ClientFactory
+       {
+               #region Constructors
+
+               private ClientFactory()
+               {
+               }
+
+               #endregion
+
+               #region Static Methods
+
+               public static IDatabase CreateDatabase(int serverType)
+               {
+                       switch (serverType)
+                       {
+                               case 0:
+                                       // C# Client
+                                       return new FirebirdSql.Data.Gds.GdsDatabase();
+                               
+#if    (!NETCF)
+
+                               case 1:
+                                       // PInvoke Client
+                                       return new FirebirdSql.Data.Embedded.FesDatabase();
+
+#endif
+
+                               default:                                        
+                                       throw new NotSupportedException("Specified server type is not correct.");
+                       }
+               }
+
+               public static IServiceManager CreateServiceManager(int serverType)
+               {
+                       switch (serverType)
+                       {
+                               case 0:
+                                       // C# Client
+                                       return new FirebirdSql.Data.Gds.GdsServiceManager();
+
+#if    (!NETCF)
+
+                               case 1:
+                                       // PInvoke Client
+                                       return new FirebirdSql.Data.Embedded.FesServiceManager();
+
+#endif
+
+                               default:                                        
+                                       throw new NotSupportedException("Specified server type is not correct.");
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCharacterSets.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCharacterSets.cs
new file mode 100644 (file)
index 0000000..63b03ac
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbCharacterSets : FbDbSchema
+       {
+               #region Constructors
+
+               public FbCharacterSets() : base("CharacterSets")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS CHARACTER_SET_CATALOG, " +
+                                       "null AS CHARACTER_SET_SCHEMA, " +
+                                       "rdb$character_set_name AS CHARACTER_SET_NAME, " +
+                                       "rdb$character_set_id AS CHARACTER_SET_ID, " +
+                                       "rdb$default_collate_name AS DEFAULT_COLLATION," +
+                                       "rdb$bytes_per_character AS     BYTES_PER_CHARACTER, " +
+                                       "rdb$description AS     DESCRIPTION     " +
+                                "FROM " +
+                                       "rdb$character_sets");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* CHARACTER_SET_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* CHARACTER_SET_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* CHARACTER_SET_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$character_set_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rdb$character_set_name");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCheckConstraints.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCheckConstraints.cs
new file mode 100644 (file)
index 0000000..7627d99
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Text;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbCheckConstraints :     FbDbSchema
+       {
+               #region Constructors
+
+               public FbCheckConstraints()     : base("CheckConstraints")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS CONSTRAINT_CATALOG, " +
+                                       "null AS CONSTRAINT_SCHEMA,     " +
+                                       "chk.rdb$constraint_name AS     CONSTRAINT_NAME, " +
+                                       "trig.rdb$trigger_source AS     CHECK_CLAUSULE, " +
+                                       "trig.rdb$description AS DESCRIPTION " +
+                               "FROM RDB$CHECK_CONSTRAINTS     chk     " +
+                                       "left join rdb$triggers trig ON chk.rdb$trigger_name = trig.rdb$trigger_name"
+                               );
+                                               
+                       if (restrictions !=     null)
+                       {
+                               /* CONSTRAINT_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* CONSTRAINT_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* CONSTRAINT_NAME */
+                               if (restrictions.Length >= 3 && restrictions[1] != null)
+                               {
+                                       where.Append("chk.rdb$constraint_name = @p0");
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0}", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY chk.rdb$constraint_name");
+
+                       return sql;
+               }
+
+               protected override object[]     ParseRestrictions(object[] restrictions)
+               {
+                       object[] parsed = restrictions;
+
+                       if (parsed != null)
+                       {
+                               if (parsed.Length == 7 && parsed[6]     != null)
+                               {
+                                       switch (parsed[6].ToString().ToUpper(CultureInfo.CurrentCulture))
+                                       {
+                                               case "UNIQUE":
+                                                       parsed[3] =     "u";
+                                                       break;
+
+                                               case "PRIMARY KEY":
+                                                       parsed[3] =     "p";
+                                                       break;
+
+                                               case "FOREIGN KEY":
+                                                       parsed[3] =     "f";
+                                                       break;
+
+                                               case "CHECK":
+                                                       parsed[3] =     "c";
+                                                       break;
+                                       }
+                               }
+                       }
+
+                       return parsed;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbChecksByTable.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbChecksByTable.cs
new file mode 100644 (file)
index 0000000..1a7d348
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Text;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbChecksByTable : FbDbSchema
+       {
+               #region Constructors
+
+               public FbChecksByTable() : base("CheckConstraintsByTable")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS CONSTRAINT_CATALOG, " +
+                                       "null AS CONSTRAINT_SCHEMA,     " +
+                                       "chktb.rdb$constraint_name AS CONSTRAINT_NAME, " +
+                                       "chktb.rdb$relation_name AS     TABLE_NAME,     " +
+                                       "trig.rdb$trigger_source AS     CHECK_CLAUSULE, " +
+                                       "trig.rdb$description AS DESCRIPTION " +
+                               "FROM rdb$relation_constraints chktb " +
+                                       "left join rdb$check_constraints chk ON (chktb.rdb$constraint_name = chk.rdb$constraint_name AND chktb.rdb$constraint_type = 'CHECK') " +
+                                       "left join rdb$triggers trig ON chk.rdb$trigger_name = trig.rdb$trigger_name");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* CONSTRAINT_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* CONSTRAINT_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* CONSTRAINT_NAME */
+                               if (restrictions.Length >= 3 && restrictions[1] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "chktb.rdb$constraint_name     = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY chktb.rdb$relation_name, chktb.rdb$constraint_name");
+
+                       return sql;
+               }
+
+               protected override object[]     ParseRestrictions(object[] restrictions)
+               {
+                       object[] parsed = restrictions;
+
+                       if (parsed != null)
+                       {
+                               if (parsed.Length == 7 && parsed[6]     != null)
+                               {
+                                       switch (parsed[6].ToString().ToUpper(CultureInfo.CurrentCulture))
+                                       {
+                                               case "UNIQUE":
+                                                       parsed[3] =     "u";
+                                                       break;
+
+                                               case "PRIMARY KEY":
+                                                       parsed[3] =     "p";
+                                                       break;
+
+                                               case "FOREIGN KEY":
+                                                       parsed[3] =     "f";
+                                                       break;
+
+                                               case "CHECK":
+                                                       parsed[3] =     "c";
+                                                       break;
+                                       }
+                               }
+                       }
+
+                       return parsed;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCollations.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCollations.cs
new file mode 100644 (file)
index 0000000..f3604e5
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Globalization;
+using System.Data;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbCollations     : FbDbSchema
+       {
+               #region Constructors
+
+               public FbCollations() : base("Collations")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS COLLATION_CATALOG,     " +
+                                       "null AS COLLATION_SCHEMA, " +
+                                       "coll.rdb$collation_name AS     COLLATION_NAME, " +
+                                       "cs.rdb$character_set_name AS CHARACTER_SET_NAME, "     +
+                                       "coll.rdb$description AS DESCRIPTION " +
+                               "FROM rdb$collations coll "     +
+                                       "left join rdb$character_sets cs ON     coll.rdb$character_set_id =     cs.rdb$character_set_id"
+                               );
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* COLLATION_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* COLLATION_SCHEMA     */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* COLLATION_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "coll.rdb$collation_name =     @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY cs.rdb$character_set_name, coll.rdb$collation_name");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbColumnPrivileges.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbColumnPrivileges.cs
new file mode 100644 (file)
index 0000000..141eca7
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbColumnPrivileges :     FbDbSchema
+       {
+               #region Constructors
+
+               public FbColumnPrivileges()     : base("ColumnPrivileges")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS TABLE_CATALOG, " +
+                                       "null AS TABLE_SCHEMA, " + 
+                                       "rdb$relation_name AS TABLE_NAME, "     +
+                                       "rdb$field_name AS COLUMN_NAME, " +
+                                       "rdb$user AS GRANTEE, " +
+                                       "rdb$grantor AS GRANTOR, " +
+                                       "rdb$privilege AS PRIVILEGE, " + 
+                                       "rdb$grant_option AS WITH_GRANT " +
+                               "FROM " +
+                                       "rdb$user_privileges");
+
+                       where.Append("rdb$object_type = 0");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* TABLE_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* TABLE_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* TABLE_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$relation_name = @p{0}", index++);
+                               }
+
+                               /* COLUMN_NAME */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$field_name = @p{0}", index++);
+                               }
+
+                               /* GRANTOR */
+                               if (restrictions.Length >= 6 && restrictions[5] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$grantor = @p{0}", index++);
+                               }
+
+                               /* GRANTEE */
+                               if (restrictions.Length >= 5 && restrictions[4] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$user = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rdb$relation_name");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbColumns.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbColumns.cs
new file mode 100644 (file)
index 0000000..75b5a9f
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbColumns : FbDbSchema
+       {
+               #region Constructors
+
+               public FbColumns() : base("Columns")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS TABLE_CATALOG, " +
+                                       "null AS TABLE_SCHEMA, " +
+                                       "rfr.rdb$relation_name AS TABLE_NAME, " +
+                                       "rfr.rdb$field_name     AS COLUMN_NAME, " +
+                                       "null AS COLUMN_DATA_TYPE, " +
+                                       "fld.rdb$field_sub_type AS COLUMN_SUB_TYPE,     " +
+                                       "cast(fld.rdb$field_length AS integer) AS COLUMN_SIZE, " +
+                                       "cast(fld.rdb$field_precision AS integer) AS NUMERIC_PRECISION, " +
+                                       "cast(fld.rdb$field_scale AS integer) AS NUMERIC_SCALE, " +
+                                       "cast(fld.rdb$character_length AS integer) AS CHARACTER_LENGTH, " +
+                                       "cast(fld.rdb$field_length AS integer) AS CHARACTER_OCTET_LENGTH, "     +
+                                       "rfr.rdb$field_position AS ORDINAL_POSITION, " +
+                                       "null AS DOMAIN_CATALOG, " +
+                                       "null AS DOMAIN_SCHEMA, " +
+                                       "rfr.rdb$field_source AS DOMAIN_NAME, " +
+                                       "fld.rdb$default_source AS COLUMN_DEFAULT, " +
+                                       "fld.rdb$computed_source AS     COMPUTED_SOURCE, " +
+                                       "fld.rdb$dimensions     AS IS_ARRAY, " +
+                                       "rfr.rdb$null_flag AS IS_NULLABLE, " +
+                                       "0 AS IS_READONLY, " +
+                                       "fld.rdb$field_type     AS FIELD_TYPE, " +
+                                       "null AS CHARACTER_SET_CATALOG, " +
+                                       "null AS CHARACTER_SET_SCHEMA, " +
+                                       "cs.rdb$character_set_name AS CHARACTER_SET_NAME, "     +
+                                       "null AS COLLATION_CATALOG,     " +
+                                       "null AS COLLATION_SCHEMA, " +
+                                       "coll.rdb$collation_name AS     COLLATION_NAME, " +
+                                       "rfr.rdb$description AS DESCRIPTION     " +
+                               "FROM " +
+                                       "rdb$relation_fields rfr " +
+                                       "left join rdb$fields fld ON rfr.rdb$field_source =     fld.rdb$field_name " +
+                                       "left join rdb$character_sets cs ON     cs.rdb$character_set_id = fld.rdb$character_set_id " +
+                                       "left join rdb$collations coll ON (coll.rdb$collation_id = fld.rdb$collation_id AND     coll.rdb$character_set_id =     fld.rdb$character_set_id)");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* TABLE_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* TABLE_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* TABLE_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rfr.rdb$relation_name = @p{0}", index++);
+                               }
+
+                               /* COLUMN_NAME */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rfr.rdb$field_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rfr.rdb$relation_name, rfr.rdb$field_position");
+
+                       return sql;
+               }
+
+               protected override DataTable ProcessResult(DataTable schema)
+               {
+                       schema.BeginLoadData();
+
+                       foreach (DataRow row in schema.Rows)
+                       {
+                               int     blrType = Convert.ToInt32(row["FIELD_TYPE"], CultureInfo.InvariantCulture);
+                               
+                               int     subType = 0;
+                               if (row["COLUMN_SUB_TYPE"] != System.DBNull.Value)
+                               {
+                                       subType = Convert.ToInt32(row["COLUMN_SUB_TYPE"], CultureInfo.InvariantCulture);
+                               }
+
+                               int     scale = 0 ;
+                               if (row["NUMERIC_SCALE"] !=     System.DBNull.Value)
+                               {
+                                       scale = Convert.ToInt32(row["NUMERIC_SCALE"], CultureInfo.InvariantCulture);
+                               }
+
+                               if (row["IS_NULLABLE"] == DBNull.Value)
+                               {
+                                       row["IS_NULLABLE"] = true;
+                               }
+                               else
+                               {
+                                       row["IS_NULLABLE"] = false;
+                               }
+
+                               if (row["IS_ARRAY"]     == DBNull.Value)
+                               {
+                                       row["IS_ARRAY"] = false;
+                               }
+                               else
+                               {
+                                       row["IS_ARRAY"] = true;
+                               }
+
+                               FbDbType dbType = (FbDbType)TypeHelper.GetDbDataType(blrType, subType, scale);
+                               row["COLUMN_DATA_TYPE"] = TypeHelper.GetDataTypeName((DbDataType)dbType).ToLower(CultureInfo.CurrentUICulture);
+
+                               if (dbType == FbDbType.Binary || dbType == FbDbType.Text)
+                               {
+                                       row["COLUMN_SIZE"] = Int32.MaxValue;
+                               }
+
+                               if (dbType == FbDbType.Char     || dbType == FbDbType.VarChar)
+                               {
+                                       row["COLUMN_SIZE"] = row["CHARACTER_LENGTH"];
+                               }
+                               else
+                               {
+                                       row["CHARACTER_OCTET_LENGTH"] = 0;
+                               }
+
+                               if (row["NUMERIC_PRECISION"] == System.DBNull.Value     &&
+                                  (dbType == FbDbType.Decimal || dbType ==     FbDbType.Numeric))
+                               {
+                                       row["NUMERIC_PRECISION"] = row["COLUMN_SIZE"];
+                               }
+
+                               row["NUMERIC_SCALE"] = (-1)     * scale;
+
+                               string domainName =     row["DOMAIN_NAME"].ToString();
+                               if (domainName != null && domainName.StartsWith("RDB$"))
+                               {
+                                       row["DOMAIN_NAME"] = null;
+                               }
+                       }
+
+                       schema.EndLoadData();
+                       schema.AcceptChanges();
+
+                       // Remove not more needed columns
+                       schema.Columns.Remove("FIELD_TYPE");
+                       schema.Columns.Remove("CHARACTER_LENGTH");
+
+                       return schema;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDataTypes.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDataTypes.cs
new file mode 100644 (file)
index 0000000..c9f83c6
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbDataTypes
+       {
+               #region Constructors
+
+               private FbDataTypes()
+               {
+               }
+
+               #endregion
+
+               public static DataTable GetSchema()
+               {
+                       DataTable table = new DataTable("DataTypes");
+
+                       table.Columns.Add("TypeName", typeof(System.String));
+                       table.Columns.Add("DbType",     typeof(System.Int32));
+                       table.Columns.Add("ProviderDbType",     typeof(System.Int32));
+                       table.Columns.Add("ColumnSize", typeof(System.Int64));
+                       table.Columns.Add("CreateFormat", typeof(System.String));
+                       table.Columns.Add("CreateParameters", typeof(System.String));
+                       table.Columns.Add("DataType", typeof(System.String));
+                       table.Columns.Add("IsAutoIncrementable", typeof(System.Boolean));
+                       table.Columns.Add("IsBestMatch", typeof(System.Boolean));
+                       table.Columns.Add("IsCaseSensitive", typeof(System.Boolean));
+                       table.Columns.Add("IsFixedLength", typeof(System.Boolean));
+                       table.Columns.Add("IsFixedPrecisionScale", typeof(System.Boolean));
+                       table.Columns.Add("IsLong",     typeof(System.Boolean));
+                       table.Columns.Add("IsNullable", typeof(System.Boolean));
+                       table.Columns.Add("IsSearchable", typeof(System.Boolean));
+                       table.Columns.Add("IsSearchableWithLike", typeof(System.Boolean));
+                       table.Columns.Add("IsUnsigned", typeof(System.Boolean));
+                       table.Columns.Add("MaximumScale", typeof(System.Int16));
+                       table.Columns.Add("MinimumScale", typeof(System.Int16));
+                       table.Columns.Add("IsConcurrencyType", typeof(System.Boolean));
+                       table.Columns.Add("IsLiteralSupported", typeof(System.Boolean));
+                       table.Columns.Add("LiteralPrefix", typeof(System.String));
+                       table.Columns.Add("LiteralSuffix", typeof(System.String));
+
+                       DataRowCollection r     = table.Rows;
+
+                       r.Add(new object[] { "array", DbType.Object, FbDbType.Array, Int32.MaxValue, "", "", "System.Array", false,     false, false, false, false,     true , true, false,     false, false, 0, 0,     false, false, null,     null });
+                       r.Add(new object[] { "bigint", DbType.Int64, FbDbType.BigInt, 8, "", "", "System.Int64", false, false, false, true , true ,     false, true, true, true, false, 0, 0, false, false,     null, null });
+                       r.Add(new object[] { "blob", DbType.Binary,     FbDbType.Binary, Int32.MaxValue, "", "", "System.Byte[]", false, false, false, false, false, true ,     true, false, false,     false, 0, 0, false,     false, null, null });
+                       r.Add(new object[] { "blob sub_type     1",     DbType.String, FbDbType.Text, Int32.MaxValue, "", "", "System.String", false, false, true ,     true , false, true , true, true, true, false, 0, 0,     false, true, "'", "'" });
+                       r.Add(new object[] { "char", DbType.StringFixedLength, FbDbType.Char, Int16.MaxValue, "", "length",     "System.String", false, false, true     , false, false, false, true, true, true, false, 0, 0, false, true, "'", "'"     });
+                       r.Add(new object[] { "date", DbType.Date, FbDbType.Date, 4,     "",     "",     "System.DateTime", false, false, false, true , false, false, true, true, true, false, 0, 0,     false, null, null });
+                       r.Add(new object[] { "decimal", DbType.Decimal, FbDbType.Decimal, 0, "", "precision,scale",     "System.Decimal", false, false, false, true     , false, false, true, true,     true, false, 18, 0,     false, null, null });
+                       r.Add(new object[] { "double precision", DbType.Double, FbDbType.Double, 8,     "",     "",     "System.Double", false, false, false, true , true ,     false, true, true, true, false, 0, 0, false, null, null });
+                       r.Add(new object[] { "float", DbType.Single, FbDbType.Float, 4, "",     "",     "System.Float", false, false, false, true ,     true , false, true,     true, true,     false, 0, 0, false,     null, null });
+                       r.Add(new object[] { "integer", DbType.Int32, FbDbType.Integer, 4, "", "", "System.Int32", false, false, false, true , true     , false, true, true, true, false, 0, 0, false, null, null });
+                       r.Add(new object[] { "numeric", DbType.Decimal, FbDbType.Numeric, 0, "", "precision,scale",     "System.Decimal", false, false, false, true     , false, false, true, true,     true, false, 18, 0,     false, null, null });
+                       r.Add(new object[] { "smallint", DbType.Int16, FbDbType.SmallInt, 2, "", "", "System.Int16", false,     false, false, true , true ,     false, true, true, true, false, 0, 0, false, null, null });                        
+                       r.Add(new object[] { "time", DbType.Time, FbDbType.Time, 4,     "",     "",     "System.DateTime", false, false, false, true , false, false, true, true, true, false, 0, 0,     false, null, null });
+                       r.Add(new object[] { "timestamp", DbType.DateTime, FbDbType.TimeStamp, 8, "", "", "System.DateTime", false,     false, false, true , false,     false, true, true, true, false, 0, 0, false, null, null });
+                       r.Add(new object[] { "varchar", DbType.String, FbDbType.VarChar, Int16.MaxValue, "", "length", "System.String", false, false, true , false,     false, false, true,     true, true,     false, 0, 0, false,     true, "'", "'" });
+
+                       return table;
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDbSchema.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDbSchema.cs
new file mode 100644 (file)
index 0000000..3b74f10
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Collections;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal abstract class FbDbSchema
+       {
+               #region Fields
+
+               private string schemaName;
+               
+               #endregion
+
+               #region Constructors
+
+               public FbDbSchema(string schemaName)
+               {
+                       this.schemaName = schemaName;
+               }
+
+               #endregion
+
+               #region Abstract Methods
+
+               protected abstract StringBuilder GetCommandText(object[] restrictions);
+
+               #endregion
+
+               #region Methods
+
+               public virtual DataTable GetSchema(FbConnection connection,     object[] restrictions)
+               {
+                       restrictions = this.ParseRestrictions(restrictions);
+
+                       FbCommand               command = this.BuildCommand(connection, restrictions);
+                       FbDataAdapter   adapter = new FbDataAdapter(command);
+                       DataSet                 dataSet = new DataSet(this.schemaName);
+                       
+                       try
+                       {
+                               adapter.Fill(dataSet, this.schemaName);
+                       }
+                       catch (Exception ex)
+                       {
+                               throw new FbException(ex.Message);
+                       }
+                       finally
+                       {
+                               adapter.Dispose();
+                               command.Dispose();
+                       }
+
+                       TrimStringFields(dataSet.Tables[this.schemaName]);
+
+                       return this.ProcessResult(dataSet.Tables[this.schemaName]);
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected FbCommand     BuildCommand(FbConnection connection, object[] restrictions)
+               {
+                       DataView collections = FbMetaDataCollections.GetSchema().DefaultView;
+                       collections.RowFilter = "CollectionName = '" + this.schemaName + "'";
+
+                       if (collections.Count == 0)
+                       {
+                               throw new NotSupportedException("Unsupported collection name.");
+                       }
+
+                       if (restrictions !=     null &&
+                               restrictions.Length     > (int)collections[0]["NumberOfRestrictions"])
+                       {
+                               throw new InvalidOperationException("The number of specified restrictions is not valid.");
+                       }
+
+                       DataView restriction = FbRestrictions.GetSchema().DefaultView;
+                       restriction.RowFilter = "CollectionName = '" + this.schemaName + "'";
+
+                       if (restriction.Count != (int)collections[0]["NumberOfRestrictions"])
+                       {
+                               throw new InvalidOperationException("Incorrect restriction definitions.");
+                       }
+
+                       StringBuilder   builder = this.GetCommandText(restrictions);
+                       FbCommand               schema  = connection.CreateCommand();
+
+                       schema.CommandText = builder.ToString();
+
+                       if (connection.InnerConnection.HasActiveTransaction)
+                       {
+                               schema.Transaction = connection.InnerConnection.ActiveTransaction;
+                       }
+
+                       if (restrictions !=     null && restrictions.Length     > 0)
+                       {
+                               // Add parameters
+                               int     index = 0;
+
+                               for     (int i = 0;     i <     restrictions.Length; i++)
+                               {
+                                       string rname = restriction[i]["RestrictionDefault"].ToString().ToLower(CultureInfo.CurrentUICulture);
+                                       if (restrictions[i]     != null &&
+                                               !rname.EndsWith("_catalog")     &&
+                                               !rname.EndsWith("_schema") &&
+                                               rname != "table_type")
+                                       {
+                                               string pname = String.Format(CultureInfo.CurrentUICulture, "@p{0}",     index++);
+
+                                               FbParameter     p =     schema.Parameters.Add(pname, restrictions[i].ToString());
+                                               p.FbDbType = FbDbType.VarChar;
+                                               p.Size = 255;
+                                       }
+                               }
+                       }
+
+                       return schema;
+               }
+
+               protected virtual DataTable     ProcessResult(DataTable schema)
+               {
+                       return schema;
+               }
+
+               protected virtual object[] ParseRestrictions(object[] restrictions)
+               {
+                       return restrictions;
+               }
+               
+               #endregion
+
+               #region Private Static Methods
+
+               private static void     TrimStringFields(DataTable schema)
+               {
+                       schema.BeginLoadData();
+
+                       foreach (DataRow row in schema.Rows)
+                       {
+                               for     (int i = 0;     i <     schema.Columns.Count; i++)
+                               {
+                                       if (schema.Columns[i].DataType == typeof(System.String))
+                                       {
+                                               row[schema.Columns[i]] = row[schema.Columns[i]].ToString().Trim();
+                                       }
+                               }
+                       }
+                       
+                       schema.EndLoadData();
+                       schema.AcceptChanges();
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDbSchemaFactory.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDbSchemaFactory.cs
new file mode 100644 (file)
index 0000000..af92a4f
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbDbSchemaFactory
+       {
+               #region Constructors
+
+               private FbDbSchemaFactory()
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public static DataTable GetSchema(
+                       FbConnection    connection,     
+                       string                  collectionName,
+                       object[]                restrictions)
+               {
+                       FbDbSchema returnSchema = null;
+
+                       switch (collectionName.ToLower(CultureInfo.CurrentUICulture))
+                       {
+                               case "charactersets":
+                                       returnSchema = new FbCharacterSets();
+                                       break;
+
+                               case "checkconstraints":
+                                       returnSchema = new FbCheckConstraints();
+                                       break;
+
+                               case "checkconstraintsbytable":
+                                       returnSchema = new FbChecksByTable();
+                                       break;
+
+                               case "collations":
+                                       returnSchema = new FbCollations();
+                                       break;
+
+                               case "columns":
+                                       returnSchema = new FbColumns();
+                                       break;
+
+                               case "columnprivileges":
+                                       returnSchema = new FbColumnPrivileges();
+                                       break;
+
+                               case "datatypes":
+                                       return FbDataTypes.GetSchema();
+
+                               case "domains":
+                                       returnSchema = new FbDomains();
+                                       break;
+
+                               case "foreignkeys":
+                                       returnSchema = new FbForeignKeys();
+                                       break;
+
+                               case "functions":
+                                       returnSchema = new FbFunctions();
+                                       break;
+
+                               case "generators":
+                                       returnSchema = new FbGenerators();
+                                       break;
+
+                               case "indexes":
+                                       returnSchema = new FbIndexes();
+                                       break;
+
+                               case "metadatacollections":
+                                       return FbMetaDataCollections.GetSchema();
+
+                               case "primarykeys":     
+                                       returnSchema = new FbPrimaryKeys();
+                                       break;
+
+                               case "procedures":
+                                       returnSchema = new FbProcedures();
+                                       break;
+
+                               case "procedureparameters":     
+                                       returnSchema = new FbProcedureParameters();
+                                       break;
+
+                               case "procedureprivileges":
+                                       returnSchema = new FbProcedurePrivilegesSchema();
+                                       break;
+
+                               case "restrictions":
+                                       return FbRestrictions.GetSchema();
+
+                               case "roles":
+                                       returnSchema = new FbRoles();
+                                       break;
+
+                               case "tables": 
+                                       returnSchema = new FbTables();
+                                       break;
+
+                               case "tableconstraints":
+                                       returnSchema = new FbTableConstraints();
+                                       break;
+
+                               case "tableprivileges":
+                                       returnSchema = new FbTablePrivileges();                                 
+                                       break;
+
+                               case "triggers": 
+                                       returnSchema = new FbTriggers();
+                                       break;
+
+                               case "uniquekeys":
+                                       returnSchema = new FbUniqueKeys();
+                                       break;
+
+                               case "viewcolumnusage":
+                                       returnSchema = new FbViewColumnUsage();
+                                       break;
+
+                               case "views":
+                                       returnSchema = new FbViews();
+                                       break;
+
+                               case "viewprivileges":
+                                       returnSchema = new FbViewPrivileges();
+                                       break;
+
+                               default:
+                                       throw new NotSupportedException("The specified metadata collection is not supported.");
+                       }
+
+                       return returnSchema.GetSchema(connection, restrictions);
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDomains.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDomains.cs
new file mode 100644 (file)
index 0000000..72c0b9b
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbDomains : FbDbSchema
+       {
+               #region Constructors
+
+               public FbDomains() : base("Domains")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS DOMAIN_CATALOG, " +
+                                       "null AS DOMAIN_SCHEMA, " +
+                                       "fld.rdb$field_name     AS DOMAIN_NAME, " +
+                                       "null AS DOMAIN_DATA_TYPE, " +
+                                       "rdb$field_sub_type     AS DOMAIN_SUB_TYPE,     " +
+                                       "cast(fld.rdb$field_length AS integer) AS DOMAIN_SIZE, " +
+                                       "cast(fld.rdb$field_precision AS integer) AS NUMERIC_PRECISION, " +
+                                       "cast(fld.rdb$field_scale  AS integer) AS NUMERIC_SCALE, " +
+                                       "cast(fld.rdb$character_length AS integer) AS CHARACTER_LENGTH, " +
+                                       "cast(fld.rdb$field_length AS integer) AS CHARACTER_OCTET_LENGTH, "     +
+                                       "fld.rdb$null_flag AS IS_NULLABLE, " +
+                                       "fld.rdb$dimensions     AS ARRAY_DIMENSIONS, " +
+                                       "fld.rdb$description AS DESCRIPTION, " +
+                                       "fld.rdb$field_type     AS FIELD_TYPE, " +
+                                       "null AS CHARACTER_SET_CATALOG, " +
+                                       "null AS CHARACTER_SET_SCHEMA, " +
+                                       "cs.rdb$character_set_name AS CHARACTER_SET_NAME, "     +
+                                       "null AS COLLATION_CATALOG,     " +
+                                       "null AS COLLATION_SCHEMA, " +
+                                       "coll.rdb$collation_name AS     COLLATION_NAME " +
+                               "FROM " +
+                                       "rdb$fields     fld     " +
+                                       "left join rdb$character_sets cs ON     cs.rdb$character_set_id = fld.rdb$character_set_id " +
+                                       "left join rdb$collations coll ON (coll.rdb$collation_id = fld.rdb$collation_id AND     coll.rdb$character_set_id =     fld.rdb$character_set_id)");
+
+                       where.Append("not rdb$field_name starting with 'RDB$'");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* DOMAIN_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* DOMAIN_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* DOMAIN_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$field_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rdb$field_name");
+
+                       return sql;
+               }
+
+               protected override DataTable ProcessResult(DataTable schema)
+               {
+                       schema.BeginLoadData();
+
+                       foreach (DataRow row in schema.Rows)
+                       {
+                               int     blrType = Convert.ToInt32(row["FIELD_TYPE"], CultureInfo.InvariantCulture);
+                               
+                               int     subType = 0;
+                               if (row["DOMAIN_SUB_TYPE"] != System.DBNull.Value)
+                               {
+                                       subType = Convert.ToInt32(row["DOMAIN_SUB_TYPE"], CultureInfo.InvariantCulture);
+                               }
+
+                               int     scale = 0 ;
+                               if (row["NUMERIC_SCALE"] !=     System.DBNull.Value)
+                               {
+                                       scale = Convert.ToInt32(row["NUMERIC_SCALE"], CultureInfo.InvariantCulture);
+                               }
+
+                               FbDbType dbType = (FbDbType)TypeHelper.GetDbDataType(blrType, subType, scale);
+                               row["DOMAIN_DATA_TYPE"] = TypeHelper.GetDataTypeName((DbDataType)dbType).ToLower(CultureInfo.CurrentUICulture);
+
+                               if (dbType == FbDbType.Char     || dbType == FbDbType.VarChar)
+                               {
+                                       row["DOMAIN_SIZE"] = row["CHARACTER_LENGTH"];
+                               }
+                               else
+                               {
+                                       row["CHARACTER_OCTET_LENGTH"] = 0;
+                               }
+
+                               if (dbType == FbDbType.Binary || dbType == FbDbType.Text)
+                               {
+                                       row["DOMAIN_SIZE"] = Int32.MaxValue;
+                               }
+
+                               if (row["NUMERIC_PRECISION"] == System.DBNull.Value     &&
+                                  (dbType == FbDbType.Decimal || dbType ==     FbDbType.Numeric))
+                               {
+                                       row["NUMERIC_PRECISION"] = row["DOMAIN_SIZE"];
+                               }
+
+                               row["NUMERIC_SCALE"] = (-1)     * scale;
+
+                               if (row["IS_NULLABLE"] == DBNull.Value)
+                               {
+                                       row["IS_NULLABLE"] = true;
+                               }
+                               else
+                               {
+                                       row["IS_NULLABLE"] = false;
+                               }
+                       }
+
+                       schema.EndLoadData();
+                       schema.AcceptChanges();
+
+                       // Remove not more needed columns
+                       schema.Columns.Remove("FIELD_TYPE");
+                       schema.Columns.Remove("CHARACTER_LENGTH");
+
+                       return schema;
+               }
+               
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbForeignKeys.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbForeignKeys.cs
new file mode 100644 (file)
index 0000000..e268593
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbForeignKeys : FbDbSchema
+       {
+               #region Constructors
+
+               public FbForeignKeys() : base("ForeignKeys")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS PK_TABLE_CATALOG, " +
+                                       "null AS PK_TABLE_SCHEMA, "     +
+                                       "pk.rdb$relation_name AS PK_TABLE_NAME, " +
+                                       "pkseg.rdb$field_name AS PK_COLUMN_NAME, " +
+                                       "pk.rdb$constraint_name AS PK_NAME,     " +
+                                       "null AS FK_TABLE_CATALOG, " +
+                                       "null AS FK_TABLE_SCHEMA, "     +
+                                       "fk.rdb$relation_name AS FK_TABLE_NAME, " +
+                                       "fkseg.rdb$field_name AS FK_COLUMN_NAME, " +
+                                       "fk.rdb$constraint_name AS FK_NAME,     " +
+                                       "pkseg.rdb$field_position AS ORDINAL_POSITION, " +
+                                       "ref.rdb$match_option AS MATCH_OPTION, " +
+                                       "ref.rdb$update_rule AS UPDATE_RULE, " +
+                                       "ref.rdb$delete_rule AS DELETE_RULE, " +
+                                       "fk.rdb$deferrable AS IS_DEFERRABLE, " + 
+                                       "fk.rdb$initially_deferred AS INITIALLY_DEFERRED " +
+                               "FROM " +
+                                       "rdb$relation_constraints fk, " +
+                                       "rdb$index_segments     fkseg, " +
+                                       "rdb$relation_constraints pk, " +
+                                       "rdb$index_segments     pkseg, " +
+                                       "rdb$ref_constraints ref ");
+
+                       where.Append(
+                                       "fk.rdb$constraint_name = ref.rdb$constraint_name and " +
+                                       "fk.rdb$index_name = fkseg.rdb$index_name and " +
+                                       "pk.rdb$constraint_name = ref.rdb$const_name_uq and     " +
+                                       "pk.rdb$index_name = pkseg.rdb$index_name and " +
+                                       "pkseg.rdb$field_position =     fkseg.rdb$field_position ");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* PK_TABLE_CATALOG     */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* PK_TABLE_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* PK_TABLE_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " and pk.rdb$relation_name     = @p{0}", index++);
+                               }
+
+                               /* FK_TABLE_CATALOG     */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                               }
+
+                               /* FK_TABLE_SCHEMA */
+                               if (restrictions.Length >= 5 && restrictions[4] != null)
+                               {
+                               }
+
+                               /* FK_TABLE_NAME */
+                               if (restrictions.Length >= 6 && restrictions[5] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " and fk.rdb$relation_name     = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY fk.rdb$constraint_name, pk.rdb$relation_name,     pkseg.rdb$field_position");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbFunctions.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbFunctions.cs
new file mode 100644 (file)
index 0000000..1ef200f
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbFunctions : FbDbSchema
+       {
+               #region Constructors
+
+               public FbFunctions() : base("Functions")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS FUNCTION_CATALOG, " +
+                                       "null AS FUNCTION_SCHEMA, "     +
+                                       "rdb$function_name AS FUNCTION_NAME, " +
+                                       "rdb$system_flag AS     IS_SYSTEM_FUNCTION,     " +
+                                       "rdb$function_type AS FUNCTION_TYPE, " +
+                                       "rdb$query_name AS QUERY_NAME, " +
+                                       "rdb$module_name AS     FUNCTION_MODULE_NAME, " +
+                                       "rdb$entrypoint AS FUNCTION_ENTRY_POINT, " +
+                                       "rdb$return_argument AS RETURN_ARGUMENT, " +
+                                       "rdb$description AS     DESCRIPTION     " +
+                               "FROM rdb$functions");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* FUNCTION_CATALOG     */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* FUNCTION_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* FUNCTION_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$function_name     = @p{0}", index++);
+                               }
+
+                               /* IS_SYSTEM_FUNCTION */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$system_flag =     @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rdb$function_name");
+
+                       return sql;
+               }
+
+               protected override DataTable ProcessResult(DataTable schema)
+               {
+                       schema.BeginLoadData();
+
+                       foreach (DataRow row in schema.Rows)
+                       {
+                               if (row["IS_SYSTEM_FUNCTION"] == DBNull.Value ||
+                                       Convert.ToInt32(row["IS_SYSTEM_FUNCTION"], CultureInfo.InvariantCulture) ==     0)
+                               {
+                                       row["IS_SYSTEM_FUNCTION"] =     false;
+                               }
+                               else
+                               {
+                                       row["IS_SYSTEM_FUNCTION"] =     true;
+                               }
+                       }
+
+                       schema.EndLoadData();
+                       schema.AcceptChanges();
+
+                       return schema;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbGenerators.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbGenerators.cs
new file mode 100644 (file)
index 0000000..3e68f96
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbGenerators     : FbDbSchema
+       {
+               #region Constructors
+
+               public FbGenerators() : base("Generators")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS GENERATOR_CATALOG,     " +
+                                       "null AS GENERATOR_SCHEMA, " +
+                                       "rdb$generator_name     AS GENERATOR_NAME, " +
+                                       "rdb$system_flag AS     IS_SYSTEM_GENERATOR, " +
+                                       "rdb$generator_id AS GENERATOR_ID "     +
+                               "FROM " +
+                                       "rdb$generators");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* GENERATOR_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* GENERATOR_SCHEMA     */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* GENERATOR_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$generator_name = @p{0}", index++);
+                               }
+
+                               /* GENERATOR_SCHEMA     */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$system_flag =     @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rdb$generator_name");
+
+                       return sql;
+               }
+
+               protected override DataTable ProcessResult(DataTable schema)
+               {
+                       schema.BeginLoadData();
+
+                       foreach (DataRow row in schema.Rows)
+                       {
+                               if (row["IS_SYSTEM_GENERATOR"] == DBNull.Value ||
+                                       Convert.ToInt32(row["IS_SYSTEM_GENERATOR"],     CultureInfo.InvariantCulture) == 0)
+                               {
+                                       row["IS_SYSTEM_GENERATOR"] = false;
+                               }
+                               else
+                               {
+                                       row["IS_SYSTEM_GENERATOR"] = true;
+                               }
+                       }
+
+                       schema.EndLoadData();
+                       schema.AcceptChanges();
+
+                       return schema;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbIndexes.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbIndexes.cs
new file mode 100644 (file)
index 0000000..e182c6e
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbIndexes : FbDbSchema
+       {
+               #region Constructors
+
+               public FbIndexes() : base("Indexes")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS TABLE_CATALOG, " +
+                                       "null AS TABLE_SCHEMA, " +
+                                       "idx.rdb$relation_name AS TABLE_NAME, " +
+                                       "idx.rdb$index_name     AS INDEX_NAME, " +
+                                       "idx.rdb$index_type     AS INDEX_TYPE, " +
+                                       "seg.rdb$field_name     AS COLUMN_NAME, " +
+                                       "seg.rdb$field_position AS ORDINAL_POSITION, " +
+                                       "idx.rdb$index_inactive AS IS_INACTIVE, " +
+                                       "idx.rdb$system_flag AS IS_SYSTEM_INDEX, " +
+                                       "idx.rdb$unique_flag AS IS_UNIQUE, " +
+                                       "idx.rdb$statistics     AS INDEX_STATISTICS, " +
+                                       "idx.rdb$description AS DESCRIPTION     " +
+                               "FROM " +
+                                       "rdb$indices idx " +
+                                       "left join rdb$index_segments seg ON idx.rdb$index_name = seg.rdb$index_name");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* TABLE_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* TABLE_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* TABLE_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$relation_name     = @p{0}", index++);
+                               }
+
+                               /* INDEX_NAME */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$index_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY idx.rdb$relation_name, idx.rdb$index_name, seg.rdb$field_position");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbMetaDataCollections.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbMetaDataCollections.cs
new file mode 100644 (file)
index 0000000..8eacf10
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal sealed class FbMetaDataCollections
+       {
+               private FbMetaDataCollections()
+               {
+               }
+
+               public static DataTable GetSchema()
+               {
+                       DataTable table = new DataTable("MetaDataCollections");
+
+                       table.Columns.Add("CollectionName",     typeof(string));
+                       table.Columns.Add("NumberOfRestrictions", typeof(int));
+                       table.Columns.Add("NumberOfIdentifierParts", typeof(int));
+
+                       table.Rows.Add(new object[]     { "CharacterSets", 3, 0});
+                       table.Rows.Add(new object[]     { "CheckConstraints", 3, 0});
+                       table.Rows.Add(new object[]     { "CheckConstraintsByTable", 3, 0});
+                       table.Rows.Add(new object[]     { "Collations", 3, 0});
+                       table.Rows.Add(new object[]     { "ColumnPrivileges", 6, 0 });
+                       table.Rows.Add(new object[]     { "Columns", 4, 0});
+                       table.Rows.Add(new object[]     { "DataTypes", 0, 0     });
+                       table.Rows.Add(new object[]     { "Domains", 3, 0});
+                       table.Rows.Add(new object[]     { "ForeignKeys", 6,     0});
+                       table.Rows.Add(new object[]     { "Functions", 4, 0});
+                       table.Rows.Add(new object[]     { "Generators", 4, 0});
+                       table.Rows.Add(new object[]     { "Indexes", 4, 0});
+                       table.Rows.Add(new object[]     { "MetaDataCollections", 0,     0 });
+                       table.Rows.Add(new object[]     { "PrimaryKeys", 3,     0});
+                       table.Rows.Add(new object[]     { "ProcedureParameters", 4,     0});
+                       table.Rows.Add(new object[]     { "ProcedurePrivileges", 5,     0});
+                       table.Rows.Add(new object[]     { "Procedures", 3, 0});
+                       table.Rows.Add(new object[]     { "Restrictions", 0, 0 });
+                       table.Rows.Add(new object[]     { "Roles", 1, 0});
+                       table.Rows.Add(new object[]     { "Tables",     4, 0});
+                       table.Rows.Add(new object[]     { "TableConstraints", 7, 0});
+                       table.Rows.Add(new object[]     { "TablePrivileges", 5, 0});
+                       table.Rows.Add(new object[]     { "Triggers", 4, 0});
+                       table.Rows.Add(new object[]     { "UniqueKeys", 3, 0});
+                       table.Rows.Add(new object[]     { "ViewColumnUsage", 3, 0});                    
+                       table.Rows.Add(new object[]     { "ViewPrivileges",     5, 0 });
+                       table.Rows.Add(new object[]     { "Views", 3, 0 });
+
+                       return table;
+               }
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbPrimaryKeys.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbPrimaryKeys.cs
new file mode 100644 (file)
index 0000000..18f48c3
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbPrimaryKeys : FbDbSchema
+       {
+               #region Constructors
+
+               public FbPrimaryKeys() : base("PrimaryKeys")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS TABLE_CATALOG, " +
+                                       "null AS TABLE_SCHEMA, " +
+                                       "rel.rdb$relation_name AS TABLE_NAME, " +
+                                       "seg.rdb$field_name     AS COLUMN_NAME, " +
+                                       "seg.rdb$field_position AS ORDINAL_POSITION, " +
+                                       "rel.rdb$constraint_name AS     PK_NAME " +
+                               "FROM " +
+                                       "rdb$relation_constraints rel " +
+                                       "left join rdb$indices idx ON rel.rdb$index_name = idx.rdb$index_name " +
+                                       "left join rdb$index_segments seg ON idx.rdb$index_name = seg.rdb$index_name");
+
+                       where.Append("rel.rdb$constraint_type = 'PRIMARY KEY'");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* TABLE_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* TABLE_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* TABLE_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rel.rdb$relation_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rel.rdb$relation_name, rel.rdb$constraint_name, seg.rdb$field_position");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedureParameters.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedureParameters.cs
new file mode 100644 (file)
index 0000000..f293655
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbProcedureParameters : FbDbSchema
+       {
+               #region Constructors
+
+               public FbProcedureParameters() : base("ProcedureParameters")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS PROCEDURE_CATALOG,     " +
+                                       "null AS PROCEDURE_SCHEMA, " +
+                                       "pp.rdb$procedure_name AS PROCEDURE_NAME, "     +
+                                       "pp.rdb$parameter_name AS PARAMETER_NAME, "     +
+                                       "null AS PARAMETER_DATA_TYPE, " +
+                                       "fld.rdb$field_sub_type AS PARAMETER_SUB_TYPE, " +
+                                       "pp.rdb$parameter_number AS     ORDINAL_POSITION, "     +
+                                       "cast(pp.rdb$parameter_type     AS integer)     AS PARAMETER_DIRECTION, " +
+                                       "cast(fld.rdb$field_length AS integer) AS PARAMETER_SIZE, "     +
+                                       "cast(fld.rdb$field_precision AS integer) AS NUMERIC_PRECISION, " +
+                                       "cast(fld.rdb$field_scale AS integer) AS NUMERIC_SCALE, " +
+                                       "cast(fld.rdb$character_length AS integer) AS CHARACTER_LENGTH, " +
+                                       "cast(fld.rdb$field_length AS integer) AS CHARACTER_OCTET_LENGTH, "     +
+                                       "null AS CHARACTER_SET_CATALOG, " +
+                                       "null AS CHARACTER_SET_SCHEMA, " +
+                                       "cs.rdb$character_set_name AS CHARACTER_SET_NAME, "     +
+                                       "null AS COLLATION_CATALOG,     " +
+                                       "null AS COLLATION_SCHEMA, " +
+                                       "coll.rdb$collation_name AS     COLLATION_NAME, " +
+                                       "null AS COLLATION_CATALOG,     " +
+                                       "null AS COLLATION_SCHEMA, " +
+                                       "pp.rdb$description     AS DESCRIPTION, " +
+                                       "fld.rdb$field_type     AS FIELD_TYPE " +
+                               "FROM " +
+                                       "rdb$procedure_parameters pp " +
+                                       "left join rdb$fields fld ON pp.rdb$field_source = fld.rdb$field_name " +
+                                       "left join rdb$character_sets cs ON     cs.rdb$character_set_id = fld.rdb$character_set_id " +
+                                       "left join rdb$collations coll ON (coll.rdb$collation_id = fld.rdb$collation_id AND     coll.rdb$character_set_id =     fld.rdb$character_set_id) ");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* PROCEDURE_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* PROCEDURE_SCHEMA     */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* PROCEDURE_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "pp.rdb$procedure_name = @p{0}", index++);
+                               }
+
+                               /* PROCEDURE_PARAMETER */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "pp.rdb$parameter_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY pp.rdb$procedure_name, pp.rdb$parameter_type,     pp.rdb$parameter_number");
+
+                       return sql;
+               }
+
+               protected override DataTable ProcessResult(DataTable schema)
+               {
+                       schema.BeginLoadData();
+
+                       foreach (DataRow row in schema.Rows)
+                       {
+                               int     blrType = Convert.ToInt32(row["FIELD_TYPE"], CultureInfo.InvariantCulture);
+
+                               int     subType = 0;
+                               if (row["PARAMETER_SUB_TYPE"] != System.DBNull.Value)
+                               {
+                                       subType = Convert.ToInt32(row["PARAMETER_SUB_TYPE"], CultureInfo.InvariantCulture);
+                               }
+
+                               int     scale = 0 ;
+                               if (row["NUMERIC_SCALE"] !=     System.DBNull.Value)
+                               {
+                                       scale = Convert.ToInt32(row["NUMERIC_SCALE"], CultureInfo.InvariantCulture);
+                               }
+
+                               FbDbType dbType = (FbDbType)TypeHelper.GetDbDataType(blrType, subType, scale);
+                               row["PARAMETER_DATA_TYPE"] = TypeHelper.GetDataTypeName((DbDataType)dbType).ToLower(CultureInfo.CurrentUICulture);
+
+                               if (dbType == FbDbType.Char     || dbType == FbDbType.VarChar)
+                               {
+                                       row["PARAMETER_SIZE"] = row["CHARACTER_LENGTH"];
+                               }
+                               else
+                               {
+                                       row["CHARACTER_OCTET_LENGTH"] = 0;
+                               }
+
+                               if (dbType == FbDbType.Binary || dbType == FbDbType.Text)
+                               {
+                                       row["PARAMETER_SIZE"] = Int32.MaxValue;
+                               }
+
+                               if (row["NUMERIC_PRECISION"] == System.DBNull.Value     &&
+                                  (dbType == FbDbType.Decimal || dbType ==     FbDbType.Numeric))
+                               {
+                                       row["NUMERIC_PRECISION"] = row["PARAMETER_SIZE"];
+                               }
+
+                               row["NUMERIC_SCALE"] = (-1)     * scale;                                
+
+                               int     direction =     Convert.ToInt32(row["PARAMETER_DIRECTION"],     CultureInfo.InvariantCulture);
+                               switch (direction)
+                               {
+                                       case 0:
+                                               row["PARAMETER_DIRECTION"] = ParameterDirection.Input;
+                                               break;
+
+                                       case 1:
+                                               row["PARAMETER_DIRECTION"] = ParameterDirection.Output;
+                                               break;
+                               }
+                       }
+
+                       schema.EndLoadData();
+                       schema.AcceptChanges();
+
+                       // Remove not more needed columns
+                       schema.Columns.Remove("FIELD_TYPE");
+                       schema.Columns.Remove("CHARACTER_LENGTH");
+
+                       return schema;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedurePrivileges.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedurePrivileges.cs
new file mode 100644 (file)
index 0000000..ab1c3b5
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbProcedurePrivilegesSchema : FbDbSchema
+       {
+               #region Constructors
+
+               public FbProcedurePrivilegesSchema() : base("ProcedurePrivileges")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                    "null AS PROCEDURE_CATALOG, " +
+                    "null AS PROCEDURE_SCHEMA, " +
+                    "rdb$relation_name AS PROCEDURE_NAME, " +
+                    "rdb$user AS GRANTEE, " +
+                                       "rdb$grantor AS GRANTOR, " +
+                                       "rdb$privilege AS PRIVILEGE, " +
+                                       "rdb$grant_option AS WITH_GRANT " +
+                               "FROM " +
+                                       "rdb$user_privileges");
+
+                       where.Append("rdb$object_type = 5");
+
+                       if (restrictions != null)
+                       {
+                               int index = 0;
+
+                /* PROCEDURE_CATALOG */
+                if (restrictions.Length >= 1 && restrictions[0] != null)
+                {
+                }
+
+                /* PROCEDURE_SCHEMA */
+                if (restrictions.Length >= 2 && restrictions[1] != null)
+                {
+                }
+
+                /* PROCEDURE_NAME */
+                if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                    where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$relation_name = @p{0}", index++);
+                }
+
+                /* GRANTOR */
+                if (restrictions.Length >= 5 && restrictions[4] != null)
+                {
+                    where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$grantor = @p{0}", index++);
+                }
+
+                /* GRANTEE */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                    where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$user = @p{0}", index++);
+                }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+            }
+
+                       sql.Append(" ORDER BY rdb$relation_name");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedures.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedures.cs
new file mode 100644 (file)
index 0000000..5297bff
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbProcedures     : FbDbSchema
+       {
+               #region Constructors
+
+               public FbProcedures() : base("Procedures")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS PROCEDURE_CATALOG,     " +
+                                       "null AS PROCEDURE_SCHEMA, " +
+                                       "rdb$procedure_name     AS PROCEDURE_NAME, " +
+                                       "rdb$procedure_inputs AS INPUTS, " +
+                                       "rdb$procedure_outputs AS OUTPUTS, " +
+                                       "rdb$description AS     DESCRIPTION     " +
+                               "FROM " +
+                                       "rdb$procedures");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* PROCEDURE_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* PROCEDURE_SCHEMA     */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* PROCEDURE_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$procedure_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rdb$procedure_name");
+
+                       return sql;
+               }
+
+               protected override DataTable ProcessResult(DataTable schema)
+               {
+                       schema.BeginLoadData();
+
+                       foreach (DataRow row in schema.Rows)
+                       {
+                               if (row["INPUTS"] == DBNull.Value)
+                               {
+                                       row["INPUTS"] = 0;
+                               }
+                               if (row["OUTPUTS"] == DBNull.Value)
+                               {
+                                       row["OUTPUTS"] = 0;
+                               }
+                       }
+
+                       schema.EndLoadData();
+                       schema.AcceptChanges();
+                       
+                       return schema;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbRestrictions.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbRestrictions.cs
new file mode 100644 (file)
index 0000000..fa8d19d
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal sealed class FbRestrictions
+       {
+               private FbRestrictions()
+               {
+               }
+
+               public static DataTable GetSchema()
+               {
+                       DataTable table = new DataTable("Restrictions");
+
+                       table.Columns.Add("CollectionName",     typeof(System.String));
+                       table.Columns.Add("RestrictionName", typeof(System.String));
+                       table.Columns.Add("RestrictionDefault", typeof(System.String));
+                       table.Columns.Add("RestrictionNumber", typeof(System.Int32));
+
+                       table.Rows.Add(new object[]     { "CharacterSets", "Catalog", "table_catalog", 1 });
+                       table.Rows.Add(new object[]     { "CharacterSets", "Schema", "table_schema", 2 });
+                       table.Rows.Add(new object[]     { "CharacterSets", "Name", "character_set_name", 3 });
+                       table.Rows.Add(new object[]     { "CheckConstraints", "Catalog", "constraint_catalog", 1 });
+                       table.Rows.Add(new object[]     { "CheckConstraints", "Schema", "constraint_schema", 2 });
+                       table.Rows.Add(new object[]     { "CheckConstraints", "Name", "constraint_name", 3 });
+                       table.Rows.Add(new object[]     { "CheckConstraintsByTable", "Catalog", "constraint_catalog", 1 });
+                       table.Rows.Add(new object[]     { "CheckConstraintsByTable", "Schema", "constraint_schema",     2 });
+                       table.Rows.Add(new object[]     { "CheckConstraintsByTable", "Name", "constraint_name", 3 });
+                       table.Rows.Add(new object[]     { "Collations", "Catalog", "collation_catalog", 1 });
+                       table.Rows.Add(new object[]     { "Collations", "Schema", "collation_schema", 2 });
+                       table.Rows.Add(new object[]     { "Collations", "Name", "collation_name", 3     });
+                       table.Rows.Add(new object[]     { "ColumnPrivileges", "TableCatalog", "table_catalog", 1 });
+                       table.Rows.Add(new object[]     { "ColumnPrivileges", "TableSchema", "table_schema", 2 });
+                       table.Rows.Add(new object[]     { "ColumnPrivileges", "TableName", "table_name", 3 });
+                       table.Rows.Add(new object[]     { "ColumnPrivileges", "ColumnName",     "column_name", 4 });
+                       table.Rows.Add(new object[]     { "ColumnPrivileges", "Grantor", "grantor",     5 });
+                       table.Rows.Add(new object[]     { "ColumnPrivileges", "Grantee", "grantee",     6 });
+                       table.Rows.Add(new object[]     { "Columns", "TableCatalog", "table_catalog", 1 });
+                       table.Rows.Add(new object[]     { "Columns", "TableSchema",     "table_schema", 2 });
+                       table.Rows.Add(new object[]     { "Columns", "TableName", "table_name", 3 });
+                       table.Rows.Add(new object[]     { "Columns", "ColumnName", "column_name", 4     });
+                       table.Rows.Add(new object[]     { "Domains", "Catalog", "domain_catalog", 1     });
+                       table.Rows.Add(new object[]     { "Domains", "Schema", "domain_schema", 2 });
+                       table.Rows.Add(new object[]     { "Domains", "Name", "domain_name",     3 });
+                       table.Rows.Add(new object[]     { "ForeignKeys", "PkTableCatalog", "pk_table_catalog", 1 });
+                       table.Rows.Add(new object[]     { "ForeignKeys", "PkTableSchema", "pk_table_schema", 2 });
+                       table.Rows.Add(new object[]     { "ForeignKeys", "PkTableName", "pk_table_name", 3 });
+                       table.Rows.Add(new object[]     { "ForeignKeys", "FkTableCatalog", "fk_table_catalog", 4 });
+                       table.Rows.Add(new object[]     { "ForeignKeys", "FkTableSchema", "fk_table_schema", 5 });
+                       table.Rows.Add(new object[]     { "ForeignKeys", "FkTableName", "fk_table_name", 6 });
+                       table.Rows.Add(new object[]     { "Functions", "Catalog", "function_catalog", 1 });
+                       table.Rows.Add(new object[]     { "Functions", "Schema", "function_schema",     2 });
+                       table.Rows.Add(new object[]     { "Functions", "Name", "function_name", 3 });
+                       table.Rows.Add(new object[]     { "Functions", "IsSystemFunction", "is_system_function", 4 });
+                       table.Rows.Add(new object[]     { "Generators", "Catalog", "generator_catalog", 1 });
+                       table.Rows.Add(new object[]     { "Generators", "Schema", "generator_schema", 2 });
+                       table.Rows.Add(new object[]     { "Generators", "Name", "generator_name", 3     });
+                       table.Rows.Add(new object[]     { "Generators", "IsSystemGenerator", "is_system_generator",     4 });
+                       table.Rows.Add(new object[]     { "Indexes", "TableCatalog", "table_catalog", 1 });
+                       table.Rows.Add(new object[]     { "Indexes", "TableSchema",     "table_schema", 2 });
+                       table.Rows.Add(new object[]     { "Indexes", "TableName", "table_name", 3 });
+                       table.Rows.Add(new object[]     { "Indexes", "Name", "index_name", 4 });
+                       table.Rows.Add(new object[]     { "PrimaryKeys", "TableCatalog", "table_catalog", 1     });
+                       table.Rows.Add(new object[]     { "PrimaryKeys", "TableSchema", "table_schema", 2 });
+                       table.Rows.Add(new object[]     { "PrimaryKeys", "TableName", "table_name",     3 });
+                       table.Rows.Add(new object[]     { "ProcedureParameters", "ProcedureCatalog", "procedure_catalog", 1     });
+                       table.Rows.Add(new object[]     { "ProcedureParameters", "ProcedureSchema",     "procedure_schema",     2 });
+                       table.Rows.Add(new object[]     { "ProcedureParameters", "ProcedureName", "procedure_name",     3 });
+                       table.Rows.Add(new object[]     { "ProcedureParameters", "Name", "procedure_parameter", 4 });
+                       table.Rows.Add(new object[]     { "ProcedurePrivileges", "ProcedureCatalog", "procedure_catalog", 1     });
+                       table.Rows.Add(new object[]     { "ProcedurePrivileges", "ProcedureSchema",     "procedure_schema",     2 });
+                       table.Rows.Add(new object[]     { "ProcedurePrivileges", "ProcedureName", "procedure_name",     3 });
+                       table.Rows.Add(new object[]     { "ProcedurePrivileges", "Grantor",     "grantor", 4 });
+                       table.Rows.Add(new object[]     { "ProcedurePrivileges", "Grantee",     "grantee", 5 });
+                       table.Rows.Add(new object[]     { "Procedures", "ProcedureCatalog",     "procedure_catalog", 1 });
+                       table.Rows.Add(new object[]     { "Procedures", "ProcedureSchema", "procedure_schema", 2 });
+                       table.Rows.Add(new object[]     { "Procedures", "Name", "procedure_name", 3     });
+                       table.Rows.Add(new object[]     { "Roles", "Name", "role_name", 1 });
+                       table.Rows.Add(new object[]     { "TableConstraints", "ConstraintCatalog", "constraint_catalog", 1 });
+                       table.Rows.Add(new object[]     { "TableConstraints", "ConstraintSchema", "constraint_schema", 2 });
+                       table.Rows.Add(new object[]     { "TableConstraints", "ConstraintName", "constraint_name", 3 });
+                       table.Rows.Add(new object[]     { "TableConstraints", "TableCatalog", "table_catalog", 4 });
+                       table.Rows.Add(new object[]     { "TableConstraints", "TableSchema", "table_schema", 5 });
+                       table.Rows.Add(new object[]     { "TableConstraints", "TableName", "table_name", 6 });
+                       table.Rows.Add(new object[]     { "TableConstraints", "ConstraintType", "constraint_type", 7 });
+                       table.Rows.Add(new object[]     { "TablePrivileges", "TableCatalog", "table_catalog", 1 });
+                       table.Rows.Add(new object[]     { "TablePrivileges", "TableSchema",     "table_schema", 2 });
+                       table.Rows.Add(new object[]     { "TablePrivileges", "TableName", "table_name", 3 });
+                       table.Rows.Add(new object[]     { "TablePrivileges", "Grantor", "grantor", 4 });
+                       table.Rows.Add(new object[]     { "TablePrivileges", "Grantee", "grantee", 5 });
+                       table.Rows.Add(new object[]     { "Tables",     "Catalog", "table_catalog",     1 });
+                       table.Rows.Add(new object[]     { "Tables",     "Schema", "table_schema", 2     });
+                       table.Rows.Add(new object[]     { "Tables",     "Name", "table_name", 3 });
+                       table.Rows.Add(new object[]     { "Tables",     "Type", "table_type", 4 });
+                       table.Rows.Add(new object[]     { "Triggers", "TableCatalog", "table_catalog", 1 });
+                       table.Rows.Add(new object[]     { "Triggers", "TableSchema", "table_schema", 2 });
+                       table.Rows.Add(new object[]     { "Triggers", "TableName", "table_name", 3 });
+                       table.Rows.Add(new object[]     { "Triggers", "Name", "trigger_name", 4 });
+                       table.Rows.Add(new object[]     { "UniqueKeys", "TableCatalog", "table_catalog", 1 });
+                       table.Rows.Add(new object[]     { "UniqueKeys", "TableSchema", "table_schema", 2 });
+                       table.Rows.Add(new object[]     { "UniqueKeys", "TableName", "table_name", 3 });
+                       table.Rows.Add(new object[]     { "ViewColumnUsage", "ViewCatalog",     "view_catalog", 1 });
+                       table.Rows.Add(new object[]     { "ViewColumnUsage", "ViewSchema", "view_schema", 2     });
+                       table.Rows.Add(new object[]     { "ViewColumnUsage", "ViewName", "view_name", 3 });
+                       table.Rows.Add(new object[]     { "ViewPrivileges",     "ViewCatalog", "view_catalog", 1 });
+                       table.Rows.Add(new object[]     { "ViewPrivileges",     "ViewSchema", "view_schema", 2 });
+                       table.Rows.Add(new object[]     { "ViewPrivileges",     "ViewName",     "view_name", 3 });
+                       table.Rows.Add(new object[]     { "ViewPrivileges",     "Grantor", "grantor", 4 });
+                       table.Rows.Add(new object[]     { "ViewPrivileges",     "Grantee", "grantee", 5 });
+                       table.Rows.Add(new object[]     { "Views", "Catalog", "view_catalog", 1 });
+                       table.Rows.Add(new object[]     { "Views", "Schema", "view_schema",     2 });
+                       table.Rows.Add(new object[]     { "Views", "Name", "view_name", 3 });
+
+                       return table;
+               }
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbRoles.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbRoles.cs
new file mode 100644 (file)
index 0000000..a4eef8b
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbRoles : FbDbSchema
+       {
+               #region Constructors
+
+               public FbRoles() : base("Roles")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "rdb$role_name AS ROLE_NAME, " +
+                                       "rdb$owner_name AS OWNER_NAME " +
+                               "FROM rdb$roles");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$role_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rdb$role_name");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTableConstraints.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTableConstraints.cs
new file mode 100644 (file)
index 0000000..1f12805
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbTableConstraints :     FbDbSchema
+       {
+               #region Constructors
+
+               public FbTableConstraints()     : base("TableConstraints")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS CONSTRAINT_CATALOG, " +
+                                       "null AS CONSTRAINT_SCHEMA,     " +
+                                       "rc.rdb$constraint_name AS CONSTRAINT_NAME,     " +
+                                       "null AS TABLE_CATALOG, " +
+                                       "null AS TABLE_SCHEMA, " +
+                                       "rc.rdb$relation_name AS TABLE_NAME, " +
+                                       "rc.rdb$constraint_type AS CONSTRAINT_TYPE,     " +
+                                       "rc.rdb$deferrable AS IS_DEFERRABLE, " +
+                                       "rc.rdb$initially_deferred AS INITIALLY_DEFERRED " +
+                               "FROM " +
+                                       "rdb$relation_constraints rc");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* CONSTRAINT_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* CONSTRAINT_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* CONSTRAINT_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rc.rdb$constraint_name = @p{0}", index++);
+                               }
+
+                               /* TABLE_CATALOG */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                               }
+
+                               /* TABLE_SCHEMA */
+                               if (restrictions.Length >= 5 && restrictions[4] != null)
+                               {
+                               }
+
+                               /* TABLE_NAME */
+                               if (restrictions.Length >= 6 && restrictions[5] != null)
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rc.rdb$relation_name = @p{0}", index++);
+                               }
+
+                               /* CONSTRAINT_TYPE */
+                               if (restrictions.Length >= 7 && restrictions[6] != null)
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rc.rdb$constraint_type = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rc.rdb$relation_name,     rc.rdb$constraint_name");
+
+                       return sql;
+               }
+
+               protected override object[]     ParseRestrictions(object[] restrictions)
+               {
+                       object[] parsed = restrictions;
+
+                       if (parsed != null)
+                       {
+                               if (parsed.Length == 7 && parsed[6]     != null)
+                               {
+                                       switch (parsed[6].ToString().ToUpper(CultureInfo.CurrentCulture))
+                                       {
+                                               case "UNIQUE":
+                                                       parsed[3] =     "u";
+                                                       break;
+
+                                               case "PRIMARY KEY":
+                                                       parsed[3] =     "p";
+                                                       break;
+
+                                               case "FOREIGN KEY":
+                                                       parsed[3] =     "f";
+                                                       break;
+
+                                               case "CHECK":
+                                                       parsed[3] =     "c";
+                                                       break;
+                                       }
+                               }
+                       }
+
+                       return parsed;
+               }
+               
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTablePrivileges.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTablePrivileges.cs
new file mode 100644 (file)
index 0000000..c5ed90c
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbTablePrivileges : FbDbSchema
+       {
+               #region Constructors
+
+               public FbTablePrivileges() : base("TablePrivileges")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS TABLE_CATALOG, " +
+                                       "null AS TABLE_SCHEMA, " +
+                                       "rdb$relation_name AS TABLE_NAME, "     +
+                                       "rdb$user AS GRANTEE, " +
+                                       "rdb$grantor AS GRANTOR, " +
+                                       "rdb$privilege AS PRIVILEGE, " +
+                                       "rdb$grant_option AS WITH_GRANT " +
+                               "FROM " +
+                                       "rdb$user_privileges");
+
+                       where.Append("rdb$object_type = 0");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* TABLE_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* TABLE_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* TABLE_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$relation_name = @p{0}", index++);
+                               }
+
+                               /* GRANTOR */
+                               if (restrictions.Length >= 4 && restrictions[4] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$grantor = @p{0}", index++);
+                               }
+
+                               /* GRANTEE */
+                               if (restrictions.Length >= 5 && restrictions[4] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$user = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rdb$relation_name");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTables.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTables.cs
new file mode 100644 (file)
index 0000000..08de4ee
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbTables : FbDbSchema
+       {
+               #region Constructors
+
+               public FbTables() :     base("Tables")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS TABLE_CATALOG, " +
+                                       "null AS TABLE_SCHEMA, " +
+                                       "rdb$relation_name AS TABLE_NAME, "     +
+                                       "null AS TABLE_TYPE, " +
+                                       "rdb$system_flag AS     IS_SYSTEM_TABLE, " +
+                                       "rdb$owner_name AS OWNER_NAME, " +
+                                       "rdb$description AS     DESCRIPTION, " +
+                                       "rdb$view_source AS     VIEW_SOURCE     " +
+                               "FROM " +
+                                       "rdb$relations");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* TABLE_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+                               
+                               /* TABLE_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+                               
+                               /* TABLE_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$relation_name     = @p{0}", index++);
+                               }
+
+                               /* TABLE_TYPE */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+
+                                       switch (restrictions[3].ToString())
+                                       {
+                                               case "VIEW":
+                                                       where.Append("rdb$view_source IS NOT NULL");
+                                                       break;
+
+                                               case "SYSTEM TABLE":
+                                                       where.Append("rdb$view_source IS NULL and rdb$system_flag =     1");
+                                                       break;
+
+                                               case "TABLE":
+                                               default:
+                                                       where.Append("rdb$view_source IS NULL and rdb$system_flag =     0");
+                                                       break;
+                                       }
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rdb$system_flag, rdb$owner_name, rdb$relation_name");
+
+                       return sql;
+               }
+
+               protected override DataTable ProcessResult(DataTable schema)
+               {
+                       schema.BeginLoadData();
+
+                       foreach (DataRow row in schema.Rows)
+                       {
+                               row["TABLE_TYPE"] =     "TABLE";
+                               if (row["IS_SYSTEM_TABLE"] == DBNull.Value ||
+                                       Convert.ToInt32(row["IS_SYSTEM_TABLE"], CultureInfo.InvariantCulture) == 0)
+                               {
+                                       row["IS_SYSTEM_TABLE"] = false;
+                               }
+                               else
+                               {
+                                       row["IS_SYSTEM_TABLE"] = true;
+                                       row["TABLE_TYPE"] =     "SYSTEM_TABLE";
+                               }                                
+                               if (row["VIEW_SOURCE"] != null && 
+                                       row["VIEW_SOURCE"].ToString().Length > 0)
+                               {
+                                       row["TABLE_TYPE"] =     "VIEW";
+                               }
+                       }
+
+                       schema.EndLoadData();
+                       schema.AcceptChanges();
+
+                       schema.Columns.Remove("VIEW_SOURCE");
+
+                       return schema;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTriggers.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTriggers.cs
new file mode 100644 (file)
index 0000000..77fc938
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbTriggers :     FbDbSchema
+       {
+               #region Constructors
+
+               public FbTriggers()     : base("Triggers")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS TABLE_CATALOG, " +
+                                       "null AS TABLE_SCHEMA, " +
+                                       "rdb$relation_name AS TABLE_NAME, "     +
+                                       "rdb$trigger_name AS TRIGGER_NAME, " + 
+                                       "rdb$system_flag AS     IS_SYSTEM_TRIGGER, " +
+                                       "rdb$trigger_type AS TRIGGER_TYPE, " +
+                                       "rdb$trigger_inactive AS IS_INACTIVE, " +
+                                       "rdb$trigger_sequence AS SEQUENCE, " +
+                                       "rdb$trigger_source     AS SOURCE, " +
+                                       "rdb$description AS     DESCRIPTION     " +
+                               "FROM " +
+                                       "rdb$triggers");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* TABLE_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* TABLE_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* TABLE_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$relation_name     = @p{0}", index++);
+                               }
+
+                               /* TRIGGER_NAME */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, "rdb$trigger_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rdb$relation_name, rdb$trigger_name");
+
+                       return sql;
+               }
+
+               protected override DataTable ProcessResult(DataTable schema)
+               {
+                       schema.BeginLoadData();
+
+                       foreach (DataRow row in schema.Rows)
+                       {
+                               if (row["IS_SYSTEM_TRIGGER"] == DBNull.Value ||
+                                       Convert.ToInt32(row["IS_SYSTEM_TRIGGER"], CultureInfo.InvariantCulture) == 0)
+                               {
+                                       row["IS_SYSTEM_TRIGGER"] = false;
+                               }
+                               else
+                               {
+                                       row["IS_SYSTEM_TRIGGER"] = true;
+                               }
+                       }
+
+                       schema.EndLoadData();
+                       schema.AcceptChanges();
+
+                       return schema;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbUniqueKeys.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbUniqueKeys.cs
new file mode 100644 (file)
index 0000000..5b055b7
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbUniqueKeys     : FbDbSchema
+       {
+               #region Constructors
+
+               public FbUniqueKeys() : base("PrimaryKeys")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql =     new     StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS TABLE_CATALOG, " +
+                                       "null AS TABLE_SCHEMA, " +
+                                       "rel.rdb$relation_name AS TABLE_NAME, " +
+                                       "seg.rdb$field_name     AS COLUMN_NAME, " +
+                                       "seg.rdb$field_position AS ORDINAL_POSITION, " +
+                                       "rel.rdb$constraint_name AS     UK_NAME " +
+                               "FROM " +
+                                       "rdb$relation_constraints rel " +
+                                       "left join rdb$indices idx ON rel.rdb$index_name = idx.rdb$index_name " +
+                                       "left join rdb$index_segments seg ON idx.rdb$index_name = seg.rdb$index_name");
+
+                       where.Append("rel.rdb$constraint_type = 'UNIQUE'");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* TABLE_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* TABLE_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* TABLE_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rel.rdb$relation_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rel.rdb$relation_name, rel.rdb$constraint_name, seg.rdb$field_position");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViewColumnUsage.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViewColumnUsage.cs
new file mode 100644 (file)
index 0000000..ddd6dcf
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbViewColumnUsage : FbDbSchema
+       {
+               #region Constructors
+
+               public FbViewColumnUsage() : base("ViewColumnUsage")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql =     new     StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS VIEW_CATALOG, " +
+                                       "null AS VIEW_SCHEMA, " +
+                                       "rel.rdb$relation_name AS VIEW_NAME, " +
+                                       "rfr.rdb$field_name     AS COLUMN_NAME, " +
+                                       "null AS COLUMN_DATA_TYPE, " +
+                                       "fld.rdb$field_sub_type AS COLUMN_SUB_TYPE,     " +
+                                       "cast(fld.rdb$field_length AS integer) AS COLUMN_SIZE, " +
+                                       "cast(fld.rdb$field_precision AS integer) AS NUMERIC_PRECISION, " +
+                                       "cast(fld.rdb$field_scale AS integer) AS NUMERIC_SCALE, " +
+                                       "cast(fld.rdb$character_length AS integer) AS CHARACTER_LENGTH, " +
+                                       "cast(fld.rdb$field_length AS integer) AS CHARACTER_OCTET_LENGTH, "     +
+                                       "rfr.rdb$field_position AS ORDINAL_POSITION, " +
+                                       "fld.rdb$default_source AS COLUMN_DEFAULT, " +
+                                       "fld.rdb$null_flag AS IS_NULLABLE, " +
+                                       "fld.rdb$dimensions     AS IS_ARRAY, " +
+                                       "0 AS IS_READONLY, " +
+                                       "fld.rdb$field_type     AS FIELD_TYPE, " +
+                                       "null AS CHARACTER_SET_CATALOG, " +
+                                       "null AS CHARACTER_SET_SCHEMA, " +
+                                       "cs.rdb$character_set_name AS CHARACTER_SET_NAME, "     +
+                                       "null AS COLLATION_CATALOG,     " +
+                                       "null AS COLLATION_SCHEMA, " +
+                                       "coll.rdb$collation_name AS     COLLATION_NAME, " +
+                                       "rfr.rdb$description AS DESCRIPTION     " +
+                               "FROM " +
+                                       "rdb$relations rel " +
+                                       "left join rdb$relation_fields rfr ON rel.rdb$relation_name     = rfr.rdb$relation_name " +
+                                       "left join rdb$fields fld ON rfr.rdb$field_source =     fld.rdb$field_name " +
+                                       "left join rdb$character_sets cs ON     cs.rdb$character_set_id = fld.rdb$character_set_id " +
+                                       "left join rdb$collations coll ON (coll.rdb$collation_id = fld.rdb$collation_id AND     coll.rdb$character_set_id =     fld.rdb$character_set_id)");
+
+                       where.Append("rel.rdb$view_source IS NOT NULL");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* VIEW_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* VIEW_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* VIEW_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rel.rdb$relation_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rel.rdb$relation_name, rfr.rdb$field_position");
+
+                       return sql;
+               }
+
+               protected override DataTable ProcessResult(DataTable schema)
+               {
+                       schema.BeginLoadData();
+
+                       foreach (DataRow row in schema.Rows)
+                       {
+                               int     blrType = Convert.ToInt32(row["FIELD_TYPE"], CultureInfo.InvariantCulture);
+
+                               int     subType = 0;
+                               if (row["COLUMN_SUB_TYPE"] != System.DBNull.Value)
+                               {
+                                       subType = Convert.ToInt32(row["COLUMN_SUB_TYPE"], CultureInfo.InvariantCulture);
+                               }
+
+                               int     scale = 0;
+                               if (row["NUMERIC_SCALE"] !=     System.DBNull.Value)
+                               {
+                                       scale = Convert.ToInt32(row["NUMERIC_SCALE"], CultureInfo.InvariantCulture);
+                               }
+
+                               if (row["IS_NULLABLE"] == DBNull.Value)
+                               {
+                                       row["IS_NULLABLE"] = true;
+                               }
+                               else
+                               {
+                                       row["IS_NULLABLE"] = false;
+                               }
+
+                               if (row["IS_ARRAY"]     == DBNull.Value ||
+                                       Convert.ToInt32(row["IS_ARRAY"], CultureInfo.InvariantCulture) == 0)
+                               {
+                                       row["IS_ARRAY"] = false;
+                               }
+                               else
+                               {
+                                       row["IS_ARRAY"] = true;
+                               }
+
+                               FbDbType dbType = (FbDbType)TypeHelper.GetDbDataType(blrType, subType, scale);
+                               row["COLUMN_DATA_TYPE"] = TypeHelper.GetDataTypeName((DbDataType)dbType).ToLower(CultureInfo.CurrentUICulture);
+
+                               if (dbType == FbDbType.Char     || dbType == FbDbType.VarChar)
+                               {
+                                       row["COLUMN_SIZE"] = row["CHARACTER_LENGTH"];
+                               }
+                               else
+                               {
+                                       row["CHARACTER_OCTET_LENGTH"] = 0;
+                               }
+
+                               if (dbType == FbDbType.Binary || dbType == FbDbType.Text)
+                               {
+                                       row["COLUMN_SIZE"] = Int32.MaxValue;
+                               }
+
+                               if (row["NUMERIC_PRECISION"] == System.DBNull.Value     &&
+                                  (dbType == FbDbType.Decimal || dbType ==     FbDbType.Numeric))
+                               {
+                                       row["NUMERIC_PRECISION"] = row["COLUMN_SIZE"];
+                               }
+
+                               row["NUMERIC_SCALE"] = (-1)     * scale;
+                       }
+
+                       schema.EndLoadData();
+                       schema.AcceptChanges();
+
+                       // Remove not more needed columns
+                       schema.Columns.Remove("FIELD_TYPE");
+                       schema.Columns.Remove("CHARACTER_LENGTH");
+
+                       return schema;
+               }
+
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViewPrivileges.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViewPrivileges.cs
new file mode 100644 (file)
index 0000000..d8a69d1
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbViewPrivileges : FbDbSchema
+       {
+               #region Constructors
+
+               public FbViewPrivileges() :     base("ViewPrivileges")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS VIEW_CATALOG, " +
+                                       "null AS VIEW_SCHEMA, " +
+                                       "priv.rdb$relation_name AS VIEW_NAME, " +
+                                       "priv.rdb$user AS GRANTEE, " +
+                                       "priv.rdb$grantor AS GRANTOR, " +
+                                       "priv.rdb$privilege     AS PRIVILEGE, " +
+                                       "priv.rdb$grant_option AS WITH_GRANT " +
+                               "FROM " +
+                                       "rdb$user_privileges priv "     +
+                                       "left join rdb$relations rel ON priv.rdb$relation_name = rel.rdb$relation_name");
+
+                       where.Append("priv.rdb$object_type = 0");
+                       where.Append(" AND rel.rdb$view_source IS NOT NULL");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* VIEW_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+                                       
+                               /* VIEW_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* VIEW_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND priv.rdb$relation_name = @p{0}", index++);
+                               }
+
+                               /* GRANTOR */
+                               if (restrictions.Length >= 4 && restrictions[3] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND priv.rdb$grantor = @p{0}", index++);
+                               }
+
+                               /* GRANTEE */
+                               if (restrictions.Length >= 5 && restrictions[4] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND priv.rdb$user = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY priv.rdb$relation_name, priv.rdb$user");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViews.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViews.cs
new file mode 100644 (file)
index 0000000..706fcdb
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird.DbSchema
+{
+       internal class FbViews : FbDbSchema
+       {
+               #region Constructors
+
+               public FbViews() : base("Views")
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override StringBuilder GetCommandText(object[] restrictions)
+               {
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       sql.Append(
+                               @"SELECT " +
+                                       "null AS VIEW_CATALOG, " +
+                                       "null AS VIEW_SCHEMA, " +
+                                       "rel.rdb$relation_name AS VIEW_NAME, " +
+                                       "rel.rdb$view_source AS DEFINITION,     " +
+                                       "rel.rdb$description AS DESCRIPTION     " +
+                               "FROM " +
+                                       "rdb$relations rel");
+
+                       where.Append("rel.rdb$view_source IS NOT NULL");
+
+                       if (restrictions !=     null)
+                       {
+                               int     index = 0;
+
+                               /* VIEW_CATALOG */
+                               if (restrictions.Length >= 1 && restrictions[0] != null)
+                               {
+                               }
+
+                               /* VIEW_SCHEMA */
+                               if (restrictions.Length >= 2 && restrictions[1] != null)
+                               {
+                               }
+
+                               /* VIEW_NAME */
+                               if (restrictions.Length >= 3 && restrictions[2] != null)
+                               {
+                                       where.AppendFormat(CultureInfo.CurrentUICulture, " AND rel.rdb$relation_name = @p{0}", index++);
+                               }
+                       }
+
+                       if (where.Length > 0)
+                       {
+                               sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
+                       }
+
+                       sql.Append(" ORDER BY rel.rdb$relation_name");
+
+                       return sql;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCharset.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCharset.cs
new file mode 100644 (file)
index 0000000..d50404b
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/overview/*'/>
+#if    (!NETCF)
+       [Serializable]
+#endif
+       public enum     FbCharset :     int
+       {
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Default"]/*'/>
+               Default                 = -1,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="None"]/*'/>
+               None                    = 0,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Octets"]/*'/>
+               Octets                  = 1,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Ascii"]/*'/>
+               Ascii                   = 2,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="UnicodeFss"]/*'/>
+               UnicodeFss              = 3,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="ShiftJis0208"]/*'/>
+               ShiftJis0208    = 5,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="EucJapanese0208"]/*'/>
+               EucJapanese0208 = 6,    
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Iso2022Japanese"]/*'/>
+               Iso2022Japanese = 7,    
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Dos437"]/*'/>
+               Dos437                  = 10,   
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Dos850"]/*'/>
+               Dos850                  = 11,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Dos865"]/*'/>
+               Dos865                  = 12,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Dos860"]/*'/>
+               Dos860                  = 13,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Dos863"]/*'/>
+               Dos863                  = 14,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Iso8859_1"]/*'/>
+               Iso8859_1               = 21,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Iso8859_2"]/*'/>
+               Iso8859_2               = 22,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Ksc5601"]/*'/>
+               Ksc5601                 = 44,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Dos861"]/*'/>
+               Dos861                  = 47,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Windows1250"]/*'/>
+               Windows1250             = 51,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Windows1251"]/*'/>
+               Windows1251             = 52,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Windows1252"]/*'/>
+               Windows1252             = 53,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Windows1253"]/*'/>
+               Windows1253             = 54,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Windows1254"]/*'/>
+               Windows1254             = 55,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Big5"]/*'/>
+               Big5                    = 56,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Gb2312"]/*'/>
+               Gb2312                  = 57,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Windows1255"]/*'/>
+               Windows1255             = 58,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Windows1256"]/*'/>
+               Windows1256             = 59,
+               ///     <include file='Doc/en_EN/FbCharset.xml' path='doc/enum[@name="FbCharset"]/field[@name="Windows1257"]/*'/>
+               Windows1257             = 60
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommand.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommand.cs
new file mode 100644 (file)
index 0000000..2fc4e00
--- /dev/null
@@ -0,0 +1,1258 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Globalization;
+using System.Text;
+using System.Text.RegularExpressions;
+
+using FirebirdSql.Data.Common;
+#if    (NET)
+using FirebirdSql.Data.Firebird.Design;
+using System.ComponentModel.Design;
+#endif
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/overview/*'/>
+#if    (NET)
+       [ToolboxItem(true)]
+       [ToolboxBitmap(typeof(FbCommand), "Resources.FbCommand.bmp")]
+       [Designer(typeof(FbCommandDesigner), typeof(IDesigner))]
+#endif
+       public sealed class     FbCommand :     Component, IDbCommand, ICloneable
+       {
+               #region Private static fields
+
+               private static Regex namedRegex = new Regex(
+                       @"(('[^']*?\@[^']*')*[^'@]*?)*(?<param>@\w+)*([^'@]*?('[^']*?\@*[^']*'))*",
+                       RegexOptions.Compiled | RegexOptions.ExplicitCapture);
+
+               #endregion
+
+               #region Fields
+
+               private CommandType                             commandType;
+               private UpdateRowSource                 updatedRowSource;
+               private FbConnection                    connection;
+               private FbTransaction                   transaction;
+               private FbParameterCollection   parameters;
+               private StatementBase                   statement;
+               private FbDataReader                    activeReader;
+               private string                                  commandText;
+               private bool                                    disposed;
+               private bool                                    designTimeVisible;
+               private bool                                    implicitTransaction;
+               private int                                             commandTimeout;
+               private StringCollection                namedParameters;
+               private int                                             fetchSize;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/property[@name="CommandText"]/*'/>
+#if    (NET)
+               [Category("Data")]
+               [DefaultValue("")]
+               [RefreshProperties(RefreshProperties.All)]
+               [Editor(typeof(Design.FbCommandTextUIEditor), typeof(System.Drawing.Design.UITypeEditor))]
+#endif
+               public string CommandText
+               {
+                       get     { return this.commandText; }
+                       set
+                       {
+                               lock (this)
+                               {
+                                       if (this.statement != null &&
+                                               this.commandText !=     null &&
+                                               this.commandText !=     value &&
+                                               this.commandText.Length != 0)
+                                       {
+                                               this.Release();
+                                       }
+
+                                       this.commandText = value;
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/property[@name="CommandType"]/*'/>
+#if    (!NETCF)
+               [Category("Data"), DefaultValue(CommandType.Text), RefreshProperties(RefreshProperties.All)]
+#endif
+               public CommandType CommandType
+               {
+                       get     { return this.commandType; }
+                       set     { this.commandType = value;     }
+               }
+
+               int     IDbCommand.CommandTimeout
+               {
+                       get     { return this.commandTimeout; }
+                       set
+                       {
+                               if (value <     0)
+                               {
+                                       throw new ArgumentException("The property value assigned is     less than 0.");
+                               }
+
+                               this.commandTimeout     = value;
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/property[@name="CommandPlan"]/*'/>
+#if    (!NETCF)
+               [Browsable(false)]
+#endif
+               public string CommandPlan
+               {
+                       get
+                       {
+                               if (this.statement != null)
+                               {
+                                       return this.statement.GetExecutionPlan();
+                               }
+                               return null;
+                       }
+               }
+
+               IDbConnection IDbCommand.Connection
+               {
+                       get     { return this.Connection; }
+                       set     { this.Connection =     (FbConnection)value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/property[@name="Connection"]/*'/>
+#if    (!NETCF)
+               [Category("Behavior"), DefaultValue(null)]
+#endif
+               public FbConnection     Connection
+               {
+                       get     { return this.connection; }
+                       set
+                       {
+                               lock (this)
+                               {
+                                       if (this.activeReader != null)
+                                       {
+                                               throw new InvalidOperationException("There is already an open DataReader associated     with this Command which must be closed first.");
+                                       }
+
+                                       if (this.transaction != null && this.transaction.IsUpdated)
+                                       {
+                                               this.transaction = null;
+                                       }
+
+                                       if (this.connection     != null && 
+                                               this.connection != value &&     
+                                               this.connection.State == ConnectionState.Open)
+                                       {
+                                               this.Release();
+                                       }
+
+                                       this.connection = value;
+                               }
+                       }
+               }
+
+               IDataParameterCollection IDbCommand.Parameters
+               {
+                       get     { return this.Parameters; }
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/property[@name="Parameters"]/*'/>
+#if    (!NETCF)
+               [Category("Data")]
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+#endif
+               public FbParameterCollection Parameters
+               {
+                       get     { return this.parameters; }
+               }
+
+               IDbTransaction IDbCommand.Transaction
+               {
+                       get     { return this.Transaction; }
+                       set     { this.Transaction = (FbTransaction)value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/property[@name="Transaction"]/*'/>
+#if    (!NETCF)
+               [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+               public FbTransaction Transaction
+               {
+                       get     { return this.implicitTransaction ?     null : this.transaction; }
+                       set
+                       {
+                               lock (this)
+                               {
+                                       if (this.activeReader != null)
+                                       {
+                                               throw new InvalidOperationException("There is already an open DataReader associated     with this Command which must be closed first.");
+                                       }
+
+                                       this.RollbackImplicitTransaction();
+
+                                       this.transaction = value;
+
+                                       if (this.statement != null)
+                                       {
+                                               if (this.transaction != null)
+                                               {
+                                                       this.statement.Transaction = this.transaction.Transaction;
+                                               }
+                                               else
+                                               {
+                                                       this.statement.Transaction = null;
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/property[@name="UpdatedRowSource"]/*'/>
+#if    (!NETCF)
+               [Category("Behavior"), DefaultValue(UpdateRowSource.Both)]
+#endif
+               public UpdateRowSource UpdatedRowSource
+               {
+                       get     { return this.updatedRowSource; }
+                       set     { this.updatedRowSource = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/property[@name="FetchSize"]/*'/>
+#if    (!NETCF)
+               [Category("Behavior"), DefaultValue(200)]
+#endif
+               public int FetchSize
+               {
+                       get     { return this.fetchSize; }
+                       set
+                       {
+                               if (this.activeReader != null)
+                               {
+                                       throw new InvalidOperationException("There is already an open DataReader associated     with this Command which must be closed first.");
+                               }
+                               this.fetchSize = value;
+                       }
+               }
+
+               #endregion
+
+               #region Design-Time     properties
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/property[@name="DesignTimeVisible"]/*'/>
+#if    (!NETCF)
+               [Browsable(false), DesignOnly(true), DefaultValue(true)]
+#endif
+               public bool     DesignTimeVisible
+               {
+                       get     { return this.designTimeVisible; }
+                       set     
+                       { 
+                               this.designTimeVisible = value; 
+#if    (!NETCF)
+                               TypeDescriptor.Refresh(this);
+#endif
+                       }
+               }
+
+               #endregion
+
+               #region Internal Properties
+
+               internal int RecordsAffected
+               {
+                       get
+                       {
+                               if (this.statement != null)
+                               {
+                                       return this.statement.RecordsAffected;
+                               }
+                               return -1;
+                       }
+               }
+
+               internal bool IsDisposed
+               {
+                       get     { return this.disposed; }
+               }
+
+               internal FbDataReader ActiveReader
+               {
+                       get     { return this.activeReader;     }
+                       set     { this.activeReader     = value; }
+               }
+
+               internal FbTransaction ActiveTransaction
+               {
+                       get     { return this.transaction; }
+               }
+
+               internal bool HasImplicitTransaction
+               {
+                       get
+                       {
+                               if (this.implicitTransaction)
+                               {
+                                       return true;
+                               }
+                               return false;
+                       }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/constructor[@name="ctor"]/*'/>
+               public FbCommand() : this(null, null, null)
+               {
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/constructor[@name="ctor(System.String)"]/*'/>
+               public FbCommand(string cmdText) : this(cmdText, null, null)
+               {
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/constructor[@name="ctor(System.String,FbConnection)"]/*'/>
+               public FbCommand(string cmdText, FbConnection connection) 
+                       : this(cmdText, connection,     null)
+               {
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/constructor[@name="ctor(System.String,FbConnection,Transaction)"]/*'/>
+               public FbCommand(string cmdText, FbConnection connection, FbTransaction transaction) 
+                       : base()
+               {
+                       this.designTimeVisible  = true;
+                       this.parameters                 = new FbParameterCollection();
+                       this.updatedRowSource   = UpdateRowSource.Both;
+                       this.commandType                = CommandType.Text;
+                       this.designTimeVisible  = true;
+                       this.commandTimeout             = 30;
+                       this.namedParameters    = new StringCollection();
+                       this.fetchSize                  = 200;
+                       this.commandText                = "";
+
+                       if (connection != null)
+                       {
+                               this.fetchSize = connection.ConnectionOptions.FetchSize;
+                       }
+
+                       if (cmdText     != null)
+                       {
+                               this.CommandText = cmdText;
+                       }
+                       this.Connection         = connection;
+                       this.transaction        = transaction;
+               }
+
+               #endregion
+
+               #region IDisposable     Methods
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/method[@name="Dispose(System.Boolean)"]/*'/>
+               protected override void Dispose(bool disposing)
+               {
+                       lock (this)
+                       {
+                               if (!this.disposed)
+                               {
+                                       try
+                                       {
+                                               // If there     are     an active reader close it
+                                               this.CloseReader();
+
+                                               // Release any unmanaged resources
+                                               this.Release();
+
+                                               // release any managed resources
+                                               if (disposing)
+                                               {
+                                                       this.commandText                        = null;
+                                                       this.commandTimeout                     = 0;
+                                                       this.implicitTransaction        = false;
+                                                       this.connection                         = null;
+                                                       this.transaction                        = null;
+                                                       this.parameters                         = null;
+                                                       
+                                                       this.namedParameters.Clear();
+                                                       this.namedParameters            = null;
+                                               }
+
+                                               this.disposed = true;
+                                       }
+                                       finally
+                                       {
+                                               base.Dispose(disposing);
+                                       }
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region ICloneable Methods
+
+               object ICloneable.Clone()
+               {
+                       FbCommand command =     new     FbCommand();
+
+                       command.CommandText                     = this.commandText;
+                       command.Connection                      = this.connection;
+                       command.Transaction                     = this.transaction;
+                       command.CommandType                     = this.CommandType;
+                       command.UpdatedRowSource        = this.UpdatedRowSource;
+
+                       for     (int i = 0;     i <     this.Parameters.Count; i++)
+                       {
+                               command.Parameters.Add(((ICloneable)this.Parameters[i]).Clone());
+                       }
+
+                       return command;
+               }
+
+               #endregion
+
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/method[@name="Cancel"]/*'/>
+               public void     Cancel()
+               {
+                       throw new NotSupportedException();
+               }
+
+               IDbDataParameter IDbCommand.CreateParameter()
+               {
+                       return CreateParameter();
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/method[@name="CreateParameter"]/*'/>
+               public FbParameter CreateParameter()
+               {
+                       return new FbParameter();
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/method[@name="Prepare"]/*'/>
+               public void     Prepare()
+               {
+                       lock (this)
+                       {
+                               this.CheckCommand();
+
+                               try
+                               {
+                                       this.Prepare(false);
+                               }
+                               catch (IscException     ex)
+                               {
+                                       if (this.HasImplicitTransaction)
+                                       {
+                                               this.RollbackImplicitTransaction();
+                                       }
+
+                                       throw new FbException(ex.Message, ex);
+                               }
+                               catch (Exception)
+                               {
+                                       if (this.HasImplicitTransaction)
+                                       {
+                                               this.RollbackImplicitTransaction();
+                                       }
+
+                                       throw;
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/method[@name="ExecuteNonQuery"]/*'/>
+               public int ExecuteNonQuery()
+               {
+                       lock (this)
+                       {
+                               this.CheckCommand();
+
+                               try
+                               {
+                                       this.ExecuteCommand(CommandBehavior.Default, false);
+
+                                       if (this.CommandType == CommandType.StoredProcedure)
+                                       {
+                                               this.SetOutputParameters();
+                                       }
+
+                                       if (this.HasImplicitTransaction)
+                                       {
+                                               this.CommitImplicitTransaction();
+                                       }
+                               }
+                               catch (IscException     ex)
+                               {
+                                       if (this.HasImplicitTransaction)
+                                       {
+                                               this.RollbackImplicitTransaction();
+                                       }
+
+                                       throw new FbException(ex.Message, ex);
+                               }
+                               catch (Exception)
+                               {
+                                       if (this.HasImplicitTransaction)
+                                       {
+                                               this.RollbackImplicitTransaction();
+                                       }
+
+                                       throw;
+                               }
+                       }
+
+                       return this.statement.RecordsAffected;
+               }
+
+               IDataReader     IDbCommand.ExecuteReader()
+               {
+                       return this.ExecuteReader();
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/method[@name="ExecuteReader"]/*'/>
+               public FbDataReader     ExecuteReader()
+               {
+                       return this.ExecuteReader(CommandBehavior.Default);
+               }
+
+               IDataReader     IDbCommand.ExecuteReader(CommandBehavior behavior)
+               {
+                       return this.ExecuteReader(behavior);
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/method[@name="ExecuteReader(System.Data.CommandBehavior)"]/*'/>
+               public FbDataReader     ExecuteReader(CommandBehavior behavior)
+               {
+                       lock (this)
+                       {
+                               this.CheckCommand();
+
+                               try
+                               {
+                                       this.ExecuteCommand(behavior, true);
+                               }
+                               catch (IscException     ex)
+                               {
+                                       if (this.HasImplicitTransaction)
+                                       {
+                                               this.RollbackImplicitTransaction();
+                                       }
+
+                                       throw new FbException(ex.Message, ex);
+                               }
+                               catch
+                               {
+                                       if (this.HasImplicitTransaction)
+                                       {
+                                               this.RollbackImplicitTransaction();
+                                       }
+
+                                       throw;
+                               }
+                       }
+
+                       this.activeReader =     new     FbDataReader(this, this.connection,     behavior);
+
+                       return this.activeReader;
+               }
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbCommand"]/method[@name="ExecuteScalar"]/*'/>
+               public object ExecuteScalar()
+               {
+                       object val = null;
+
+                       lock (this)
+                       {
+                               this.CheckCommand();
+
+                               try
+                               {
+                                       bool returnsSet = !(this.CommandType == CommandType.StoredProcedure);
+
+                                       this.ExecuteCommand(CommandBehavior.Default, returnsSet);
+
+                                       // Gets only the values of the first row
+                                       DbValue[] values = this.statement.Fetch();
+                                       if (values != null && values.Length     > 0)
+                                       {
+                                               val     = values[0].Value;
+                                       }
+
+                                       if (this.CommandType == CommandType.StoredProcedure)
+                                       {
+                                               this.SetOutputParameters();
+                                       }
+
+                                       if (this.HasImplicitTransaction)
+                                       {
+                                               this.CommitImplicitTransaction();
+                                       }
+                               }
+                               catch (IscException     ex)
+                               {
+                                       if (this.HasImplicitTransaction)
+                                       {
+                                               this.RollbackImplicitTransaction();
+                                       }
+
+                                       throw new FbException(ex.Message, ex);
+                               }
+                               catch (Exception)
+                               {
+                                       if (this.implicitTransaction &&
+                                               this.transaction !=     null)
+                                       {
+                                               this.RollbackImplicitTransaction();
+                                       }
+
+                                       throw;
+                               }
+                       }
+
+                       return val;
+               }
+
+               #endregion
+
+               #region Internal Methods
+
+               internal void CloseReader()
+               {
+                       if (this.activeReader != null)
+                       {
+                               this.activeReader.Close();
+                               this.activeReader =     null;
+                       }
+               }
+
+               internal DbValue[] Fetch()
+               {
+                       try
+                       {
+                               if (this.statement != null)
+                               {
+                                       // Fetch the next row
+                                       return this.statement.Fetch();
+                               }
+                       }
+                       catch (IscException     ex)
+                       {
+                               throw new FbException(ex.Message, ex);
+                       }
+
+                       return null;
+               }
+
+               internal Descriptor     GetFieldsDescriptor()
+               {
+                       if (this.statement != null)
+                       {
+                               return this.statement.Fields;
+                       }
+
+                       return null;
+               }
+
+               internal void SetOutputParameters()
+               {
+                       if (this.parameters.Count >     0 && this.statement     != null)
+                       {
+                               IEnumerator     paramEnumerator = this.parameters.GetEnumerator();
+                               int     i =     0;
+
+                               if (this.statement != null &&
+                                       this.statement.StatementType == DbStatementType.StoredProcedure)
+                               {
+                                       DbValue[] values = (DbValue[])this.statement.GetOuputParameters();
+
+                                       if (values != null && values.Length     > 0)
+                                       {
+                                               while (paramEnumerator.MoveNext())
+                                               {
+                                                       FbParameter     parameter =     (FbParameter)paramEnumerator.Current;
+
+                                                       if (parameter.Direction == ParameterDirection.Output ||
+                                                               parameter.Direction     == ParameterDirection.InputOutput ||
+                                                               parameter.Direction     == ParameterDirection.ReturnValue)
+                                                       {
+                                                               parameter.Value = values[i].Value;
+                                                               i++;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               internal void CommitImplicitTransaction()
+               {
+                       if (this.transaction != null && this.implicitTransaction)
+                       {
+                               try
+                               {
+                                       this.transaction.Commit();
+                               }
+                               catch (Exception)
+                               {
+                                       this.RollbackImplicitTransaction();
+
+                                       throw;
+                               }
+                               finally
+                               {
+                                       this.implicitTransaction = false;
+                                       this.transaction = null;
+                                       if (this.statement != null)
+                                       {
+                                               this.statement.Transaction = null;
+                                       }
+                               }
+                       }
+               }
+
+               internal void RollbackImplicitTransaction()
+               {
+                       if (this.transaction != null && this.implicitTransaction)
+                       {
+                               try
+                               {
+                                       this.transaction.Rollback();
+                               }
+                               catch (Exception)
+                               {
+                               }
+                               finally
+                               {
+                                       this.implicitTransaction = false;
+                                       this.transaction = null;
+                                       if (this.statement != null)
+                                       {
+                                               this.statement.Transaction = null;
+                                       }
+                               }
+                       }
+               }
+
+               internal void Close()
+               {
+                       if (this.statement != null)
+                       {
+                               this.statement.Close();
+                       }
+               }
+
+               internal void Release()
+               {
+                       this.RollbackImplicitTransaction();
+
+                       if (this.connection     != null && this.connection.State ==     ConnectionState.Open)
+                       {
+                               this.connection.InnerConnection.RemovePreparedCommand(this);
+                       }
+
+                       if (this.statement != null)
+                       {
+                               this.statement.Dispose();
+                               this.statement = null;
+                       }
+               }
+
+               internal bool IsDDLCommand()
+               {
+                       return this.statement.StatementType     == DbStatementType.DDL;
+               }
+
+               #endregion
+
+               #region Input parameter descriptor generation methods
+
+               private Descriptor BuildParametersDescriptor()
+               {
+                       short count     = this.ValidateInputParameters();
+
+                       if (count >     0)
+                       {
+                               if (this.namedParameters.Count > 0)
+                               {
+                                       count = (short)this.namedParameters.Count;
+                                       return this.BuildNamedParametersDescriptor(count);
+                               }
+                               else
+                               {
+                                       return this.BuildPlaceHoldersDescriptor(count);
+                               }
+                       }
+
+                       return null;
+               }
+
+               private Descriptor BuildNamedParametersDescriptor(short count)
+               {
+                       Descriptor descriptor = new     Descriptor(count);
+                       int     index = 0;
+
+                       for     (int i = 0;     i <     this.namedParameters.Count;     i++)
+                       {
+                               FbParameter     parameter =     this.parameters[this.namedParameters[i]];
+
+                               if (parameter.Direction == ParameterDirection.Input     ||
+                                       parameter.Direction     == ParameterDirection.InputOutput)
+                               {
+                                       if (!this.BuildParameterDescriptor(descriptor, parameter, index++))
+                                       {
+                                               return null;
+                                       }
+                               }
+                       }
+
+                       return descriptor;
+               }
+
+               private Descriptor BuildPlaceHoldersDescriptor(short count)
+               {
+                       Descriptor descriptor = new     Descriptor(count);
+                       int     index = 0;
+
+                       for     (int i = 0;     i <     this.parameters.Count; i++)
+                       {
+                               FbParameter     parameter =     this.parameters[i];
+
+                               if (parameter.Direction == ParameterDirection.Input     ||
+                                       parameter.Direction     == ParameterDirection.InputOutput)
+                               {
+                                       if (!this.BuildParameterDescriptor(descriptor, parameter, index++))
+                                       {
+                                               return null;
+                                       }
+                               }
+                       }
+
+                       return descriptor;
+               }
+
+               private bool BuildParameterDescriptor(
+                       Descriptor      descriptor,     
+                       FbParameter     parameter, 
+                       int                     index)
+               {
+                       Charset charset = this.connection.InnerConnection.Database.Charset;
+                       FbDbType type = parameter.FbDbType;
+
+                       // Check the parameter character set
+                       if (parameter.Charset != FbCharset.Default)
+                       {
+                               int     idx     = Charset.SupportedCharsets.IndexOf((int)parameter.Charset);
+                               charset = Charset.SupportedCharsets[idx];
+                       }
+                       else
+                       {
+                               if (type ==     FbDbType.Guid)
+                               {
+                                       charset = Charset.SupportedCharsets["OCTETS"];
+                               }
+                       }
+
+                       // Set parameter Data Type
+                       descriptor[index].DataType = (short)TypeHelper.GetFbType(
+                               (DbDataType)type,
+                               parameter.IsNullable);
+
+                       // Set parameter Sub Type
+                       switch (type)
+                       {
+                               case FbDbType.Binary:
+                                       descriptor[index].SubType =     0;
+                                       break;
+
+                               case FbDbType.Text:
+                                       descriptor[index].SubType =     1;
+                                       break;
+
+                               case FbDbType.Guid:
+                                       descriptor[index].SubType =     (short)charset.ID;
+                                       break;
+
+                               case FbDbType.Char:
+                               case FbDbType.VarChar:
+                                       descriptor[index].SubType =     (short)charset.ID;
+                                       if (parameter.Size > 0)
+                                       {
+                                               short len =     (short)(parameter.Size * charset.BytesPerCharacter);
+                                               descriptor[index].Length = len;
+                                       }
+                                       break;
+                       }
+
+                       // Set parameter length
+                       if (descriptor[index].Length == 0)
+                       {
+                               descriptor[index].Length = TypeHelper.GetSize((DbDataType)type);
+                       }
+
+                       // Verify parameter
+                       if (descriptor[index].SqlType == 0 || descriptor[index].Length == 0)
+                       {
+                               return false;
+                       }
+
+                       return true;
+               }
+
+               private short ValidateInputParameters()
+               {
+                       short count     = 0;
+
+                       for     (int i = 0;     i <     this.parameters.Count; i++)
+                       {
+                               if (this.parameters[i].Direction ==     ParameterDirection.Input ||
+                                       this.parameters[i].Direction == ParameterDirection.InputOutput)
+                               {
+                                       FbDbType type = this.parameters[i].FbDbType;
+
+                                       if (type ==     FbDbType.Array ||
+                                               type == FbDbType.Decimal ||
+                                               type == FbDbType.Numeric)
+                                       {
+                                               return -1;
+                                       }
+                                       else
+                                       {
+                                               count++;
+                                       }
+                               }
+                       }
+
+                       return count;
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void DescribeInput()
+               {
+                       if (this.parameters.Count >     0)
+                       {
+                               Descriptor descriptor = this.BuildParametersDescriptor();
+                               if (descriptor == null)
+                               {
+                                       this.statement.DescribeParameters();
+                               }
+                               else
+                               {
+                                       this.statement.Parameters =     descriptor;
+                               }
+                       }
+               }
+
+               private void Prepare(bool returnsSet)
+               {
+                       FbConnectionInternal innerConn = this.connection.InnerConnection;
+
+                       // Check if     we have a valid transaction
+                       if (this.transaction == null)
+                       {
+                               this.implicitTransaction = true;
+                               IsolationLevel il =     this.connection.ConnectionOptions.IsolationLevel;
+
+                               this.transaction = new FbTransaction(this.connection, il);
+                               this.transaction.BeginTransaction();
+
+                               // Update Statement     transaction
+                               if (this.statement != null)
+                               {
+                                       this.statement.Transaction = this.transaction.Transaction;
+                               }
+                       }
+
+                       // Check if     we have a valid statement handle
+                       if (this.statement == null)
+                       {
+                               this.statement = innerConn.Database.CreateStatement(this.transaction.Transaction);
+                       }
+
+                       // Prepare the statement if     needed
+                       if (!this.statement.IsPrepared)
+                       {
+                               string sql = this.commandText;
+
+                               if (this.commandType == CommandType.StoredProcedure)
+                               {
+                                       sql     = this.BuildStoredProcedureSql(sql,     returnsSet);
+                               }
+
+                               this.statement.Prepare(this.ParseNamedParameters(sql));
+
+                               this.DescribeInput();
+
+                               // Add this     command to the active command list
+                               innerConn.AddPreparedCommand(this);
+                       }
+                       else
+                       {
+                               // Close statement for subsequently     executions
+                               this.Close();
+                       }
+               }
+
+               private void ExecuteCommand(CommandBehavior     behavior, bool returnsSet)
+               {
+                       // Prepare statement
+                       this.Prepare(returnsSet);
+
+                       if ((behavior & CommandBehavior.SequentialAccess) == CommandBehavior.SequentialAccess ||
+                               (behavior &     CommandBehavior.SingleResult) == CommandBehavior.SingleResult ||
+                               (behavior &     CommandBehavior.SingleRow) == CommandBehavior.SingleRow ||
+                               (behavior &     CommandBehavior.CloseConnection) ==     CommandBehavior.CloseConnection ||
+                               behavior ==     CommandBehavior.Default)
+                       {
+                               // Set the fetch size
+                               this.statement.FetchSize = this.fetchSize;
+
+                               // Update input parameter values
+                               if (this.parameters.Count >     0)
+                               {
+                                       if (this.statement.Parameters == null)
+                                       {
+                                               this.DescribeInput();
+                                       }
+                                       this.UpdateParameterValues();
+                               }
+
+                               // Execute statement
+                               this.statement.Execute();
+                       }
+               }
+
+               private string BuildStoredProcedureSql(string spName, bool returnsSet)
+               {
+                       string sql = spName     == null ? "" : spName.ToLower(CultureInfo.CurrentCulture);
+
+                       if (sql.Length > 0 &&
+                               !sql.StartsWith("execute procedure ") && !sql.StartsWith("select "))
+                       {
+                               StringBuilder paramsText = new StringBuilder();
+
+                               // Append the stored proc parameter     name
+                               paramsText.Append(sql);
+                               if (parameters.Count > 0)
+                               {
+                                       paramsText.Append("(");
+                                       for     (int i = 0;     i <     this.parameters.Count; i++)
+                                       {
+                                               if (this.parameters[i].Direction ==     ParameterDirection.Input ||
+                                                       this.parameters[i].Direction == ParameterDirection.InputOutput)
+                                               {
+                                                       // Append parameter     name to parameter list
+                                                       paramsText.Append(this.parameters[i].ParameterName);
+                                                       if (i != parameters.Count -     1)
+                                                       {
+                                                               paramsText = paramsText.Append(",");
+                                                       }
+                                               }
+                                       }
+                                       paramsText.Append(")");
+                                       paramsText.Replace(",)", ")");
+                                       paramsText.Replace("()", "");
+                               }
+
+                               if (returnsSet)
+                               {
+                                       sql     = "select *     from " + paramsText.ToString();
+                               }
+                               else
+                               {
+                                       sql     = "execute procedure " + paramsText.ToString();
+                               }
+                       }
+
+                       return sql;
+               }
+
+               private string ParseNamedParameters(string sql)
+               {
+                       this.namedParameters.Clear();
+
+                       if (sql.IndexOf("@") != -1)
+                       {
+                               MatchEvaluator me =     new     MatchEvaluator(NamedParametersEvaluator);
+
+                               sql     = namedRegex.Replace(sql, me);
+                       }
+
+                       return sql;
+               }
+
+               private string NamedParametersEvaluator(Match match)
+               {
+                       string input = match.Value;
+
+                       if (match.Groups["param"].Success)
+                       {
+                               Group g = match.Groups["param"];
+
+                               this.namedParameters.Add(g.Value);
+
+                               return Regex.Replace(input,     g.Value, "?");
+                       }
+                       else
+                       {
+                               return match.Value;
+                       }
+               }
+
+               private void UpdateParameterValues()
+               {
+                       int     index = -1;
+
+                       for     (int i = 0;     i <     this.statement.Parameters.Count; i++)
+                       {
+                               index = i;
+
+                               if (this.namedParameters.Count > 0)
+                               {
+                                       index = this.parameters.IndexOf(this.namedParameters[i]);
+                               }
+
+                               if (index != -1)
+                               {
+                                       if (this.parameters[index].Value ==     DBNull.Value ||
+                                               this.parameters[index].Value == null)
+                                       {
+                                               this.statement.Parameters[i].NullFlag = -1;
+                                               this.statement.Parameters[i].Value = DBNull.Value;
+                                               if (!this.statement.Parameters[i].AllowDBNull())
+                                               {
+                                                       this.statement.Parameters[i].DataType++;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               // Parameter value is not null
+                                               this.statement.Parameters[i].NullFlag = 0;
+
+                                               switch (this.statement.Parameters[i].DbDataType)
+                                               {
+                                                       case DbDataType.Binary:
+                                                               {
+                                                                       BlobBase blob = this.statement.CreateBlob();
+                                                                       blob.Write((byte[])this.parameters[index].Value);
+                                                                       this.statement.Parameters[i].Value = blob.Id;
+                                                               }
+                                                               break;
+
+                                                       case DbDataType.Text:
+                                                               {
+                                                                       BlobBase blob = this.statement.CreateBlob();
+                                                                       blob.Write((string)this.parameters[index].Value);
+                                                                       this.statement.Parameters[i].Value = blob.Id;
+                                                               }
+                                                               break;
+
+                                                       case DbDataType.Array:
+                                                               {
+                                                                       if (this.statement.Parameters[i].ArrayHandle == null)
+                                                                       {
+                                                                               this.statement.Parameters[i].ArrayHandle =
+                                                                               this.statement.CreateArray(
+                                                                                       this.statement.Parameters[i].Relation,
+                                                                                       this.statement.Parameters[i].Name);
+                                                                       }
+                                                                       else
+                                                                       {
+                                                                               this.statement.Parameters[i].ArrayHandle.DB     = this.statement.DB;
+                                                                               this.statement.Parameters[i].ArrayHandle.Transaction = this.statement.Transaction;
+                                                                       }
+
+                                                                       this.statement.Parameters[i].ArrayHandle.Handle = 0;
+                                                                       this.statement.Parameters[i].ArrayHandle.Write((System.Array)this.parameters[index].Value);
+                                                                       this.statement.Parameters[i].Value = this.statement.Parameters[i].ArrayHandle.Handle;
+                                                               }
+                                                               break;
+
+                                                       case DbDataType.Guid:
+                                                               if (!(this.parameters[index].Value is Guid)     &&
+                                                                       !(this.parameters[index].Value is byte[]))
+                                                               {
+                                                                       throw new InvalidOperationException("Incorrect Guid     value.");
+                                                               }
+                                                               this.statement.Parameters[i].Value = this.parameters[index].Value;
+                                                               break;
+
+                                                       default:
+                                                               this.statement.Parameters[i].Value = this.parameters[index].Value;
+                                                               break;
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               private void CheckCommand()
+               {
+                       if (this.transaction != null && this.transaction.IsUpdated)
+                       {
+                               this.transaction = null;
+                       }
+
+                       if (this.connection     == null ||
+                               this.connection.State != ConnectionState.Open)
+                       {
+                               throw new InvalidOperationException("Connection must valid and open");
+                       }
+
+                       if (this.activeReader != null)
+                       {
+                               throw new InvalidOperationException("There is already an open DataReader associated     with this Command which must be closed first.");
+                       }
+
+                       if (this.transaction == null && 
+                               this.connection.InnerConnection.HasActiveTransaction)
+                       {
+                               throw new InvalidOperationException("Execute requires the Command object to     have a Transaction object when the Connection object assigned to the command is in a pending local transaction.  The Transaction property of the Command has not been initialized.");
+                       }
+
+                       if (this.transaction != null && !this.transaction.IsUpdated     &&
+                               !this.connection.Equals(transaction.Connection))
+                       {
+                               throw new InvalidOperationException("Command Connection is not equal to Transaction     Connection.");
+                       }
+
+                       if (this.commandText == null || this.commandText.Length == 0)
+                       {
+                               throw new InvalidOperationException("The command text for this Command has not been     set.");
+                       }
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommandBuilder.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommandBuilder.cs
new file mode 100644 (file)
index 0000000..c930a88
--- /dev/null
@@ -0,0 +1,1068 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.ComponentModel;
+using System.Data;
+using System.Data.Common;
+using System.Globalization;
+using System.Text;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/overview/*'/>
+       public sealed class     FbCommandBuilder : Component
+       {
+               #region Fields
+
+               private FbDataAdapter   dataAdapter;
+               private string                  sqlInsert;
+               private string                  sqlUpdate;
+               private string                  sqlDelete;
+               private string                  separator;
+               private string                  whereClausule1;
+               private string                  whereClausule2;
+               private string                  setClausule;
+               private DataTable               schemaTable;
+               private FbCommand               insertCommand;
+               private FbCommand               updateCommand;
+               private FbCommand               deleteCommand;          
+               private string                  quotePrefix;
+               private string                  quoteSuffix;
+               private bool                    disposed;
+               private bool                    hasPrimaryKey;
+               private string                  tableName;
+               private string                  timestampColumnName;
+               private bool                    usingCoalesce;
+               
+               private FbCommandBuilderBehavior        commandBuilderBehavior;
+               private FbRowUpdatingEventHandler       adapterHandler;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/property[@name="DataAdapter"]/*'/>
+#if    (!NETCF)
+               [DefaultValue(null)]
+#endif
+               public FbDataAdapter DataAdapter
+               {
+                       get     { return this.dataAdapter; }
+                       set
+                       {                       
+                               this.dataAdapter = value;
+
+                               // Registers the CommandBuilder as a listener for RowUpdating events that are 
+                               // generated by the     FbDataAdapter specified in this property.
+                               if (this.dataAdapter != null)
+                               {
+                                       this.adapterHandler     = new FbRowUpdatingEventHandler(this.RowUpdatingHandler);
+                                       this.dataAdapter.RowUpdating += this.adapterHandler;
+                               }
+                       }
+               }
+               
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/property[@name="QuotePrefix"]/*'/>
+               public string QuotePrefix
+               {
+                       get     { return this.quotePrefix; }
+                       set
+                       {
+                               if (this.insertCommand != null || 
+                                       this.updateCommand != null || 
+                                       this.deleteCommand != null)
+                               {
+                                       throw new InvalidOperationException("This property cannot be changed after an insert, update, or delete command has     been generated.");
+                               }
+                               
+                               this.quotePrefix = value;
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/property[@name="QuoteSuffix"]/*'/>
+               public string QuoteSuffix
+               {
+                       get     { return this.quoteSuffix; }
+                       set
+                       {
+                               if (this.insertCommand != null || 
+                                       this.updateCommand != null || 
+                                       this.deleteCommand != null)
+                               {
+                                       throw new InvalidOperationException("This property cannot be changed after an insert, update, or delete command has     been generated.");
+                               }
+                               
+                               this.quoteSuffix = value;
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/property[@name="CommandBuilderBehavior"]/*'/>
+#if    (!NETCF)
+               [DefaultValue(FbCommandBuilderBehavior.Default)]
+#endif
+               public FbCommandBuilderBehavior CommandBuilderBehavior
+               {
+                       get     { return this.commandBuilderBehavior; }
+                       set     { this.commandBuilderBehavior = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/property[@name="timestampColumnName"]/*'/>
+#if    (!NETCF)
+               [DefaultValue("")]
+#endif
+               public string TimestampColumnName
+               {
+                       get     { return this.timestampColumnName; }
+                       set     
+                       { 
+                               if (value == null)
+                               {
+                                       value = String.Empty;
+                               }
+                               this.timestampColumnName = value;
+                       }
+               }
+
+
+               #endregion
+
+               #region Internal properties
+
+               internal FbCommand SelectCommand
+               {
+                       get
+                       {
+                               if (this.dataAdapter.SelectCommand != null)
+                               {
+                                       return this.dataAdapter.SelectCommand;
+                               }
+
+                               return null;
+                       }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/constructor[@name="ctor"]/*'/>
+               public FbCommandBuilder() :     base()
+               {                       
+                       this.sqlInsert                  = "INSERT INTO {0} ({1}) VALUES ({2})";
+                       this.sqlUpdate                  = "UPDATE {0} SET {1} WHERE     ({2})";
+                       this.sqlDelete                  = "DELETE FROM {0} WHERE ({1})";
+                       this.whereClausule1             = "(({0} IS     NULL) OR ({0} = {1}))";
+                       this.whereClausule2             = "({0} = {1})";
+                       this.setClausule                = "{0} = {1}";
+                       this.separator                  = ",";
+                       this.quotePrefix                = "\"";
+                       this.quoteSuffix                = "\"";
+                       this.timestampColumnName= String.Empty;
+                       this.commandBuilderBehavior     = FbCommandBuilderBehavior.Default;                     
+
+                       GC.SuppressFinalize(this);
+               }
+
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/property[@name="ctor(FbDataAdapter)"]/*'/>
+               public FbCommandBuilder(FbDataAdapter adapter) : this()
+               {
+                       this.DataAdapter = adapter;
+               }
+
+               #endregion
+
+               #region IDisposable     Methods
+
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/method[@name="Dispose(System.Boolean)"]/*'/>
+               protected override void Dispose(bool disposing)
+               {
+                       if (!this.disposed)
+                       {
+                               try
+                               {
+                                       if (disposing)
+                                       {
+                                               // Clear generated commands
+                                               this.RefreshSchema();
+
+                                               // Clear FbDataAdapter handler if needed
+                                               if (this.adapterHandler != null)
+                                               {
+                                                       this.dataAdapter.RowUpdating -= adapterHandler;
+                                               }
+
+                                               // Clear fields
+                                               this.sqlInsert                  = null;
+                                               this.sqlUpdate                  = null;
+                                               this.sqlDelete                  = null;
+                                               this.whereClausule1             = null;
+                                               this.whereClausule2             = null;
+                                               this.setClausule                = null;
+                                               this.separator                  = null;
+                                               this.quotePrefix                = null;
+                                               this.quoteSuffix                = null;
+                                               this.timestampColumnName= null;
+                                               this.dataAdapter                = null;
+                                       }
+                                       
+                                       // release any unmanaged resources
+                                       
+                                       this.disposed = true;
+                               }
+                               finally 
+                               {
+                                       base.Dispose(disposing);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Static Methods
+
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/method[@name="DeriveParameters(FbCommand)"]/*'/>
+               public static void DeriveParameters(FbCommand command)
+               {
+                       if (command.CommandType != CommandType.StoredProcedure)
+                       {
+                               throw new InvalidOperationException("The command text is not a valid stored     procedure name.");
+                       }
+
+                       string spName           = command.CommandText.Trim();
+                       string quotePrefix      = "\"";
+                       string quoteSuffix      = "\"";
+
+                       if (spName.StartsWith(quotePrefix) && spName.EndsWith(quoteSuffix))
+                       {
+                               spName = spName.Substring(1, spName.Length - 2);
+                       }
+                       else
+                       {
+                               spName = spName.ToUpper(CultureInfo.CurrentUICulture);
+                       }
+
+                       command.Parameters.Clear();
+
+                       DataView dataTypes = command.Connection.GetSchema("DataTypes").DefaultView;
+
+                       DataTable spSchema = command.Connection.GetSchema(
+                               "ProcedureParameters", new string[]     { null, null, spName });
+                       
+                       int     count = 1;
+                       foreach (DataRow row in spSchema.Rows)
+                       {
+                               dataTypes.RowFilter     = String.Format(
+                                       CultureInfo.CurrentUICulture,
+                                       "TypeName =     '{0}'", 
+                                       row["PARAMETER_DATA_TYPE"]);
+
+                               FbParameter     parameter =     command.Parameters.Add(
+                                       "@"     + row["PARAMETER_NAME"].ToString().Trim(),
+                                       FbDbType.VarChar);
+
+                               parameter.FbDbType = (FbDbType)dataTypes[0]["ProviderDbType"];
+
+                               parameter.Direction     = (ParameterDirection)row["PARAMETER_DIRECTION"];
+
+                               parameter.Size = Convert.ToInt32(row["PARAMETER_SIZE"], CultureInfo.InvariantCulture);
+
+                               if (parameter.FbDbType == FbDbType.Decimal ||
+                                       parameter.FbDbType == FbDbType.Numeric)
+                               {
+                                       if (row["NUMERIC_PRECISION"] != DBNull.Value)
+                                       {
+                                               parameter.Precision     = Convert.ToByte(row["NUMERIC_PRECISION"], CultureInfo.InvariantCulture);
+                                       }
+                                       if (row["NUMERIC_SCALE"] !=     DBNull.Value)
+                                       {
+                                               parameter.Scale = Convert.ToByte(row["NUMERIC_SCALE"], CultureInfo.InvariantCulture);
+                                       }
+                               }
+
+                               count++;
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/method[@name="GetInsertCommand"]/*'/>
+               public FbCommand GetInsertCommand()
+               {
+                       lock (this)
+                       {
+                               if (this.insertCommand == null)
+                               {
+                                       this.BuildInsertCommand(null, null);
+                               }
+                       }
+                       
+                       return this.insertCommand;
+               }
+               
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/method[@name="GetUpdateCommand"]/*'/>
+               public FbCommand GetUpdateCommand()
+               {
+                       lock (this)
+                       {
+                               if (this.updateCommand == null)
+                               {
+                                       this.BuildUpdateCommand(null, null);
+                               }
+                       }
+                       
+                       return updateCommand;
+               }
+
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/method[@name="GetDeleteCommand"]/*'/>
+               public FbCommand GetDeleteCommand()
+               {
+                       lock (this)
+                       {
+                               if (this.deleteCommand == null)
+                               {
+                                       this.BuildDeleteCommand(null, null);
+                               }
+                       }
+                       
+                       return this.deleteCommand;
+               }
+
+               ///     <include file='Doc/en_EN/FbCommandBuilder.xml' path='doc/class[@name="FbCommandBuilder"]/method[@name="RefreshSchema"]/*'/>
+               public void     RefreshSchema()
+               {
+                       lock (this)
+                       {
+                               // Clear DataAdapter commands if needed
+                               if (this.dataAdapter != null)
+                               {
+                                       if (this.insertCommand == this.dataAdapter.InsertCommand)
+                                       {
+                                               this.dataAdapter.InsertCommand = null;
+                                       }
+                                       if (this.deleteCommand == this.dataAdapter.DeleteCommand)
+                                       {
+                                               this.dataAdapter.DeleteCommand = null;
+                                       }
+                                       if (this.updateCommand == this.dataAdapter.UpdateCommand)
+                                       {
+                                               this.dataAdapter.UpdateCommand = null;
+                                       }
+                               }
+
+                               // Clear commands
+                               if (this.insertCommand != null)
+                               {
+                                       this.insertCommand.Dispose();
+                               }
+                               if (this.updateCommand != null)
+                               {
+                                       this.updateCommand.Dispose();
+                               }
+                               if (this.deleteCommand != null)
+                               {
+                                       this.deleteCommand.Dispose();
+                               }
+                               if (this.schemaTable != null)
+                               {
+                                       this.schemaTable.Dispose();
+                               }
+                               this.insertCommand = null;
+                               this.updateCommand = null;
+                               this.deleteCommand = null;                      
+                               this.schemaTable   = null;
+                       }
+               }
+
+               #endregion
+
+               #region Command Building Methods
+
+               private FbCommand BuildInsertCommand(DataRow row, DataTableMapping tableMapping)
+               {                                               
+                       if (this.commandBuilderBehavior == FbCommandBuilderBehavior.KeyAndTimestampFields &&
+                               (this.timestampColumnName == null ||
+                               this.timestampColumnName.Length == 0))
+                       {
+                               throw new InvalidOperationException();
+                       }
+
+                       StringBuilder   sql             = new StringBuilder();
+                       StringBuilder   fields  = new StringBuilder();
+                       StringBuilder   values  = new StringBuilder();
+
+                       this.BuildSchemaTable();
+
+                       this.CreateCommand(ref this.insertCommand);
+
+                       int     i =     0;
+                       foreach (DataRow schemaRow in schemaTable.Rows)
+                       {                               
+                               if (this.IsUpdatable(schemaRow, row, tableMapping))
+                               {
+                                       if (fields.Length >     0)
+                                       {
+                                               fields.Append(this.separator);
+                                       }
+                                       if (values.Length >     0)
+                                       {
+                                               values.Append(this.separator);
+                                       }
+
+                                       fields.Append(this.GetQuotedIdentifier(schemaRow["BaseColumnName"]));
+                                       
+                                       FbParameter     parameter =     this.CreateParameter(schemaRow, i, false);
+
+                                       values.Append(parameter.ParameterName);
+                                                                               
+                                       if (row != null && tableMapping != null)
+                                       {
+                                               DataColumn column =     this.GetDataColumn(
+                                                       schemaRow["BaseColumnName"].ToString(),
+                                                       tableMapping,
+                                                       row);
+
+                                               if (column != null)
+                                               {
+                                                       parameter.Value = row[column];
+                                               }
+                                       }
+
+                                       i++;
+
+                                       this.insertCommand.Parameters.Add(parameter);
+                               }
+                       }
+
+                       sql.AppendFormat(
+                               CultureInfo.CurrentUICulture,
+                               this.sqlInsert, 
+                               this.GetQuotedIdentifier(tableName), 
+                               fields.ToString(), 
+                               values.ToString());
+
+                       this.insertCommand.CommandText = sql.ToString();
+
+                       return this.insertCommand;
+               }
+               
+               private FbCommand BuildUpdateCommand(DataRow row, DataTableMapping tableMapping)
+               {
+                       if (this.commandBuilderBehavior == FbCommandBuilderBehavior.KeyAndTimestampFields &&
+                               (this.timestampColumnName == null ||
+                               this.timestampColumnName.Length == 0))
+                       {
+                               throw new InvalidOperationException();
+                       }
+
+                       StringBuilder sql                       = new StringBuilder();
+                       StringBuilder sets                      = new StringBuilder();
+                       StringBuilder where                     = new StringBuilder();
+
+                       this.BuildSchemaTable();
+
+                       if (!this.hasPrimaryKey)
+                       {
+                               throw new InvalidOperationException("Dynamic SQL generation     for     the     UpdateCommand is not supported against a SelectCommand that     does not return any     key     column information.");
+                       }
+
+                       this.CreateCommand(ref this.updateCommand);
+
+                       int     i =     0;
+                       foreach (DataRow schemaRow in schemaTable.Rows)
+                       {                               
+                               if (this.IsUpdatable(schemaRow, row, tableMapping))
+                               {
+                                       if (sets.Length > 0)
+                                       {
+                                               sets.Append(separator);
+                                       }
+
+                                       FbParameter     parameter =     this.CreateParameter(schemaRow, i, false);
+
+                                       // Update SET clausule
+                                       sets.AppendFormat(
+                                               CultureInfo.CurrentUICulture,
+                                               setClausule, 
+                                               this.GetQuotedIdentifier(schemaRow["BaseColumnName"]),
+                                               parameter.ParameterName);
+                                       
+                                       if (row != null && tableMapping != null)
+                                       {
+                                               DataColumn column =     this.GetDataColumn(
+                                                       schemaRow["BaseColumnName"].ToString(),
+                                                       tableMapping,
+                                                       row);
+
+                                               if (column != null)
+                                               {
+                                                       parameter.Value = row[column];
+                                               }
+                                       }
+
+                                       i++;
+
+                                       this.updateCommand.Parameters.Add(parameter);
+                               }                               
+                       }
+                       
+                       // Build where clausule
+                       foreach (DataRow schemaRow in schemaTable.Rows)
+                       {                               
+                               if (this.IncludedInWhereClause(schemaRow))
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+                               
+                                       string quotedId = this.GetQuotedIdentifier(schemaRow["BaseColumnName"]);
+
+                                       // Create parameters for this field
+                                       FbParameter     parameter =     this.CreateParameter(schemaRow, i, true);
+
+                                       // Add where clausule for this field
+                                       if ((bool)schemaRow["IsKey"])
+                                       {
+                                               where.AppendFormat(
+                                                       CultureInfo.CurrentUICulture,
+                                                       whereClausule2, 
+                                                       quotedId, 
+                                                       parameter.ParameterName);
+                                       }
+                                       else
+                                       {
+                                               if (this.usingCoalesce)
+                                               {
+                                                       string typeName = TypeHelper.GetDataTypeName((DbDataType)parameter.FbDbType);
+
+                                                       switch (typeName)
+                                                       {
+                                                               case "VARCHAR":
+                                                               case "CHAR":
+                                                                       typeName = String.Format(
+                                                                               CultureInfo.CurrentUICulture,
+                                                                               "{0}({1})",     
+                                                                               typeName,
+                                                                               schemaRow["ColumnSize"]);
+                                                                       break;
+                                                               
+                                                               case "DECIMAL":
+                                                               case "NUMERIC":
+                                                                       typeName = String.Format(
+                                                                               CultureInfo.CurrentUICulture,
+                                                                               "{0}({1},{2})", 
+                                                                               typeName,
+                                                                               schemaRow["NumericPrecision"],
+                                                                               schemaRow["NumericScale"]);
+                                                                       break;
+                                                       }
+
+                                                       where.AppendFormat(
+                                                               CultureInfo.CurrentUICulture,
+                                                               whereClausule1, 
+                                                               quotedId,
+                                                               parameter.ParameterName,
+                                                               typeName);
+                                               }
+                                               else
+                                               {
+                                                       where.AppendFormat(
+                                                               CultureInfo.CurrentUICulture,
+                                                               whereClausule1, 
+                                                               quotedId, 
+                                                               parameter.ParameterName);
+                                               }
+                                       }
+
+                                       if (row != null && tableMapping != null)
+                                       {
+                                               DataColumn column =     this.GetDataColumn(
+                                                       schemaRow["BaseColumnName"].ToString(),
+                                                       tableMapping,
+                                                       row);
+
+                                               if (column != null)
+                                               {
+                                                       parameter.Value = row[column, DataRowVersion.Original];
+                                               }
+                                       }
+
+                                       this.updateCommand.Parameters.Add(parameter);
+
+                                       i++;                                    
+                               }                               
+                       }
+
+                       sql.AppendFormat(
+                               CultureInfo.CurrentUICulture,
+                               this.sqlUpdate, 
+                               this.GetQuotedIdentifier(tableName), 
+                               sets.ToString(), 
+                               where.ToString());
+                       
+                       this.updateCommand.CommandText = sql.ToString();
+
+                       return this.updateCommand;
+               }
+
+               private FbCommand BuildDeleteCommand(DataRow row, DataTableMapping tableMapping)
+               {
+                       if (this.commandBuilderBehavior == FbCommandBuilderBehavior.KeyAndTimestampFields &&
+                               (this.timestampColumnName == null ||
+                               this.timestampColumnName.Length == 0))
+                       {
+                               throw new InvalidOperationException();
+                       }
+
+                       StringBuilder sql       = new StringBuilder();
+                       StringBuilder where     = new StringBuilder();
+
+                       this.BuildSchemaTable();
+
+                       if (!this.hasPrimaryKey)
+                       {
+                               throw new InvalidOperationException("Dynamic SQL generation     for     the     DeleteCommand is not supported against a SelectCommand that     does not return any     key     column information.");
+                       }
+
+                       this.CreateCommand(ref this.deleteCommand);
+               
+                       // Build where clausule
+                       int     i =     0;
+                       foreach (DataRow schemaRow in schemaTable.Rows)
+                       {                               
+                               if (this.IncludedInWhereClause(schemaRow)) 
+                               {
+                                       if (where.Length > 0)
+                                       {
+                                               where.Append(" AND ");
+                                       }
+                               
+                                       string quotedId = this.GetQuotedIdentifier(schemaRow["BaseColumnName"]);
+
+                                       // Create parameters for this field
+                                       FbParameter     parameter =     this.CreateParameter(schemaRow, i, true);
+
+                                       if ((bool)schemaRow["IsKey"])
+                                       {
+                                               where.AppendFormat(
+                                                       CultureInfo.CurrentUICulture,
+                                                       whereClausule2, 
+                                                       quotedId, 
+                                                       parameter.ParameterName);
+                                       }
+                                       else
+                                       {
+                                               if (this.usingCoalesce)
+                                               {
+                                                       string typeName = TypeHelper.GetDataTypeName((DbDataType)parameter.FbDbType);
+
+                                                       switch (typeName)
+                                                       {
+                                                               case "VARCHAR":
+                                                               case "CHAR":
+                                                                       typeName = String.Format(
+                                                                               CultureInfo.CurrentUICulture,
+                                                                               "{0}({1})",     
+                                                                               typeName,
+                                                                               schemaRow["ColumnSize"]);
+                                                                       break;
+                                                               
+                                                               case "DECIMAL":
+                                                               case "NUMERIC":
+                                                                       typeName = String.Format(
+                                                                               CultureInfo.CurrentUICulture,
+                                                                               "{0}({1},{2})", 
+                                                                               typeName,
+                                                                               schemaRow["NumericPrecision"],
+                                                                               schemaRow["NumericScale"]);
+                                                                       break;
+                                                       }
+
+                                                       where.AppendFormat(
+                                                               CultureInfo.CurrentUICulture,
+                                                               whereClausule1, 
+                                                               quotedId,
+                                                               parameter.ParameterName,
+                                                               typeName);
+                                               }
+                                               else
+                                               {
+                                                       where.AppendFormat(
+                                                               CultureInfo.CurrentUICulture,
+                                                               whereClausule1, 
+                                                               quotedId,
+                                                               parameter.ParameterName);
+                                               }
+                                       }
+
+                                       if (row != null && tableMapping != null)
+                                       {
+                                               DataColumn column =     this.GetDataColumn(
+                                                       schemaRow["BaseColumnName"].ToString(),
+                                                       tableMapping,
+                                                       row);
+
+                                               if (column != null)
+                                               {
+                                                       parameter.Value = row[column, DataRowVersion.Original];
+                                               }
+                                       }
+
+                                       this.deleteCommand.Parameters.Add(parameter);
+
+                                       i++;
+                               }
+                       }
+
+                       sql.AppendFormat(
+                               CultureInfo.CurrentUICulture,
+                               this.sqlDelete, 
+                               this.GetQuotedIdentifier(tableName), 
+                               where.ToString());
+                       
+                       this.deleteCommand.CommandText = sql.ToString();
+
+                       return this.deleteCommand;
+               }
+
+               private bool IsUpdatable(
+                       DataRow                         schemaRow, 
+                       DataRow                         row, 
+                       DataTableMapping        tableMapping)
+               {
+                       if (row != null && tableMapping != null)
+                       {
+                               DataColumn column =     this.GetDataColumn(
+                                       schemaRow["BaseColumnName"].ToString(),
+                                       tableMapping,
+                                       row);
+
+                               if (column != null)
+                               {
+                                       if (column.Expression != null && 
+                                               column.Expression.Length !=     0)
+                                       {
+                                               return false;
+                                       }
+                                       if (column.ReadOnly)
+                                       {
+                                               return false;
+                                       }
+                               }
+                       }
+
+                       if ((bool)schemaRow["IsExpression"])
+                       {
+                               return false;
+                       }
+                       if ((bool)schemaRow["IsAutoIncrement"])
+                       {
+                               return false;
+                       }
+                       if ((bool)schemaRow["IsRowVersion"])
+                       {
+                               return false;
+                       }
+                       if ((bool)schemaRow["IsReadOnly"])
+                       {
+                               return false;
+                       }
+
+                       return true;
+               }
+
+               private bool IncludedInWhereClause(DataRow schemaRow)
+               {
+                       if (!(bool)schemaRow["IsKey"] &&
+                               (this.commandBuilderBehavior == FbCommandBuilderBehavior.KeyFields ||
+                               this.commandBuilderBehavior     == FbCommandBuilderBehavior.KeyAndTimestampFields))
+                       {
+                               if (this.timestampColumnName != schemaRow["BaseColumnName"].ToString())
+                               {
+                                       return false;
+                               }
+                       }
+
+                       FbDbType dbType = (FbDbType)schemaRow["ProviderType"];
+
+                       if (dbType == FbDbType.Array || dbType == FbDbType.Binary)
+                       {
+                               return false;
+                       }
+
+                       if ((bool)schemaRow["IsLong"])
+                       {
+                               return false;
+                       }
+
+                       return true;
+               }
+
+               private void BuildSchemaTable()
+               {
+                       bool mustClose = false;
+
+                       if (this.SelectCommand == null)
+                       {
+                               throw new InvalidOperationException("The DataAdapter.SelectCommand property     needs to be     initialized.");
+                       }
+                       if (this.SelectCommand.Connection == null)
+                       {
+                               throw new InvalidOperationException("The DataAdapter.SelectCommand.Connection property needs to be initialized.");
+                       }
+
+                       if (this.schemaTable == null)
+                       {                               
+                               if (this.SelectCommand.Connection.State == ConnectionState.Closed)
+                               {
+                                       mustClose =     true;
+                                       this.SelectCommand.Connection.Open();                                           
+                               }
+
+                               try
+                               {
+                                       FbCommand schemaCmd     = (FbCommand)((ICloneable)this.SelectCommand).Clone();
+
+                                       FbDataReader reader     = schemaCmd.ExecuteReader(
+                                               CommandBehavior.SchemaOnly);
+                                       
+                                       this.schemaTable = reader.GetSchemaTable();
+
+                                       reader.Close();
+
+                                       schemaCmd.Dispose();
+                                       schemaCmd =     null;
+
+                                       this.CheckSchemaTable();
+
+                                       this.UpdateFormats();
+                               }
+                               catch
+                               {
+                                       throw;
+                               }
+                               finally
+                               {
+                                       if (mustClose)
+                                       {
+                                               this.SelectCommand.Connection.Close();
+                                       }
+                               }
+                       }                       
+               }
+
+               private void CheckSchemaTable()
+               {
+                       this.tableName          = String.Empty;
+                       this.hasPrimaryKey      = false;
+
+                       foreach (DataRow schemaRow in schemaTable.Rows)
+                       {
+                               if (this.tableName.Length == 0)
+                               {
+                                       this.tableName = (string)schemaRow["BaseTableName"];
+                               }
+                               if (this.tableName != (string)schemaRow["BaseTableName"] &&
+                                       !(bool)schemaRow["IsExpression"])
+                               {
+                                       throw new InvalidOperationException("Dynamic SQL generation     is not supported against multiple base tables.");
+                               }
+                               if ((bool)schemaRow["IsKey"] || (bool)schemaRow["IsUnique"])
+                               {
+                                       this.hasPrimaryKey = true;
+                               }
+                       }
+               }
+
+               private string GetQuotedIdentifier(object identifier)
+               {
+                       string suffix = this.quoteSuffix !=     null ? this.quoteSuffix : String.Empty;
+                       string prefix = this.quotePrefix !=     null ? this.quotePrefix : String.Empty;
+
+                       return prefix + identifier.ToString() + suffix;
+               }
+
+               private void CreateCommand(ref FbCommand command)
+               {
+                       if (command     == null)
+                       {
+                               command = this.SelectCommand.Connection.CreateCommand();
+                       }
+
+                       command.Transaction                     = this.SelectCommand.Transaction;
+                       command.CommandType                     = CommandType.Text;
+                       command.UpdatedRowSource        = UpdateRowSource.None;
+                       command.Parameters.Clear();
+               }
+
+               private FbParameter     CreateParameter(
+                       DataRow schemaRow, 
+                       int             index, 
+                       bool    isWhereParameter)
+               {
+                       string pname = String.Format(CultureInfo.CurrentUICulture, "@p{0}",     index + 1);
+                       FbParameter     parameter       = new FbParameter(pname, (FbDbType)schemaRow["ProviderType"]);
+
+                       parameter.Size = Convert.ToInt32(schemaRow["ColumnSize"], CultureInfo.InvariantCulture);
+                       if (schemaRow["NumericPrecision"] != DBNull.Value)
+                       {
+                               parameter.Precision     = Convert.ToByte(schemaRow["NumericPrecision"], CultureInfo.InvariantCulture);
+                       }
+                       if (schemaRow["NumericScale"] != DBNull.Value)
+                       {
+                               parameter.Scale = Convert.ToByte(schemaRow["NumericScale"],     CultureInfo.InvariantCulture);
+                       }
+                       parameter.SourceColumn  = schemaRow["BaseColumnName"].ToString();
+                       parameter.IsNullable    = Convert.ToBoolean(schemaRow["AllowDbNull"], CultureInfo.InvariantCulture);
+
+                       if (isWhereParameter)
+                       {
+                               parameter.SourceVersion = DataRowVersion.Original;
+                       }
+                       else
+                       {
+                               parameter.SourceVersion = DataRowVersion.Current;
+                       }
+
+                       return parameter;
+               }
+
+               private DataColumn GetDataColumn(
+                       string                          columnName,
+                       DataTableMapping        tableMapping,
+                       DataRow                         row)
+               {
+                       DataColumn dataColumn = null;
+
+                       // Get the DataColumnMapping that matches
+                       // the given column     name
+                       DataColumnMapping columnMapping = tableMapping.GetColumnMappingBySchemaAction(
+                               columnName,
+                               this.dataAdapter.MissingMappingAction);
+
+                       if (columnMapping != null)
+                       {
+                               // Get the DataColumn for the given     column name
+                               dataColumn = columnMapping.GetDataColumnBySchemaAction(
+                                       row.Table, 
+                                       null, 
+                                       this.dataAdapter.MissingSchemaAction);
+                       }
+
+                       return dataColumn;
+               }
+
+               #endregion
+
+               #region Event Handler Methods
+
+               private void RowUpdatingHandler(object sender, FbRowUpdatingEventArgs e)
+               {
+                       if (e.Status != UpdateStatus.Continue)
+                       {
+                               return;
+                       }
+
+                       if (e.Command != null)
+                       {
+                               // Check that we can really     build a new     command.
+                               // If the command passed in     the     FbRowUpdatingEventArgs
+                               // is different than the one existent in the CommabdBuilder
+                               // we can't     build a new     command
+
+                               FbCommand command =     null;
+
+                               switch (e.StatementType)
+                               {
+                                       case StatementType.Insert:
+                                               command = this.insertCommand;
+                                               break;
+
+                                       case StatementType.Delete:
+                                               command = this.deleteCommand;
+                                               break;
+
+                                       case StatementType.Update:
+                                               command = this.updateCommand;
+                                               break;
+                               }
+                               
+                               if (command     != e.Command)
+                               {
+                                       return;
+                               }
+                       }
+
+                       try     
+                       {
+                               switch (e.StatementType) 
+                               {
+                                       case StatementType.Insert:
+                                               e.Command =     this.BuildInsertCommand(
+                                                               e.Row, 
+                                                               e.TableMapping);
+                                               break;
+
+                                       case StatementType.Update:
+                                               e.Command =     this.BuildUpdateCommand(
+                                                               e.Row, 
+                                                               e.TableMapping);
+                                               break;
+                                       
+                                       case StatementType.Delete:
+                                               e.Command =     this.BuildDeleteCommand(
+                                                               e.Row, 
+                                                               e.TableMapping);
+                                               break;
+                               }
+                       }
+                       catch (Exception exception)     
+                       {
+                               e.Errors = exception;
+                               e.Status = UpdateStatus.ErrorsOccurred;
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void UpdateFormats()
+               {
+                       this.usingCoalesce = false;
+
+                       if (this.SelectCommand.Connection != null)
+                       {
+                               string version = this.SelectCommand.Connection.ServerVersion;
+
+                               if (version.IndexOf("Firebird 1.5")     > 0)
+                               {
+                                       this.whereClausule1     = "(({0} IS     NULL AND COALESCE({1}, CAST(NULL AS     {2})) IS NULL) OR ({0} = {1}))";
+                                       this.usingCoalesce      = true;
+                               }
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommandBuilderBehavior.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommandBuilderBehavior.cs
new file mode 100644 (file)
index 0000000..ec44dc7
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbCommandBuilderBehavior.xml' path='doc/enum[@name="FbCommandBuilderBehavior"]/overview/*'/>
+#if    (!NETCF)
+       [Serializable]
+#endif
+       public enum     FbCommandBuilderBehavior
+       {
+               ///     <include file='Doc/en_EN/FbCommandBuilderBehavior.xml' path='doc/enum[@name="FbCommandBuilderBehavior"]/field[@name="Default"]/*'/>
+               Default,
+               ///     <include file='Doc/en_EN/FbCommandBuilderBehavior.xml' path='doc/enum[@name="FbCommandBuilderBehavior"]/field[@name="AllFields"]/*'/>
+               AllFields,
+               ///     <include file='Doc/en_EN/FbCommandBuilderBehavior.xml' path='doc/enum[@name="FbCommandBuilderBehavior"]/field[@name="KeyFields"]/*'/>
+               KeyFields,
+               ///     <include file='Doc/en_EN/FbCommandBuilderBehavior.xml' path='doc/enum[@name="FbCommandBuilderBehavior"]/field[@name="KeyAndTimestampFields"]/*'/>
+               KeyAndTimestampFields
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnection.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnection.cs
new file mode 100644 (file)
index 0000000..fe5a0a2
--- /dev/null
@@ -0,0 +1,880 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Globalization;
+using System.Text;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{      
+       ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/overview/*'/>
+#if    (!NETCF)
+       [ToolboxItem(true)]
+       [ToolboxBitmap(typeof(FbConnection), "Resources.FbConnection.bmp")]
+       [DefaultEvent("InfoMessage")]
+#endif
+       public sealed class     FbConnection : Component, IDbConnection, ICloneable
+       {       
+               #region Events
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/event[@name="StateChange"]/*'/>
+               public event StateChangeEventHandler StateChange;
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/event[@name="InfoMessage"]/*'/>
+               public event FbInfoMessageEventHandler InfoMessage;
+               
+               #endregion
+
+               #region Fields
+
+               private FbConnectionInternal    innerConnection;
+               private ConnectionState                 state;
+               private bool                                    disposed;
+               private string                                  connectionString;
+               private FbConnectionString              options;
+
+               #endregion
+               
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/property[@name="ConnectionString"]/*'/>
+#if    (NET)
+               [Category("Data"), RecommendedAsConfigurableAttribute(true), RefreshProperties(RefreshProperties.All), DefaultValue("")]
+               [Editor(typeof(Design.FbConnectionStringUIEditor), typeof(System.Drawing.Design.UITypeEditor))]
+#endif
+               public string ConnectionString
+               {
+                       get     { return this.connectionString; }
+                       set
+                       {
+                               lock (this)
+                               {
+                                       if (this.state == ConnectionState.Closed)
+                                       {
+                                               if (value == null)
+                                               {
+                                                       value = "";
+                                               }
+                                               
+                                               this.options.Load(value);
+                                               this.options.Validate();
+                                               this.connectionString = value;
+                                       }
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/property[@name="ConnectionTimeout"]/*'/>
+#if    (!NETCF)
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+               public int ConnectionTimeout
+               {
+                       get     { return this.options.ConnectionTimeout; }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/property[@name="Database"]/*'/>
+#if    (!NETCF)
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+               public string Database
+               {
+                       get     { return this.options.Database; }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/property[@name="DataSource"]/*'/>
+#if    (!NETCF)
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+               public string DataSource
+               {
+                       get     { return this.options.DataSource; }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/property[@name="ServerVersion"]/*'/>
+#if    (!NETCF)
+               [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+               public string ServerVersion
+               {
+                       get
+                       {
+                               if (this.state == ConnectionState.Closed)
+                               {
+                                       throw new InvalidOperationException("The connection     is closed.");
+                               }
+
+                               if (this.innerConnection !=     null)
+                               {
+                                       return this.innerConnection.Database.ServerVersion;
+                               }
+
+                               return String.Empty;
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/property[@name="State"]/*'/>
+#if    (!NETCF)
+               [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+               public ConnectionState State
+               {
+                       get     { return this.state; }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/property[@name="PacketSize"]/*'/>
+#if    (!NETCF)
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+               public int PacketSize
+               {
+                       get     { return this.options.PacketSize; }
+               }
+                               
+               #endregion              
+
+               #region Internal Properties
+
+               internal FbConnectionInternal InnerConnection
+               {
+                       get     { return this.innerConnection; }
+               }
+
+               internal FbConnectionString     ConnectionOptions
+               {
+                       get     { return this.options; }
+               }
+
+               internal bool IsClosed
+               {
+                       get     { return this.state     == ConnectionState.Closed; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/constructor[@name="ctor"]/*'/>
+               public FbConnection() : this(null)
+               {
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/constructor[@name="ctor(System.String)"]/*'/>  
+               public FbConnection(string connectionString) : base()
+               {
+                       this.options              =     new     FbConnectionString();
+                       this.state                        =     ConnectionState.Closed;
+                       this.connectionString = "";
+
+                       if (connectionString != null)
+                       {
+                               this.ConnectionString = connectionString;
+                       }
+               }               
+
+               #endregion
+
+               #region IDisposable     Methods
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="Dispose(System.Boolean)"]/*'/>
+               protected override void Dispose(bool disposing)
+               {
+                       lock (this)
+                       {
+                               if (!this.disposed)
+                               {
+                                       try
+                                       {
+                                               // release any unmanaged resources
+                                               this.Close();
+
+                                               if (disposing)
+                                               {
+                                                       // release any managed resources
+                                                       this.innerConnection = null;
+                                               }
+                                               
+                                               this.disposed = true;
+                                       }
+                                       catch
+                                       {
+                                       }
+                                       finally
+                                       {
+                                               base.Dispose(disposing);
+                                       }
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region ICloneable Methods
+
+               object ICloneable.Clone()
+               {
+                       return new FbConnection(this.ConnectionString);
+               }
+
+               #endregion
+
+               #region Static Properties
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/property[@name="ConnectionPoolsCount"]/*'/>
+               public static int ConnectionPoolsCount
+               {
+                       get     { return FbPoolManager.Instance.PoolsCount;     }
+               }
+
+               #endregion
+
+               #region Static Methods
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="GetPooledConnectionCount(FbConnection)"]/*'/>
+               public static int GetPooledConnectionCount(FbConnection connection)
+               {
+                       FbPoolManager           manager = FbPoolManager.Instance;
+                       FbConnectionPool        pool    = manager.FindPool(connection.ConnectionString);
+
+                       if (pool !=     null)
+                       {
+                               return pool.Count;
+                       }
+
+                       return 0;
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="ClearAllPools"]/*'/>
+               public static void ClearAllPools()
+               {
+                       FbPoolManager manager = FbPoolManager.Instance;
+
+                       manager.ClearAllPools();
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="ClearPool(FbConnection)"]/*'/>
+               public static void ClearPool(FbConnection connection)
+               {
+                       FbPoolManager manager = FbPoolManager.Instance;
+
+                       manager.ClearPool(connection.ConnectionString);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="CreateDatabase(System.String)"]/*'/>
+               public static void CreateDatabase(string connectionString)
+               {
+                       FbConnection.CreateDatabase(connectionString, 4096,     true, false);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="CreateDatabase(System.String, System.Boolean)"]/*'/>
+               public static void CreateDatabase(string connectionString, bool overwrite)
+               {
+                       FbConnection.CreateDatabase(connectionString, 4096,     true, overwrite);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="CreateDatabase(System.String,System.Int32,System.Boolean,System.Boolean)"]/*'/>
+               public static void CreateDatabase(
+                       string  connectionString,
+                       int             pageSize,
+                       bool    forcedWrites,
+                       bool    overwrite)
+               {
+                       FbConnectionString options = new FbConnectionString(connectionString);
+                       options.Validate();
+
+                       try
+                       {
+                               // DPB configuration
+                               DatabaseParameterBuffer dpb     = new DatabaseParameterBuffer();
+
+                               // Dpb version
+                               dpb.Append(IscCodes.isc_dpb_version1);
+
+                               // Dummy packet interval
+                               dpb.Append(IscCodes.isc_dpb_dummy_packet_interval,
+                                       new     byte[] { 120, 10, 0, 0 });
+
+                               // User name
+                               dpb.Append(IscCodes.isc_dpb_user_name, options.UserID);
+
+                               // User password
+                               dpb.Append(IscCodes.isc_dpb_password, options.Password);
+
+                               // Database     dialect
+                               dpb.Append(IscCodes.isc_dpb_sql_dialect,
+                                       new     byte[] { options.Dialect, 0, 0, 0 });
+
+                               // Character set
+                               if (options.Charset.Length > 0)
+                               {
+                                       int     index = Charset.SupportedCharsets.IndexOf(options.Charset);
+
+                                       if (index == -1)
+                                       {
+                                               throw new ArgumentException("Character set is not valid.");
+                                       }
+                                       else
+                                       {
+                                               dpb.Append(
+                                                       IscCodes.isc_dpb_set_db_charset,
+                                                       Charset.SupportedCharsets[index].Name);
+                                       }
+                               }
+
+                               if (!overwrite)
+                               {
+                                       // Check if     the     database exists
+                                       FbConnectionInternal c = new FbConnectionInternal(options);
+
+                                       try
+                                       {
+                                               c.Connect();
+                                               c.Disconnect();
+
+                                               IscException ex = new IscException(IscCodes.isc_db_or_file_exists);
+                                               throw new FbException(ex.Message, ex);
+                                       }
+                                       catch (FbException ex)
+                                       {
+                                               if (ex.ErrorCode !=     335544344)
+                                               {
+                                                       throw;
+                                               }
+                                       }
+                               }
+
+                               // Page Size
+                               if (pageSize > 0)
+                               {
+                                       dpb.Append(IscCodes.isc_dpb_page_size, pageSize);
+                               }
+
+                               // Forced writes
+                               dpb.Append(IscCodes.isc_dpb_force_write,
+                                       (short)(forcedWrites ? 1 : 0));
+
+                               // Create the new database
+                               FbConnectionInternal db = new FbConnectionInternal(options);
+                               db.CreateDatabase(dpb);
+                       }
+                       catch (IscException     ex)
+                       {
+                               throw new FbException(ex.Message, ex);
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="DropDatabase(System.String)"]/*'/>
+               public static void DropDatabase(string connectionString)
+               {
+                       // Configure Attachment
+                       FbConnectionString options = new FbConnectionString(connectionString);
+                       options.Validate();
+
+                       try
+                       {
+                               // Drop the     database        
+                               FbConnectionInternal db = new FbConnectionInternal(options);
+                               db.DropDatabase();
+                       }
+                       catch (IscException     ex)
+                       {
+                               throw new FbException(ex.Message, ex);
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="CreateDatabase(System.Collections.Hashtable)"]/*'/>
+               [Obsolete("Use CreateDatabase(string connectionString) instead")]               
+               public static void CreateDatabase(Hashtable     values)
+               {
+                       bool            overwrite       = false;
+                       int                     index           = 0;
+                       byte            dialect         = 3;
+                       int                     serverType      = 0;
+
+                       if (!values.ContainsKey("User")         ||
+                               !values.ContainsKey("Password") || 
+                               !values.ContainsKey("Database"))
+                       {
+                               throw new ArgumentException("CreateDatabase     requires a user name, password and database     path.");
+                       }
+
+                       if (values.ContainsKey("ServerType"))
+                       {
+                               serverType = Convert.ToInt32(values["ServerType"], CultureInfo.InvariantCulture);
+                       }
+
+                       if (!values.ContainsKey("DataSource"))
+                       {
+                               values.Add("DataSource", "localhost");
+                       }
+
+                       if (!values.ContainsKey("Port"))
+                       {
+                               values.Add("Port", 3050);
+                       }
+
+                       if (values.ContainsKey("Dialect"))
+                       {
+                               dialect = Convert.ToByte(values["Dialect"],     CultureInfo.InvariantCulture);
+                       }
+
+                       if (dialect     < 1     || dialect > 3)
+                       {
+                               throw new ArgumentException("Incorrect database dialect it should be 1, 2, or 3.");
+                       }
+
+                       if (values.ContainsKey("Overwrite"))
+                       {
+                               overwrite =     (bool)values["Overwrite"];
+                       }
+
+                       try     
+                       {
+                               // Configure Attachment
+                               FbConnectionStringBuilder csb = new     FbConnectionStringBuilder();
+
+                               csb.DataSource  = values["DataSource"].ToString();
+                               csb.UserID              = values["User"].ToString();
+                               csb.Password    = values["Password"].ToString();
+                               csb.Database    = values["Database"].ToString();
+                               csb.Port                = Convert.ToInt32(values["Port"], CultureInfo.InvariantCulture);
+                               csb.ServerType = serverType;
+
+                               FbConnectionString options = new FbConnectionString(csb);
+
+                               // DPB configuration
+                               DatabaseParameterBuffer dpb     = new DatabaseParameterBuffer();
+                               
+                               // Dpb version
+                               dpb.Append(IscCodes.isc_dpb_version1);
+
+                               // Dummy packet interval
+                               dpb.Append(IscCodes.isc_dpb_dummy_packet_interval, 
+                                       new     byte[] {120, 10, 0,     0});
+
+                               // User name
+                               dpb.Append(IscCodes.isc_dpb_user_name, 
+                                       values["User"].ToString());
+
+                               // User password
+                               dpb.Append(IscCodes.isc_dpb_password, 
+                                       values["Password"].ToString());
+
+                               // Database     dialect
+                               dpb.Append(IscCodes.isc_dpb_sql_dialect, 
+                                       new     byte[] {dialect, 0,     0, 0});
+
+                               // Character set
+                               if (values.ContainsKey("Charset"))
+                               {
+                                       index = Charset.SupportedCharsets.IndexOf(values["Charset"].ToString());
+
+                                       if (index == -1)
+                                       {
+                                               throw new ArgumentException("Character set is not valid.");
+                                       }
+                                       else
+                                       {
+                                               dpb.Append(
+                                                       IscCodes.isc_dpb_set_db_charset,
+                                                       Charset.SupportedCharsets[index].Name);
+                                       }
+                               }
+
+                               if (!overwrite)
+                               {
+                                       try
+                                       {
+                                               // Check if     the     database exists
+                                               FbConnectionInternal check = new FbConnectionInternal(options);
+
+                                               check.Connect();
+                                               check.Disconnect();
+
+                                               IscException ex = new IscException(IscCodes.isc_db_or_file_exists);
+
+                                               throw new FbException(ex.Message, ex);
+                                       }
+                                       catch (Exception)
+                                       {
+                                               throw;
+                                       }
+                               }
+
+                               // Page Size
+                               if (values.ContainsKey("PageSize"))
+                               {
+                                       dpb.Append(IscCodes.isc_dpb_page_size, Convert.ToInt32(values["PageSize"], CultureInfo.InvariantCulture));
+                               }
+
+                               // Forced writes
+                               if (values.ContainsKey("ForcedWrite"))
+                               {
+                                       dpb.Append(IscCodes.isc_dpb_force_write, 
+                                               (short)((bool)values["ForcedWrite"]     ? 1     : 0));
+                               }
+
+                               // Create the new database
+                               FbConnectionInternal c = new FbConnectionInternal(options);
+                               c.CreateDatabase(dpb);
+                       }
+                       catch (IscException     ex)     
+                       {
+                               throw new FbException(ex.Message, ex);
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="DropDatabase(System.Collections.Hashtable)"]/*'/>
+               [Obsolete("Use DropDatabase(string connectionString) instead")]
+               public static void DropDatabase(Hashtable values)
+               {
+                       int     serverType = 0;
+
+                       if (!values.ContainsKey("User")         ||
+                               !values.ContainsKey("Password") ||
+                               !values.ContainsKey("Database"))
+                       {
+                               throw new ArgumentException("CreateDatabase     requires a user name, password and database     path.");
+                       }
+
+                       if (!values.ContainsKey("DataSource"))
+                       {
+                               values.Add("DataSource", "localhost");
+                       }
+
+                       if (!values.ContainsKey("Port"))
+                       {
+                               values.Add("Port", 3050);
+                       }
+
+                       if (values.ContainsKey("ServerType"))
+                       {
+                               serverType = Convert.ToInt32(values["ServerType"], CultureInfo.InvariantCulture);
+                       }
+
+                       try     
+                       {
+                               // Configure Attachment
+                               FbConnectionStringBuilder csb = new     FbConnectionStringBuilder();
+
+                               csb.DataSource  = values["DataSource"].ToString();
+                               csb.Port                = Convert.ToInt32(values["Port"], CultureInfo.InvariantCulture);
+                               csb.Database    = values["Database"].ToString();
+                               csb.UserID              = values["User"].ToString();
+                               csb.Password    = values["Password"].ToString();
+                               csb.ServerType  = serverType;
+
+                               FbConnectionString options = new FbConnectionString(csb);
+
+                               // Drop the     database
+                               FbConnectionInternal db = new FbConnectionInternal(options);
+                               db.DropDatabase();
+                       }
+                       catch (IscException     ex)     
+                       {
+                               throw new FbException(ex.Message, ex);
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               IDbTransaction IDbConnection.BeginTransaction()
+               {
+                       return this.BeginTransaction();
+               }
+
+               IDbTransaction IDbConnection.BeginTransaction(IsolationLevel level)
+               {
+                       return this.BeginTransaction(level);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="BeginTransaction"]/*'/>
+               public FbTransaction BeginTransaction()
+               {
+                       return this.BeginTransaction(IsolationLevel.ReadCommitted, null);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="BeginTransaction(System.String)"]/*'/>
+               public FbTransaction BeginTransaction(string transactionName)
+               {
+                       return this.BeginTransaction(IsolationLevel.ReadCommitted, transactionName);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="BeginTransaction(System.Data.IsolationLevel)"]/*'/>
+               public FbTransaction BeginTransaction(IsolationLevel level)
+               {
+                       return this.BeginTransaction(level,     null);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="BeginTransaction(System.Data.IsolationLevel,System.String)"]/*'/>
+               public FbTransaction BeginTransaction(IsolationLevel level,     string transactionName)
+               {
+                       if (this.IsClosed)
+                       {
+                               throw new InvalidOperationException("BeginTransaction requires an open and available Connection.");
+                       }
+
+                       return this.innerConnection.BeginTransaction(level,     transactionName);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="BeginTransaction(FbTransactionOptions)"]/*'/>
+               public FbTransaction BeginTransaction(FbTransactionOptions options)
+               {
+                       return this.BeginTransaction(options, null);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="BeginTransaction(FbTransactionOptions, System.String)"]/*'/>
+               public FbTransaction BeginTransaction(FbTransactionOptions options,     string transactionName)
+               {
+                       if (this.IsClosed)
+                       {
+                               throw new InvalidOperationException("BeginTransaction requires an open and available Connection.");
+                       }
+
+                       return this.innerConnection.BeginTransaction(options, transactionName);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="ChangeDatabase(System.String)"]/*'/>
+               public void     ChangeDatabase(string db)
+               {
+                       lock (this)
+                       {
+                               if (this.IsClosed)
+                               {
+                                       throw new InvalidOperationException("ChangeDatabase     requires an     open and available Connection.");
+                               }
+
+                               if (db == null || db.Trim().Length == 0)
+                               {
+                                       throw new InvalidOperationException("Database name is not valid.");
+                               }
+
+                               string cs =     this.connectionString;
+
+                               try
+                               {
+                                       FbConnectionStringBuilder csb = new     FbConnectionStringBuilder(this.connectionString);
+
+                                       /* Close current connection     */
+                                       this.Close();
+
+                                       /* Set up the new Database      */
+                                       csb.Database = db;
+
+                                       /* Open new     connection      */
+                                       this.Open();
+                               }
+                               catch (IscException     ex)
+                               {
+                                       this.ConnectionString = cs;
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="Open"]/*'/>
+               public void     Open()
+               {
+                       lock (this)
+                       {
+                               if (this.connectionString == null || this.connectionString.Length == 0)
+                               {
+                                       throw new InvalidOperationException("Connection String is not initialized.");
+                               }
+                               if (!this.IsClosed && this.state !=     ConnectionState.Connecting)
+                               {
+                                       throw new InvalidOperationException("Connection already Open.");
+                               }
+
+                               try
+                               {
+                                       this.OnStateChange(this.state, ConnectionState.Connecting);
+                                       
+                                       if (this.options.Pooling)
+                                       {
+                                               // Use Connection Pooling
+                                               FbConnectionPool pool = FbPoolManager.Instance.CreatePool(this.connectionString);
+                                               this.innerConnection = pool.CheckOut();
+                                               this.innerConnection.OwningConnection = this;
+                                       }
+                                       else
+                                       {
+                                               // Do not use Connection Pooling
+                                               this.innerConnection = new FbConnectionInternal(this.options, this);
+                                               this.innerConnection.Connect();
+                                       }
+
+                                       // Bind Warning messages event
+                                       this.innerConnection.Database.WarningMessage = new WarningMessageCallback(this.OnWarningMessage);
+
+                                       // Update the connection state
+                                       this.OnStateChange(this.state, ConnectionState.Open);
+                               }
+                               catch(IscException ex)
+                               {
+                                       this.OnStateChange(this.state, ConnectionState.Closed);
+                                       throw new FbException(ex.Message, ex);
+                               }
+                               catch (Exception)
+                               {
+                                       this.OnStateChange(this.state, ConnectionState.Closed);
+                                       throw;
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="Close"]/*'/>
+               public void     Close()
+               {
+                       if (this.IsClosed)
+                       {
+                               return;
+                       }
+                               
+                       lock (this)
+                       {
+                               try
+                               {
+                                       lock (this.innerConnection)
+                                       {
+                                               // Close the Remote     Event Manager
+                                               this.innerConnection.CloseEventManager();
+
+                                               // Unbind Warning messages event
+                                               this.innerConnection.Database.WarningMessage = null;
+
+                                               // Dispose Transaction
+                                               this.innerConnection.DisposeTransaction();
+
+                                               // Dispose all active statemenets
+                                               this.innerConnection.DisposePreparedCommands();
+
+                                               // Close connection     or send it back to the pool
+                                               if (this.innerConnection.Pooled)
+                                               {
+                                                       // Get Connection Pool
+                                                       FbConnectionPool pool = FbPoolManager.Instance.FindPool(this.connectionString);
+
+                                                       // Send connection to the Pool
+                                                       pool.CheckIn(this.innerConnection);
+                                               }
+                                               else
+                                               {
+                                                       this.innerConnection.Disconnect();
+                                               }
+                                       }
+
+                                       // Update connection state
+                                       this.OnStateChange(this.state, ConnectionState.Closed);
+                               }
+                               catch(IscException ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+               }
+
+               IDbCommand IDbConnection.CreateCommand()
+               {
+                       return this.CreateCommand();
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="CreateCommand"]/*'/>
+               public FbCommand CreateCommand()
+               {
+                       FbCommand command =     new     FbCommand();
+
+                       lock (this)
+                       {
+                               command.Connection = this;
+                       }
+       
+                       return command;
+               }
+
+               #endregion
+
+               #region Database Schema
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="GetSchema"]/*'/>
+               public DataTable GetSchema()
+               {
+                       return this.GetSchema("MetaDataCollections");
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="GetSchema(System.String)"]/*'/>
+               public DataTable GetSchema(string collectionName)
+               {
+                       return this.GetSchema(collectionName, null);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="GetSchema(System.String, System.String[])"]/*'/>
+               public DataTable GetSchema(string collectionName, string[] restrictions)
+               {
+                       if (this.IsClosed)
+                       {
+                               throw new InvalidOperationException("The connection     is closed.");
+                       }
+
+                       return this.innerConnection.GetSchema(collectionName, restrictions);
+               }
+
+               ///     <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="GetDbSchemaTable"]/*'/>
+               [Obsolete("Use GetSchema methods instead")]
+               public DataTable GetDbSchemaTable(FbDbSchemaType schema, object[] restrictions)
+               {
+                       if (this.state == ConnectionState.Closed)
+                       {
+                               throw new InvalidOperationException("The conneciton     is closed.");
+                       }
+
+                       return innerConnection.GetSchema(schema.ToString(),     restrictions);
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void OnWarningMessage(IscException warning)
+               {
+                       if (this.InfoMessage != null)
+                       {
+                               this.InfoMessage(this, new FbInfoMessageEventArgs(warning));
+                       }
+               }
+
+               private void OnStateChange(ConnectionState originalState, ConnectionState currentState)
+               {
+                       this.state = currentState;
+                       if (this.StateChange != null)
+                       {
+                               this.StateChange(this, new StateChangeEventArgs(originalState, currentState));
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionInternal.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionInternal.cs
new file mode 100644 (file)
index 0000000..e452ecd
--- /dev/null
@@ -0,0 +1,382 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.Data;
+using System.Text;
+
+using FirebirdSql.Data.Common;
+using FirebirdSql.Data.Firebird.DbSchema;
+
+namespace FirebirdSql.Data.Firebird
+{      
+       internal class FbConnectionInternal     : MarshalByRefObject
+       {
+               #region Fields
+
+               private IDatabase                       db;
+               private long                            created;
+               private long                            lifetime;
+               private bool                            pooled;
+               private FbTransaction           activeTransaction;
+               private ArrayList                       preparedCommands;
+               private FbConnectionString      options;
+               private FbConnection            owningConnection;
+
+               #endregion
+
+               #region Properties
+
+               public IDatabase Database
+               {
+                       get     { return this.db; }
+               }
+
+               public long     Lifetime
+               {
+                       get     { return this.lifetime; }
+                       set     { this.lifetime = value; }
+               }
+
+               public long     Created
+               {
+                       get     { return this.created; }
+                       set     { this.created = value; }
+               }
+               
+               public bool     Pooled
+               {
+                       get     { return this.pooled; }
+                       set     { this.pooled = value; }
+               }
+
+               public bool     HasActiveTransaction
+               {
+                       get
+                       {
+                               return this.activeTransaction != null && !this.activeTransaction.IsUpdated;
+                       }
+               }
+
+               public ArrayList PreparedCommands
+               {
+                       get
+                       {
+                               if (this.preparedCommands == null)
+                               {
+                                       this.preparedCommands = new     ArrayList();
+                               }
+                               
+                               return this.preparedCommands;
+                       }
+               }
+
+               public FbTransaction ActiveTransaction
+               {
+                       get     { return this.activeTransaction; }
+               }
+
+               public FbConnectionString ConnectionOptions
+               {
+                       get     { return this.options; }
+               }
+
+               public FbConnection     OwningConnection
+               {
+                       get     { return this.owningConnection; }
+                       set     { this.owningConnection = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public FbConnectionInternal(FbConnectionString options) : this(options, null)
+               {
+               }
+
+               public FbConnectionInternal(FbConnectionString options, FbConnection owningConnection)
+               {
+                       this.options                    = options;
+                       this.owningConnection   = owningConnection;
+               }
+
+               #endregion
+
+               #region Create and Drop database methods
+
+               public void     CreateDatabase(DatabaseParameterBuffer dpb)
+               {
+                       IDatabase db = ClientFactory.CreateDatabase(this.options.ServerType);
+                       db.CreateDatabase(dpb, this.options.DataSource, this.options.Port, this.options.Database);
+               }
+
+               public void     DropDatabase()
+               {
+                       IDatabase db = ClientFactory.CreateDatabase(this.options.ServerType);
+                       db.Attach(this.BuildDpb(db,     this.options), this.options.DataSource, this.options.Port, this.options.Database);
+                       db.DropDatabase();
+               }
+
+               #endregion
+
+               #region Connect and     Disconenct methods
+
+               public void     Connect()
+               {                                                       
+                       try
+                       {
+                               this.db                         = ClientFactory.CreateDatabase(this.options.ServerType);
+                               this.db.Charset         = Charset.SupportedCharsets[this.options.Charset];
+                               this.db.Dialect         = this.options.Dialect;
+                               this.db.PacketSize      = this.options.PacketSize;
+
+                               DatabaseParameterBuffer dpb     = this.BuildDpb(this.db, options);
+
+                               this.db.Attach(dpb,     this.options.DataSource, this.options.Port,     this.options.Database);
+                       }
+                       catch (IscException     ex)
+                       {
+                               throw new FbException(ex.Message, ex);
+                       }
+               }
+               
+               public void     Disconnect()
+               {       
+                       try
+                       {
+                               this.db.Dispose();
+                               this.owningConnection   = null;
+                               this.options                    = null;
+                               this.lifetime                   = 0;
+                               this.pooled                             = false;
+                               this.db                                 = null;
+                               
+                               this.DisposePreparedCommands();
+                       }
+                       catch (IscException     ex)
+                       {
+                               throw new FbException(ex.Message, ex);
+                       }
+               }
+
+               #endregion
+
+               #region Transaction     Methods
+
+               public FbTransaction BeginTransaction(IsolationLevel level,     string transactionName)
+               {
+                       lock (this)
+                       {
+                               if (this.HasActiveTransaction)
+                               {
+                                       throw new InvalidOperationException("A transaction is currently active. Parallel transactions are not supported.");
+                               }
+
+                               try
+                               {
+                                       this.activeTransaction = new FbTransaction(this.owningConnection, level);
+                                       this.activeTransaction.BeginTransaction();
+
+                                       if (transactionName     != null)
+                                       {
+                                               this.activeTransaction.Save(transactionName);
+                                       }
+                               }
+                               catch (IscException     ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+
+                       return this.activeTransaction;
+               }
+
+               public FbTransaction BeginTransaction(FbTransactionOptions options,     string transactionName)
+               {
+                       lock (this)
+                       {
+                               if (this.HasActiveTransaction)
+                               {
+                                       throw new InvalidOperationException("A transaction is currently active. Parallel transactions are not supported.");
+                               }
+
+                               try
+                               {
+                                       this.activeTransaction = new FbTransaction(
+                                               this.owningConnection, 
+                                               IsolationLevel.Unspecified);
+                                       this.activeTransaction.BeginTransaction(options);
+
+                                       if (transactionName     != null)
+                                       {
+                                               this.activeTransaction.Save(transactionName);
+                                       }
+                               }
+                               catch (IscException     ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+
+                       return this.activeTransaction;
+               }
+
+               public void     DisposeTransaction()
+               {
+                       if (this.activeTransaction != null)
+                       {
+                               this.activeTransaction.Dispose();
+                               this.activeTransaction = null;
+                       }
+               }
+
+               public void     TransactionUpdated()
+               {
+                       for     (int i = 0;     i <     this.PreparedCommands.Count; i++)
+                       {
+                               FbCommand command =     (FbCommand)this.PreparedCommands[i];
+                               
+                               if (command.Transaction != null)
+                               {
+                                       command.CloseReader();
+                                       command.Transaction     = null;
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Schema Methods
+                               
+               public DataTable GetSchema(string collectionName, string[] restrictions)
+               {
+                       return FbDbSchemaFactory.GetSchema(this.owningConnection, collectionName, restrictions);
+               }
+
+               [Obsolete]
+               public DataTable GetSchema(string collectionName, object[] restrictions)
+               {
+                       return FbDbSchemaFactory.GetSchema(this.owningConnection, collectionName, restrictions);
+               }
+
+               #endregion
+
+               #region Prepared Commands Methods
+
+               public void     AddPreparedCommand(FbCommand command)
+               {
+                       if (!this.PreparedCommands.Contains(command))
+                       {
+                               this.PreparedCommands.Add(command);
+                       }
+               }
+
+               public void     RemovePreparedCommand(FbCommand command)
+               {
+                       this.PreparedCommands.Remove(command);
+               }
+
+               public void     DisposePreparedCommands()
+               {
+                       if (this.preparedCommands != null)
+                       {
+                               if (this.PreparedCommands.Count > 0)
+                               {
+                                       FbCommand[]     commands = (FbCommand[])this.PreparedCommands.ToArray(typeof(FbCommand));
+
+                                       for     (int i = 0;     i <     commands.Length; i++ )
+                                       {
+                                               // Release statement handle
+                                               commands[i].Release();
+                                       }
+                               }
+
+                               this.PreparedCommands.Clear();
+                               this.preparedCommands = null;
+                       }
+               }
+
+               #endregion
+
+               #region Firebird Events Methods
+
+               public void     CloseEventManager()
+               {
+                       if (this.db.HasRemoteEventSupport)
+                       {
+                               lock (this.db)
+                               {
+                                       this.db.CloseEventManager();
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Connection Verification
+
+               public bool     Verify()
+               {
+                       // Do not actually ask for any information
+                       byte[] items  = new     byte[]
+                       {
+                               IscCodes.isc_info_end
+                       };
+
+                       try     
+                       {
+                               this.db.GetDatabaseInfo(items, 16);
+
+                               return true;
+                       }
+                       catch
+                       {
+                               return false;
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private DatabaseParameterBuffer BuildDpb(IDatabase db, FbConnectionString options)
+               {
+                       DatabaseParameterBuffer dpb     = db.CreateDatabaseParameterBuffer();
+
+                       dpb.Append(IscCodes.isc_dpb_version1);
+                       dpb.Append(IscCodes.isc_dpb_dummy_packet_interval,
+                               new     byte[] { 120, 10, 0, 0 });
+                       dpb.Append(IscCodes.isc_dpb_sql_dialect,
+                               new     byte[] { Convert.ToByte(options.Dialect), 0, 0, 0 });
+                       dpb.Append(IscCodes.isc_dpb_lc_ctype, options.Charset);
+                       if (options.Role !=     null && options.Role.Length     > 0)
+                       {
+                               dpb.Append(IscCodes.isc_dpb_sql_role_name, options.Role);
+                       }
+                       dpb.Append(IscCodes.isc_dpb_connect_timeout, options.ConnectionTimeout);
+                       dpb.Append(IscCodes.isc_dpb_user_name, options.UserID);
+                       dpb.Append(IscCodes.isc_dpb_password, options.Password);
+
+                       return dpb;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionPool.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionPool.cs
new file mode 100644 (file)
index 0000000..09bbc5f
--- /dev/null
@@ -0,0 +1,567 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Collections;
+using System.Threading;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       internal sealed class FbPoolManager
+       {
+               #region Static fields
+
+               private static FbPoolManager instance;
+
+               #endregion
+
+               #region Fields
+
+               private Hashtable pools;
+               private Hashtable handlers;
+
+               #endregion
+
+               #region Static Properties
+
+               public static FbPoolManager     Instance
+               {
+                       get
+                       {
+                               if (FbPoolManager.instance == null)
+                               {
+                                       FbPoolManager.instance = new FbPoolManager();
+                               }
+
+                               return FbPoolManager.instance;
+                       }
+               }
+
+               #endregion
+
+               #region Priperties
+
+               public int PoolsCount
+               {
+                       get     
+                       {
+                               if (this.pools != null)
+                               {
+                                       return this.pools.Count;
+                               }
+                               return 0;
+                       }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               private FbPoolManager()
+               {
+                       this.pools              = Hashtable.Synchronized(new Hashtable());
+                       this.handlers   = Hashtable.Synchronized(new Hashtable());
+               }
+
+               #endregion
+
+               #region Methods
+
+               public FbConnectionPool FindPool(string connectionString)
+               {
+                       FbConnectionPool pool = null;
+
+                       lock (this)
+                       {
+                               if (this.pools.ContainsKey(connectionString.GetHashCode()))
+                               {
+                                       pool = (FbConnectionPool)pools[connectionString.GetHashCode()];
+                               }
+                       }
+
+                       return pool;
+               }
+
+               public FbConnectionPool CreatePool(string connectionString)
+               {
+                       FbConnectionPool pool = null;
+
+                       lock (this)
+                       {
+                               pool = this.FindPool(connectionString);
+
+                               if (pool ==     null)
+                               {
+                                       lock (this.pools.SyncRoot)
+                                       {
+                                               int     hashcode = connectionString.GetHashCode();
+
+                                               // Create an empty pool handler
+                                               EmptyPoolEventHandler handler = new     EmptyPoolEventHandler(this.OnEmptyPool);
+
+                                               this.handlers.Add(hashcode,     handler);
+
+                                               // Create the new connection pool
+                                               pool = new FbConnectionPool(connectionString);
+
+                                               this.pools.Add(hashcode, pool);
+
+                                               pool.EmptyPool += handler;
+                                       }
+                               }
+                       }
+
+                       return pool;
+               }
+
+               public void     ClearAllPools()
+               {
+                       lock (this)
+                       {
+                               lock (this.pools.SyncRoot)
+                               {
+                                       FbConnectionPool[] tempPools = new FbConnectionPool[this.pools.Count];
+
+                                       this.pools.Values.CopyTo(tempPools,     0);
+
+                                       foreach (FbConnectionPool pool in tempPools)
+                                       {
+                                               // Clear pool
+                                               pool.Clear();
+                                       }
+
+                                       // Clear Hashtables
+                                       this.pools.Clear();
+                                       this.handlers.Clear();
+                               }
+                       }
+               }
+
+               public void     ClearPool(string connectionString)
+               {
+                       lock (this)
+                       {
+                               lock (this.pools.SyncRoot)
+                               {
+                                       int     hashCode = connectionString.GetHashCode();
+
+                                       if (this.pools.ContainsKey(hashCode))
+                                       {
+                                               FbConnectionPool pool = (FbConnectionPool)this.pools[hashCode];
+
+                                               // Clear pool
+                                               pool.Clear();
+                                       }
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void OnEmptyPool(object sender, EventArgs e)
+               {
+                       lock (this.pools.SyncRoot)
+                       {
+                               int     hashCode = (int)sender;
+
+                               if (this.pools.ContainsKey(hashCode))
+                               {
+                                       FbConnectionPool pool = (FbConnectionPool)this.pools[hashCode];
+                                       EmptyPoolEventHandler handler = (EmptyPoolEventHandler)this.handlers[hashCode];
+
+                                       pool.EmptyPool -= handler;
+
+                                       this.pools.Remove(hashCode);
+                                       this.handlers.Remove(hashCode);
+
+                                       pool    = null;
+                                       handler = null;
+                               }
+                       }
+               }
+
+               #endregion
+       }
+       
+       internal delegate void EmptyPoolEventHandler(object     sender, EventArgs e);
+
+       internal class FbConnectionPool : MarshalByRefObject
+       {
+               #region Fields
+
+               private string                          connectionString;
+               private FbConnectionString      options;
+               private ArrayList                       locked;
+               private ArrayList                       unlocked;
+               private Thread                          cleanUpThread;          
+               private bool                            isRunning;
+               private long                            lifeTime;
+
+               #endregion
+
+               #region Events
+
+               public event EmptyPoolEventHandler EmptyPool;
+
+               #endregion
+
+               #region Properties
+
+               public int Count
+               {
+                       get     { return this.unlocked.Count + this.locked.Count; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public FbConnectionPool(string connectionString)
+               {
+                       this.connectionString   = connectionString;
+                       this.options                    = new FbConnectionString(connectionString);
+                       this.lifeTime                   = this.options.ConnectionLifeTime *     TimeSpan.TicksPerSecond;
+
+                       if (this.options.MaxPoolSize == 0)
+                       {
+                               this.locked             = ArrayList.Synchronized(new ArrayList());
+                               this.unlocked   = ArrayList.Synchronized(new ArrayList());
+                       }
+                       else
+                       {
+                               this.locked             = ArrayList.Synchronized(new ArrayList(this.options.MaxPoolSize));
+                               this.unlocked   = ArrayList.Synchronized(new ArrayList(this.options.MaxPoolSize));
+                       }
+
+                       // If a minimun number of connections is requested
+                       // initialize the pool
+                       this.Initialize();
+
+                       // Start the cleanup thread     only if needed
+                       if (this.lifeTime != 0)
+                       {
+                               this.isRunning = true;
+
+                               this.cleanUpThread = new Thread(new     ThreadStart(this.RunCleanup));
+                               this.cleanUpThread.Name = "Cleanup Thread";                     
+                               this.cleanUpThread.Start();
+                               this.cleanUpThread.IsBackground = true;
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void     CheckIn(FbConnectionInternal connection)
+               {
+                       connection.OwningConnection     = null;
+                       connection.Created                      = System.DateTime.Now.Ticks;
+
+                       this.locked.Remove(connection);
+                       this.unlocked.Add(connection);
+               }
+
+               public FbConnectionInternal     CheckOut()
+               {
+                       FbConnectionInternal newConnection = null;
+
+                       lock (this)
+                       {
+                               this.CheckMaxPoolSize();
+
+                               lock (this.unlocked.SyncRoot)
+                               {
+                                       newConnection = this.GetConnection();
+                                       if (newConnection != null)
+                                       {
+                                               return newConnection;
+                                       }
+                               }
+
+                               newConnection = this.Create();
+
+                               // Set connection pooling settings to the new connection
+                               newConnection.Lifetime  = this.options.ConnectionLifeTime;
+                               newConnection.Pooled    = true;
+
+                               // Added to     the     locked connections list.
+                               this.locked.Add(newConnection);
+                       }
+                       
+                       return newConnection;
+               }       
+
+               public void     Clear()
+               {
+                       lock (this)
+                       {
+                               // Stop cleanup thread
+                               if (this.cleanUpThread != null)
+                               {
+                                       this.cleanUpThread.Abort();
+                                       this.cleanUpThread.Join();
+                               }
+
+                               // Close all unlocked connections
+                               FbConnectionInternal[] list     = (FbConnectionInternal[])this.unlocked.ToArray(typeof(FbConnectionInternal));
+
+                               foreach (FbConnectionInternal connection in     list)
+                               {
+                                       connection.Disconnect();
+                               }
+
+                               // Close all locked     connections
+                               list = (FbConnectionInternal[])this.locked.ToArray(typeof(FbConnectionInternal));
+
+                               foreach (FbConnectionInternal connection in     list)
+                               {
+                                       connection.Disconnect();
+                               }
+
+                               // Clear lists
+                               this.unlocked.Clear();
+                               this.locked.Clear();
+
+                               // Raise EmptyPool event
+                               if (this.EmptyPool != null)
+                               {
+                                       this.EmptyPool(this.connectionString.GetHashCode(),     null);
+                               }
+
+                               // Reset fields
+                               this.unlocked                   = null;
+                               this.locked                             = null;
+                               this.connectionString   = null;
+                               this.cleanUpThread              = null;
+                               this.EmptyPool                  = null;
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private bool CheckMinPoolSize()
+               {
+                       if (this.options.MinPoolSize > 0 &&     this.Count == this.options.MinPoolSize)
+                       {
+                               return false;
+                       }
+                       else
+                       {
+                               return true;
+                       }
+               }
+
+               private void CheckMaxPoolSize()
+               {
+                       lock (this)
+                       {
+                               if (this.options.MaxPoolSize > 0 &&     
+                                       (this.Count     + 1) >= this.options.MaxPoolSize)
+                               {
+                                       long timeout    = this.options.ConnectionTimeout * TimeSpan.TicksPerSecond;
+                                       long start              = DateTime.Now.Ticks;
+
+                                       while (true)
+                                       {
+                                               if ((this.Count + 1) >= this.options.MaxPoolSize)
+                                               {
+                                                       if ((DateTime.Now.Ticks - start) > timeout)
+                                                       {
+                                                               throw new SystemException("Timeout exceeded.");
+                                                       }
+
+                                                       Thread.Sleep(100);
+                                               }
+                                               else
+                                               {
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               private void Initialize()
+               {
+                       lock (this)
+                       {
+                               for     (int i = 0;     i <     this.options.MinPoolSize; i++)
+                               {
+                                       this.unlocked.Add(this.Create());
+                               }
+                       }
+               }
+
+               private FbConnectionInternal Create()
+               {
+                       FbConnectionInternal connection = new FbConnectionInternal(this.options);
+                       connection.Connect();
+
+                       connection.Pooled       = true;
+                       connection.Created      = DateTime.Now.Ticks;
+
+                       return connection;
+               }
+
+               private FbConnectionInternal GetConnection()
+               {
+                       FbConnectionInternal[]  list    = (FbConnectionInternal[])this.unlocked.ToArray(typeof(FbConnectionInternal));
+                       FbConnectionInternal    result  = null;
+                       long                                    check   = -1;
+
+                       Array.Reverse(list);
+
+                       foreach (FbConnectionInternal connection in     list)
+                       {
+                               if (connection.Verify())
+                               {
+                                       if (this.lifeTime != 0)
+                                       {
+                                               long now        = DateTime.Now.Ticks;
+                                               long expire     = connection.Created + this.lifeTime;
+
+                                               if (now >= expire)
+                                               {
+                                                       if (this.CheckMinPoolSize())
+                                                       {
+                                                               this.unlocked.Remove(connection);
+                                                               this.Expire(connection);
+                                                       }
+                                               }
+                                               else
+                                               {
+                                                       if (expire > check)
+                                                       {
+                                                               check   = expire;
+                                                               result  = connection;
+                                                       }
+                                               }
+                                       }
+                                       else
+                                       {
+                                               result = connection;
+                                               break;
+                                       }
+                               }
+                               else
+                               {
+                                       this.unlocked.Remove(connection);
+                                       this.Expire(connection);
+                               }
+                       }
+
+                       if (result != null)
+                       {
+                               this.unlocked.Remove(result);
+                               this.locked.Add(result);
+                       }
+
+                       return result;
+               }
+
+               private void RunCleanup()
+               {
+                       int     interval = Convert.ToInt32(TimeSpan.FromTicks(this.lifeTime).TotalMilliseconds);
+
+                       if (interval > 60000)
+                       {
+                               interval = 60000;
+                       }
+
+                       try
+                       {
+                               while (this.isRunning)
+                               {
+                                       Thread.Sleep(interval);
+
+                                       this.Cleanup();
+                               
+                                       if (this.Count == 0)
+                                       {
+                                               lock (this)
+                                               {
+                                                       // Empty pool
+                                                       if (this.EmptyPool != null)
+                                                       {
+                                                               this.EmptyPool(this.connectionString.GetHashCode(),     null);
+                                                       }
+
+                                                       // Stop running
+                                                       this.isRunning = false;
+                                               }
+                                       }
+                               }
+                       }
+                       catch (ThreadAbortException)
+                       {
+                               this.isRunning = false;
+                       }
+               }
+
+               private void Expire(FbConnectionInternal connection)
+               {
+                       try     
+                       {
+                               if (connection.Verify())
+                               {
+                                       connection.Disconnect();
+                               }
+                       }
+                       catch (Exception)
+                       {
+                               throw new FbException("Error closing database connection.");
+                       }
+               }
+               
+               private void Cleanup()
+               {
+                       lock (this.unlocked.SyncRoot)
+                       {
+                               if (this.unlocked.Count > 0     && this.lifeTime !=     0)
+                               {
+                                       FbConnectionInternal[] list     = (FbConnectionInternal[])this.unlocked.ToArray(typeof(FbConnectionInternal));
+
+                                       foreach (FbConnectionInternal connection in     list)
+                                       {
+                                               long now = DateTime.Now.Ticks;
+                                               long expire     = connection.Created + this.lifeTime;
+
+                                               if (now >= expire)
+                                               {
+                                                       if (this.CheckMinPoolSize())
+                                                       {
+                                                               this.unlocked.Remove(connection);
+                                                               this.Expire(connection);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionString.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionString.cs
new file mode 100644 (file)
index 0000000..4e1a872
--- /dev/null
@@ -0,0 +1,482 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2004 Carlos Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.Data;
+using System.Globalization;
+using System.Text.RegularExpressions;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       internal sealed class FbConnectionString
+       {
+               #region Static Fields
+
+               public static readonly Hashtable Synonyms =     GetSynonyms();
+
+               #endregion
+
+               #region Static Methods
+
+               // This is somethig     that should     be needed in .NET 2.0
+               // for use with the     DbConnectionOptions     or DbConnectionString classes.
+               private static Hashtable GetSynonyms()
+               {
+                       Hashtable synonyms = new Hashtable();
+
+                       synonyms.Add("data source",     "data source");
+                       synonyms.Add("server", "data source");
+                       synonyms.Add("host", "data source");
+                       synonyms.Add("port", "port number");
+                       synonyms.Add("port number",     "port number");
+                       synonyms.Add("database", "database");
+                       synonyms.Add("user id", "user id");
+                       synonyms.Add("uid",     "user id");
+                       synonyms.Add("user", "user id");
+                       synonyms.Add("user name", "user id");
+                       synonyms.Add("password", "password");
+                       synonyms.Add("user password", "password");
+                       synonyms.Add("dialect", "dialect");
+                       synonyms.Add("charset", "charset");
+                       synonyms.Add("pooling", "pooling");
+                       synonyms.Add("max pool size", "max pool size");
+                       synonyms.Add("min pool size", "min pool size");
+                       synonyms.Add("character set", "charset");
+                       synonyms.Add("connection lifetime",     "connection     lifetime");
+                       synonyms.Add("timeout", "connection     timeout");
+                       synonyms.Add("connection timeout", "connection timeout");
+                       synonyms.Add("packet size",     "packet size");
+                       synonyms.Add("role", "role name");
+                       synonyms.Add("role name", "role name");
+                       synonyms.Add("fetch     size", "fetch size");
+                       synonyms.Add("fetchsize", "fetch size");
+                       synonyms.Add("server type",     "server type");
+                       synonyms.Add("servertype", "server type");
+                       synonyms.Add("isolation level", "isolation level");
+
+                       return synonyms;
+               }
+
+               #endregion
+
+               #region Private fields
+
+               private Hashtable       options;
+               private bool            isServiceConnectionString;
+
+               #endregion
+
+               #region Properties
+
+               public string UserID
+               {
+                       get     { return this.GetString("user id");     }
+               }
+
+               public string Password
+               {
+                       get     { return this.GetString("password"); }
+               }
+
+               public string DataSource
+               {
+                       get     { return this.GetString("data source"); }
+               }
+
+               public int Port
+               {
+                       get     { return this.GetInt32("port number"); }
+               }
+
+               public string Database
+               {
+                       get     { return this.GetString("database"); }
+               }
+
+               public short PacketSize
+               {
+                       get     { return this.GetInt16("packet size"); }
+               }
+
+               public string Role
+               {
+                       get     { return this.GetString("role name"); }
+               }
+
+               public byte     Dialect
+               {
+                       get     { return this.GetByte("dialect"); }
+               }
+
+               public string Charset
+               {
+                       get     { return this.GetString("charset");     }
+               }
+
+               public int ConnectionTimeout
+               {
+                       get     { return this.GetInt32("connection timeout"); }
+               }
+
+               public bool     Pooling
+               {
+                       get     { return this.GetBoolean("pooling"); }
+               }
+
+               public long     ConnectionLifeTime
+               {
+                       get     { return this.GetInt64("connection lifetime"); }
+               }
+
+               public int MinPoolSize
+               {
+                       get     { return this.GetInt32("min     pool size"); }
+               }
+
+               public int MaxPoolSize
+               {
+                       get     { return this.GetInt32("max     pool size"); }
+               }
+
+               public int FetchSize
+               {
+                       get     { return this.GetInt32("fetch size"); }
+               }
+
+               public int ServerType
+               {
+                       get     { return this.GetInt32("server type"); }
+               }
+
+               public IsolationLevel IsolationLevel
+               {
+                       get     { return this.GetIsolationLevel("isolation level");     }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public FbConnectionString()
+               {
+                       this.SetDefaultOptions();
+               }
+
+               public FbConnectionString(FbConnectionStringBuilder     csb) : this(csb.ToString())
+               {
+               }
+
+               public FbConnectionString(string connectionString)
+               {
+                       this.Load(connectionString);
+               }
+
+               internal FbConnectionString(bool isServiceConnectionString)
+               {
+                       this.isServiceConnectionString = isServiceConnectionString;
+                       this.SetDefaultOptions();
+               }
+
+               #endregion
+
+               #region Public methods
+
+               public void     Load(string     connectionString)
+               {
+                       this.SetDefaultOptions();
+
+                       if (connectionString != null && connectionString.Length > 0)
+                       {
+                               Hashtable               synonyms = GetSynonyms();
+                               MatchCollection keyPairs = Regex.Matches(connectionString, @"([\w\s\d]*)\s*=\s*([^;]*)");
+
+                               foreach (Match keyPair in keyPairs)
+                               {
+                                       if (keyPair.Groups.Count ==     3)
+                                       {
+                                               string[] values = new string[] 
+                                               {
+                                                       keyPair.Groups[1].Value.Trim(),
+                                                       keyPair.Groups[2].Value.Trim()
+                                               };
+
+                                               if (values.Length == 2 &&
+                                                       values[0] != null && values[0].Length > 0 &&
+                                                       values[1] != null && values[1].Length > 0)
+                                               {
+                                                       values[0] =     values[0].ToLower(CultureInfo.CurrentCulture);
+
+                                                       if (synonyms.Contains(values[0]))
+                                                       {
+                                                               string key = (string)synonyms[values[0]];
+                                                               this.options[key] =     values[1].Trim();
+                                                       }
+                                               }
+                                       }
+                               }
+
+                               if (this.Database != null && this.Database.Length >     0)
+                               {
+                                       this.ParseConnectionInfo(this.Database);
+                               }
+                       }
+               }
+
+               public void     Validate()
+               {
+                       if ((this.UserID ==     null || this.UserID.Length == 0) ||
+                               (this.Password == null || this.Password.Length == 0) ||
+                               ((this.Database == null || this.Database.Length == 0) && !this.isServiceConnectionString) ||
+                               ((this.DataSource == null || this.DataSource.Length     == 0) && this.ServerType !=     1) ||
+                               (this.Charset == null || this.Charset.Length == 0) ||
+                               this.Port == 0 ||
+                               (this.ServerType !=     0 && this.ServerType != 1) ||
+                               (this.MinPoolSize >     this.MaxPoolSize))
+                       {
+                               throw new ArgumentException("An invalid connection string argument has been     supplied or     a required connection string argument has not been supplied.");
+                       }
+                       else
+                       {
+                               if (this.Dialect < 1 || this.Dialect > 3)
+                               {
+                                       throw new ArgumentException("Incorrect database dialect it should be 1, 2, or 3.");
+                               }
+                               if (this.PacketSize     < 512 || this.PacketSize > 32767)
+                               {
+                                       throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, "'Packet Size' value of {0}     is not valid.\r\nThe value should be an integer >= 512 and <= 32767.", this.PacketSize));
+                               }
+
+                               this.CheckIsolationLevel();
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void SetDefaultOptions()
+               {
+                       if (this.options ==     null)
+                       {
+                               this.options = new Hashtable();
+                       }
+
+                       this.options.Clear();
+
+                       // Add default key pairs values
+                       this.options.Add("data source", "");
+                       this.options.Add("port number", 3050);
+                       this.options.Add("user id",     "SYSDBA");
+                       this.options.Add("password", "masterkey");
+                       this.options.Add("role name", String.Empty);
+                       this.options.Add("database", String.Empty);
+                       this.options.Add("charset",     "None");
+                       this.options.Add("dialect",     3);
+                       this.options.Add("packet size", 8192);
+                       this.options.Add("pooling",     true);
+                       this.options.Add("connection lifetime", 0);
+                       this.options.Add("min pool size", 0);
+                       this.options.Add("max pool size", 100);
+                       this.options.Add("connection timeout", 15);
+                       this.options.Add("fetch size", 200);
+                       this.options.Add("server type", 0);
+                       this.options.Add("isolation     level", IsolationLevel.ReadCommitted.ToString());
+               }
+
+               private void ParseConnectionInfo(string connectInfo)
+               {
+                       string  database        = null;
+                       string  dataSource      = null;
+                       int             portNumber      = -1;
+
+                       // allows standard syntax //host:port/....
+                       // and old fb syntax host/port:....
+                       connectInfo     = connectInfo.Trim();
+                       char hostSepChar;
+                       char portSepChar;
+
+                       if (connectInfo.StartsWith("//"))
+                       {
+                               connectInfo     = connectInfo.Substring(2);
+                               hostSepChar     = '/';
+                               portSepChar     = ':';
+                       }
+                       else
+                       {
+                               hostSepChar     = ':';
+                               portSepChar     = '/';
+                       }
+
+                       int     sep     = connectInfo.IndexOf(hostSepChar);
+                       if (sep == 0 || sep     == connectInfo.Length - 1)
+                       {
+                               throw new ArgumentException("An invalid connection string argument has been     supplied or     a required connection string argument has not been supplied.");
+                       }
+                       else if (sep > 0)
+                       {
+                               dataSource      = connectInfo.Substring(0, sep);
+                               database        = connectInfo.Substring(sep     + 1);
+                               int     portSep = dataSource.IndexOf(portSepChar);
+
+                               if (portSep     == 0 || portSep == dataSource.Length - 1)
+                               {
+                                       throw new ArgumentException("An invalid connection string argument has been     supplied or     a required connection string argument has not been supplied.");
+                               }
+                               else if (portSep > 0)
+                               {
+                                       portNumber = Int32.Parse(dataSource.Substring(portSep + 1),     CultureInfo.InvariantCulture);
+                                       dataSource = dataSource.Substring(0, portSep);
+                               }
+                               else if (portSep < 0 && dataSource.Length == 1)
+                               {
+                                       if (this.DataSource     == null || this.DataSource.Length == 0)
+                                       {
+                                               dataSource = "localhost";
+                                       }
+                                       else
+                                       {
+                                               dataSource = null;
+                                       }
+
+                                       database = connectInfo;
+                               }
+                       }
+                       else if (sep == -1)
+                       {
+                               database = connectInfo;
+                       }
+
+                       this.options["database"] = database;
+                       if (dataSource != null)
+                       {
+                               this.options["data source"]     = dataSource;
+                       }
+                       if (portNumber != -1)
+                       {
+                               this.options["port"] = portNumber;
+                       }
+               }
+
+               private string GetString(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return (string)this.options[key];
+                       }
+                       return null;
+               }
+
+               private bool GetBoolean(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return Boolean.Parse(this.options[key].ToString());
+                       }
+                       return false;
+               }
+
+               private byte GetByte(string     key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return Convert.ToByte(this.options[key], CultureInfo.CurrentUICulture);
+                       }
+                       return 0;
+               }
+
+               private short GetInt16(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return Convert.ToInt16(this.options[key], CultureInfo.InvariantCulture);
+                       }
+                       return 0;
+               }
+
+               private int     GetInt32(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return Convert.ToInt32(this.options[key], CultureInfo.InvariantCulture);
+                       }
+                       return 0;
+               }
+
+               private long GetInt64(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return Convert.ToInt64(this.options[key], CultureInfo.InvariantCulture);
+                       }
+                       return 0;
+               }
+
+               private IsolationLevel GetIsolationLevel(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               string il =     this.options[key].ToString().ToLower(CultureInfo.CurrentUICulture);
+                               switch (il)
+                               {
+                                       case "readcommitted":
+                                               return IsolationLevel.ReadCommitted;
+
+                                       case "readuncommitted":
+                                               return IsolationLevel.ReadUncommitted;
+
+                                       case "repeatableread":
+                                               return IsolationLevel.RepeatableRead;
+
+                                       case "serializable":
+                                               return IsolationLevel.Serializable;
+
+                                       case "chaos":
+                                               return IsolationLevel.Chaos;
+
+                                       case "unspecified":
+                                               return IsolationLevel.Unspecified;
+                               }
+                       }
+
+                       return IsolationLevel.ReadCommitted;
+               }
+
+               private void CheckIsolationLevel()
+               {
+                       string il =     this.options["isolation level"].ToString().ToLower(CultureInfo.CurrentUICulture);
+                       switch (il)
+                       {
+                               case "readcommitted":
+                               case "readuncommitted":
+                               case "repeatableread":
+                               case "serializable":
+                               case "chaos":
+                               case "unspecified":
+                                       break;
+
+                               default:
+                                       throw new ArgumentException("Specified Isolation Level is not valid.");
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs
new file mode 100644 (file)
index 0000000..6f57be9
--- /dev/null
@@ -0,0 +1,350 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2004 Carlos Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.Data;
+using System.Globalization;
+using System.Text;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/overview/*'/>
+       public sealed class     FbConnectionStringBuilder
+       {
+               #region Private fields
+
+               private Hashtable options;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="ConnectionString"]/*'/>
+               public string ConnectionString
+               {
+                       get     { return this.ToString(); }
+                       set     { this.Load(value);     }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="UserID"]/*'/>
+               public string UserID
+               {
+                       get     { return this.GetString("user id");     }
+                       set     { this.SetValue("user id", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="Password"]/*'/>
+               public string Password
+               {
+                       get     { return this.GetString("password"); }
+                       set     { this.SetValue("password",     value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="DataSource"]/*'/>
+               public string DataSource
+               {
+                       get     { return this.GetString("data source"); }
+                       set     { this.SetValue("data source", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="Port"]/*'/>
+               public int Port
+               {
+                       get     { return this.GetInt32("port number"); }
+                       set     { this.SetValue("port number", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="Database"]/*'/>
+               public string Database
+               {
+                       get     { return this.GetString("database"); }
+                       set     { this.SetValue("database",     value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="PacketSize"]/*'/>
+               public short PacketSize
+               {
+                       get     { return this.GetInt16("packet size"); }
+                       set     { this.SetValue("packet size", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="Role"]/*'/>
+               public string Role
+               {
+                       get     { return this.GetString("role name"); }
+                       set
+                       {
+                               if (value == null)
+                               {
+                                       value = String.Empty;
+                               }
+                               this.SetValue("role     name", value);
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="Dialect"]/*'/>
+               public byte     Dialect
+               {
+                       get     { return this.GetByte("dialect"); }
+                       set     { this.SetValue("dialect", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="Charset"]/*'/>
+               public string Charset
+               {
+                       get     { return this.GetString("charset");     }
+                       set     { this.SetValue("charset", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="ConnectionTimeout"]/*'/>
+               public int ConnectionTimeout
+               {
+                       get     { return this.GetInt32("connection timeout"); }
+                       set     { this.SetValue("connection     timeout", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="Pooling"]/*'/>
+               public bool     Pooling
+               {
+                       get     { return this.GetBoolean("pooling"); }
+                       set     { this.SetValue("pooling", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="ConnectionLifeTime"]/*'/>
+               public long     ConnectionLifeTime
+               {
+                       get     { return this.GetInt64("connection lifetime"); }
+                       set     { this.SetValue("connection     lifetime", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="MinPoolSize"]/*'/>
+               public int MinPoolSize
+               {
+                       get     { return this.GetInt32("min     pool size"); }
+                       set     { this.SetValue("min pool size", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="MaxPoolSize"]/*'/>
+               public int MaxPoolSize
+               {
+                       get     { return this.GetInt32("max     pool size"); }
+                       set     { this.SetValue("max pool size", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="FetchSize"]/*'/>
+               public int FetchSize
+               {
+                       get     { return this.GetInt32("fetch size"); }
+                       set     { this.SetValue("fetch size", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="ServerType"]/*'/>
+               public int ServerType
+               {
+                       get     { return this.GetInt32("server type"); }
+                       set     { this.SetValue("server type", value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/property[@name="IsolationLevel"]/*'/>
+               public IsolationLevel IsolationLevel
+               {
+                       get     { return this.GetIsolationLevel("isolation level");     }
+                       set     { this.SetValue("isolation level", value.ToString()); }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/constructor[@name="ctor"]/*'/>
+               public FbConnectionStringBuilder() : this(null)
+               {
+               }
+
+               ///     <include file='Doc/en_EN/FbConnectionStringBuilder.xml' path='doc/class[@name="FbConnectionStringBuilder"]/constructor[@name="ctor(System.String)"]/*'/>
+               public FbConnectionStringBuilder(string connectionString)
+               {
+                       this.options = new Hashtable();
+
+                       if (connectionString != null && connectionString.Length > 0) 
+                       {
+                               this.Load(connectionString);
+                       }
+               }
+
+               #endregion
+
+               #region Overriden methods
+
+               ///     <summary>
+               ///     Overrided method, returns the Firebird connection string.
+               ///     </summary>
+               ///     <returns>The Firebird connection string.</returns>
+               public override string ToString()
+               {
+                       StringBuilder cs = new StringBuilder();
+
+                       IDictionaryEnumerator e = this.options.GetEnumerator();
+                       while (e.MoveNext())
+                       {
+                               if (e.Value     != null)
+                               {
+                                       if (cs.Length > 0)
+                                       {
+                                               cs.Append(";");
+                                       }
+                                       string key = CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(e.Key.ToString());
+                                       cs.AppendFormat(CultureInfo.CurrentUICulture, "{0}={1}", key, e.Value);
+                               }
+                       }
+
+                       return cs.ToString();
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void Load(string connectionString)
+               {
+                       string[]        keyPairs = connectionString.Split(';');
+                       Hashtable       synonyms = FbConnectionString.Synonyms;
+
+                       if (this.options !=     null)
+                       {
+                               this.options.Clear();
+                       }
+
+                       foreach (string keyPair in keyPairs)
+                       {
+                               string[] values = keyPair.Split('=');
+
+                               if (values.Length == 2 &&
+                                       values[0] != null && values[0].Length > 0 &&
+                                       values[1] != null && values[1].Length > 0)
+                               {
+                                       values[0] =     values[0].ToLower(CultureInfo.CurrentUICulture);
+
+                                       if (synonyms.Contains(values[0]))
+                                       {
+                                               string key = (string)synonyms[values[0]];
+                                               this.options[key] =     values[1].Trim();
+                                       }
+                               }
+                       }
+               }
+
+               private string GetString(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return (string)this.options[key];
+                       }
+                       return null;
+               }
+
+               private bool GetBoolean(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return Boolean.Parse(this.options[key].ToString());
+                       }
+                       return false;
+               }
+
+               private byte GetByte(string     key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return Convert.ToByte(this.options[key], CultureInfo.InvariantCulture);
+                       }
+                       return 0;
+               }
+
+               private short GetInt16(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return Convert.ToInt16(this.options[key], CultureInfo.InvariantCulture);
+                       }
+                       return 0;
+               }
+
+               private int     GetInt32(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return Convert.ToInt32(this.options[key], CultureInfo.InvariantCulture);
+                       }
+                       return 0;
+               }
+
+               private long GetInt64(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               return Convert.ToInt64(this.options[key], CultureInfo.InvariantCulture);
+                       }
+                       return 0;
+               }
+
+               private void SetValue(string key, object value)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               this.options[key] =     value;
+                       }
+                       else
+                       {
+                               this.options.Add(key, value);
+                       }
+               }
+
+               private IsolationLevel GetIsolationLevel(string key)
+               {
+                       if (this.options.Contains(key))
+                       {
+                               string il =     this.options[key].ToString().ToLower(CultureInfo.CurrentUICulture);
+                               switch (il)
+                               {
+                                       case "readcommitted":
+                                               return IsolationLevel.ReadCommitted;
+
+                                       case "readuncommitted":
+                                               return IsolationLevel.ReadUncommitted;
+
+                                       case "repeatableread":
+                                               return IsolationLevel.RepeatableRead;
+
+                                       case "serializable":
+                                               return IsolationLevel.Serializable;
+
+                                       case "chaos":
+                                               return IsolationLevel.Chaos;
+
+                                       case "unspecified":
+                                               return IsolationLevel.Unspecified;
+                               }
+                       }
+                       return IsolationLevel.ReadCommitted;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDataAdapter.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDataAdapter.cs
new file mode 100644 (file)
index 0000000..3f95708
--- /dev/null
@@ -0,0 +1,587 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Data;
+using System.Data.Common;
+using System.Drawing;
+
+#if    (NET)
+using System.ComponentModel.Design;
+using FirebirdSql.Data.Firebird.Design;
+#endif
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/overview/*'/>
+#if    (NET)
+       [ToolboxItem(true)]
+       [ToolboxBitmap(typeof(FbDataAdapter), "Resources.FbDataAdapter.bmp")]
+       [DefaultEvent("RowUpdated")]
+       [DesignerAttribute(typeof(FbDataAdapterDesigner), typeof(IDesigner))]
+#endif 
+       public sealed class     FbDataAdapter : DbDataAdapter, IDbDataAdapter
+       {
+               #region Static Fields
+
+               private static readonly object EventRowUpdated = new object();
+               private static readonly object EventRowUpdating = new object();
+
+               #endregion
+
+               #region Events
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/event[@name="RowUpdated"]/*'/>
+               public event FbRowUpdatedEventHandler RowUpdated
+               {
+                       add
+                       {
+                               base.Events.AddHandler(EventRowUpdated, value);
+                       }
+
+                       remove
+                       {
+                               base.Events.RemoveHandler(EventRowUpdated, value);
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/event[@name="RowUpdating"]/*'/>
+               public event FbRowUpdatingEventHandler RowUpdating
+               {
+                       add
+                       {
+                               base.Events.AddHandler(EventRowUpdating, value);
+                       }
+
+                       remove
+                       {
+                               base.Events.RemoveHandler(EventRowUpdating,     value);
+                       }
+               }
+
+               #endregion
+
+               #region Fields
+
+               private FbCommand selectCommand;
+               private FbCommand insertCommand;
+               private FbCommand updateCommand;
+               private FbCommand deleteCommand;
+
+               private bool disposed;
+
+               #endregion
+
+               #region Properties
+
+               IDbCommand IDbDataAdapter.SelectCommand
+               {
+                       get     { return this.selectCommand; }
+                       set     { this.selectCommand = (FbCommand)value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/property[@name="SelectCommand"]/*'/>
+#if    (!NETCF)
+               [Category("Fill"), DefaultValue(null)]
+#endif
+               public FbCommand SelectCommand
+               {
+                       get     { return this.selectCommand; }
+                       set     { this.selectCommand = value; }
+               }
+
+               IDbCommand IDbDataAdapter.InsertCommand
+               {
+                       get     { return this.insertCommand; }
+                       set     { this.insertCommand = (FbCommand)value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/property[@name="InsertCommand"]/*'/>
+#if    (!NETCF)                
+               [Category("Update"), DefaultValue(null)]
+#endif
+               public FbCommand InsertCommand
+               {
+                       get     { return this.insertCommand; }
+                       set     { this.insertCommand = value; }
+               }
+
+               IDbCommand IDbDataAdapter.UpdateCommand
+               {
+                       get     { return this.updateCommand; }
+                       set     { this.updateCommand = (FbCommand)value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/property[@name="UpdateCommand"]/*'/>             
+#if    (!NETCF)
+               [Category("Update"), DefaultValue(null)]
+#endif
+               public FbCommand UpdateCommand
+               {
+                       get     { return this.updateCommand; }
+                       set     { this.updateCommand = value; }
+               }
+
+               IDbCommand IDbDataAdapter.DeleteCommand
+               {
+                       get     { return this.deleteCommand; }
+                       set     { this.deleteCommand = (FbCommand)value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/property[@name="DeleteCommand"]/*'/>
+#if    (!NETCF)
+               [Category("Update"), DefaultValue(null)]
+#endif
+               public FbCommand DeleteCommand
+               {
+                       get     { return this.deleteCommand; }
+                       set     { this.deleteCommand = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/constructor[@name="ctor"]/*'/>
+               public FbDataAdapter() : base()
+               {
+               }
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/constructor[@name="ctor(FbCommand)"]/*'/>
+               public FbDataAdapter(FbCommand selectCommand) : base()
+               {
+                       this.SelectCommand = selectCommand;
+               }
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/constructor[@name="ctor(System.String,FbConnection)"]/*'/>               
+               public FbDataAdapter(string     selectCommandText, FbConnection selectConnection) :     base()
+               {
+                       this.SelectCommand = new FbCommand(selectCommandText, selectConnection);
+               }
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/constructor[@name="ctor(System.String,System.String)"]/*'/>
+               public FbDataAdapter(string     selectCommandText, string selectConnectionString) :     base()
+               {
+                       FbConnection connection = new FbConnection(selectConnectionString);
+                       this.SelectCommand = new FbCommand(selectCommandText, connection);
+               }
+
+               #endregion
+
+               #region IDisposable     Methods
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/method[@name="Dispose(System.Boolean)"]/*'/>
+               protected override void Dispose(bool disposing)
+               {
+                       lock (this)
+                       {
+                               if (!this.disposed)
+                               {
+                                       try
+                                       {
+                                               // Release any managed resources
+                                               if (disposing)
+                                               {
+                                                       if (this.SelectCommand != null)
+                                                       {
+                                                               this.SelectCommand.Dispose();
+                                                       }
+                                                       if (this.InsertCommand != null)
+                                                       {
+                                                               this.InsertCommand.Dispose();
+                                                       }
+                                                       if (this.UpdateCommand != null)
+                                                       {
+                                                               this.UpdateCommand.Dispose();
+                                                       }
+                                               }
+
+                                               // release any unmanaged resources
+
+                                               this.disposed = true;
+                                       }
+                                       finally
+                                       {
+                                               base.Dispose(disposing);
+                                       }
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/method[@name="CreateRowUpdatingEvent(System.Data.DataRow,System.Data.IDbCommand,System.Data.StatementType,System.Data.Common.DataTableMapping)"]/*'/>
+               protected override RowUpdatingEventArgs CreateRowUpdatingEvent(
+                       DataRow                         dataRow,
+                       IDbCommand                      command,
+                       StatementType           statementType,
+                       DataTableMapping        tableMapping)
+               {
+                       return new FbRowUpdatingEventArgs(dataRow, command,     statementType, tableMapping);
+               }
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/method[@name="CreateRowUpdatedEvent(System.Data.DataRow,System.Data.IDbCommand,System.Data.StatementType,System.Data.Common.DataTableMapping)"]/*'/>
+               protected override RowUpdatedEventArgs CreateRowUpdatedEvent(
+                       DataRow                         dataRow,
+                       IDbCommand                      command,
+                       StatementType           statementType,
+                       DataTableMapping        tableMapping)
+               {
+                       return new FbRowUpdatedEventArgs(dataRow, command, statementType, tableMapping);
+               }
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/method[@name="OnRowUpdating(System.Data.Common.RowUpdatingEventArgs)"]/*'/>
+               protected override void OnRowUpdating(RowUpdatingEventArgs value)
+               {
+                       FbRowUpdatingEventHandler handler =     null;
+
+                       handler = (FbRowUpdatingEventHandler)base.Events[EventRowUpdating];
+
+                       if ((null != handler) &&
+                               (value is FbRowUpdatingEventArgs) &&
+                               (value != null))
+                       {
+                               handler(this, (FbRowUpdatingEventArgs)value);
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataAdapter.xml'     path='doc/class[@name="FbDataAdapter"]/method[@name="OnRowUpdated(System.Data.Common.RowUpdatedEventArgs)"]/*'/>
+               protected override void OnRowUpdated(RowUpdatedEventArgs value)
+               {
+                       FbRowUpdatedEventHandler handler = null;
+
+                       handler = (FbRowUpdatedEventHandler)base.Events[EventRowUpdated];
+
+                       if ((handler != null) &&
+                               (value is FbRowUpdatedEventArgs) &&
+                               (value != null))
+                       {
+                               handler(this, (FbRowUpdatedEventArgs)value);
+                       }
+               }
+
+               #endregion
+
+               #region Update DataRow Collection
+
+               ///     <summary>
+               ///     Review .NET     Framework documentation.
+               ///     </summary>
+               protected override int Update(DataRow[] dataRows, DataTableMapping tableMapping)
+               {
+                       int                       updated               = 0;
+                       IDbCommand        command               = null;
+                       StatementType statementType     = StatementType.Insert;
+                       ArrayList         connections   = new ArrayList();
+
+                       foreach (DataRow row in dataRows)
+                       {
+                               if (row.RowState ==     DataRowState.Detached ||
+                                       row.RowState == DataRowState.Unchanged)
+                               {
+                                       continue;
+                               }
+
+                               switch (row.RowState)
+                               {
+                                       case DataRowState.Added:
+                                               command           =     this.insertCommand;
+                                               statementType = StatementType.Insert;
+                                               break;
+
+                                       case DataRowState.Modified:
+                                               command           =     this.updateCommand;
+                                               statementType = StatementType.Update;
+                                               break;
+
+                                       case DataRowState.Deleted:
+                                               command           =     this.deleteCommand;
+                                               statementType = StatementType.Delete;
+                                               break;
+                               }
+
+                               /* The order of execution can be reviewed in the .NET 1.1 documentation
+                                *
+                                * 1. The values in     the     DataRow are     moved to the parameter values. 
+                                * 2. The OnRowUpdating event is raised. 
+                                * 3. The command executes.     
+                                * 4. If the command is set     to FirstReturnedRecord, then the first returned result is placed in     the     DataRow. 
+                                * 5. If there are output parameters, they are placed in the DataRow. 
+                                * 6. The OnRowUpdated event is raised. 
+                                * 7 AcceptChanges is called. 
+                                */
+
+                               try
+                               {
+                                       /* 1. Update Parameter values (It's     very similar to what we 
+                                        * are doing in the     FbCommandBuilder class).
+                                        *
+                                        * Only input parameters should be updated.
+                                        */
+                                       if (command     != null && command.Parameters.Count     > 0)
+                                       {
+                                               this.UpdateParameterValues(command,     statementType, row,     tableMapping);
+                                       }
+
+                                       // 2. Raise     RowUpdating     event
+                                       RowUpdatingEventArgs updatingArgs =     this.CreateRowUpdatingEvent(row, command, statementType, tableMapping);
+                                       this.OnRowUpdating(updatingArgs);
+
+                                       if (updatingArgs.Status == UpdateStatus.SkipAllRemainingRows)
+                                       {
+                                               break;
+                                       }
+                                       else if (updatingArgs.Status == UpdateStatus.ErrorsOccurred)
+                                       {
+                                               if (updatingArgs.Errors == null)
+                                               {
+                                                       throw new InvalidOperationException("RowUpdatingEvent: Errors occurred; no additional is information available.");
+                                               }
+                                               throw updatingArgs.Errors;
+                                       }
+                                       else if (updatingArgs.Status == UpdateStatus.SkipCurrentRow)
+                                       {
+                                       }
+                                       else if (updatingArgs.Status == UpdateStatus.Continue)
+                                       {
+                                               if (command     != updatingArgs.Command)
+                                               {
+                                                       command = updatingArgs.Command;
+                                               }
+                                               if (command     == null)
+                                               {
+                                                       /* Samples of exceptions thrown by DbDataAdapter class
+                                                        *
+                                                        *      Update requires a valid InsertCommand when passed DataRow collection with new rows
+                                                        *      Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
+                                                        *      Update requires a valid DeleteCommand when passed DataRow collection with deleted rows.
+                                                        */
+                                                       string message = this.CreateExceptionMessage(statementType);
+                                                       throw new InvalidOperationException(message);
+                                               }
+
+                                               // 3. Execute the command
+                                               if (command.Connection.State == ConnectionState.Closed)
+                                               {
+                                                       command.Connection.Open();
+                                                       // Track command connection
+                                                       connections.Add(command.Connection);
+                                               }
+
+                                               int     rowsAffected = command.ExecuteNonQuery();
+                                               if (rowsAffected ==     0)
+                                               {
+                                                       throw new DBConcurrencyException("An attempt to execute an INSERT, UPDATE, or DELETE statement resulted in zero records affected.");
+                                               }
+
+                                               updated++;
+
+                                               /* 4. If the command is set     to FirstReturnedRecord, then the 
+                                                * first returned result is     placed in the DataRow. 
+                                                * 
+                                                * We have nothing to do in     this case as there are no 
+                                                * support for batch commands.
+                                                */
+
+                                               /* 5. Check     if we have output parameters and they should 
+                                                * be updated.
+                                                *
+                                                * Only output paraneters should be     updated
+                                                */
+                                               if (command.UpdatedRowSource == UpdateRowSource.OutputParameters ||
+                                                       command.UpdatedRowSource ==     UpdateRowSource.Both)
+                                               {
+                                                       // Process output parameters
+                                                       foreach (IDataParameter parameter in command.Parameters)
+                                                       {
+                                                               if ((parameter.Direction ==     ParameterDirection.Output ||
+                                                                       parameter.Direction     == ParameterDirection.ReturnValue ||
+                                                                       parameter.Direction     == ParameterDirection.InputOutput) &&
+                                                                       parameter.SourceColumn != null &&
+                                                                       parameter.SourceColumn.Length > 0)
+                                                               {
+                                                                       DataColumn column =     null;
+
+                                                                       DataColumnMapping columnMapping = tableMapping.GetColumnMappingBySchemaAction(
+                                                                               parameter.SourceColumn,
+                                                                               this.MissingMappingAction);
+
+                                                                       if (columnMapping != null)
+                                                                       {
+                                                                               column = columnMapping.GetDataColumnBySchemaAction(
+                                                                                       row.Table,
+                                                                                       null,
+                                                                                       this.MissingSchemaAction);
+
+                                                                               if (column != null)
+                                                                               {
+                                                                                       row[column]     = parameter.Value;
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+
+                                               // 6. Raise     RowUpdated event
+                                               RowUpdatedEventArgs     updatedArgs     = this.CreateRowUpdatedEvent(row, command, statementType, tableMapping);
+                                               this.OnRowUpdated(updatedArgs);
+
+                                               if (updatedArgs.Status == UpdateStatus.SkipAllRemainingRows)
+                                               {
+                                                       break;
+                                               }
+                                               else if (updatedArgs.Status     == UpdateStatus.ErrorsOccurred)
+                                               {
+                                                       if (updatingArgs.Errors == null)
+                                                       {
+                                                               throw new InvalidOperationException("RowUpdatedEvent: Errors occurred; no additional is information     available.");
+                                                       }
+                                                       throw updatedArgs.Errors;
+                                               }
+                                               else if (updatedArgs.Status     == UpdateStatus.SkipCurrentRow)
+                                               {
+                                               }
+                                               else if (updatingArgs.Status == UpdateStatus.Continue)
+                                               {
+                                                       // 7. Call AcceptChanges
+                                                       row.AcceptChanges();
+                                               }
+                                       }
+                               }
+                               catch (Exception ex)
+                               {
+                                       if (this.ContinueUpdateOnError)
+                                       {
+                                               row.RowError = ex.Message;
+                                       }
+                                       else
+                                       {
+                                               this.CloseConnections(connections);
+
+                                               throw;
+                                       }
+                               }
+                       }
+
+                       this.CloseConnections(connections);
+
+                       return updated;
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private string CreateExceptionMessage(StatementType     statementType)
+               {
+                       System.Text.StringBuilder sb = new System.Text.StringBuilder();
+
+                       sb.Append("Update requires a valid ");
+                       sb.Append(statementType.ToString());
+                       sb.Append("Command when passed DataRow collection with ");
+
+                       switch (statementType)
+                       {
+                               case StatementType.Insert:
+                                       sb.Append("new");
+                                       break;
+
+                               case StatementType.Update:
+                                       sb.Append("modified");
+                                       break;
+
+                               case StatementType.Delete:
+                                       sb.Append("deleted");
+                                       break;
+                       }
+
+                       sb.Append("     rows.");
+
+                       return sb.ToString();
+               }
+
+               private void UpdateParameterValues(
+                       IDbCommand                      command,
+                       StatementType           statementType,
+                       DataRow                         row, 
+                       DataTableMapping        tableMapping)
+               {
+                       foreach (IDataParameter parameter in command.Parameters)
+                       {
+                               // Process only input parameters
+                               if (parameter.Direction != ParameterDirection.Input     &&
+                                       parameter.Direction     != ParameterDirection.InputOutput)
+                               {
+                                       continue;
+                               }
+
+                               DataColumn column =     null;
+
+                               /* Get the DataColumnMapping that matches the given
+                                * column name
+                                */
+                               DataColumnMapping columnMapping = tableMapping.GetColumnMappingBySchemaAction(
+                                       parameter.SourceColumn,
+                                       this.MissingMappingAction);
+
+                               if (columnMapping != null)
+                               {
+                                       column = columnMapping.GetDataColumnBySchemaAction(
+                                               row.Table,
+                                               null,
+                                               this.MissingSchemaAction);
+
+                                       if (column != null)
+                                       {
+                                               DataRowVersion dataRowVersion = DataRowVersion.Default;
+
+                                               if (statementType == StatementType.Insert)
+                                               {
+                                                       dataRowVersion = DataRowVersion.Current;
+                                               }
+                                               else if (statementType == StatementType.Update)
+                                               {
+                                                       dataRowVersion = parameter.SourceVersion;
+                                               }
+                                               else if (statementType == StatementType.Delete)
+                                               {
+                                                       dataRowVersion = DataRowVersion.Original;
+                                               }
+
+                                               parameter.Value = row[column, dataRowVersion];
+                                       }
+                               }
+                       }
+               }
+
+               private void CloseConnections(ArrayList connections)
+               {
+                       foreach (IDbConnection c in     connections)
+                       {
+                               c.Close();
+                       }
+                       connections.Clear();
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDataReader.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDataReader.cs
new file mode 100644 (file)
index 0000000..1644aa2
--- /dev/null
@@ -0,0 +1,786 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Data;
+using System.Data.Common;
+using System.Globalization;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{      
+       ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/overview/*'/>
+       public sealed class     FbDataReader : MarshalByRefObject, IDataReader, IEnumerable, IDisposable, IDataRecord
+       {               
+               #region Fields
+               
+               private const int               STARTPOS = -1;
+               private bool                    disposed;
+               private bool                    isClosed;
+               private bool                    eof;
+               private int                             position;
+               private int                             recordsAffected;
+               private DataTable               schemaTable;
+               private FbCommand               command;
+               private FbConnection    connection;
+               private DbValue[]               row;
+               private Descriptor              fields;
+               private CommandBehavior behavior;
+
+               #endregion
+
+               #region Constructors
+
+               internal FbDataReader(
+                       FbCommand               command, 
+                       FbConnection    connection,
+                       CommandBehavior behavior)
+               {
+                       this.position            = STARTPOS;
+                       this.recordsAffected = -1;
+                       this.command             = command;
+                       this.behavior            = behavior;
+                       this.connection          = connection;
+
+                       this.fields     = this.command.GetFieldsDescriptor();
+               }
+
+               #endregion
+
+               #region Finalizer
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/destructor[@name="Finalize"]/*'/>
+               ~FbDataReader()
+               {
+                       this.Dispose(false);
+               }
+
+               #endregion
+
+               #region IDisposable     Methods
+
+               void IDisposable.Dispose() 
+               {
+                       this.Dispose(true);
+                       System.GC.SuppressFinalize(this);
+               }
+
+               private void Dispose(bool disposing)
+               {
+                       if (!this.disposed)
+                       {
+                               try
+                               {
+                                       if (disposing)
+                                       {
+                                               // release any managed resources
+                                               this.Close();
+                                       }
+
+                                       // release any unmanaged resources
+                               }
+                               finally
+                               {
+                               }
+                                                       
+                               this.disposed = true;
+                       }
+               }
+
+               #endregion
+
+               #region IDataReader     Properties & Methods
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/property[@name="Depth"]/*'/>
+               public int Depth 
+               {
+                       get     
+                       { 
+                               this.CheckState();
+
+                               return 0; 
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/property[@name="IsClosed"]/*'/>
+               public bool     IsClosed
+               {
+                       get     { return this.isClosed; }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/property[@name="RecordsAffected"]/*'/>
+               public int RecordsAffected 
+               {
+                       get     { return this.IsClosed ? this.recordsAffected : -1;     }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/property[@name="HasRows"]/*'/>
+               public bool     HasRows
+               {
+                       get     { return true; }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="Close"]/*'/>
+               public void     Close()
+               {
+                       bool closeConnection = false;
+
+                       if (this.isClosed)
+                       {
+                               return;
+                       }
+
+                       this.isClosed   = true;
+                       this.position   = STARTPOS;
+
+                       this.UpdateRecordsAffected();
+
+                       if (this.connection     != null)
+                       {
+                               if ((this.behavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection)
+                               {
+                                       closeConnection = true;
+                               }
+                       }
+
+                       if (this.command !=     null && !this.command.IsDisposed)
+                       {
+                               if (this.command.CommandType == CommandType.StoredProcedure)
+                               {
+                                       // Set values of output parameters
+                                       this.command.SetOutputParameters();
+                               }
+
+                               if (this.command.HasImplicitTransaction)
+                               {
+                                       // Commit implicit transaction if needed
+                                       this.command.CommitImplicitTransaction();
+                               }
+
+                               // Set null     the     active reader of the command
+                               this.command.ActiveReader =     null;
+                       }
+
+                       if (closeConnection)
+                       {
+                               this.connection.Close();
+                       }
+
+                       this.command            = null;
+                       this.connection         = null;
+                       this.row                        = null;
+                       this.schemaTable        = null;
+                       this.fields                     = null;
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="NextResult"]/*'/>
+               public bool     NextResult()
+               {
+                       return false;
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="Read"]/*'/>
+               public bool     Read()
+               {
+                       this.CheckState();
+
+                       bool retValue = false;
+
+                       if ((this.behavior & CommandBehavior.SingleRow) == CommandBehavior.SingleRow &&
+                               this.position != STARTPOS)
+                       {
+                       }
+                       else
+                       {
+                               if ((this.behavior & CommandBehavior.SchemaOnly) ==     CommandBehavior.SchemaOnly)
+                               {
+                               }
+                               else
+                               {
+                                       this.row = this.command.Fetch();
+
+                                       if (this.row != null)
+                                       {
+                                               this.position++;
+                                               retValue = true;
+                                       }
+                                       else
+                                       {
+                                               this.eof = true;
+                                       }
+                               }
+                       }
+
+                       return retValue;
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetSchemaTable"]/*'/>
+               public DataTable GetSchemaTable()
+               {
+                       this.CheckState();
+
+                       if (this.schemaTable != null)
+                       {
+                               return this.schemaTable;
+                       }
+
+                       DataRow schemaRow;
+
+                       this.schemaTable = this.GetSchemaTableStructure();
+
+                       /* Prepare statement for schema fields information      */
+                       FbCommand schemaCmd     = new FbCommand(
+                               this.GetSchemaCommandText(),
+                               this.command.Connection,
+                               this.command.ActiveTransaction);
+
+                       schemaCmd.Parameters.Add("@TABLE_NAME", FbDbType.Char, 31);
+                       schemaCmd.Parameters.Add("@COLUMN_NAME", FbDbType.Char, 31);
+                       schemaCmd.Prepare();
+                       
+                       schemaTable.BeginLoadData();                    
+                       for     (int i = 0;     i <     this.fields.Count; i++)
+                       {
+                               bool isKeyColumn        = false;
+                               bool isUnique           = false;
+                               bool isReadOnly         = false;
+                               int      precision              = 0;
+
+                               if (!this.fields[i].IsExpression())
+                               {
+                                       /* Get Schema data for the field        */
+                                       schemaCmd.Parameters[0].Value = this.fields[i].Relation;
+                                       schemaCmd.Parameters[1].Value = this.fields[i].Name;
+
+                                       FbDataReader r = schemaCmd.ExecuteReader();
+
+                                       if (r.Read())
+                                       {
+                                               isReadOnly      = (this.IsReadOnly(r) || this.fields[i].IsExpression()) ? true : false;
+                                               isKeyColumn     = (r.GetInt32(2) ==     1) ? true :     false;
+                                               isUnique        = (r.GetInt32(3) ==     1) ? true :     false;
+                                               precision       = r.IsDBNull(4) ? -1 : r.GetInt32(4);
+                                       }
+
+                                       /* Close the Reader     */
+                                       r.Close();
+                               }
+
+                               /* Create new row for the Schema Table  */
+                               schemaRow =     schemaTable.NewRow();
+
+                               schemaRow["ColumnName"]         = this.GetName(i);
+                               schemaRow["ColumnOrdinal"]      = i;
+                               schemaRow["ColumnSize"]         = this.fields[i].GetSize();
+                               if (fields[i].IsDecimal())
+                               {
+                                       schemaRow["NumericPrecision"] = schemaRow["ColumnSize"];
+                                       if (precision > 0)
+                                       {
+                                               schemaRow["NumericPrecision"] = precision;
+                                       }
+                                       schemaRow["NumericScale"] =     this.fields[i].NumericScale*(-1);
+                               }
+                               schemaRow["DataType"]           = this.GetFieldType(i);
+                               schemaRow["ProviderType"]       = this.GetProviderType(i);
+                               schemaRow["IsLong"]                     = this.fields[i].IsLong();
+                               schemaRow["AllowDBNull"]        = this.fields[i].AllowDBNull();
+                               schemaRow["IsRowVersion"]       = false;
+                               schemaRow["IsAutoIncrement"]= false;
+                               schemaRow["IsReadOnly"]         = isReadOnly;
+                               schemaRow["IsKey"]                      = isKeyColumn;
+                               schemaRow["IsUnique"]           = isUnique;
+                               schemaRow["IsAliased"]          = this.fields[i].IsAliased();
+                               schemaRow["IsExpression"]       = this.fields[i].IsExpression();
+                               schemaRow["BaseSchemaName"]     = DBNull.Value;
+                               schemaRow["BaseCatalogName"]= DBNull.Value;
+                               schemaRow["BaseTableName"]      = this.fields[i].Relation;
+                               schemaRow["BaseColumnName"]     = this.fields[i].Name;
+
+                               schemaTable.Rows.Add(schemaRow);
+
+                               /* Close statement      */
+                               schemaCmd.Close();
+                       }
+                       schemaTable.EndLoadData();
+
+                       /* Dispose command      */
+                       schemaCmd.Dispose();
+
+                       return schemaTable;
+               }
+
+               #endregion
+
+               #region IDataRecord     Properties & Methods
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/indexer[@name="Item(System.Int32)"]/*'/>
+               public object this[int i]
+               {
+                       get     { return this.GetValue(i); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/indexer[@name="Item(System.String)"]/*'/>
+               public object this[String name]
+               {                       
+                       get     { return this.GetValue(this.GetOrdinal(name)); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/property[@name="FieldCount"]/*'/>
+               public int FieldCount
+               {                       
+                       get     
+                       {
+                               this.CheckState();
+
+                               return this.fields.Count;
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetOrdinal(System.String)"]/*'/>
+               public int GetOrdinal(string name)
+               {
+                       this.CheckState();
+
+                       for     (int i = 0;     i <     this.fields.Count; i++)
+                       {
+                               if (GlobalizationHelper.CultureAwareCompare(name, this.fields[i].Alias))
+                               {
+                                       return i;
+                               }
+                       }
+                                               
+                       throw new IndexOutOfRangeException("Could not find specified column     in results.");
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetName(System.Int32)"]/*'/>
+               public string GetName(int i)
+               {
+                       this.CheckState();
+                       this.CheckIndex(i);
+
+                       if (this.fields[i].Alias.Length > 0)
+                       {
+                               return this.fields[i].Alias;
+                       }
+                       else
+                       {
+                               return this.fields[i].Name;
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetDataTypeName(System.Int32)"]/*'/>
+               public String GetDataTypeName(int i)
+               {
+                       this.CheckState();
+                       this.CheckIndex(i);
+
+                       return TypeHelper.GetDataTypeName(this.fields[i].DbDataType);
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetFieldType(System.Int32)"]/*'/>
+               public Type     GetFieldType(int i)
+               {
+                       this.CheckState();
+                       this.CheckIndex(i);
+
+                       return this.fields[i].GetSystemType();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetValue(System.Int32)"]/*'/>
+               public object GetValue(int i)
+               {
+                       this.CheckState();
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       return this.row[i].Value;
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetValues(System.Array)"]/*'/>
+               public int GetValues(object[] values)
+               {
+                       this.CheckState();
+                       this.CheckPosition();
+                       
+                       for     (int i = 0;     i <     this.fields.Count; i++)
+                       {
+                               values[i] =     this.GetValue(i);
+                       }
+
+                       return values.Length;
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetBoolean(System.Int32)"]/*'/>
+               public bool     GetBoolean(int i)
+               {
+                       this.CheckPosition();
+
+                       return this.row[i].GetBoolean();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetByte(System.Int32)"]/*'/>
+               public byte     GetByte(int     i)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       return this.row[i].GetByte();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetBytes(System.Int32,System.Int64,System.Byte[],System.Int32,System.Int32)"]/*'/>
+               public long     GetBytes(
+                       int             i, 
+                       long    dataIndex, 
+                       byte[]  buffer, 
+                       int             bufferIndex, 
+                       int             length)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       int     bytesRead       = 0;
+                       int     realLength      = length;
+
+                       if (buffer == null)
+                       {
+                               if (this.IsDBNull(i))
+                               {
+                                       return 0;
+                               }
+                               else
+                               {
+                                       return this.row[i].GetBinary().Length;
+                               }
+                       }
+                       
+                       byte[] byteArray = (byte[])row[i].GetBinary();
+
+                       if (length > (byteArray.Length - dataIndex))
+                       {
+                               realLength = byteArray.Length - (int)dataIndex;
+                       }
+                                                               
+                       Array.Copy(byteArray, (int)dataIndex, buffer, bufferIndex, realLength);
+
+                       if ((byteArray.Length - dataIndex) < length)
+                       {
+                               bytesRead =     byteArray.Length - (int)dataIndex;
+                       }
+                       else
+                       {
+                               bytesRead =     length;
+                       }
+
+                       return bytesRead;
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetChar(System.Int32)"]/*'/>
+               [EditorBrowsable(EditorBrowsableState.Never)]
+               public char     GetChar(int     i)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       return this.row[i].GetChar();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetChars(System.Int32,System.Int64,System.Char[],System.Int32,System.Int32)"]/*'/>
+               public long     GetChars(
+                       int             i, 
+                       long    dataIndex, 
+                       char[]  buffer, 
+                       int             bufferIndex, 
+                       int             length)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       if (buffer == null)
+                       {
+                               if (this.IsDBNull(i))
+                               {
+                                       return 0;
+                               }
+                               else
+                               {
+                                       char[] data     = ((string)this.GetValue(i)).ToCharArray();
+
+                                       return data.Length;
+                               }
+                       }
+                       
+                       int     charsRead       = 0;
+                       int     realLength      = length;
+                       
+                       char[] charArray = ((string)this.GetValue(i)).ToCharArray();
+
+                       if (length > (charArray.Length - dataIndex))
+                       {
+                               realLength = charArray.Length - (int)dataIndex;
+                       }
+                                                               
+                       System.Array.Copy(charArray, (int)dataIndex, buffer, 
+                               bufferIndex, realLength);
+
+                       if ( (charArray.Length - dataIndex)     < length)
+                       {
+                               charsRead =     charArray.Length - (int)dataIndex;
+                       }
+                       else
+                       {
+                               charsRead =     length;
+                       }
+
+                       return charsRead;
+               }
+               
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetGuid(System.Int32)"]/*'/>
+               public Guid     GetGuid(int     i)
+               {
+                       this.CheckPosition();
+
+                       this.CheckIndex(i);
+
+                       return this.row[i].GetGuid();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetInt16(System.Int32)"]/*'/>
+               public Int16 GetInt16(int i)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       return this.row[i].GetInt16();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetInt32(System.Int32)"]/*'/>
+               public Int32 GetInt32(int i)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       return this.row[i].GetInt32();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetInt64(System.Int32)"]/*'/>            
+               public Int64 GetInt64(int i)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       return this.row[i].GetInt64();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetFloat(System.Int32)"]/*'/>
+               public float GetFloat(int i)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       return this.row[i].GetFloat();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetDouble(System.Int32)"]/*'/>
+               public double GetDouble(int     i)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       return this.row[i].GetDouble();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetString(System.Int32)"]/*'/>
+               public String GetString(int     i)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       return this.row[i].GetString();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetDecimal(System.Int32)"]/*'/>
+               public Decimal GetDecimal(int i)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+
+                       return this.row[i].GetDecimal();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetDateTime(System.Int32)"]/*'/>
+               public DateTime GetDateTime(int i)
+               {
+                       this.CheckPosition();
+
+                       this.CheckIndex(i);
+
+                       return this.row[i].GetDateTime();
+               }
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="GetData(System.Int32)"]/*'/>
+               [EditorBrowsable(EditorBrowsableState.Never)]
+               public IDataReader GetData(int i)
+               {
+                       throw new NotSupportedException("GetData not supported.");
+               }               
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="IsDBNull(System.Int32)"]/*'/>
+               public bool     IsDBNull(int i)
+               {
+                       this.CheckPosition();
+                       this.CheckIndex(i);
+                       
+                       return this.row[i].IsDBNull();
+               }
+
+               #endregion
+
+               #region IEnumerable     Methods
+
+               ///     <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="IEnumerable.GetEnumerator"]/*'/>
+               IEnumerator     IEnumerable.GetEnumerator()
+               {
+                       return new DbEnumerator(this);
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void CheckPosition()
+               {
+                       if (this.eof || this.position == STARTPOS)
+                       {
+                               throw new InvalidOperationException("There are no data to read.");
+                       }
+               }
+
+               private void CheckState()
+               {
+                       if (this.isClosed)
+                       {
+                               throw new InvalidOperationException("Invalid attempt of read when the reader is closed.");
+                       }
+               }
+
+               private void CheckIndex(int     i)
+               {
+                       if (i < 0 || i >= this.FieldCount)
+                       {
+                               throw new IndexOutOfRangeException("Could not find specified column     in results.");
+                       }
+               }
+
+               private FbDbType GetProviderType(int i)
+               {
+                       return (FbDbType)this.fields[i].DbDataType;
+               }
+
+               private bool IsReadOnly(FbDataReader r)
+               {
+                       /* [0] = COMPUTED_BLR
+                        * [1] = COMPUTED_SOURCE
+                        */
+                       if (!r.IsDBNull(0) || !r.IsDBNull(1))
+                       {
+                               return true;
+                       }
+
+                       return false;
+               }
+
+               private DataTable GetSchemaTableStructure()
+               {
+                       DataTable schema = new DataTable("Schema");                     
+
+                       // Schema table structure
+                       schema.Columns.Add("ColumnName"         , System.Type.GetType("System.String"));
+                       schema.Columns.Add("ColumnOrdinal"      , System.Type.GetType("System.Int32"));
+                       schema.Columns.Add("ColumnSize"         , System.Type.GetType("System.Int32"));
+                       schema.Columns.Add("NumericPrecision", System.Type.GetType("System.Int32"));
+                       schema.Columns.Add("NumericScale"       , System.Type.GetType("System.Int32"));
+                       schema.Columns.Add("DataType"           , System.Type.GetType("System.Type"));
+                       schema.Columns.Add("ProviderType"       , System.Type.GetType("System.Int32"));
+                       schema.Columns.Add("IsLong"                     , System.Type.GetType("System.Boolean"));
+                       schema.Columns.Add("AllowDBNull"        , System.Type.GetType("System.Boolean"));
+                       schema.Columns.Add("IsReadOnly"         , System.Type.GetType("System.Boolean"));
+                       schema.Columns.Add("IsRowVersion"       , System.Type.GetType("System.Boolean"));
+                       schema.Columns.Add("IsUnique"           , System.Type.GetType("System.Boolean"));
+                       schema.Columns.Add("IsKey"                      , System.Type.GetType("System.Boolean"));
+                       schema.Columns.Add("IsAutoIncrement", System.Type.GetType("System.Boolean"));
+                       schema.Columns.Add("IsAliased"          , System.Type.GetType("System.Boolean"));
+                       schema.Columns.Add("IsExpression"       , System.Type.GetType("System.Boolean"));
+                       schema.Columns.Add("BaseSchemaName"     , System.Type.GetType("System.String"));
+                       schema.Columns.Add("BaseCatalogName", System.Type.GetType("System.String"));
+                       schema.Columns.Add("BaseTableName"      , System.Type.GetType("System.String"));
+                       schema.Columns.Add("BaseColumnName"     , System.Type.GetType("System.String"));
+                       
+                       return schema;
+               }
+
+               private string GetSchemaCommandText()
+               {
+                       System.Text.StringBuilder sql = new     System.Text.StringBuilder();
+                       sql.Append(
+                               "SELECT \n"     +
+                                       "fld.rdb$computed_blr      as computed_blr,\n"  +
+                                       "fld.rdb$computed_source   as computed_source,\n"       +
+                                       "(select count(*)\n"                                                    +
+                                       "from rdb$relation_constraints rel,     rdb$indices     idx, rdb$index_segments seg\n"  +
+                                       "where rel.rdb$constraint_type = 'PRIMARY KEY'\n"       +
+                                       "and rel.rdb$index_name = idx.rdb$index_name\n" +
+                                       "and idx.rdb$index_name = seg.rdb$index_name\n" +
+                                       "and rel.rdb$relation_name = rfr.rdb$relation_name\n"   +
+                                       "and seg.rdb$field_name = rfr.rdb$field_name) as primary_key,\n"        +
+                                       "(select count(*)\n"    +
+                                       "from rdb$relation_constraints rel,     rdb$indices     idx, rdb$index_segments seg\n"  +
+                                       "where rel.rdb$constraint_type = 'UNIQUE'\n"    +
+                                       "and rel.rdb$index_name = idx.rdb$index_name\n" +
+                                       "and idx.rdb$index_name = seg.rdb$index_name\n" +
+                                       "and rel.rdb$relation_name = rfr.rdb$relation_name\n"   +
+                                       "and seg.rdb$field_name = rfr.rdb$field_name) as unique_key,\n" +
+                                       "fld.rdb$field_precision as     numeric_precision\n" +
+                               "from rdb$relation_fields rfr, rdb$fields fld\n"        +
+                                       "where rfr.rdb$field_source     = fld.rdb$field_name");
+                               
+                       sql.Append("\n and rfr.rdb$relation_name = ?"); 
+                       sql.Append("\n and rfr.rdb$field_name = ?");
+                       sql.Append("\n order by rfr.rdb$relation_name, rfr.rdb$field_position");
+
+                       return sql.ToString();                  
+               }
+
+               private void UpdateRecordsAffected()
+               {
+                       if (this.command !=     null && !this.command.IsDisposed)
+                       {
+                               if (this.command.RecordsAffected !=     -1)
+                               {
+                                       this.recordsAffected = this.recordsAffected     == -1 ? 0 :     this.recordsAffected;
+                                       this.recordsAffected += this.command.RecordsAffected;
+                               }
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDatabaseInfo.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDatabaseInfo.cs
new file mode 100644 (file)
index 0000000..3df494a
--- /dev/null
@@ -0,0 +1,331 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Text;
+using System.Data;
+using System.Collections;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/overview/*'/>
+       public sealed class     FbDatabaseInfo
+       {
+               #region Fields
+
+               private FbConnection connection;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="Connection"]/*'/>
+               public FbConnection     Connection
+               {
+                       get     { return this.connection; }
+                       set     { this.connection =     value;}
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="IscVersion"]/*'/>
+               public string IscVersion
+               {
+                       get     { return this.GetString(IscCodes.isc_info_isc_version); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="ServerVersion"]/*'/>
+               public string ServerVersion
+               {
+                       get     { return this.GetString(IscCodes.isc_info_firebird_version); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="ServerClass"]/*'/>
+               public string ServerClass
+               {
+                       get     { return this.GetString(IscCodes.isc_info_db_class); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="PageSize"]/*'/>
+               public int PageSize
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_page_size); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="AllocationPages"]/*'/>
+               public int AllocationPages
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_allocation); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="BaseLevel"]/*'/>
+               public string BaseLevel
+               {
+                       get     { return this.GetString(IscCodes.isc_info_base_level); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="DbId"]/*'/>
+               public string DbId
+               {
+                       get     { return this.GetString(IscCodes.isc_info_db_id); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="Implementation"]/*'/>
+               public string Implementation
+               {
+                       get     { return this.GetString(IscCodes.isc_info_implementation); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="NoReserve"]/*'/>
+               public bool     NoReserve
+               {
+                       get     { return this.GetBoolean(IscCodes.isc_info_no_reserve); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="OdsVersion"]/*'/>
+               public int OdsVersion
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_ods_version); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="OdsMinorVersion"]/*'/>
+               public int OdsMinorVersion
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_ods_minor_version); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="MaxMemory"]/*'/>
+               public int MaxMemory
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_max_memory); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="CurrentMemory"]/*'/>
+               public int CurrentMemory
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_current_memory); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="ForcedWrites"]/*'/>
+               public bool     ForcedWrites
+               {
+                       get     { return this.GetBoolean(IscCodes.isc_info_forced_writes); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="NumBuffers"]/*'/>
+               public int NumBuffers
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_num_buffers); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="SweepInterval"]/*'/>
+               public int SweepInterval
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_sweep_interval); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="ReadOnly"]/*'/>
+               public bool     ReadOnly
+               {
+                       get     { return this.GetBoolean(IscCodes.isc_info_db_read_only); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="Fetches"]/*'/>
+               public int Fetches
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_fetches); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="Marks"]/*'/>
+               public int Marks
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_marks); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="Reads"]/*'/>
+               public int Reads
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_reads); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="Writes"]/*'/>
+               public int Writes
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_writes); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="BackoutCount"]/*'/>
+               public int BackoutCount
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_backout_count); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="DeleteCount"]/*'/>
+               public int DeleteCount
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_delete_count); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="ExpungeCount"]/*'/>
+               public int ExpungeCount
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_expunge_count); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="InsertCount"]/*'/>
+               public int InsertCount
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_insert_count); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="PurgeCount"]/*'/>
+               public int PurgeCount
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_purge_count); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="ReadIdxCount"]/*'/>
+               public int ReadIdxCount
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_read_idx_count); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="ReadSeqCount"]/*'/>
+               public int ReadSeqCount
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_read_seq_count); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="UpdateCount"]/*'/>
+               public int UpdateCount
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_update_count); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="DatabaseSizeInPages"]/*'/>
+               public int DatabaseSizeInPages
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_db_size_in_pages);     }
+               }
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="OldestTransaction"]/*'/>
+               public int OldestTransaction
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_oldest_transaction); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="OldestActiveTransaction"]/*'/>
+               public int OldestActiveTransaction
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_oldest_active); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="OldestActiveSnapshot"]/*'/>
+               public int OldestActiveSnapshot
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_oldest_snapshot); }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="NextTransaction"]/*'/>
+               public int NextTransaction
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_next_transaction);     }
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/property[@name="ActiveTransactions"]/*'/>
+               public int ActiveTransactions
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_active_transactions); }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/constructor[@name="ctor"]/*'/>
+               public FbDatabaseInfo()
+               {
+               }
+
+               ///     <include file='Doc/en_EN/FbDatabaseInfo.xml' path='doc/class[@name="FbDatabaseInfo"]/constructor[@name="ctor(FbConnection)"]/*'/>
+               public FbDatabaseInfo(FbConnection connection)
+               {
+                       this.connection = connection;
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private string GetString(byte item)
+               {
+                       this.CheckConnection();
+
+                       IDatabase db = this.Connection.InnerConnection.Database;
+                       byte[] items = new byte[]
+                               {
+                                       item,
+                                       IscCodes.isc_info_end
+                               };
+
+                       return (string)db.GetDatabaseInfo(items)[0];
+               }
+
+               private int     GetInt32(byte item)
+               {
+                       this.CheckConnection();
+
+                       IDatabase db = this.Connection.InnerConnection.Database;
+                       byte[] items = new byte[]
+                               {
+                                       item,
+                                       IscCodes.isc_info_end
+                               };
+
+                       ArrayList info = db.GetDatabaseInfo(items);
+
+                       return (info.Count > 0 ? (int)info[0] : 0);
+               }
+
+               private bool GetBoolean(byte item)
+               {
+                       this.CheckConnection();
+
+                       IDatabase db = this.Connection.InnerConnection.Database;
+                       byte[] items = new byte[]
+                               {
+                                       item,
+                                       IscCodes.isc_info_end
+                               };
+
+                       ArrayList info = db.GetDatabaseInfo(items);
+
+                       return (info.Count > 0 ? (bool)info[0] : false);
+               }
+
+               private void CheckConnection()
+               {
+                       if (this.connection     == null || 
+                               this.connection.State == ConnectionState.Closed)
+                       {
+                               throw new InvalidOperationException("Connection must valid and open");
+                       }                       
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDbSchemaType.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDbSchemaType.cs
new file mode 100644 (file)
index 0000000..e5ca668
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/overview/*'/>
+#if    (!NETCF)
+       [Serializable]
+#endif
+       [Obsolete("Use the FbConnection.GetSchema()     methods.")]
+       public enum     FbDbSchemaType
+       {
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="CharacterSets"]/*'/>
+               CharacterSets,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="CheckConstraints"]/*'/>
+               CheckConstraints,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="CheckConstraintsByTable"]/*'/>
+               CheckConstraintsByTable,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Collations"]/*'/>
+               Collations,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Columns"]/*'/>
+               Columns,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="ColumnPrivileges"]/*'/>
+               ColumnPrivileges,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="DataTypes"]/*'/>
+               DataTypes,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Domains"]/*'/>
+               Domains,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="ForeignKeys"]/*'/>
+               ForeignKeys,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Functions"]/*'/>
+               Functions,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Generators"]/*'/>
+               Generators,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Indexes"]/*'/>
+               Indexes,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="MetaDataCollections"]/*'/>
+               MetaDataCollections,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="PrimaryKeys"]/*'/>
+               PrimaryKeys,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="ProcedureParameters"]/*'/>
+               ProcedureParameters,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="ProcedurePrivileges"]/*'/>
+               ProcedurePrivileges,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Procedures"]/*'/>
+               Procedures,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Restrictions"]/*'/>
+               Restrictions,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Roles"]/*'/>
+               Roles,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="TableConstraints"]/*'/>
+               TableConstraints,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="TablePrivileges"]/*'/>
+               TablePrivileges,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Tables"]/*'/>
+               Tables,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Triggers"]/*'/>
+               Triggers,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="UniqueKeys"]/*'/>
+               UniqueKeys,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="ViewColumnUsage"]/*'/>
+               ViewColumnUsage,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="ViewPrivileges"]/*'/>
+               ViewPrivileges,
+               ///     <include file='Doc/en_EN/FbDbSchemaType.xml' path='doc/enum[@name="FbDbSchemaType"]/field[@name="Views"]/*'/>
+               Views
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDbType.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDbType.cs
new file mode 100644 (file)
index 0000000..513b617
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/overview/*'/>
+#if    (!NETCF)
+       [Serializable]
+#endif
+       public enum     FbDbType
+       {
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Array"]/*'/>
+               Array                   ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="BigInt"]/*'/>
+               BigInt                  ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Binary"]/*'/>
+               Binary                  ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Char"]/*'/>
+               Char                    ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Date"]/*'/>
+               Date                    ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Decimal"]/*'/>
+               Decimal                 ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Double"]/*'/>
+               Double                  ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Float"]/*'/>
+               Float                   ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Guid"]/*'/>
+               Guid,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Integer"]/*'/>
+               Integer                 ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Numeric"]/*'/>
+               Numeric                 ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="SmallInt"]/*'/>
+               SmallInt                ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Text"]/*'/>
+               Text                    ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="Time"]/*'/>
+               Time                    ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="TimeStamp"]/*'/>
+               TimeStamp               ,
+               ///     <include file='Doc/en_EN/FbDbType.xml' path='doc/enum[@name="FbDbType"]/field[@name="VarChar"]/*'/>
+               VarChar
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbError.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbError.cs
new file mode 100644 (file)
index 0000000..1c46bd4
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbError.xml' path='doc/class[@name="FbError"]/overview/*'/>
+#if    (!NETCF)
+       [Serializable]
+#endif
+       public sealed class     FbError
+       {
+               #region Fields
+
+               private byte    classError;
+               private int             lineNumber;
+               private string  message;
+               private int             number;
+               
+               #endregion
+
+               #region Properties
+               
+               ///     <include file='Doc/en_EN/FbError.xml' path='doc/class[@name="FbError"]/property[@name="Class"]/*'/>
+               public byte     Class
+               {
+                       get     { return this.classError; }
+               }
+
+               ///     <include file='Doc/en_EN/FbError.xml' path='doc/class[@name="FbError"]/property[@name="LineNumber"]/*'/>                
+               public int LineNumber
+               {
+                       get     { return this.lineNumber; }
+               }
+
+               ///     <include file='Doc/en_EN/FbError.xml' path='doc/class[@name="FbError"]/property[@name="Message"]/*'/>
+               public string Message
+               {
+                       get     { return this.message; }
+               }
+
+               ///     <include file='Doc/en_EN/FbError.xml' path='doc/class[@name="FbError"]/property[@name="Number"]/*'/>
+               public int Number
+               {
+                       get     { return this.number; }
+               }
+
+               #endregion
+
+               #region Constructors
+               
+               internal FbError(string message, int number) : this(0, 0, message, number)
+               {                       
+               }
+
+               internal FbError(byte classError, string message, int   number) 
+                       : this(classError, 0, message, number)
+               {                       
+               }
+
+               internal FbError(byte classError, int line,     string message, int     number)
+               {                       
+                       this.classError = classError;
+                       this.lineNumber = line;
+                       this.number             = number;
+                       this.message    = message;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbErrorCollection.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbErrorCollection.cs
new file mode 100644 (file)
index 0000000..ff0488d
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbErrorCollection.xml' path='doc/class[@name="FbErrorCollection"]/overview/*'/>
+#if    (!NETCF)
+       [Serializable, ListBindable(false)]
+#endif
+       public sealed class     FbErrorCollection :     ICollection, IEnumerable
+       {
+               #region Fields
+
+               private ArrayList errors;
+
+               #endregion
+
+               #region Indexers
+
+               ///     <include file='Doc/en_EN/FbErrorCollection.xml' path='doc/class[@name="FbErrorCollection"]/indexer[@name="Item(System.Int32)"]/*'/>
+               public FbError this[int index] 
+               {
+                       get     { return (FbError)this.errors[index]; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               internal FbErrorCollection()
+               {
+                       this.errors     = ArrayList.Synchronized(new ArrayList());
+               }
+
+               #endregion
+
+               #region ICollection     Properties
+
+               ///     <include file='Doc/en_EN/FbErrorCollection.xml' path='doc/class[@name="FbErrorCollection"]/property[@name="Count"]/*'/>
+               public int Count 
+               {
+                       get     { return this.errors.Count;     }
+               }
+               
+               bool ICollection.IsSynchronized
+               {
+                       get     { return this.errors.IsSynchronized; }
+               }
+
+               object ICollection.SyncRoot     
+               {
+                       get     { return this.errors.SyncRoot; }
+               }
+
+               #endregion
+
+               #region ICollection     Methods
+
+               ///     <include file='Doc/en_EN/FbErrorCollection.xml' path='doc/class[@name="FbErrorCollection"]/method[@name="CopyTo(System.Array,System.Int32)"]/*'/>       
+               public void     CopyTo(Array array,     int     index)
+               {
+                       this.errors.CopyTo(array, index);
+               }
+               
+               #endregion
+
+               #region IEnumerable     Methods
+
+               IEnumerator     IEnumerable.GetEnumerator()
+               {
+                       return this.errors.GetEnumerator();
+               }
+
+               #endregion
+
+               #region Internal Methods
+
+               ///     <include file='Doc/en_EN/FbErrorCollection.xml' path='doc/class[@name="FbErrorCollection"]/method[@name="IndexOf(System.String)"]/*'/>          
+               internal int IndexOf(string     errorMessage)
+               {
+                       int     index = 0;
+                       foreach (FbError item in this)
+                       {
+                               if (GlobalizationHelper.CultureAwareCompare(item.Message, errorMessage))
+                               {
+                                       return index;
+                               }
+                               index++;
+                       }
+
+                       return -1;
+               }
+
+               ///     <include file='Doc/en_EN/FbErrorCollection.xml' path='doc/class[@name="FbErrorCollection"]/method[@name="Add(FbError)"]/*'/>
+               internal FbError Add(FbError error)
+               {
+                       this.errors.Add(error);
+
+                       return error;
+               }
+
+               ///     <include file='Doc/en_EN/FbErrorCollection.xml' path='doc/class[@name="FbErrorCollection"]/method[@name="Add(System.String,System.Int32)"]/*'/>
+               internal FbError Add(string     errorMessage, int number)
+               {
+                       FbError error = new     FbError(errorMessage, number);                  
+
+                       return this.Add(error);
+               }
+               
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbException.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbException.cs
new file mode 100644 (file)
index 0000000..4144f88
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.ComponentModel;
+using System.Runtime.Serialization;
+using System.Security.Permissions;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbException.xml' path='doc/class[@name="FbException"]/overview/*'/>
+#if    (!NETCF) 
+       [Serializable] 
+#endif
+       public sealed class     FbException     : SystemException
+       {
+               #region Fields
+               
+               private FbErrorCollection       errors = new FbErrorCollection();
+               private int                                     errorCode;
+               
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbException.xml' path='doc/class[@name="FbException"]/property[@name="Errors"]/*'/>
+#if    (!NETCF)
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+#endif
+               public FbErrorCollection Errors
+               {
+                       get     { return this.errors; }
+               }
+
+               ///     <include file='Doc/en_EN/FbException.xml' path='doc/class[@name="FbException"]/property[@name="ErrorCode"]/*'/>
+               public int ErrorCode
+               {
+                       get     { return this.errorCode; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               internal FbException() : base()
+               {
+               }
+
+               internal FbException(string     message) : base(message)
+               {
+               }
+
+               internal FbException(string     message, IscException ex) :     base(message)
+               {
+                       this.errorCode  = ex.ErrorCode;
+#if    (!NETCF)
+                       this.Source             = ex.Source;
+#endif
+
+                       this.GetIscExceptionErrors(ex);
+               }
+
+#if    (!NETCF)
+
+               internal FbException(SerializationInfo info, StreamingContext context)
+                       : base(info, context)
+               {
+                       this.errors             = (FbErrorCollection)info.GetValue("errors", typeof(FbErrorCollection));
+                       this.errorCode  = info.GetInt32("errorCode");
+               }
+
+#endif
+
+               #endregion
+
+               #region Methods
+
+#if    (!NETCF)
+
+               ///     <include file='Doc/en_EN/FbException.xml' path='doc/class[@name="FbException"]/method[@name="GetObjectData(SerializationInfo, StreamingContext)"]/*'/>
+               [SecurityPermissionAttribute(SecurityAction.Demand,     SerializationFormatter=true)]
+               public override void GetObjectData(SerializationInfo info, StreamingContext     context)
+               {
+                       info.AddValue("errors", this.errors);
+                       info.AddValue("errorCode", this.errorCode);
+
+                       base.GetObjectData(info, context);
+               }
+
+#endif
+
+               #endregion
+
+               #region Internal Methods
+
+               internal void GetIscExceptionErrors(IscException ex)
+               {
+                       foreach (IscError error in ex.Errors)
+                       {
+                               this.errors.Add(error.Message, error.ErrorCode);
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbInfoMessageEventArgs.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbInfoMessageEventArgs.cs
new file mode 100644 (file)
index 0000000..e8a2f0f
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       #region Delegates
+
+       ///     <include file='Doc/en_EN/FbInfoMessageEventArgs.xml' path='doc/delegate[@name="FbInfoMessageEventHandler"]/overview/*'/>
+       public delegate void FbInfoMessageEventHandler(object sender, FbInfoMessageEventArgs e);
+
+       #endregion
+
+       ///     <include file='Doc/en_EN/FbInfoMessageEventArgs.xml' path='doc/class[@name="FbInfoMessageEventArgs"]/overview/*'/>
+       public sealed class     FbInfoMessageEventArgs : EventArgs
+       {
+               #region Fields
+
+               private FbErrorCollection errors = new FbErrorCollection();
+               private string                    message =     String.Empty;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbInfoMessageEventArgs.xml' path='doc/class[@name="FbInfoMessageEventArgs"]/property[@name="Errors"]/*'/>
+               public FbErrorCollection Errors
+               {
+                       get     { return this.errors; }
+               }
+
+               ///     <include file='Doc/en_EN/FbInfoMessageEventArgs.xml' path='doc/class[@name="FbInfoMessageEventArgs"]/property[@name="Message"]/*'/>
+               public string Message
+               {
+                       get     { return this.message; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               internal FbInfoMessageEventArgs(IscException ex)
+               {
+                       this.message = ex.Message;
+                       
+                       foreach (IscError error in ex.Errors)
+                       {
+                               this.errors.Add(error.Message, error.ErrorCode);
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbParameter.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbParameter.cs
new file mode 100644 (file)
index 0000000..be6a03e
--- /dev/null
@@ -0,0 +1,409 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.ComponentModel;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/overview/*'/>
+#if    (NET)
+       [ParenthesizePropertyName(true)]
+       [TypeConverter(typeof(Design.FbParameterConverter))]
+#endif
+       public sealed class     FbParameter     : MarshalByRefObject, IDbDataParameter, IDataParameter, ICloneable
+       {
+               #region Fields
+               
+               private FbParameterCollection   parent;
+               private FbDbType                                fbType;
+               private ParameterDirection              direction;
+               private DataRowVersion                  sourceVersion;
+               private bool                                    isNullable;
+               private string                                  parameterName;
+               private string                                  sourceColumn;
+               private object                                  value;
+               private byte                                    precision;
+               private byte                                    scale;
+               private int                                             size;
+               private FbCharset                               charset;
+               private bool                                    inferType;              
+
+               #endregion
+
+               #region Properties
+
+               string IDataParameter.ParameterName
+               {
+                       get     { return this.ParameterName; }
+                       set     { this.ParameterName = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="ParameterName"]/*'/>
+#if    (!NETCF)
+               [DefaultValue("")]
+#endif
+               public string ParameterName
+               {
+                       get     { return this.parameterName; }
+                       set     { this.parameterName = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="Precision"]/*'/>
+#if    (!NETCF)
+               [Category("Data"), DefaultValue((byte)0)]
+#endif
+               public byte     Precision
+               {
+                       get     { return this.precision; }
+                       set     { this.precision = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="Scale"]/*'/>
+#if    (!NETCF)
+               [Category("Data"), DefaultValue((byte)0)]
+#endif
+               public byte     Scale
+               {
+                       get     { return this.scale; }
+                       set     { this.scale = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="Size"]/*'/>
+#if    (!NETCF)
+               [Category("Data"), DefaultValue(0)]
+#endif
+               public int Size
+               {
+                       get     { return this.size;     }
+                       set     { this.size     = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="DbType"]/*'/>
+#if    (!NETCF)
+               [Browsable(false), Category("Data"), RefreshProperties(RefreshProperties.All),
+               DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+               public DbType DbType 
+               {
+                       get     { return TypeHelper.GetDbType((DbDataType)this.fbType); }
+                       set     { this.fbType = (FbDbType)TypeHelper.GetDbDataType(value); }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="FbDbType"]/*'/>
+#if    (!NETCF)
+               [RefreshProperties(RefreshProperties.All), Category("Data"), DefaultValue(FbDbType.VarChar)]
+#endif
+               public FbDbType FbDbType
+               {
+                       get     { return this.fbType; }
+                       set     
+                       { 
+                               this.fbType             = value; 
+                               this.inferType  = false;
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="Direction"]/*'/>
+#if    (!NETCF)
+               [Category("Data"), DefaultValue(ParameterDirection.Input)]
+#endif
+               public ParameterDirection Direction     
+               {
+                       get     { return this.direction; }
+                       set     { this.direction = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="IsNullable"]/*'/>
+#if    (!NETCF)
+               [Browsable(false), DesignOnly(true), DefaultValue(false), EditorBrowsable(EditorBrowsableState.Advanced)]
+#endif
+               public Boolean IsNullable
+               {
+                       get     { return this.isNullable; }
+                       set     { this.isNullable =     value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="SourceColumn"]/*'/>
+#if    (!NETCF)
+               [Category("Data"), DefaultValue("")]
+#endif
+               public string SourceColumn
+               {
+                       get     { return this.sourceColumn;     }
+                       set     { this.sourceColumn     = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="SourceVersion"]/*'/>
+#if    (!NETCF)
+               [Category("Data"), DefaultValue(DataRowVersion.Current)]
+#endif
+               public DataRowVersion SourceVersion     
+               {
+                       get     { return this.sourceVersion; }
+                       set     { this.sourceVersion = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="Value"]/*'/>
+#if    (!NETCF)
+               [Category("Data"), TypeConverter(typeof(StringConverter)), DefaultValue(null)]
+#endif
+               public object Value
+               {
+                       get     { return this.value; }
+                       set     
+                       { 
+                               if (value == null)
+                               {
+                                       value = System.DBNull.Value;
+                               }
+
+                               if (this.FbDbType == FbDbType.Guid &&
+                                       !(value is Guid) &&     !(value is byte[]))
+                               {
+                                       throw new InvalidOperationException("Incorrect Guid     value.");
+                               }
+                               
+                               this.value = value;
+                               
+                               if (this.inferType)
+                               {
+                                       this.SetFbDbType(value);
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/property[@name="Charset"]/*'/>
+#if    (!NETCF)
+               [Category("Data"), DefaultValue(FbCharset.Default)]
+#endif
+               public FbCharset Charset
+               {
+                       get     { return this.charset; }
+                       set     { this.charset = value; }
+               }
+
+               #endregion
+
+               #region Internal Properties
+
+               internal FbParameterCollection Parent
+               {
+                       get     { return this.parent; }
+                       set     { this.parent = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/constrctor[@name="ctor"]/*'/>
+               public FbParameter()
+               {
+                       this.fbType                     = FbDbType.VarChar;
+                       this.direction          = ParameterDirection.Input;
+                       this.sourceVersion      = DataRowVersion.Current;
+                       this.sourceColumn       = String.Empty;
+                       this.parameterName      = String.Empty;
+                       this.inferType          = true;
+                       this.charset            = FbCharset.Default;
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/constrctor[@name="ctor(System.String,System.Object)"]/*'/>
+               public FbParameter(string parameterName, object value)  : this()
+               {
+                       this.parameterName      = parameterName;
+                       this.Value                      = value;
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/constrctor[@name="ctor(System.String,FbDbType)"]/*'/>
+               public FbParameter(string parameterName, FbDbType fbType) :     this()
+               {
+                       this.inferType          = false;
+                       this.parameterName      = parameterName;
+                       this.fbType                     = fbType;
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/constrctor[@name="ctor(System.String,FbDbType,System.Int32)"]/*'/>
+               public FbParameter(string parameterName, FbDbType fbType, int size)     : this()
+               {
+                       this.inferType          = false;
+                       this.parameterName      = parameterName;
+                       this.fbType                     = fbType;
+                       this.size                       = size;                 
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/constrctor[@name="ctor(System.String,FbDbType,System.Int32,System.String)"]/*'/>
+               public FbParameter(
+                       string          parameterName, 
+                       FbDbType        fbType, 
+                       int                     size, 
+                       string          sourceColumn) : this()
+               {
+                       this.inferType  = false;
+                       this.parameterName      = parameterName;
+                       this.fbType                     = fbType;
+                       this.size                       = size;
+                       this.sourceColumn       = sourceColumn;
+               }
+
+               ///     <include file='Doc/en_EN/FbParameter.xml' path='doc/class[@name="FbParameter"]/constrctor[@name="ctor(System.String,FbDbType,System.Int32,System.Data.ParameterDirection,System.Boolean,System.Byte,System.Byte,System.String,System.Data.DataRowVersion,System.Object)"]/*'/>
+#if    (!NETCF)
+               [EditorBrowsable(EditorBrowsableState.Advanced)]
+#endif
+               public FbParameter(
+                       string                          parameterName,
+                       FbDbType                        dbType,
+                       int                                     size,
+                       ParameterDirection      direction,
+                       bool                            isNullable,
+                       byte                            precision,
+                       byte                            scale,
+                       string                          sourceColumn,
+                       DataRowVersion          sourceVersion,
+                       object                          value)
+               {
+                       this.inferType  = false;
+                       this.parameterName      = parameterName;
+                       this.fbType                     = dbType;
+                       this.size                       = size;
+                       this.direction          = direction;
+                       this.isNullable         = isNullable;
+                       this.precision          = precision;
+                       this.scale                      = scale;
+                       this.sourceColumn       = sourceColumn;
+                       this.sourceVersion      = sourceVersion;
+                       this.value                      = value;
+               }
+
+               #endregion
+
+               #region ICloneable Methods
+
+               object ICloneable.Clone()
+               {
+                       FbParameter     p =     new     FbParameter(
+                               this.parameterName,
+                               this.fbType,
+                               this.size,
+                               this.direction,
+                               this.isNullable,
+                               this.precision,
+                               this.scale,
+                               this.sourceColumn,
+                               this.sourceVersion,
+                               this.value);
+
+                       // Set extra properties
+                       p.Charset =     this.charset;
+
+                       return p;
+               }
+
+               #endregion
+
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbCommand.xml' path='doc/class[@name="FbParameter"]/method[@name="ToString"]/*'/>
+               public override string ToString()
+               {
+                       return this.parameterName;
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void SetFbDbType(object value)
+               {
+                       if (value == null)
+                       {
+                               value = System.DBNull.Value;
+                       }
+
+                       TypeCode code = Type.GetTypeCode(value.GetType());
+
+                       switch (code)
+                       {
+                               case TypeCode.Object:
+                                       this.fbType     = FbDbType.Binary;
+                                       break;
+
+                               case TypeCode.Char:
+                                       this.fbType     = FbDbType.Char;
+                                       break;
+
+                               case TypeCode.DBNull:
+                               case TypeCode.String:
+                                       this.fbType     = FbDbType.VarChar;
+                                       break;
+
+                               case TypeCode.Boolean:
+                               case TypeCode.Byte:
+                               case TypeCode.SByte:
+                               case TypeCode.Int16:
+                               case TypeCode.UInt16:
+                                       this.fbType     = FbDbType.SmallInt;
+                                       break;
+
+                               case TypeCode.Int32:
+                               case TypeCode.UInt32:
+                                       this.fbType     = FbDbType.Integer;
+                                       break;
+
+                               case TypeCode.Int64:
+                               case TypeCode.UInt64:
+                                       this.fbType     = FbDbType.BigInt;
+                                       break;
+
+                               case TypeCode.Single:
+                                       this.fbType     = FbDbType.Float;
+                                       break;
+
+                               case TypeCode.Double:
+                                       this.fbType     = FbDbType.Double;
+                                       break;
+
+                               case TypeCode.Decimal:
+                                       this.fbType     = FbDbType.Decimal;
+                                       break;
+
+                               case TypeCode.DateTime:
+                                       this.fbType     = FbDbType.TimeStamp;
+                                       break;
+
+                               case TypeCode.Empty:
+                               default:
+                                       if (value is Guid)
+                                       {
+                                               this.fbType     = FbDbType.Guid;
+                                       }
+                                       else
+                                       {
+                                               throw new SystemException("Value is     of unknown data type");
+                                       }
+                                       break;
+                       }
+               }
+                       
+               #endregion              
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbParameterCollection.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbParameterCollection.cs
new file mode 100644 (file)
index 0000000..487e7a7
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.ComponentModel;
+using System.Collections;
+using System.Globalization;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/overview/*'/>
+#if    (NET)
+       [ListBindable(false)]
+       [Editor(typeof(Design.FbParameterCollectionEditor),     typeof(System.Drawing.Design.UITypeEditor))]
+#endif
+       public sealed class     FbParameterCollection : MarshalByRefObject,     IDataParameterCollection, IList, ICollection, IEnumerable
+       {       
+               #region Fields
+
+               private ArrayList parameters;
+
+               #endregion
+
+               #region Indexers
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/indexer[@name="Item(System.String)"]/*'/>
+#if    (!NETCF)
+               [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+               public FbParameter this[string parameterName]
+               {
+                       get     { return (FbParameter)this[this.IndexOf(parameterName)]; }
+                       set     { this[this.IndexOf(parameterName)]     = (FbParameter)value; }
+               }
+
+               object IDataParameterCollection.this[string     parameterName] 
+               {
+                       get     { return this[parameterName]; }
+                       set     { this[parameterName] = (FbParameter)value;     }
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/indexer[@name="Item(System.Int32)"]/*'/>
+#if    (!NETCF)
+               [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+               public FbParameter this[int     index]
+               {
+                       get     { return (FbParameter)this.parameters[index]; }
+                       set     { this.parameters[index] = (FbParameter)value; }
+               }
+
+               object IList.this[int index]
+               {
+                       get     { return (FbParameter)this[index]; }
+                       set     { this[index] = (FbParameter)value;     }
+               }
+               
+               #endregion
+
+               #region Constructors
+
+               internal FbParameterCollection()
+               {
+                       this.parameters = ArrayList.Synchronized(new ArrayList());
+               }
+
+               #endregion
+
+               #region IList Properties
+
+               bool IList.IsFixedSize
+               {
+                       get     { return this.parameters.IsFixedSize; }
+               }
+
+               bool IList.IsReadOnly
+               {
+                       get     { return this.parameters.IsReadOnly; }
+               }
+
+               #endregion
+
+               #region ICollection     Properties
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/property[@name="Count"]/*'/>
+#if    (!NETCF)
+               [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#endif
+               public int Count 
+               {
+                       get     { return this.parameters.Count; }
+               }
+               
+               bool ICollection.IsSynchronized 
+               {
+                       get     { return this.parameters.IsSynchronized; }
+               }
+
+               object ICollection.SyncRoot     
+               {
+                       get     { return this.parameters.SyncRoot; }
+               }
+
+               #endregion
+
+               #region ICollection     Methods
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="CopyTo(System.Array,System.Int32)"]/*'/>
+               public void     CopyTo(Array array,     int     index)
+               {
+                       this.parameters.CopyTo(array, index);
+               }
+
+               #endregion
+
+               #region IList Methods
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="Clear"]/*'/>
+               public void     Clear()
+               {
+                       this.parameters.Clear();
+               }
+
+               #endregion
+
+               #region IEnumerable     Methods
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="GetEnumerator"]/*'/>
+               public IEnumerator GetEnumerator()
+               {
+                       return this.parameters.GetEnumerator();
+               }
+
+               #endregion
+
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="Contains(System.Object)"]/*'/>
+               public bool     Contains(object value)
+               {
+                       return this.parameters.Contains(value);
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="Contains(System.String)"]/*'/>
+               public bool     Contains(string parameterName)
+               {
+                       return (-1 != this.IndexOf(parameterName));
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="IndexOf(System.Object)"]/*'/>
+               public int IndexOf(object value)
+               {
+                       return this.parameters.IndexOf(value);
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="IndexOf(System.String)"]/*'/>
+               public int IndexOf(string parameterName)
+               {
+                       int     index = 0;
+                       foreach (FbParameter item in this.parameters)
+                       {
+                               if (GlobalizationHelper.CultureAwareCompare(item.ParameterName, parameterName))
+                               {
+                                       return index;
+                               }
+                               index++;
+                       }
+                       return -1;
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="Insert(System.Int32,System.Object)"]/*'/>
+               public void     Insert(int index, object value)                 
+               {
+                       this.parameters.Insert(index, value);
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="Remove(System.Object)"]/*'/>
+               public void     Remove(object value)
+               {
+                       if (!(value     is FbParameter))
+                       {
+                               throw new InvalidCastException("The     parameter passed was not a FbParameter.");
+                       }
+                       if (!this.Contains(value))
+                       {
+                               throw new SystemException("The parameter does not exist in the collection.");
+                       }
+
+                       this.parameters.Remove(value);
+
+                       ((FbParameter)value).Parent     = null;
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="RemoveAt(System.Int32)"]/*'/>
+               public void     RemoveAt(int index)
+               {
+                       if (index <     0 || index > this.Count)
+                       {
+                               throw new IndexOutOfRangeException("The specified index does not exist.");
+                       }
+
+                       FbParameter     parameter =     this[index];
+                       this.parameters.RemoveAt(index);
+                       parameter.Parent = null;
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="RemoveAt(System.String)"]/*'/>
+               public void     RemoveAt(string parameterName)
+               {
+                       this.RemoveAt(this.IndexOf(parameterName));
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="Add(System.String,System.Object)"]/*'/>
+               public FbParameter Add(string parameterName, object     value)
+               {
+                       FbParameter     param = new     FbParameter(parameterName, value);
+
+                       return this.Add(param);
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="Add(System.String,FbDbType)"]/*'/>
+               public FbParameter Add(string parameterName, FbDbType type)
+               {
+                       FbParameter     param = new     FbParameter(parameterName, type);                       
+                       
+                       return this.Add(param);
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="Add(System.String,FbDbType,System.Int32)"]/*'/>
+               public FbParameter Add(string parameterName, FbDbType fbType, int size)
+               {
+                       FbParameter     param = new     FbParameter(parameterName, fbType, size);
+
+                       return this.Add(param);
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="Add(System.String,FbDbType,System.Int32,System.String)"]/*'/>
+               public FbParameter Add(
+                       string          parameterName, 
+                       FbDbType        fbType, 
+                       int                     size, 
+                       string          sourceColumn)
+               {
+                       FbParameter     param = new     FbParameter(
+                               parameterName, 
+                               fbType, 
+                               size, 
+                               sourceColumn);
+
+                       return this.Add(param);
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="Add(System.Object)"]/*'/>
+               public int Add(object value)
+               {
+                       if (!(value     is FbParameter))
+                       {
+                               throw new InvalidCastException("The     parameter passed was not a FbParameter.");
+                       }
+                       
+                       return this.IndexOf(this.Add(value as FbParameter));
+               }
+
+               ///     <include file='Doc/en_EN/FbParameterCollection.xml'     path='doc/class[@name="FbParameterCollection"]/method[@name="Add(FbParameter)"]/*'/>
+               public FbParameter Add(FbParameter value)
+               {
+                       lock (this.parameters.SyncRoot)
+                       {
+                               if (value == null)
+                               {
+                                       throw new ArgumentException("The value parameter is     null.");
+                               }
+                               if (value.Parent !=     null)
+                               {
+                                       throw new ArgumentException("The FbParameter specified in the value     parameter is already added to this or another FbParameterCollection.");
+                               }
+                               if (value.ParameterName == null || 
+                                       value.ParameterName.Length == 0)
+                               {
+                                       value.ParameterName     = this.GenerateParameterName();
+                               }
+                               else
+                               {
+                                       if (this.IndexOf(value) != -1)
+                                       {
+                                               throw new ArgumentException("FbParameterCollection already contains     FbParameter     with ParameterName '" + value.ParameterName     + "'.");
+                                       }
+                               }
+
+                               this.parameters.Add(value);
+                               
+                               return value;
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private string GenerateParameterName()
+               {
+                       int             index   = this.Count + 1;
+                       string  name    = String.Empty;
+
+                       while (index > 0)
+                       {
+                               name = "Parameter" + index.ToString(CultureInfo.InvariantCulture);
+
+                               if (this.IndexOf(name) == -1)
+                               {
+                                       index = -1;
+                               }
+                               else
+                               {
+                                       index++;
+                               }
+                       }
+
+                       return name;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRemoteEvent.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRemoteEvent.cs
new file mode 100644 (file)
index 0000000..db0b1e9
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbRemoteEvent.xml'     path='doc/class[@name="FbRemoteEvent"]/overview/*'/>
+       public sealed class     FbRemoteEvent
+       {
+               #region Events
+
+               ///     <include file='Doc/en_EN/FbRemoteEvent.xml'     path='doc/class[@name="FbRemoteEvent"]/event[@name="RemoteEventCounts"]/*'/>
+               public event FbRemoteEventEventHandler RemoteEventCounts;
+
+               #endregion
+
+               #region Fields
+
+               private FbConnection    connection;
+               private RemoteEvent             revent;
+
+               #endregion
+
+               #region Indexers
+
+               ///     <include file='Doc/en_EN/FbRemoteEvent.xml'     path='doc/class[@name="FbRemoteEvent"]/indexer[@name="Item(System.Int32)"]/*'/>
+               public string this[int index]
+               {
+                       get     { return this.revent.Events[index];     }
+               }
+               
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbRemoteEvent.xml'     path='doc/class[@name="FbRemoteEvent"]/property[@name="Connection"]/*'/>
+               public FbConnection     Connection
+               {
+                       get     { return this.connection; }
+                       set     { this.connection =     value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbRemoteEvent.xml'     path='doc/class[@name="FbRemoteEvent"]/property[@name="HasChanges"]/*'/>
+               public bool     HasChanges
+               {
+                       get     { return this.revent.HasChanges; }
+               }
+
+               #endregion
+
+               #region Constructors
+               
+               ///     <include file='Doc/en_EN/FbRemoteEvent.xml'     path='doc/class[@name="FbRemoteEvent"]/constructor[@name="ctor(FbConnection)"]/*'/>
+               public FbRemoteEvent(FbConnection connection) : this(connection, null)
+               {
+               }
+
+               ///     <include file='Doc/en_EN/FbRemoteEvent.xml'     path='doc/class[@name="FbRemoteEvent"]/constructor[@name="ctor(FbConnection, System.Array)"]/*'/>
+               public FbRemoteEvent(FbConnection connection, string[] events)
+               {
+                       this.connection = connection;
+                       this.revent             = connection.InnerConnection.Database.CreateEvent();
+                       this.revent.EventCountsCallback = new EventCountsCallback(this.OnRemoteEventCounts);
+
+                       if (events != null)
+                       {
+                               this.AddEvents(events);
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbRemoteEvent.xml'     path='doc/class[@name="FbRemoteEvent"]/method[@name="AddEvents(System.Array)"]/*'/>
+               public void     AddEvents(string[] events)
+               {
+                       if (events == null)
+                       {
+                               throw new ArgumentNullException("events cannot be null.");
+                       }
+                       if (events.Length >     15)
+                       {
+                               throw new ArgumentException("Max number of events for request interest is 15");
+                       }
+
+                       if (events.Length != this.revent.Events.Count)
+                       {
+                               this.revent.ResetCounts();
+                       }
+                       else
+                       {
+                               string[] actualEvents = new     string[this.revent.Events.Count];
+                               this.revent.Events.CopyTo(actualEvents, 0);
+
+                               for     (int i = 0;     i <     actualEvents.Length; i++)
+                               {
+                                       if (events[i] != actualEvents[i])
+                                       {
+                                               this.revent.ResetCounts();
+                                               break;
+                                       }
+                               }
+                       }
+
+                       this.revent.Events.Clear();
+                       
+                       for     (int i = 0;     i <     events.Length; i++)
+                       {
+                               this.revent.Events.Add(events[i]);
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbRemoteEvent.xml'     path='doc/class[@name="FbRemoteEvent"]/method[@name="QueueEvents"]/*'/>
+               public void     QueueEvents()
+               {
+                       this.revent.QueueEvents();
+               }
+
+               ///     <include file='Doc/en_EN/FbRemoteEvent.xml'     path='doc/class[@name="FbRemoteEvent"]/method[@name="CancelEvents"]/*'/>
+               public void     CancelEvents()
+               {
+                       this.revent.CancelEvents();
+               }
+
+               #endregion
+
+               #region Callbacks methods
+
+               private void OnRemoteEventCounts()
+               {
+                       bool canceled = false;
+
+                       if (this.RemoteEventCounts != null)
+                       {
+                               int[] actualCounts = (int[])this.revent.ActualCounts.Clone();
+                               if (this.revent.PreviousCounts != null)
+                               {
+                                       for     (int i = 0;     i <     this.revent.ActualCounts.Length; i++ )
+                                       {
+                                               actualCounts[i] -= this.revent.PreviousCounts[i];
+                                       }
+                               }
+
+                               // Send individual event notifications
+                               for     (int i = 0;     i <     actualCounts.Length; i++ )
+                               {
+                                       FbRemoteEventEventArgs args     = new FbRemoteEventEventArgs(this.revent.Events[i],     actualCounts[i]);
+                                       this.RemoteEventCounts(this, args);
+
+                                       if (args.Cancel)
+                                       {
+                                               canceled = true;
+                                               break;
+                                       }
+                               }
+
+                               if (canceled)
+                               {
+                                       // Requeque
+                                       this.CancelEvents();
+                               }
+                               else
+                               {
+                                       // Requeque
+                                       this.QueueEvents();
+                               }
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRemoteEventEventArgs.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRemoteEventEventArgs.cs
new file mode 100644 (file)
index 0000000..7cf3a0c
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird
+{
+       #region Delegates
+
+       ///     <include file='Doc/en_EN/FbRemoteEventEventArgs.xml' path='doc/delegate[@name="FbRemoteEventEventHandler"]/overview/*'/>
+       public delegate void FbRemoteEventEventHandler(object sender, FbRemoteEventEventArgs e);
+
+       #endregion
+
+       ///     <include file='Doc/en_EN/FbRemoteEventEventArgs.xml' path='doc/class[@name="FbRemoteEventEventArgs"]/overview/*'/>
+       public sealed class     FbRemoteEventEventArgs : System.ComponentModel.CancelEventArgs
+       {
+               #region Fields
+
+               private string  name;
+               private int             counts;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbRemoteEventEventArgs.xml' path='doc/class[@name="FbRemoteEventEventArgs"]/property[@name="Name"]/*'/>
+               public string Name
+               {
+                       get     { return this.name;     }
+               }
+
+               ///     <include file='Doc/en_EN/FbRemoteEventEventArgs.xml' path='doc/class[@name="FbRemoteEventEventArgs"]/property[@name="Counts"]/*'/>
+               public int Counts
+               {
+                       get     { return this.counts; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbRemoteEventEventArgs.xml' path='doc/class[@name="FbRemoteEventEventArgs"]/constructor[@name="ctor(System.String,System.Int32)"]/*'/>
+               public FbRemoteEventEventArgs(string name, int counts) : this(name,     counts, false)
+               {
+               }
+
+               ///     <include file='Doc/en_EN/FbRemoteEventEventArgs.xml' path='doc/class[@name="FbRemoteEventEventArgs"]/constructor[@name="ctor(System.String,System.Int32,System.Boolean)"]/*'/>
+               public FbRemoteEventEventArgs(string name, int counts, bool     cancel) : base(cancel)
+               {
+                       this.name       = name;
+                       this.counts     = counts;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRowUpdatedEventArgs.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRowUpdatedEventArgs.cs
new file mode 100644 (file)
index 0000000..8533698
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       #region Delegates
+
+       ///     <include file='Doc/en_EN/FbRowUpdatedEventArgs.xml'     path='doc/delegate[@name="FbRowUpdatedEventHandler"]/*'/>
+       public delegate void FbRowUpdatedEventHandler(object sender, FbRowUpdatedEventArgs e);
+
+       #endregion
+
+       ///     <include file='Doc/en_EN/FbRowUpdatedEventArgs.xml'     path='doc/class[@name="FbRowUpdatedEventArgs"]/overview/*'/>
+       public sealed class     FbRowUpdatedEventArgs : RowUpdatedEventArgs
+       {
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbRowUpdatedEventArgs.xml'     path='doc/class[@name="FbRowUpdatedEventArgs"]/property[@name="Command"]/*'/>
+               public new FbCommand Command
+               {
+                       get      { return (FbCommand)base.Command; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbRowUpdatedEventArgs.xml'     path='doc/class[@name="FbRowUpdatedEventArgs"]/constructor[@name="ctor(DataRow,IDbCommand,StatementType,DataTableMapping)"]/*'/>
+               public FbRowUpdatedEventArgs(
+                       DataRow                         row, 
+                       IDbCommand                      command, 
+                       StatementType           statementType, 
+                       DataTableMapping                tableMapping)
+                       : base(row,     command, statementType, tableMapping) 
+               {
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRowUpdatingEventArgs.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRowUpdatingEventArgs.cs
new file mode 100644 (file)
index 0000000..a9dfedd
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       #region Delegates
+
+       ///     <include file='Doc/en_EN/FbRowUpdatingEventArgs.xml' path='doc/delegate[@name="FbRowUpdatingEventHandler"]/*'/>
+       public delegate void FbRowUpdatingEventHandler(object sender, FbRowUpdatingEventArgs e);
+
+       #endregion
+
+       ///     <include file='Doc/en_EN/FbRowUpdatingEventArgs.xml' path='doc/class[@name="FbRowUpdatingEventArgs"]/overview/*'/>
+       public sealed class     FbRowUpdatingEventArgs : RowUpdatingEventArgs
+       {
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbRowUpdatingEventArgs.xml' path='doc/class[@name="FbRowUpdatingEventArgs"]/property[@name="Command"]/*'/>
+               public new FbCommand Command
+               {
+                       get      { return (FbCommand)base.Command; }
+                       set      { base.Command = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbRowUpdatingEventArgs.xml' path='doc/class[@name="FbRowUpdatingEventArgs"]/constructor[@name="ctor(DataRow,IDbCommand,StatementType,DataTableMapping)"]/*'/>
+               public FbRowUpdatingEventArgs(
+                       DataRow                         row, 
+                       IDbCommand                      command, 
+                       StatementType           statementType, 
+                       DataTableMapping                tableMapping) 
+                       : base(row,     command, statementType, tableMapping) 
+               {
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbTransaction.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbTransaction.cs
new file mode 100644 (file)
index 0000000..e6a901b
--- /dev/null
@@ -0,0 +1,614 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Collections;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbTransaction"]/overview/*'/>
+       public sealed class     FbTransaction : MarshalByRefObject,     IDbTransaction, IDisposable
+       {
+               #region Fields
+
+               private ITransaction    transaction;
+               private bool                    disposed;
+               private FbConnection    connection;
+               private bool                    isUpdated;
+               private IsolationLevel  isolationLevel;
+
+               #endregion
+
+               #region Properties
+
+               IDbConnection IDbTransaction.Connection
+               {
+                       get     { return this.Connection; }
+               }
+
+               ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbTransaction"]/property[@name="Connection"]/*'/>
+               public FbConnection     Connection
+               {
+                       get     
+                       { 
+                               if (!this.isUpdated)
+                               {
+                                       return this.connection; 
+                               }
+                               else
+                               {
+                                       return null;
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbTransaction"]/property[@name="IsolationLevel"]/*'/>
+               public IsolationLevel IsolationLevel 
+               {
+                       get     { return this.isolationLevel; }
+               }
+
+               #endregion
+
+               #region Internal Properties
+
+               internal ITransaction Transaction
+               {
+                       get     { return this.transaction; }
+               }
+
+               internal bool IsUpdated
+               {
+                       get     { return this.isUpdated; }
+               }
+
+               #endregion
+
+               #region Constructors
+               
+               internal FbTransaction(FbConnection     connection)     
+                       : this(connection, IsolationLevel.ReadCommitted)
+               {
+               }                               
+
+               internal FbTransaction(FbConnection     connection,     IsolationLevel il)
+               {
+                       this.isolationLevel     = il;
+                       this.connection         = connection;                   
+               }                               
+
+               #endregion
+
+               #region Finalizer
+
+               ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbCommandBuilder"]/destructor[@name="Finalize"]/*'/>
+               ~FbTransaction()
+               {
+                       this.Dispose(false);
+               }
+
+               #endregion
+
+               #region IDisposable     Methods
+
+               ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbTransaction"]/method[@name="Dispose"]/*'/>
+               public void     Dispose()
+               {
+                       this.Dispose(true);
+                       GC.SuppressFinalize(this);
+               }
+
+               private void Dispose(bool disposing)
+               {
+                       lock (this)
+                       {
+                               if (!this.disposed)
+                               {
+                                       try
+                                       {
+                                               // release any unmanaged resources
+                                               if (this.transaction != null) 
+                                               {
+                                                       if ((this.transaction.State     == TransactionState.TransactionStarted
+                                                               || this.transaction.State == TransactionState.TransactionPrepared)
+                                                               && !this.isUpdated)
+                                                       {
+                                                               this.transaction.Dispose();
+                                                               this.transaction = null;
+                                                       }
+                                               }
+
+                                               // release any managed resources
+                                               if (disposing)
+                                               {
+                                                       this.connection  = null;
+                                                       this.transaction = null;
+                                               }
+                                       }
+                                       finally
+                                       {
+                                               this.isUpdated  = true;
+                                               this.disposed   = true;
+                                       }
+                               }
+                       }
+               }
+               
+               #endregion
+
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbTransaction"]/method[@name="Commit"]/*'/>
+               public void     Commit()
+               {
+                       lock (this)
+                       {
+                               if (this.isUpdated)
+                               {
+                                       throw new InvalidOperationException("This Transaction has completed; it is no longer usable.");
+                               }
+
+                               try
+                               {
+                                       this.transaction.Commit();
+                                       this.UpdateTransaction();
+                               }
+                               catch(IscException ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbTransaction"]/method[@name="Rollback"]/*'/>
+               public void     Rollback()
+               {
+                       lock (this)
+                       {
+                               if (this.isUpdated)
+                               {
+                                       throw new InvalidOperationException("This Transaction has completed; it is no longer usable.");
+                               }
+
+                               try
+                               {
+                                       this.transaction.Rollback();
+                                       this.UpdateTransaction();
+                               }
+                               catch(IscException ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbTransaction"]/method[@name="Save(System.String)"]/*'/>
+               public void     Save(string     savePointName)
+               {
+                       lock (this)
+                       {
+                               if (savePointName == null)
+                               {
+                                       throw new ArgumentException("No transaction     name was be     specified.");
+                               }
+                               else
+                               {
+                                       if (savePointName.Length ==     0)
+                                       {
+                                               throw new ArgumentException("No transaction     name was be     specified.");
+                                       }
+                               }
+                               if (this.isUpdated)
+                               {
+                                       throw new InvalidOperationException("This Transaction has completed; it is no longer usable.");
+                               }
+
+                               try
+                               {
+                                       FbCommand command =     new     FbCommand(
+                                               "SAVEPOINT " + savePointName,
+                                               this.connection, 
+                                               this);
+                                       command.ExecuteNonQuery();
+                                       command.Dispose();
+                               }
+                               catch(IscException ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbTransaction"]/method[@name="Commit(System.String)"]/*'/>
+               public void     Commit(string savePointName)
+               {
+                       lock (this)
+                       {
+                               if (savePointName == null)
+                               {
+                                       throw new ArgumentException("No transaction     name was be     specified.");
+                               }
+                               else
+                               {
+                                       if (savePointName.Length ==     0)
+                                       {
+                                               throw new ArgumentException("No transaction     name was be     specified.");
+                                       }
+                               }
+                               if (this.isUpdated)
+                               {
+                                       throw new InvalidOperationException("This Transaction has completed; it is no longer usable.");
+                               }
+
+                               try
+                               {
+                                       FbCommand command =     new     FbCommand(
+                                               "RELEASE SAVEPOINT " + savePointName,
+                                               this.connection,
+                                               this);
+                                       command.ExecuteNonQuery();
+                                       command.Dispose();
+                               }
+                               catch (IscException     ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbTransaction"]/method[@name="Rollback(System.String)"]/*'/>
+               public void     Rollback(string savePointName)
+               {
+                       lock (this)
+                       {
+                               if (savePointName == null)
+                               {
+                                       throw new ArgumentException("No transaction     name was be     specified.");
+                               }
+                               else
+                               {
+                                       if (savePointName.Length ==     0)
+                                       {
+                                               throw new ArgumentException("No transaction     name was be     specified.");
+                                       }
+                               }
+                               if (this.isUpdated)
+                               {
+                                       throw new InvalidOperationException("This Transaction has completed; it is no longer usable.");
+                               }
+
+                               try
+                               {
+                                       FbCommand command =     new     FbCommand(
+                                               "ROLLBACK WORK TO SAVEPOINT     " +     savePointName,
+                                               this.connection, 
+                                               this);
+                                       command.ExecuteNonQuery();
+                                       command.Dispose();
+                               }
+                               catch(IscException ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbTransaction"]/method[@name="CommitRetaining"]/*'/>
+               public void     CommitRetaining()
+               {
+                       lock (this)
+                       {
+                               if (this.isUpdated)
+                               {
+                                       throw new InvalidOperationException("This Transaction has completed; it is no longer usable.");
+                               }
+
+                               try
+                               {
+                                       this.transaction.CommitRetaining();
+                               }
+                               catch(IscException ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbTransaction.xml'     path='doc/class[@name="FbTransaction"]/method[@name="RollbackRetaining"]/*'/>
+               public void     RollbackRetaining()
+               {
+                       lock (this)
+                       {
+                               if (this.isUpdated)
+                               {
+                                       throw new InvalidOperationException("This Transaction has completed; it is no longer usable.");
+                               }
+
+                               try
+                               {
+                                       this.transaction.RollbackRetaining();
+                               }
+                               catch(IscException ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region InternalMethods
+
+               internal void BeginTransaction()
+               {
+                       lock (this)
+                       {
+                               try
+                               {       
+                                       IDatabase database = this.connection.InnerConnection.Database;
+                                       this.transaction = database.BeginTransaction(this.BuildTpb());
+                               }
+                               catch(IscException ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+               }
+
+               internal void BeginTransaction(FbTransactionOptions     options)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       IDatabase database = this.connection.InnerConnection.Database;
+                                       this.transaction = database.BeginTransaction(this.BuildTpb(options));
+                               }
+                               catch(IscException ex)
+                               {
+                                       throw new FbException(ex.Message, ex);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void UpdateTransaction()
+               {
+                       if (this.connection     != null)
+                       {
+                               this.connection.InnerConnection.TransactionUpdated();
+                       }
+
+                       this.isUpdated          = true;
+                       this.connection         = null;
+                       this.transaction        = null;
+               }
+
+               private TransactionParameterBuffer BuildTpb()
+               {
+                       FbTransactionOptions options = FbTransactionOptions.Write;
+
+                       options |= FbTransactionOptions.Wait;
+
+                       /* Isolation level */
+                       switch(this.isolationLevel)
+                       {
+                               case IsolationLevel.Serializable:
+                                       options |= FbTransactionOptions.Consistency;
+                                       break;
+
+                               case IsolationLevel.RepeatableRead:                     
+                                       options |= FbTransactionOptions.Concurrency;
+                                       break;
+
+                               case IsolationLevel.ReadUncommitted:
+                                       options |= FbTransactionOptions.ReadCommitted;
+                                       options |= FbTransactionOptions.RecVersion;
+                                       break;
+
+                               case IsolationLevel.ReadCommitted:
+                               default:                                        
+                                       options |= FbTransactionOptions.ReadCommitted;
+                                       options |= FbTransactionOptions.NoRecVersion;
+                                       break;
+                       }
+
+                       return this.BuildTpb(options);
+               }
+
+#if    (!NETCF)
+
+               private TransactionParameterBuffer BuildTpb(FbTransactionOptions options)
+               {
+                       TransactionParameterBuffer tpb = new TransactionParameterBuffer();
+
+                       tpb.Append(IscCodes.isc_tpb_version3);
+
+                       FbTransactionOptions[] o = (FbTransactionOptions[])     Enum.GetValues(options.GetType());
+                       for     (int i = 0;     i <     o.Length; i++) 
+                       {
+                               FbTransactionOptions option     = ((FbTransactionOptions)(o[i]));
+                               if ((options & option) == option)
+                               {
+                                       switch (option)
+                                       {
+                                               case FbTransactionOptions.Consistency:
+                                                       tpb.Append(IscCodes.isc_tpb_consistency);
+                                                       break;
+
+                                               case FbTransactionOptions.Concurrency:
+                                                       tpb.Append(IscCodes.isc_tpb_concurrency);
+                                                       break;
+
+                                               case FbTransactionOptions.Shared:
+                                                       tpb.Append(IscCodes.isc_tpb_shared);
+                                                       break;
+
+                                               case FbTransactionOptions.Protected:
+                                                       tpb.Append(IscCodes.isc_tpb_protected);
+                                                       break;
+
+                                               case FbTransactionOptions.Exclusive:
+                                                       tpb.Append(IscCodes.isc_tpb_exclusive);
+                                                       break;
+                                               
+                                               case FbTransactionOptions.Wait:
+                                                       tpb.Append(IscCodes.isc_tpb_wait);
+                                                       break;
+
+                                               case FbTransactionOptions.NoWait:
+                                                       tpb.Append(IscCodes.isc_tpb_nowait);
+                                                       break;
+
+                                               case FbTransactionOptions.Read:
+                                                       tpb.Append(IscCodes.isc_tpb_read);
+                                                       break;
+                                               
+                                               case FbTransactionOptions.Write:
+                                                       tpb.Append(IscCodes.isc_tpb_write);
+                                                       break;
+
+                                               case FbTransactionOptions.LockRead:
+                                                       tpb.Append(IscCodes.isc_tpb_lock_read);
+                                                       break;
+
+                                               case FbTransactionOptions.LockWrite:
+                                                       tpb.Append(IscCodes.isc_tpb_lock_write);
+                                                       break;
+
+                                               case FbTransactionOptions.ReadCommitted:
+                                                       tpb.Append(IscCodes.isc_tpb_read_committed);
+                                                       break;
+
+                                               case FbTransactionOptions.Autocommit:
+                                                       tpb.Append(IscCodes.isc_tpb_autocommit);
+                                                       break;
+
+                                               case FbTransactionOptions.RecVersion:
+                                                       tpb.Append(IscCodes.isc_tpb_rec_version);
+                                                       break;
+
+                                               case FbTransactionOptions.NoRecVersion:
+                                                       tpb.Append(IscCodes.isc_tpb_no_rec_version);
+                                                       break;
+
+                                               case FbTransactionOptions.RestartRequests:
+                                                       tpb.Append(IscCodes.isc_tpb_restart_requests);
+                                                       break;
+
+                                               case FbTransactionOptions.NoAutoUndo:
+                                                       tpb.Append(IscCodes.isc_tpb_no_auto_undo);
+                                                       break;
+                                       }
+                               }
+                       }
+                       
+                       return tpb;
+               }
+
+#else
+
+               private TransactionParameterBuffer BuildTpb(FbTransactionOptions options)
+               {
+                       TransactionParameterBuffer tpb = new TransactionParameterBuffer();
+
+                       tpb.Append(IscCodes.isc_tpb_version3);
+
+                       if ((options & FbTransactionOptions.Consistency) ==     FbTransactionOptions.Consistency)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_consistency);
+                       }
+                       if ((options & FbTransactionOptions.Concurrency) ==     FbTransactionOptions.Concurrency)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_concurrency);
+                       }
+                       if ((options & FbTransactionOptions.Shared)     == FbTransactionOptions.Shared)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_shared);
+                       }
+                       if ((options & FbTransactionOptions.Protected) == FbTransactionOptions.Protected)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_protected);
+                       }
+                       if ((options & FbTransactionOptions.Exclusive) == FbTransactionOptions.Exclusive)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_exclusive);
+                       }
+                       if ((options & FbTransactionOptions.Wait) == FbTransactionOptions.Wait)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_wait);
+                       }
+                       if ((options & FbTransactionOptions.NoWait)     == FbTransactionOptions.NoWait)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_nowait);
+                       }
+                       if ((options & FbTransactionOptions.Read) == FbTransactionOptions.Read)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_read);
+                       }
+                       if ((options & FbTransactionOptions.Write) == FbTransactionOptions.Write)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_write);
+                       }
+                       if ((options & FbTransactionOptions.LockRead) == FbTransactionOptions.LockRead)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_lock_read);
+                       }
+                       if ((options & FbTransactionOptions.LockWrite) == FbTransactionOptions.LockWrite)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_lock_write);
+                       }
+                       if ((options & FbTransactionOptions.ReadCommitted) == FbTransactionOptions.ReadCommitted)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_read_committed);
+                       }
+                       if ((options & FbTransactionOptions.Autocommit) == FbTransactionOptions.Autocommit)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_autocommit);
+                       }
+                       if ((options & FbTransactionOptions.RecVersion) == FbTransactionOptions.RecVersion)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_rec_version);
+                       }
+                       if ((options & FbTransactionOptions.NoRecVersion) == FbTransactionOptions.NoRecVersion)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_no_rec_version);
+                       }
+                       if ((options & FbTransactionOptions.RestartRequests) == FbTransactionOptions.RestartRequests)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_restart_requests);
+                       }
+                       if ((options & FbTransactionOptions.NoAutoUndo) == FbTransactionOptions.NoAutoUndo)
+                       {
+                               tpb.Append(IscCodes.isc_tpb_no_auto_undo);
+                       }
+                       
+                       return tpb;
+               }
+
+#endif
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbTransactionOptions.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbTransactionOptions.cs
new file mode 100644 (file)
index 0000000..bc1860e
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird
+{
+       ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/overview/*'/>
+#if    (!NETCF)
+       [Flags]
+       [Serializable]
+#endif
+       public enum     FbTransactionOptions : int
+       {
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="Consistency"]/*'/>
+               Consistency             = 1,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="Concurrency"]/*'/>
+               Concurrency             = 2,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="Shared"]/*'/>
+               Shared                  = 4,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="Protected"]/*'/>
+               Protected               = 8,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="Exclusive"]/*'/>
+               Exclusive               = 16,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="Wait"]/*'/>
+               Wait                    = 32,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="NoWait"]/*'/>
+               NoWait                  = 64,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="Read"]/*'/>
+               Read                    = 128,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="Write"]/*'/>
+               Write                   = 256,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="LockRead"]/*'/>
+               LockRead                = 512,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="LockWrite"]/*'/>
+               LockWrite               = 1024,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="ReadCommitted"]/*'/>
+               ReadCommitted   = 2048,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="Autocommit"]/*'/>
+               Autocommit              = 4096,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="RecVersion"]/*'/>
+               RecVersion              = 8192,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="NoRecVersion"]/*'/>
+               NoRecVersion    = 16384,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="RestartRequests"]/*'/>
+               RestartRequests = 32768,
+               ///     <include file='Doc/en_EN/FbTransactionOptions.xml' path='doc/enum[@name="FbTransactionOptions"]/field[@name="NoAutoUndo"]/*'/>
+               NoAutoUndo              = 65536
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/CommandExecutedEventArgs.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/CommandExecutedEventArgs.cs
new file mode 100644 (file)
index 0000000..f596c74
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2003, 2004 Abel Eduardo Pereira
+ *  All Rights Reserved.
+ */
+
+using System;
+using FirebirdSql.Data.Firebird;
+
+namespace FirebirdSql.Data.Firebird.Isql
+{
+       #region Delegates
+
+       /// <summary>
+       /// The event handler type trigged after a SQL statement execution.
+       /// </summary>
+       public delegate void CommandExecutedEventHandler(object sender, CommandExecutedEventArgs e);
+
+       #endregion
+
+       /// <summary>
+       /// Summary description for CommandExecutedEventArgs.
+       /// </summary>
+       public class CommandExecutedEventArgs
+       {
+               #region Fields
+
+               private string                          commandText;
+               private FbDataReader            dataReader;
+               private int                                     rowsAffected;
+
+               #endregion
+
+               #region Properties
+
+               /// <summary>
+               /// Returns the <see cref="SqlStatementType"/> of the current <see cref="CommandText"/>.
+               /// </summary>
+               public SqlStatementType StatementType 
+               {
+                       get { return FbBatchExecution.GetStatementType(this.commandText); }
+               }
+
+               /// <summary>
+               /// Returns the SQL statement that was executed.
+               /// </summary>
+               public string CommandText 
+               {
+                       get { return this.commandText; }
+               }
+
+               /// <summary>
+               /// Returns a <see cref="FbDataReader"/> instance case the executed SQL command returns data. If
+               /// the executed SQL command does not returns data, (for instance: the case of an UPDATE statement), 
+               /// the <b>DataReader</b> is setled to <b>null</b>.
+               /// </summary>
+               public FbDataReader DataReader
+               {
+                       get { return this.dataReader; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               /// <summary>
+               /// Creates an instance of CommandExecutedEventArgs class.
+               /// </summary>
+               /// <param name="dataReader"></param>
+               /// <param name="commandText">The CommandText of the <see cref="FbCommand"/> that was executed.</param>
+               /// <param name="rowsAffected"></param>
+               public CommandExecutedEventArgs(
+                       FbDataReader            dataReader,
+                       string                          commandText,
+                       int                                     rowsAffected)
+               {
+                       this.dataReader         = dataReader;
+                       this.commandText        = commandText;
+                       this.rowsAffected       = rowsAffected;
+               }
+
+               #endregion
+
+               #region Methods
+
+               /// <summary>
+               /// Overrided. Returns the SQL statement that was executed.
+               /// </summary>
+               /// <returns>The SQL statement that will be executed.</returns>
+               public override string ToString() 
+               {
+                       return this.commandText;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/CommandExecutingEventArgs.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/CommandExecutingEventArgs.cs
new file mode 100644 (file)
index 0000000..c13e18f
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2003,     2004 Abel Eduardo Pereira
+ *     All     Rights Reserved.
+ */
+
+using System;
+using FirebirdSql.Data.Firebird;
+
+namespace FirebirdSql.Data.Firebird.Isql
+{
+       #region Delegates
+
+       ///     <summary>
+       ///     The     event handler type trigged before a     SQL     statement execution.
+       ///     </summary>
+       public delegate void CommandExecutingEventHandler(object sender, CommandExecutingEventArgs e);
+
+       #endregion
+
+       ///     <summary>
+       ///     CommandExecutingEventArgs encapsulates the events arguments     for     the     event trigged 
+       ///     from the <see cref="FbBatchExecution"/> during the execution. 
+       ///     </summary>
+       ///     <remarks>
+       ///     
+       ///     </remarks>
+       public class CommandExecutingEventArgs: EventArgs
+       {
+               #region Private
+
+               private FbCommand sqlCommand;
+
+               #endregion
+
+               #region Properties
+
+               ///     <summary>
+               ///     Returns the     <see cref="FbCommand"/> instance that created for the SQL statement     that goes 
+               ///     for     execution. 
+               ///     </summary>
+               public FbCommand SqlCommand     
+               {
+                       get     { return this.sqlCommand; }
+               }
+
+               ///     <summary>
+               ///     Returns the     <see cref="SqlStatementType"/> of the current <see cref="SqlCommand"/>.
+               ///     </summary>
+               public SqlStatementType StatementType 
+               {
+                       get     { return FbBatchExecution.GetStatementType(this.SqlCommand.CommandText); }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <summary>
+               ///     Creates an instance     of CommandExecutingEventArgs class.
+               ///     </summary>
+               ///     <param name="sqlCommand">The FbCommand properly instanciated.</param>
+               ///     <remarks>The <b>sqlCommand</b> should be proper instanciated with a     valid 
+               ///     <see cref="FbCommand"/> and     with the SQL statement loaded in <see cref="FbCommand.CommandText"/>.
+               ///     </remarks>
+               public CommandExecutingEventArgs(FbCommand sqlCommand)
+               {
+                       this.sqlCommand = sqlCommand;
+               }
+
+               #endregion
+
+               #region Methods
+
+               ///     <summary>
+               ///     Overrided. Returns the SQL statement that goes for execution.
+               ///     </summary>
+               ///     <returns>The SQL statement that will be executed.</returns>
+               public override string ToString() 
+               {
+                       return this.sqlCommand.CommandText;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/FbBatchExecution.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/FbBatchExecution.cs
new file mode 100644 (file)
index 0000000..bd7fd0a
--- /dev/null
@@ -0,0 +1,1181 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2003,     2004 Abel Eduardo Pereira
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Globalization;
+
+using FirebirdSql.Data.Firebird;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Isql
+{
+       #region Enumerations
+
+       ///     <summary>
+       ///     DSQL and ISQL statement types.
+       ///     </summary>
+       public enum     SqlStatementType 
+       {
+               ///     <summary>
+               ///     Represents the SQL statement: <b>ALTER DATABASE</b>
+               ///     </summary>
+               AlterDatabase = 0,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>ALTER DOMAIN</b>
+               ///     </summary>
+               AlterDomain,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>ALTER EXCEPTION</b>
+               ///     </summary>
+               AlterException,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>ALTER INDEX</b>
+               ///     </summary>
+               AlterIndex,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>ALTER PROCEDURE</b>
+               ///     </summary>
+               AlterProcedure,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>ALTER TABLE</b>
+               ///     </summary>
+               AlterTable,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>ALTER TRIGGER</b>
+               ///     </summary>
+               AlterTrigger,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CLOSE</b>
+               ///     </summary>
+               Close,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>COMMIT</b>
+               ///     </summary>
+               Commit,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CONNECT</b>
+               ///     </summary>
+               Connect,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CREATE DATABASE</b>
+               ///     </summary>
+               CreateDatabase,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CREATE DOMAIN</b>
+               ///     </summary>
+               CreateDomain,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CREATE EXCEPTION</b>
+               ///     </summary>
+               CreateException,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CREATE GENERATOR</b>
+               ///     </summary>
+               CreateGenerator,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CREATE INDEX</b>
+               ///     </summary>
+               CreateIndex,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CREATE PROCEDURE</b>
+               ///     </summary>
+               CreateProcedure,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CREATE ROLE</b>
+               ///     </summary>
+               CreateRole,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CREATE SHADOW</b>
+               ///     </summary>
+               CreateShadow,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CREATE TABLE</b>
+               ///     </summary>
+               CreateTable,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CREATE TRIGGER</b>
+               ///     </summary>
+               CreateTrigger,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>CREATE VIEW</b>
+               ///     </summary>
+               CreateView,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DECLARE CURSOR</b>
+               ///     </summary>
+               DeclareCursor,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DECLARE EXTERNAL FUNCTION</b>
+               ///     </summary>
+               DeclareExternalFunction,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DECLARE FILTER</b>
+               ///     </summary>
+               DeclareFilter,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DECLARE STATEMENT</b>
+               ///     </summary>
+               DeclareStatement,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DECLARE TABLE</b>
+               ///     </summary>
+               DeclareTable,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DELETE</b>
+               ///     </summary>
+               Delete,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DESCRIBE</b>
+               ///     </summary>
+               Describe,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DISCONNECT</b>
+               ///     </summary>
+               Disconnect,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP DATABASE</b>
+               ///     </summary>
+               DropDatabase,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP DOMAIN</b>
+               ///     </summary>
+               DropDomain,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP EXCEPTION</b>
+               ///     </summary>
+               DropException,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP EXTERNAL FUNCTION</b>
+               ///     </summary>
+               DropExternalFunction,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP FILTER</b>
+               ///     </summary>
+               DropFilter,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP GENERATOR</b>
+               ///     </summary>
+               DropGenerator,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP INDEX</b>
+               ///     </summary>
+               DropIndex,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP PROCEDURE</b>
+               ///     </summary>
+               DropProcedure,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP ROLE</b>
+               ///     </summary>
+               DropRole,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP SHADOW</b>
+               ///     </summary>
+               DropShadow,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP TABLE</b>
+               ///     </summary>
+               DropTable,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP TRIGGER</b>
+               ///     </summary>
+               DropTrigger,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>DROP VIEW</b>
+               ///     </summary>
+               DropView,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>END DECLARE SECTION</b>
+               ///     </summary>
+               EndDeclareSection,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>EVENT INIT</b>
+               ///     </summary>
+               EventInit,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>EVENT WAIT</b>
+               ///     </summary>
+               EventWait,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>EXECUTE</b>
+               ///     </summary>
+               Execute,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>EXECUTE IMMEDIATE</b>
+               ///     </summary>
+               ExecuteImmediate,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>EXECUTE PROCEDURE</b>
+               ///     </summary>
+               ExecuteProcedure,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>FETCH</b>
+               ///     </summary>
+               Fetch,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>GRANT</b>
+               ///     </summary>
+               Grant,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>INSERT</b>
+               ///     </summary>
+               Insert,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>INSERT CURSOR</b>
+               ///     </summary>
+               InsertCursor,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>OPEN</b>
+               ///     </summary>
+               Open,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>PREPARE</b>
+               ///     </summary>
+               Prepare,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>REVOKE</b>
+               ///     </summary>
+               Revoke,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>ROLLBACK</b>
+               ///     </summary>
+               Rollback,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>SELECT</b>
+               ///     </summary>
+               Select,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>SET DATABASE</b>
+               ///     </summary>
+               SetDatabase,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>SET GENERATOR</b>
+               ///     </summary>
+               SetGenerator,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>SET NAMES</b>
+               ///     </summary>
+               SetNames,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>SET SQL DIALECT</b>
+               ///     </summary>
+               SetSQLDialect,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>SET STATISTICS</b>
+               ///     </summary>
+               SetStatistics,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>SET TRANSACTION</b>
+               ///     </summary>
+               SetTransaction,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>SHOW SQL DIALECT</b>
+               ///     </summary>
+               ShowSQLDialect,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>UPDATE</b>
+               ///     </summary>
+               Update,
+
+               ///     <summary>
+               ///     Represents the SQL statement: <b>WHENEVER</b>
+               ///     </summary>
+               Whenever
+       }
+
+       #endregion
+       
+       ///     <summary>
+       ///     Summary description     for     BatchExecution.
+       ///     </summary>
+       public class FbBatchExecution
+       {
+               #region Events
+
+               ///     <summary>
+               ///     The     event trigged before a SQL statement goes for execution.
+               ///     </summary>
+               public event CommandExecutingEventHandler CommandExecuting;
+
+               ///     <summary>
+               ///     The     event trigged after     a SQL statement execution.
+               ///     </summary>
+               public event CommandExecutedEventHandler CommandExecuted;
+
+               #endregion
+
+               #region Fields
+
+               private StringCollection                        sqlStatements;
+               private FbConnection                            sqlConnection;
+               private FbTransaction                           sqlTransaction;
+               private FbConnectionStringBuilder       connectionString;
+               private FbCommand                                       sqlCommand;
+
+               // control fields
+               private bool requiresNewConnection;
+
+               #endregion
+
+               #region Properties
+
+               ///     <summary>
+               ///     Represents the list     of SQL statements for batch     execution.
+               ///     </summary>
+               public StringCollection SqlStatements 
+               {
+                       get     
+                       {
+                               if (this.sqlStatements == null)
+                               {
+                                       this.sqlStatements = new StringCollection();
+                               }
+                               return this.sqlStatements; 
+                       }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <summary>
+               ///     Creates an instance     of FbBatchExecution     engine.
+               ///     </summary>
+               public FbBatchExecution()
+               {
+                       this.sqlConnection              = new FbConnection(); // do     not     specify the     connection string
+                       this.connectionString   = new FbConnectionStringBuilder();
+               }
+
+               ///     <summary>
+               ///     Creates an instance     of FbBatchExecution     engine with     the     given
+               ///     connection.
+               ///     </summary>
+               ///     <param name="sqlConnection">A <see cref="FbConnection"/> object.</param>
+               public FbBatchExecution(FbConnection sqlConnection)
+               {
+                       if (sqlConnection == null)
+                       {
+                               this.sqlConnection              = new FbConnection(); // do     not     specify the     connection string
+                               this.connectionString   = new FbConnectionStringBuilder();
+                       }
+                       else
+                       {
+                               this.sqlConnection              = sqlConnection;
+                               this.connectionString   = new FbConnectionStringBuilder(sqlConnection.ConnectionString);
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               ///     <summary>
+               ///     Starts the ordered execution of the     SQL     statements that are     in <see cref="SqlStatements"/> collection.
+               ///     </summary>
+               public virtual void     Execute()
+               {
+                       this.Execute(true);
+               }
+
+               ///     <summary>
+               ///     Starts the ordered execution of the     SQL     statements that are     in <see cref="SqlStatements"/> collection.
+               ///     </summary>
+               ///     <param name="autoCommit">Specifies if the transaction should be committed after a DDL command execution</param>
+               public virtual void     Execute(bool autoCommit) 
+               {
+                       if (this.SqlStatements == null ||this.SqlStatements.Count == 0) 
+                       {
+                               throw new InvalidOperationException("There are no commands for execution.");
+                       }
+
+                       foreach (string sqlStatement in this.SqlStatements)
+                       {
+                               if (sqlStatement ==     null || sqlStatement.Length     == 0)
+                               {
+                                       continue;
+                               }
+                               
+                               // initializate outputs to default
+                               int                             rowsAffected    = -1;
+                               FbDataReader    dataReader              = null;
+                               SqlStatementType statementType  = FbBatchExecution.GetStatementType(sqlStatement);
+
+                               // Update command configuration
+                               this.ProvideCommand().CommandText =     sqlStatement;
+
+                               // Check how transactions are going     to be handled
+                               if (statementType == SqlStatementType.Insert ||
+                                       statementType == SqlStatementType.Update ||
+                                       statementType == SqlStatementType.Delete)
+                               {
+                                       // DML commands should be inside a transaction
+                                       if (this.sqlTransaction == null)
+                                       {
+                                               this.sqlTransaction     = this.sqlConnection.BeginTransaction();
+                                       }
+                                       this.sqlCommand.Transaction     = this.sqlTransaction;
+                               }
+                               else if (this.sqlTransaction != null && (statementType != SqlStatementType.Commit && statementType != SqlStatementType.Rollback))
+                               {
+                                       // Non DML Statements should be executed using
+                                       // implicit     transaction     support
+                                       this.sqlTransaction.Commit();
+                               }
+
+                               try
+                               {
+                                       switch (statementType)
+                                       {
+                                               case SqlStatementType.AlterDatabase:
+                                               case SqlStatementType.AlterDomain:
+                                               case SqlStatementType.AlterException:
+                                               case SqlStatementType.AlterIndex:
+                                               case SqlStatementType.AlterProcedure:
+                                               case SqlStatementType.AlterTable:
+                                               case SqlStatementType.AlterTrigger:
+                                                       // raise the event
+                                                       this.OnCommandExecuting(this.sqlCommand);
+
+                                                       rowsAffected = this.ExecuteCommand(this.sqlCommand,     autoCommit);
+                                                       this.requiresNewConnection      = false;
+
+                                                       // raise the event
+                                                       this.OnCommandExecuted(sqlStatement, null, rowsAffected);
+                                                       break;
+
+                                               case SqlStatementType.Commit:
+                                                       // raise the event
+                                                       this.OnCommandExecuting(null);
+
+                                                       this.sqlTransaction.Commit();
+                                                       this.sqlTransaction     = null;
+                                                       
+                                                       // raise the event
+                                                       this.OnCommandExecuted(sqlStatement, null, -1);
+                                                       break;
+
+                                               case SqlStatementType.Connect:
+                                                       // raise the event
+                                                       this.OnCommandExecuting(null);
+
+                                                       this.ConnectToDatabase(sqlStatement);
+
+                                                       requiresNewConnection = false;
+
+                                                       // raise the event
+                                                       this.OnCommandExecuted(sqlStatement, null, -1);
+                                                       break;
+
+                                               case SqlStatementType.CreateDatabase:
+#if    (!NETCF)
+                                                       throw new NotImplementedException();
+#else
+                                                       throw new NotSupportedException();
+#endif
+
+                                               case SqlStatementType.CreateDomain:
+                                               case SqlStatementType.CreateException:
+                                               case SqlStatementType.CreateGenerator:
+                                               case SqlStatementType.CreateIndex:
+                                               case SqlStatementType.CreateProcedure:
+                                               case SqlStatementType.CreateRole:
+                                               case SqlStatementType.CreateShadow:
+                                               case SqlStatementType.CreateTable:
+                                               case SqlStatementType.CreateTrigger:
+                                               case SqlStatementType.CreateView:
+                                               case SqlStatementType.DeclareCursor:
+                                               case SqlStatementType.DeclareExternalFunction:
+                                               case SqlStatementType.DeclareFilter:
+                                               case SqlStatementType.DeclareStatement:
+                                               case SqlStatementType.DeclareTable:
+                                               case SqlStatementType.Delete:
+                                                       // raise the event
+                                                       this.OnCommandExecuting(this.sqlCommand);
+
+                                                       rowsAffected = this.ExecuteCommand(this.sqlCommand,     autoCommit);
+                                                       requiresNewConnection = false;
+
+                                                       // raise the event
+                                                       this.OnCommandExecuted(sqlStatement, null, rowsAffected);
+                                                       break;
+
+                                               case SqlStatementType.Describe:
+                                                       break;
+
+                                               case SqlStatementType.Disconnect:
+                                                       this.sqlConnection.Close();
+                                                       this.requiresNewConnection = false;
+                                                       break;
+
+                                               case SqlStatementType.DropDatabase:
+#if    (!NETCF)
+                                                       throw new NotImplementedException();
+#else
+                                                       throw new NotSupportedException();
+#endif
+
+                                               case SqlStatementType.DropDomain:
+                                               case SqlStatementType.DropException:
+                                               case SqlStatementType.DropExternalFunction:
+                                               case SqlStatementType.DropFilter:
+                                               case SqlStatementType.DropGenerator:
+                                               case SqlStatementType.DropIndex:
+                                               case SqlStatementType.DropProcedure:
+                                               case SqlStatementType.DropRole:
+                                               case SqlStatementType.DropShadow:
+                                               case SqlStatementType.DropTable:
+                                               case SqlStatementType.DropTrigger:
+                                               case SqlStatementType.DropView:
+                                               case SqlStatementType.EventInit:
+                                               case SqlStatementType.EventWait:
+                                               case SqlStatementType.Execute:
+                                               case SqlStatementType.ExecuteImmediate:
+                                                       this.ProvideCommand().CommandText =     sqlStatement;
+
+                                                       // raise the event
+                                                       this.OnCommandExecuting(this.sqlCommand);
+
+                                                       rowsAffected = this.ExecuteCommand(this.sqlCommand,     autoCommit);
+                                                       this.requiresNewConnection = false;
+
+                                                       // raise the event
+                                                       this.OnCommandExecuted(sqlStatement, null, rowsAffected);
+                                                       break;
+
+                                               case SqlStatementType.ExecuteProcedure:
+                                               case SqlStatementType.Fetch:
+                                                       break;
+
+                                               case SqlStatementType.Grant:
+                                               case SqlStatementType.Insert:
+                                               case SqlStatementType.InsertCursor:
+                                               case SqlStatementType.Open:
+                                               case SqlStatementType.Prepare:
+                                               case SqlStatementType.Revoke:
+                                                       // raise the event
+                                                       this.OnCommandExecuting(this.sqlCommand);
+
+                                                       rowsAffected = this.ExecuteCommand(this.sqlCommand,     autoCommit);
+                                                       this.requiresNewConnection = false;
+
+                                                       // raise the event
+                                                       this.OnCommandExecuted(sqlStatement, null, rowsAffected);
+                                                       break;
+
+                                               case SqlStatementType.Rollback:
+                                                       // raise the event
+                                                       this.OnCommandExecuting(null);
+
+                                                       this.sqlTransaction.Rollback();
+                                                       this.sqlTransaction     = null;
+                                                       
+                                                       // raise the event
+                                                       this.OnCommandExecuted(sqlStatement, null, -1);
+                                                       break;
+
+                                               case SqlStatementType.Select:
+                                                       this.ProvideCommand().CommandText =     sqlStatement;
+
+                                                       // raise the event
+                                                       this.OnCommandExecuting(this.sqlCommand);
+
+                                                       dataReader = this.sqlCommand.ExecuteReader();
+                                                       this.requiresNewConnection = false;
+
+                                                       // raise the event
+                                                       this.OnCommandExecuted(sqlStatement, dataReader, -1);
+                                                       if (!dataReader.IsClosed)
+                                                       {
+                                                               dataReader.Close();
+                                                       }
+                                                       break;
+
+                                               case SqlStatementType.SetDatabase:
+                                               case SqlStatementType.SetGenerator:     
+                                               case SqlStatementType.SetNames:
+                                               case SqlStatementType.SetSQLDialect:
+                                               case SqlStatementType.SetStatistics:
+                                               case SqlStatementType.SetTransaction:
+                                               case SqlStatementType.ShowSQLDialect:
+#if    (!NETCF)
+                                                       throw new NotImplementedException();
+#else
+                                                       throw new NotSupportedException();
+#endif
+                                                       
+                                               case SqlStatementType.Update:
+                                               case SqlStatementType.Whenever:
+                                                       // raise the event
+                                                       this.OnCommandExecuting(this.sqlCommand);
+
+                                                       rowsAffected = this.ExecuteCommand(this.sqlCommand,     autoCommit);
+                                                       this.requiresNewConnection = false;
+
+                                                       // raise the event
+                                                       this.OnCommandExecuted(sqlStatement, null, rowsAffected);
+                                                       break;
+                                       }
+                               }
+                               catch (Exception ex)
+                               {
+                                       if (this.sqlTransaction != null)
+                                       {
+                                               this.sqlTransaction.Rollback();
+                                               this.sqlTransaction     = null;
+                                       }
+
+                                       throw new FbException(String.Format(CultureInfo.CurrentUICulture, "An exception was     thrown when     executing command: {0}\nBatch execution aborted\nThe returned message was: {1}", sqlStatement, ex.Message));
+                               }
+                       }
+
+                       if (this.sqlTransaction != null)
+                       {
+                               // commit root transaction
+                               this.sqlTransaction.Commit();
+                               this.sqlTransaction     = null;
+                       }
+
+                       this.sqlConnection.Close();
+               }
+
+               
+               #endregion
+
+               #region Protected Internal Methods
+
+               ///     <summary>
+               ///     Updates the     connection string with the data parsed from     the     parameter and opens     a connection
+               ///     to the database.
+               ///     </summary>
+               ///     <param name="connectDbStatement"></param>
+               protected internal void ConnectToDatabase(string connectDbStatement)
+               {
+                       // CONNECT 'filespec' [USER     'username'][PASSWORD 'password'] [CACHE int] [ROLE 'rolename']
+                       StringParser parser     = new StringParser(connectDbStatement, false);
+                       parser.Token = " ";
+                       parser.ParseNext();
+                       if (parser.Result.Trim().ToUpper(CultureInfo.CurrentUICulture) != "CONNECT")
+                       {
+                               throw new Exception("Malformed isql     CONNECT statement. Expected     keyword CONNECT but     something else was found.");
+                       }
+                       parser.ParseNext();
+                       this.connectionString.Database = parser.Result.Replace("'",     "");
+                       while (parser.ParseNext() != -1)
+                       {
+                               switch (parser.Result.Trim().ToUpper(CultureInfo.CurrentUICulture))
+                               {
+                                       case "USER":
+                                               parser.ParseNext();
+                                               this.connectionString.UserID = parser.Result.Replace("'", "");
+                                               break;
+
+                                       case "PASSWORD":
+                                               parser.ParseNext();
+                                               this.connectionString.Password = parser.Result.Replace("'",     "");
+                                               break;
+
+                                       case "CACHE":
+                                               parser.ParseNext();
+                                               break;
+
+                                       case "ROLE":
+                                               parser.ParseNext();
+                                               this.connectionString.Role = parser.Result.Replace("'", "");
+                                               break;
+
+                                       default:
+                                               throw new Exception("Unexpected token '" + parser.Result.Trim() + "' on isql CONNECT statement.");
+                       
+                               }
+                       }
+                       this.requiresNewConnection = true;
+                       this.ProvideConnection();                                       
+               }
+
+               ///     <summary>
+               ///     Parses the isql statement CREATE DATABASE and creates the database and opens a connection to the recently created database.
+               ///     </summary>
+               ///     <param name="createDbStatement">the     create database statement.</param>
+               protected internal void CreateDatabase(string createDbStatement)
+               {
+                       // CREATE {DATABASE     | SCHEMA} 'filespec'
+                       // [USER 'username'     [PASSWORD 'password']]
+                       // [PAGE_SIZE [=] int]
+                       // [LENGTH [=] int [PAGE[S]]]
+                       // [DEFAULT     CHARACTER SET charset]
+                       // [<secondary_file>];  
+#if    (!NETCF)
+                       throw new NotImplementedException();
+#else
+                       throw new NotSupportedException();
+#endif
+               }
+
+               ///     <summary>
+               ///     
+               ///     </summary>
+               ///     <returns></returns>
+               protected internal FbConnection SetDatabase(string setDbStatement)
+               {
+#if    (!NETCF)
+                       throw new NotImplementedException();
+#else
+                       throw new NotSupportedException();
+#endif
+               }
+               
+               ///     <summary>
+               ///     
+               ///     </summary>
+               ///     <returns></returns>
+               protected internal FbCommand ProvideCommand()
+               {
+                       if (this.sqlCommand     == null)
+                       {
+                               this.sqlCommand = new FbCommand();
+                       }
+                       // this.sqlCommand.Transaction = ProvideTransaction();
+                       this.sqlCommand.Connection      = this.ProvideConnection();
+
+                       return this.sqlCommand;
+               }
+               
+               ///     <summary>
+               ///     
+               ///     </summary>
+               ///     <returns></returns>
+               protected internal FbConnection ProvideConnection()
+               {
+                       if (requiresNewConnection)
+                       {
+                               if ((this.sqlConnection != null) ||
+                                       (this.sqlConnection.State != ConnectionState.Closed) ||
+                                       (this.sqlConnection.State != ConnectionState.Broken))
+                               {
+                                       this.sqlConnection.Close();
+                               }
+                               this.sqlConnection = new FbConnection(this.connectionString.ToString());        
+                       }
+
+                       if (this.sqlConnection.State == ConnectionState.Closed)
+                       {
+                               this.sqlConnection.Open();
+                       }
+
+                       return this.sqlConnection;
+               }
+
+               ///     <summary>
+               ///     Executes a command and optionally commits the transaction.
+               ///     </summary>
+               ///     <param name="command">Command to execute.</param>
+               ///     <param name="autocommit">true to commit the     transaction     after execution; or     false if not.</param>
+               ///     <returns>The number     of rows affected by     the     query execution.</returns>
+               protected internal int ExecuteCommand(FbCommand command, bool autocommit)
+               {
+                       int     rowsAffected = command.ExecuteNonQuery();
+                       if (autocommit && command.IsDDLCommand())
+                       {
+                               command.Transaction.CommitRetaining();
+                       }
+
+                       return rowsAffected;
+               }
+
+               /*
+               ///     <summary>
+               ///     Changes the     <see cref="FbConnection.ConnectionString"/>     of the current (not     open) Firebird connection.
+               ///     </summary>
+               ///     <param name="sqlDialectStatement">The SET SQL Dialect statement.</param>
+               ///     <remarks>This method expects the FB     Connection in Closed state.</remarks>
+               protected internal void SetSqlDialect(string sqlDialectStatement)
+               {
+                       if (sqlConnection.State != ConnectionState.Closed)
+                       {
+                               throw new Exception("Attempting to set an SQL dialect for the database while the connection     is not closed.");
+                       }
+                       if (connectionString == null)
+                       {
+                               throw new Exception("Cannot     execute the     statement SET SQL DIALECT because you already provied an instance of FbConnection");
+                       }
+                       try
+                       {
+                               connectionString.Load(sqlConnection.ConnectionString);
+                       }
+                       catch (Exception)
+                       {
+                               sqlConnection.ConnectionString = "";
+                       }
+
+                       StringParser parser     = new StringParser(sqlDialectStatement, false);
+                       parser.Token = " ";
+                       parser.ParseNext();                                                                                     
+                       if (parser.Result.ToUpper().CompareTo("SET") != 0)
+                               throw new Exception("Expected the keyword SET but something     else was found.");
+                       parser.ParseNext();
+                       if (parser.Result.ToUpper().CompareTo("SQL") != 0)
+                               throw new Exception("Expected the keyword SQL but something     else was found.");
+                       parser.ParseNext();
+                       if (parser.Result.ToUpper().CompareTo("DIALECT") !=     0)
+                               throw new Exception("Expected the keyword DIALECT but something else was found.");
+                       parser.ParseNext();
+                       int     i =     int.Parse(parser.Result);
+                       if ((i < 0)     || (i > 3))
+                               throw new Exception("Invalid sql dialect. Available     dialects are: 1, 2 and 3");
+                       
+                       this.attachParams.Dialect =     i;
+               }
+               protected internal FbTransaction ProvideTransaction()
+               {
+                       if (this.requiresNewTransaction)
+                       {
+                               this.sqlTransaction     = sqlConnection.BeginTransaction();
+                       }
+                       return this.sqlTransaction;
+               }
+               */
+
+               #endregion
+
+               #region Event Handlers
+
+               ///     <summary>
+               ///     The     trigger function for <see cref="CommandExecuting"/>     event.
+               ///     </summary>
+               ///     <param name="sqlCommand">The SQL command that is going for execution.</param>
+               protected virtual void OnCommandExecuting(FbCommand     sqlCommand)
+               {
+                       if (CommandExecuting != null)
+                       {
+                               CommandExecutingEventArgs e     = new CommandExecutingEventArgs(sqlCommand);
+                               CommandExecuting(this, e);
+                       }
+               }
+
+               ///     <summary>
+               ///     The     trigger function for <see cref="CommandExecuted"/> event.
+               ///     </summary>
+               ///     <param name="commandText">The <see cref="FbCommand.CommandText"/> of the executed SQL command.</param>
+               ///     <param name="dataReader">The <see cref="FbDataReader"/> instance with the returned data. If     the     
+               ///     command executed is     not     meant to return data (ex: UPDATE, INSERT...) this parameter     must be 
+               ///     setled to <b>null</b>.</param>
+               ///     <param name="rowsAffected">The rows     that were affected by the executed SQL command. If the executed 
+               ///     command is not meant to return this     kind of information     (ex: SELECT) this parameter     must 
+               ///     be setled to <b>-1</b>.</param>
+               protected virtual void OnCommandExecuted(string commandText, FbDataReader dataReader, int rowsAffected) 
+               {
+                       if (CommandExecuted     != null) 
+                       {
+                               CommandExecutedEventArgs e = new CommandExecutedEventArgs(dataReader, commandText, rowsAffected);
+                               CommandExecuted(this, e);
+                       }
+               }
+
+               #endregion
+
+               #region Static Methods
+
+               ///     <summary>
+               ///     Determines the <see     cref="SqlStatementType"/> of the provided SQL statement.
+               ///     </summary>
+               ///     <param name="sqlStatement">The string containing the SQL statement.</param>
+               ///     <returns>The <see cref="SqlStatementType"/>     of the <b>sqlStatement</b>.</returns>
+               ///     <remarks>If     the     type of <b>sqlStatement</b>     could not be determinated this 
+               ///     method will     throw an exception.</remarks>
+               public static SqlStatementType GetStatementType(string sqlStatement) 
+               {
+                       char type =     sqlStatement == null ? ' ' : sqlStatement.Trim().ToUpper(CultureInfo.CurrentUICulture)[0];
+
+                       switch (type)
+                       {
+                               case 'A':
+                                       if (StringParser.StartsWith(sqlStatement, "ALTER DATABASE",     true))
+                                               return SqlStatementType.AlterDatabase;
+                                       if (StringParser.StartsWith(sqlStatement, "ALTER DOMAIN", true))
+                                               return SqlStatementType.AlterDomain;
+                                       if (StringParser.StartsWith(sqlStatement, "ALTER EXCEPTION", true))
+                                               return SqlStatementType.AlterException;
+                                       if (StringParser.StartsWith(sqlStatement, "ALTER INDEX", true))
+                                               return SqlStatementType.AlterIndex;
+                                       if (StringParser.StartsWith(sqlStatement, "ALTER PROCEDURE", true))
+                                               return SqlStatementType.AlterProcedure;
+                                       if (StringParser.StartsWith(sqlStatement, "ALTER TABLE", true))
+                                               return SqlStatementType.AlterTable;
+                                       if (StringParser.StartsWith(sqlStatement, "ALTER TRIGGER", true))
+                                               return SqlStatementType.AlterTrigger;
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+
+                               case 'C':
+                               switch (char.ToUpper(sqlStatement[1], CultureInfo.CurrentUICulture)) 
+                               {
+                                       case 'L':
+                                               if (StringParser.StartsWith(sqlStatement, "CLOSE", true))
+                                                       return SqlStatementType.Close;
+                                               throw new Exception("The type of the SQL statement could not be determinated.");
+
+                                       case 'O':
+                                               if (StringParser.StartsWith(sqlStatement, "COMMIT",     true))
+                                                       return SqlStatementType.Commit;
+                                               if (StringParser.StartsWith(sqlStatement, "CONNECT", true))
+                                                       return SqlStatementType.Connect;
+                                               throw new Exception("The type of the SQL statement could not be determinated.");
+
+                                       case 'R':
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE DATABASE", true))
+                                                       return SqlStatementType.CreateDatabase;
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE DOMAIN", true))
+                                                       return SqlStatementType.CreateDomain;
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE EXCEPTION", true))
+                                                       return SqlStatementType.CreateException;
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE GENERATOR", true))
+                                                       return SqlStatementType.CreateGenerator;
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE INDEX", true))
+                                                       return SqlStatementType.CreateIndex;
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE PROCEDURE", true))
+                                                       return SqlStatementType.CreateProcedure;
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE ROLE", true))
+                                                       return SqlStatementType.CreateRole;
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE SHADOW", true))
+                                                       return SqlStatementType.CreateShadow;
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE TABLE", true))
+                                                       return SqlStatementType.CreateTable;
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE TRIGGER",     true))
+                                                       return SqlStatementType.CreateTrigger;
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE UNIQUE INDEX", true))
+                                                       return SqlStatementType.CreateIndex;
+                                               if (StringParser.StartsWith(sqlStatement, "CREATE VIEW", true))
+                                                       return SqlStatementType.CreateView;
+                                               throw new Exception("The type of the SQL statement could not be determinated.");
+
+                                       default:
+                                               throw new Exception("The type of the SQL statement could not be determinated.");
+                               }
+                                       
+                               case 'D':
+                               switch (char.ToUpper(sqlStatement[1], CultureInfo.CurrentUICulture)) 
+                               {
+                                       case 'E':
+                                               if (StringParser.StartsWith(sqlStatement, "DECLARE CURSOR",     true))
+                                                       return SqlStatementType.DeclareCursor;
+                                               if (StringParser.StartsWith(sqlStatement, "DECLARE EXTERNAL     FUNCTION", true))
+                                                       return SqlStatementType.DeclareExternalFunction;
+                                               if (StringParser.StartsWith(sqlStatement, "DECLARE FILTER",     true))
+                                                       return SqlStatementType.DeclareFilter;
+                                               if (StringParser.StartsWith(sqlStatement, "DECLARE STATEMENT", true))
+                                                       return SqlStatementType.DeclareStatement;
+                                               if (StringParser.StartsWith(sqlStatement, "DECLARE TABLE", true))
+                                                       return SqlStatementType.DeclareTable;
+                                               if (StringParser.StartsWith(sqlStatement, "DELETE",     true))
+                                                       return SqlStatementType.Delete;
+                                               if (StringParser.StartsWith(sqlStatement, "DESCRIBE", true))
+                                                       return SqlStatementType.Describe;
+                                               throw new Exception("The type of the SQL statement could not be determinated.");
+
+                                       case 'I':
+                                               if (StringParser.StartsWith(sqlStatement, "DISCONNECT", true))
+                                                       return SqlStatementType.Disconnect;
+                                               throw new Exception("The type of the SQL statement could not be determinated.");
+
+                                       case 'R':
+                                               if (StringParser.StartsWith(sqlStatement, "DROP DATABASE", true))
+                                                       return SqlStatementType.DropDatabase;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP DOMAIN", true))
+                                                       return SqlStatementType.DropDomain;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP EXCEPTION",     true))
+                                                       return SqlStatementType.DropException;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP EXTERNAL FUNCTION",     true))
+                                                       return SqlStatementType.DropExternalFunction;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP FILTER", true))
+                                                       return SqlStatementType.DropFilter;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP GENERATOR",     true))
+                                                       return SqlStatementType.DropGenerator;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP INDEX", true))
+                                                       return SqlStatementType.DropIndex;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP PROCEDURE",     true))
+                                                       return SqlStatementType.DropProcedure;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP ROLE", true))
+                                                       return SqlStatementType.DropRole;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP SHADOW", true))
+                                                       return SqlStatementType.DropShadow;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP TABLE", true))
+                                                       return SqlStatementType.DropTable;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP TRIGGER", true))
+                                                       return SqlStatementType.DropTrigger;
+                                               if (StringParser.StartsWith(sqlStatement, "DROP VIEW", true))
+                                                       return SqlStatementType.DropView;
+                                               throw new Exception("The type of the SQL statement could not be determinated.");
+
+                                       default:
+                                               throw new Exception("The type of the SQL statement could not be determinated.");
+                               }
+                               
+                               case 'E':
+                                       if (StringParser.StartsWith(sqlStatement, "EXECUTE PROCEDURE", true))
+                                               return SqlStatementType.ExecuteProcedure;
+                                       if (StringParser.StartsWith(sqlStatement, "EXECUTE IMMEDIATE", true))
+                                               return SqlStatementType.ExecuteImmediate;
+                                       if (StringParser.StartsWith(sqlStatement, "EXECUTE", true))
+                                               return SqlStatementType.Execute;
+                                       if (StringParser.StartsWith(sqlStatement, "EVENT WAIT", true))
+                                               return SqlStatementType.EventWait;
+                                       if (StringParser.StartsWith(sqlStatement, "EVENT INIT", true))
+                                               return SqlStatementType.EventInit;
+                                       if (StringParser.StartsWith(sqlStatement, "END DECLARE SECTION", true))
+                                               return SqlStatementType.EndDeclareSection;
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+
+                               case 'F':
+                                       if (StringParser.StartsWith(sqlStatement, "FETCH", true))
+                                               return SqlStatementType.Fetch;
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+
+                               case 'G':
+                                       if (StringParser.StartsWith(sqlStatement, "GRANT", true))
+                                               return SqlStatementType.Grant;
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+
+                               case 'I':
+                                       if (StringParser.StartsWith(sqlStatement, "INSERT CURSOR", true))
+                                               return SqlStatementType.InsertCursor;
+                                       if (StringParser.StartsWith(sqlStatement, "INSERT",     true))
+                                               return SqlStatementType.Insert;
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+
+                               case 'O':
+                                       if (StringParser.StartsWith(sqlStatement, "OPEN", true))
+                                               return SqlStatementType.Open;
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+
+                               case 'P':
+                                       if (StringParser.StartsWith(sqlStatement, "PREPARE", true))
+                                               return SqlStatementType.Prepare;
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+
+                               case 'R':
+                                       if (StringParser.StartsWith(sqlStatement, "REVOKE",     true))
+                                               return SqlStatementType.Revoke;
+                                       if (StringParser.StartsWith(sqlStatement, "ROLLBACK", true))
+                                               return SqlStatementType.Rollback;
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+
+                               case 'S':                                                               
+                                       if (StringParser.StartsWith(sqlStatement, "SELECT",     true))
+                                               return SqlStatementType.Select;
+                                       if (StringParser.StartsWith(sqlStatement, "SET DATABASE", true))
+                                               return SqlStatementType.SetDatabase;
+                                       if (StringParser.StartsWith(sqlStatement, "SET GENERATOR", true))
+                                               return SqlStatementType.SetGenerator;
+                                       if (StringParser.StartsWith(sqlStatement, "SET NAMES", true))
+                                               return SqlStatementType.SetGenerator;
+                                       if (StringParser.StartsWith(sqlStatement, "SET SQL DIALECT", true))
+                                               return SqlStatementType.SetSQLDialect;
+                                       if (StringParser.StartsWith(sqlStatement, "SET STATISTICS",     true))
+                                               return SqlStatementType.SetStatistics;
+                                       if (StringParser.StartsWith(sqlStatement, "SET TRANSACTION", true))
+                                               return SqlStatementType.SetTransaction;
+                                       if (StringParser.StartsWith(sqlStatement, "SHOW SQL     DIALECT", true))
+                                               return SqlStatementType.ShowSQLDialect;
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+
+                               case 'U':
+                                       if (StringParser.StartsWith(sqlStatement, "UPDATE",     true))
+                                               return SqlStatementType.Update;
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+
+                               case 'W':
+                                       if (StringParser.StartsWith(sqlStatement, "WHENEVER", true))
+                                               return SqlStatementType.Whenever;
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+
+                               default:
+                                       throw new Exception("The type of the SQL statement could not be determinated.");
+                       }
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/FbScript.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/FbScript.cs
new file mode 100644 (file)
index 0000000..023f401
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2003,     2004 Abel Eduardo Pereira
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using System.Text;
+using System.Collections.Specialized;
+
+namespace FirebirdSql.Data.Firebird.Isql
+{
+       ///     <summary>
+       ///     FbScript parses a SQL file and returns its SQL statements. 
+       ///     The     class take in consideration     that the statement separator can change in code. 
+       ///     For     instance, in Firebird databases the     statement <c>SET TERM !! ;</c> will     change the
+       ///     statement token terminator <b>;</b>     into <b>!!</b>.
+       ///     </summary>
+       public class FbScript
+       {
+               #region Fields
+
+               private StringParser            parser;
+               private StringCollection        results;
+
+               #endregion      
+
+               #region Properties
+
+               ///     <summary>
+               ///     Returns a StringCollection containing all the SQL statements (without comments) present on the file.
+               ///     This property is loaded after the method call <see cref="Parse"/>.
+               ///     </summary>
+               public StringCollection Results
+               {
+                       get     { return this.results; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <summary>
+               ///     Creates an instance     of FbScript     class.
+               ///     </summary>
+               ///     <param name="sqlFilename">The filename for the SQL file.</param>
+               public FbScript(string sqlFilename)
+               {
+                       this.parser     = new StringParser(RemoveComments(File.OpenText(sqlFilename).ReadToEnd()), false);
+                       this.parser.Token =     ";";
+                       this.results = new StringCollection();
+               }
+
+               ///     <summary>
+               ///     Creates an instance     of FbScript     class.
+               ///     </summary>
+               ///     <param name="sqlCode">A <see cref="TextReader"/> instance.</param>
+               ///     <remarks>The all data in <see cref="TextReader"/> is read.</remarks>
+               public FbScript(TextReader sqlCode)     
+               {
+                       this.parser     = new StringParser(RemoveComments(sqlCode.ReadToEnd()), false);
+                       this.parser.Token =     ";";
+                       this.results = new StringCollection();
+               }
+               
+               #endregion
+
+               #region Methods
+
+               ///     <summary>
+               ///     Parses the SQL code     and     loads the SQL statements into the StringCollection <see cref="Results"/>.
+               ///     </summary>
+               ///     <returns>The number     of statements found.</returns>
+               public int Parse() 
+               {
+                       int             index = 0;
+                       string  atomicResult;
+                       string  newParserToken;
+
+                       this.results.Clear();
+                       while (index < this.parser.Length) 
+                       {
+                               index = this.parser.ParseNext();
+                               atomicResult = this.parser.Result.Trim();
+                               if (this.isSetTermStatement(atomicResult, out newParserToken)) 
+                               {
+                                       this.parser.Token =     newParserToken;
+                                       continue;
+                               }
+                               
+                               if (atomicResult !=     null && atomicResult.Length     > 0)
+                               {
+                                       this.results.Add(atomicResult);
+                               }
+                       }
+
+                       return this.results.Count;
+               }
+
+               ///     <summary>
+               ///     Overrided method, returns the the SQL code to be parsed (with comments removed).
+               ///     </summary>
+               ///     <returns>The SQL code to be     parsed (without comments).</returns>
+               public override string ToString() 
+               {
+                       return this.parser.ToString();
+               }
+
+               #endregion
+
+               #region Protected Static Methods
+
+               ///     <summary>
+               ///     Removes from the SQL code all comments of the type:     /*...*/ or --
+               ///     </summary>
+               ///     <param name="source">The string containing the original SQL     code.</param>
+               ///     <returns>A string containing the SQL code without comments.</returns>
+               protected static string RemoveComments(string source)
+               {
+                       int     i =     0;
+                       int     length                  = source.Length;
+                       bool insideComment      = false;
+                       bool insideString       = false;
+
+                       StringBuilder result = new StringBuilder();
+
+                       while (i < length)
+                       {
+                               if (insideComment)
+                               {
+                                       if (source[i] == '*')
+                                       {
+                                               if ((i < length - 1) && (source[i +     1] == '/'))
+                                               {
+                                                       i++;
+                                                       insideComment = false;
+                                               }
+                                       }
+                               }
+                               else if (insideString)
+                               {
+                                       if (source[i] == '\'')
+                                       {
+                                               insideString = false;
+                                       }
+                               }
+                               else
+                               {
+                                       if (source[i] == '\'')
+                                       {
+                                               insideString = true;
+                                       }
+                                       else if (source[i] == '/' || (source[i] == '-' && ((i < length - 1)     && source[i     + 1] == '-')))
+                                       {
+                                               switch (source[i])
+                                               {
+                                                       case '/':
+                                                               if ((i < length - 1) && (source[i +     1] == '*'))
+                                                               {
+                                                                       i++;
+                                                                       insideComment = true;
+                                                               }
+                                                               break;
+
+                                                       case '-':
+                                                               if ((i < length - 1) && (source[i +     1] == '-'))
+                                                               {
+                                                                       i++;
+                                                                       while (source[i] !=     '\n')
+                                                                               i++;
+                                                                       i--;
+                                                               }
+                                                               break;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               result.Append(source[i]);
+                                       }
+                               }
+
+                               i++;
+                       }
+
+                       return result.ToString();
+               }
+               #endregion
+
+               #region Private Methods
+       
+               // method assumes that statement is     trimmed 
+               private bool isSetTermStatement(string statement, out string newTerm) 
+               {
+                       bool result     = false;
+
+                       newTerm = "";
+                       if (StringParser.StartsWith(statement, "SET     TERM", true)) 
+                       {
+                               newTerm = statement.Substring(8).Trim();
+                               result = true;
+                       }
+
+                       return result;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/StringParser.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/StringParser.cs
new file mode 100644 (file)
index 0000000..4195f4b
--- /dev/null
@@ -0,0 +1,379 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2003,     2004 Abel Eduardo Pereira
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Firebird.Isql
+{
+       ///     <summary>
+       ///     StringParser parses     a string returnning     the     (sub)strings between tokens.
+       ///     </summary>
+       ///     <example>
+       ///     An example of how to use this class.
+       ///     <code>
+       ///     [STAThread]
+       ///     static void     Main(string[] args)     {
+       ///             int     currentIndex = 0;
+       ///             string s = ".NET Framework doesn't have a string parsing class?!";
+       ///             StringParser parser     = new StringParser(s, false);                   
+       ///             while (currentIndex     &lt; s.Length) {
+       ///                     Console.WriteLine("Returned     Index: {0}", currentIndex =     parser.ParseNext());
+       ///                     Console.WriteLine("Chars scanned: {0}", parser.CharsParsed);
+       ///                     Console.WriteLine("Parsing result: {0}\n", parser.Result);
+       ///             }
+       ///     }
+       ///     </code>
+       ///     <para>The output:</para>
+       ///     <code>
+       ///     Returned Index: 5
+       ///     Chars scanned: 5
+       ///     Parsing result: .NET
+       ///
+       ///     Returned Index: 15
+       ///     Chars scanned: 10
+       ///     Parsing result: Framework
+       ///
+       ///     Returned Index: 23
+       ///     Chars scanned: 8
+       ///     Parsing result: doesn't
+       ///
+       ///     Returned Index: 28
+       ///     Chars scanned: 5
+       ///     Parsing result: have
+       ///
+       ///     Returned Index: 30
+       ///     Chars scanned: 2
+       ///     Parsing result: a
+       ///
+       ///     Returned Index: 37
+       ///     Chars scanned: 7
+       ///     Parsing result: string
+       ///
+       ///     Returned Index: 45
+       ///     Chars scanned: 8
+       ///     Parsing result: parsing
+       ///
+       ///     Returned Index: 52
+       ///     Chars scanned: 7
+       ///     Parsing result: class?!
+       ///     </code>
+       ///     </example>
+       public class StringParser 
+       {
+               #region Fields
+
+               private int             charsParsed;
+               private string  source;
+               private string  token;
+               private int             currentIndex;
+               private bool    caseSensitive;
+               private int             sourceLength;
+               private string  result;
+               private int             tokenLength;
+               
+               #endregion
+
+               #region Properties
+
+               ///     <summary>
+               ///     Loaded after a parsing operation with the number of     chars parsed.
+               ///     </summary>
+               public int CharsParsed 
+               {
+                       get     { return this.charsParsed; }
+               }
+
+               ///     <summary>
+               ///     Loaded after a parsing operation with the string that was found between tokens.
+               ///     </summary>
+               public string Result 
+               {
+                       get     { return this.result; }
+               }
+
+               ///     <summary>
+               ///     The     string separator. The default value     is a white space: 0x32 ASCII code.
+               ///     </summary>
+               public string Token     
+               {
+                       get     { return this.token; }
+                       set
+                       {
+                               if (value == null || value.Length == 0) 
+                               {
+                                       throw new Exception("Token is empty!");
+                               }
+                               this.token = value;
+                               this.tokenLength = this.token.Length;
+                       }
+               }
+
+               ///     <summary>
+               ///     Returns the     length of the string that is being parsed.
+               ///     </summary>
+               public int Length 
+               {
+                       get      { return this.sourceLength; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <summary>
+               ///     Creates an instance     of StringParser.
+               ///     </summary>
+               ///     <param name="caseSensitive">Indicates if parser system should be case-sensitive (true) or case-intensitive (false).</param>
+               public StringParser(bool caseSensitive) 
+               {
+                       this.caseSensitive      = caseSensitive;
+                       this.token                      = "     ";
+                       this.tokenLength        = this.token.Length;
+               }
+
+               ///     <summary>
+               ///     Creates an instance     of StringParser.
+               ///     </summary>
+               ///     <param name="targetString">Indicates if parser system should be case-sensitive (true) or case-intensitive (false).</param>
+               ///     <param name="caseSensitive">The string to parse.</param>
+               ///     <remarks>By     defining the string     (to     parse) in constructor you can call directly     the     method <see     cref="ParseNext"/>
+               ///     without having to initializate the target string on     <see cref="Parse(System.String)"/> method. See the example for further details.
+               ///     </remarks>
+               public StringParser(string targetString, bool caseSensitive) 
+               {
+                       this.caseSensitive      = caseSensitive;
+                       this.token                      = "     ";
+                       this.tokenLength        = this.token.Length;
+                       this.source                     = targetString;
+                       this.sourceLength       = targetString.Length;
+               }
+
+               #endregion
+
+               #region Methods
+               
+               ///     <summary>
+               ///     Parses target string attempting to determine the (sub)string between the beginning of this string and the <see cref="Token"/>.
+               ///     After the parse is complete     system will     load into <see cref="CharsParsed"/>     then number     of chars scanned and into <see cref="Result"/>
+               ///     the     string that     was     found.
+               ///     </summary>
+               ///     <param name="targetString">The string to be     parsed.</param>
+               ///     <returns>The index of the char next     char after the <see     cref="Token"/> end.</returns>
+               ///     <remarks>If     nothing is parsed the method will return -1. Case the <see cref="Token"/> wasn't found until the end of the     string the method retuns 
+               ///     (in     <see cref="Result"/>) the string found between the starting     index and the end of the string. </remarks>
+               public int Parse(string targetString) 
+               {
+                       return Parse(targetString, 0);
+               }
+
+               ///     <summary>
+               ///     Parses target string attempting to determine the (sub)string between the index <b>start</b>     of this string and the <see     cref="Token"/>.
+               ///     After the parse is complete     system will     load into <see cref="CharsParsed"/>     then number     of chars scanned and into <see cref="Result"/>
+               ///     the     string that     was     found.
+               ///     </summary>
+               ///     <param name="targetString">The string to be     parsed.</param>
+               ///     <param name="start">The start index     for     parsing purposes.</param>
+               ///     <returns>The index of the char next     char after the <c>Token</c>     end.</returns>
+               ///     <remarks>If     nothing is parsed the method will return -1. Case the <see cref="Token"/> wasn't found until the end of the     string the method returns 
+               ///     (in     <see cref="Result"/>) the string found between the starting     index and the end of the string. </remarks>
+               public int Parse(string targetString, int start) 
+               {
+                       this.sourceLength =     targetString.Length;
+                       
+                       if (start >= this.sourceLength) 
+                       {
+                               throw new Exception("Cannot     start parsing after     the     end     of the string.");
+                       }
+                       
+                       this.source     = targetString;
+                       
+                       int     i =     start;
+                       while (i < this.sourceLength) 
+                       {
+                               if (string.Compare(this.source[i].ToString(), this.token[0].ToString(), !this.caseSensitive, CultureInfo.CurrentUICulture) == 0) 
+                               {
+                                       if (string.Compare(this.source.Substring(i,     this.tokenLength), this.token, !this.caseSensitive,     CultureInfo.CurrentUICulture) == 0)     
+                                       {
+                                               i += this.tokenLength; 
+                                               break;
+                                       }
+                               }
+                               i++;
+                       }
+                       
+                       this.currentIndex =     i;
+                       if (this.currentIndex != this.sourceLength)     
+                       {
+                               this.charsParsed = this.currentIndex - start;
+                               this.result     = this.source.Substring(start, this.currentIndex - start - this.tokenLength);
+                       }
+                       else 
+                       {
+                               this.charsParsed = this.currentIndex - start;
+                               this.result     = this.source.Substring(start);
+                       }
+
+                       return this.currentIndex;
+               }
+
+               ///     <summary>
+               ///     <para>Repeats the parsing starting on the index returned by     <see cref="Parse(System.String)"/> method.</para>
+               ///     You     can     also call <b>ParseNext</b> directly     (without calling <see cref="Parse(System.String)"/>) if you     define the text to be parsed at instance construction.  
+               ///     </summary>
+               ///     <returns>The index of the char next     char after the <see     cref="Token"/> end.</returns>
+               ///     <remarks>If     nothing is parsed the method will return -1. Case the <see cref="Token"/> wasn't found until the end of the     string the method returns 
+               ///     (in     <see cref="Result"/>) the string found between the starting     index and the end of the string.</remarks>
+               public int ParseNext() 
+               {
+                       if (this.currentIndex >= this.sourceLength)     
+                       {
+                               throw new Exception("Cannot     start parsing after     the     end     of the string.");
+                       }
+                       
+                       int     i =     this.currentIndex;
+                       while (i < this.sourceLength) 
+                       {
+                               if (string.Compare(this.source[i].ToString(), this.token[0].ToString(), !this.caseSensitive, CultureInfo.CurrentUICulture) == 0) 
+                               {
+                                       if (string.Compare(this.source.Substring(i,     this.tokenLength), this.token, !this.caseSensitive,     CultureInfo.CurrentUICulture) == 0)     
+                                       {
+                                               i += this.tokenLength; 
+                                               break;
+                                       }
+                               }
+                               i++;
+                       }
+                       
+                       if (i != this.sourceLength)     
+                       {
+                               this.charsParsed = i - this.currentIndex;
+                               this.result     = this.source.Substring(this.currentIndex, i - this.currentIndex - this.tokenLength);
+                       }
+                       else 
+                       {
+                               this.charsParsed = i - this.currentIndex;
+                               this.result     = this.source.Substring(this.currentIndex);
+                       }
+                       
+                       return this.currentIndex = i;
+               }       
+               
+               ///     <summary>
+               ///     Returns the     index of the substring in the string. If the substring does     not     exists the method returns <b>-1</b>.
+               ///     </summary>
+               ///     <param name="substring">The     string to be located.</param>
+               ///     <returns>The index of the substring     or -1 if the string     does not exists within the source string.
+               ///     If the the substring is empty method returns 0.</returns>
+               ///     <remarks>The instance parses for the substring in a     case sensitive or intensive     way, as you     specify at 
+               ///     class construction.</remarks>
+               public int IndexOf(string substring) 
+               {
+                       return IndexOf(substring, 0);
+               }
+
+               ///     <summary>
+               ///     Returns the     index of the substring in the string starting on index <b>startIndex</b>. 
+               ///     If the substring does not exists the method     returns <b>-1</b>.
+               ///     </summary>
+               ///     <param name="substring">The     string to be located.</param>
+               ///     <param name="startIndex">The start index of     the     source string where     parser will     start.</param>
+               ///     <returns>The index of the substring     or -1 if the string     does not exists within the source string.
+               ///     If the the substring is empty method returns <i>startIndex</i>.</returns>
+               ///     <remarks>The instance parses for the substring in a     case sensitive or intensive     way, as you     specify at 
+               ///     class construction.</remarks>
+               public int IndexOf(string substring, int startIndex)
+               {
+                       if (startIndex >= this.sourceLength)
+                       {
+                               throw new IndexOutOfRangeException("Start index out     of bounds.");
+                       }
+
+                       if (substring == null || substring.Length == 0)
+                       {
+                               return startIndex;
+                       }
+
+                       int     i =     startIndex;
+                       while (i < this.sourceLength) 
+                       {
+                               if (String.Compare(this.source[i].ToString(), substring[0].ToString(), !this.caseSensitive,     CultureInfo.CurrentUICulture) == 0)
+                               {
+                                       if (substring != null && substring.Length == 1)
+                                       {
+                                               return i;
+                                       }
+
+                                       int     j =     i +     1;
+                                       while ((j <     this.sourceLength) && ((j -     i) < substring.Length))
+                                       {
+                                               if (String.Compare(this.source[j].ToString(), substring[j -     i].ToString(), !this.caseSensitive,     CultureInfo.CurrentUICulture) == 0)
+                                               {
+                                                       j++;
+                                               }
+                                               else 
+                                               {
+                                                       break;
+                                               }
+                                       }
+
+                                       if ((j - i)     == substring.Length)
+                                       {
+                                               return i;
+                                       }
+                               }
+
+                               i++;
+                       }
+
+                       return -1;
+               }
+
+               ///     <summary>
+               ///     Overrided method that returns the string to     be parsed.
+               ///     </summary>
+               ///     <returns>The string     to be parsed.</returns>
+               public override string ToString() 
+               {
+                       return this.source;
+               }
+
+               #endregion
+
+               #region Static Methods
+
+               ///     <summary>
+               ///     Indicates if the string specified as <b>source</b> starts with the <b>token</b> string.
+               ///     </summary>
+               ///     <param name="source">The source string.</param>
+               ///     <param name="token">The token that is intended to find.</param>
+               ///     <param name="ignoreCase">Indicated is char case should be ignored.</param>
+               ///     <returns>Returns <b>true</b> if the     <b>token</b> precedes the <b>source</b>.</returns>
+               public static bool StartsWith(string source, string     token, bool     ignoreCase)     
+               {
+                       if (source.Length <     token.Length)
+                       {
+                               return false;
+                       }
+
+                       return string.Compare(token, source.Substring(0, token.Length), ignoreCase,     CultureInfo.CurrentUICulture) == 0;
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackup.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackup.cs
new file mode 100644 (file)
index 0000000..f7c271d
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/class[@name="FbBackup"]/overview/*'/>
+       public sealed class     FbBackup : FbService
+       {
+               #region Fields
+
+               private bool                    verbose;
+               private ArrayList               backupFiles;
+               private int                             factor;
+               private FbBackupFlags   options;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/class[@name="FbBackup"]/property[@name="BackupFiles"]/*'/>
+               public ArrayList BackupFiles
+               {
+                       get     { return this.backupFiles; }
+               }
+
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/class[@name="FbBackup"]/property[@name="Verbose"]/*'/>
+               public bool     Verbose
+               {
+                       get     { return this.verbose; }
+                       set     { this.verbose = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/class[@name="FbBackup"]/property[@name="Factor"]/*'/>
+               public int Factor
+               {
+                       get     { return this.factor; }
+                       set     { this.factor = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/class[@name="FbBackup"]/property[@name="Options"]/*'/>
+               public FbBackupFlags Options
+               {
+                       get     { return this.options; }
+                       set     { this.options = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/class[@name="FbBackup"]/constructor[@name="ctor"]/*'/>
+               public FbBackup() :     base()
+               {
+                       this.backupFiles = new ArrayList();
+               }
+
+               #endregion
+
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/class[@name="FbBackup"]/method[@name="Execute"]/*'/>
+               public void     Execute()
+               {
+                       try
+                       {
+                               // Configure Spb
+                               this.StartSpb = this.CreateParameterBuffer();
+
+                               this.StartSpb.Append(IscCodes.isc_action_svc_backup);
+                               this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+
+                               foreach (FbBackupFile file in backupFiles)
+                               {
+                                       this.StartSpb.Append(IscCodes.isc_spb_bkp_file, file.BackupFile);
+                                       this.StartSpb.Append(IscCodes.isc_spb_bkp_length, file.BackupLength);
+                               }
+
+                               if (verbose)
+                               {
+                                       this.StartSpb.Append(IscCodes.isc_spb_verbose);
+                               }
+
+                               this.StartSpb.Append(IscCodes.isc_spb_options, (int)this.options);
+
+                               // Start execution
+                               this.StartTask();
+
+                               if (this.verbose)
+                               {
+                                       this.ProcessServiceOutput();
+                               }
+                       }
+                       catch
+                       {
+                               throw;
+                       }
+                       finally
+                       {
+                               // Close
+                               this.Close();
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackupFile.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackupFile.cs
new file mode 100644 (file)
index 0000000..d59ffdc
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/struct[@name="FbBackupFile"]/overview/*'/>
+       public struct FbBackupFile
+       {
+               #region Fields
+
+               private string  backupFile;
+               private int             backupLength;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/struct[@name="FbBackupFile"]/property[@name="BackupFile"]/*'/>
+               public string BackupFile
+               {
+                       get     { return this.backupFile; }
+                       set     { this.backupFile =     value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/struct[@name="FbBackupFile"]/property[@name="BackupLength"]/*'/>
+               public int BackupLength
+               {
+                       get     { return this.backupLength;     }
+                       set     { this.backupLength     = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/struct[@name="FbBackupFile"]/constructor[@name="ctor(system.String,System.Int32)"]/*'/>
+               public FbBackupFile(string fileName, int fileLength)
+               {
+                       this.backupFile = fileName;
+                       this.backupLength =     fileLength;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackupFlags.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackupFlags.cs
new file mode 100644 (file)
index 0000000..3cad0be
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/enum[@name="FbBackupFlags"]/overview/*'/>
+       [Flags]
+       public enum     FbBackupFlags
+       {
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/enum[@name="FbBackupFlags"]/field[@name="IgnoreChecksums"]/*'/>
+               IgnoreChecksums         = 0x01,
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/enum[@name="FbBackupFlags"]/field[@name="IgnoreLimbo"]/*'/>
+               IgnoreLimbo                     = 0x02,
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/enum[@name="FbBackupFlags"]/field[@name="MetaDataOnly"]/*'/>
+               MetaDataOnly            = 0x04,
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/enum[@name="FbBackupFlags"]/field[@name="NoGarbageCollect"]/*'/>
+               NoGarbageCollect        = 0x08,
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/enum[@name="FbBackupFlags"]/field[@name="OldDescriptions"]/*'/>
+               OldDescriptions         = 0x10,
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/enum[@name="FbBackupFlags"]/field[@name="NonTransportable"]/*'/>
+               NonTransportable        = 0x20,
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/enum[@name="FbBackupFlags"]/field[@name="Convert"]/*'/>
+               Convert                         = 0x40,
+               ///     <include file='Doc/en_EN/FbBackup.xml' path='doc/enum[@name="FbBackupFlags"]/field[@name="Expand"]/*'/>
+               Expand                          = 0x80
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbConfiguration.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbConfiguration.cs
new file mode 100644 (file)
index 0000000..1671868
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/class[@name="FbConfiguration"]/overview/*'/>
+       public sealed class     FbConfiguration : FbService
+       {
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/class[@name="FbConfiguration"]/constructor[@name="ctor"]/*'/>
+               public FbConfiguration() : base()
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/class[@name="FbConfiguration"]/method[@name="SetSqlDialect(System.Int32)"]/*'/>
+               public void     SetSqlDialect(int sqlDialect)
+               {
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_properties);
+                       this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+                       this.StartSpb.Append(IscCodes.isc_spb_prp_set_sql_dialect, sqlDialect);
+
+                       // Start execution
+                       this.StartTask();
+
+                       this.Close();
+               }
+
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/class[@name="FbConfiguration"]/method[@name="SetSweepInterval(System.Int32)"]/*'/>
+               public void     SetSweepInterval(int sweepInterval)
+               {
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_properties);
+                       this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+                       this.StartSpb.Append(IscCodes.isc_spb_prp_sweep_interval, sweepInterval);
+
+                       // Start execution
+                       this.StartTask();
+
+                       this.Close();
+               }
+
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/class[@name="FbConfiguration"]/method[@name="SetPageBuffers(System.Int32)"]/*'/>
+               public void     SetPageBuffers(int pageBuffers)
+               {
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_properties);
+                       this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+                       this.StartSpb.Append(IscCodes.isc_spb_prp_page_buffers, pageBuffers);
+
+                       // Start execution
+                       this.StartTask();
+
+                       this.Close();
+               }
+
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/class[@name="FbConfiguration"]/method[@name="DatabaseShutdown(FbShutdownMode,System.Int32)"]/*'/>
+               public void     DatabaseShutdown(FbShutdownMode mode, int seconds)
+               {
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_properties);
+                       this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+
+                       switch (mode)
+                       {
+                               case FbShutdownMode.Forced:
+                                       this.StartSpb.Append(IscCodes.isc_spb_prp_shutdown_db, seconds);
+                                       break;
+                               
+                               case FbShutdownMode.DenyTransaction:
+                                       this.StartSpb.Append(
+                                               IscCodes.isc_spb_prp_deny_new_transactions,     seconds);
+                                       break;
+
+                               case FbShutdownMode.DenyConnection:
+                                       this.StartSpb.Append(
+                                               IscCodes.isc_spb_prp_deny_new_attachments, seconds);
+                                       break;
+                       }
+
+                       // Start execution
+                       this.StartTask();
+                       
+                       this.Close();
+               }
+
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/class[@name="FbConfiguration"]/method[@name="DatabaseOnline"]/*'/>
+               public void     DatabaseOnline()
+               {
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_properties);
+                       this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+                       this.StartSpb.Append(IscCodes.isc_spb_options, IscCodes.isc_spb_prp_db_online);
+
+                       // Start execution
+                       this.StartTask();
+                       
+                       this.Close();
+               }
+
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/class[@name="FbConfiguration"]/method[@name="ActivateShadows"]/*'/>
+               public void     ActivateShadows()
+               {
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_properties);
+                       this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+                       this.StartSpb.Append(IscCodes.isc_spb_options, IscCodes.isc_spb_prp_activate);
+
+                       // Start execution
+                       this.StartTask();
+
+                       this.Close();
+               }
+
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/class[@name="FbConfiguration"]/method[@name="SetForcedWrites(System.Boolean)"]/*'/>
+               public void     SetForcedWrites(bool forcedWrites)
+               {
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_properties);
+                       this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+
+                       // WriteMode
+                       if (forcedWrites)
+                       {
+                               this.StartSpb.Append(
+                                       IscCodes.isc_spb_prp_write_mode, (byte)IscCodes.isc_spb_prp_wm_sync);
+                       }
+                       else
+                       {
+                               this.StartSpb.Append(
+                                       IscCodes.isc_spb_prp_write_mode, (byte)IscCodes.isc_spb_prp_wm_async);
+                       }                       
+
+                       // Start execution
+                       this.StartTask();
+                       
+                       this.Close();
+               }
+
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/class[@name="FbConfiguration"]/method[@name="SetReserveSpace(System.Boolean)"]/*'/>
+               public void     SetReserveSpace(bool reserveSpace)
+               {
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_properties);
+                       this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+
+                       // Reserve Space
+                       if (reserveSpace)
+                       {
+                               this.StartSpb.Append(
+                                       IscCodes.isc_spb_prp_reserve_space,     (byte)IscCodes.isc_spb_prp_res);
+                       }
+                       else
+                       {
+                               this.StartSpb.Append(
+                                       IscCodes.isc_spb_prp_reserve_space,     (byte)IscCodes.isc_spb_prp_res_use_full);
+                       }
+
+                       // Start execution
+                       this.StartTask();                       
+                       
+                       this.Close();
+               }
+
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/class[@name="FbConfiguration"]/method[@name="SetAccessMode(System.Boolean)"]/*'/>
+               public void     SetAccessMode(bool readOnly)
+               {
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_properties);
+                       this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+                       
+                       if (readOnly)
+                       {
+                               this.StartSpb.Append(
+                                       IscCodes.isc_spb_prp_access_mode, (byte)IscCodes.isc_spb_prp_am_readonly);
+                       }
+                       else
+                       {
+                               this.StartSpb.Append(
+                                       IscCodes.isc_spb_prp_access_mode, (byte)IscCodes.isc_spb_prp_am_readwrite);
+                       }
+                       
+                       // Start execution
+                       this.StartTask();
+                       
+                       this.Close();
+               }
+               
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbDatabasesInfo.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbDatabasesInfo.cs
new file mode 100644 (file)
index 0000000..c152c34
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections.Specialized;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbDatabasesInfo"]/overview/*'/>
+       public struct FbDatabasesInfo
+       {
+               #region Fields
+
+               private int     connectionCount;
+               private StringCollection databases;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbDatabasesInfo"]/field[@name="ConnectionCount"]/*'/>
+               public int ConnectionCount
+               {
+                       get     { return this.connectionCount; }
+                       set     { this.connectionCount = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbDatabasesInfo"]/field[@name="Databases"]/*'/>
+               public StringCollection Databases
+               {
+                       get
+                       {
+                               if (this.databases == null)
+                               {
+                                       this.databases = new StringCollection();
+                               }
+                               return this.databases;
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbLog.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbLog.cs
new file mode 100644 (file)
index 0000000..0b2daaf
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbLog.xml'     path='doc/class[@name="FbLog"]/overview/*'/>
+       public sealed class     FbLog : FbService
+       {               
+               #region Constructors
+               
+               ///     <include file='Doc/en_EN/FbLog.xml'     path='doc/class[@name="FbLog"]/constructor[@name="ctor"]/*'/>
+               public FbLog() : base()
+               {                       
+               }
+               
+               #endregion
+               
+               #region Methods
+               
+               ///     <include file='Doc/en_EN/FbLog.xml'     path='doc/class[@name="FbLog"]/method[@name="Execute"]/*'/>
+               public void     Execute()
+               {
+                       try
+                       {
+                               // Configure Spb
+                               this.StartSpb = this.CreateParameterBuffer();
+
+                               this.StartSpb.Append(IscCodes.isc_action_svc_get_ib_log);
+                       
+                               // Start execution
+                               this.StartTask();
+
+                               // Process service output
+                               this.ProcessServiceOutput();
+                       }
+                       catch
+                       {
+                               throw;
+                       }
+                       finally
+                       {
+                               this.Close();
+                       }
+
+               }
+               
+               #endregion              
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbRestore.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbRestore.cs
new file mode 100644 (file)
index 0000000..f16744a
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/class[@name="FbRestore"]/overview/*'/>
+       public sealed class     FbRestore :     FbService
+       {
+               #region Fields
+
+               private ArrayList                       backupFiles;
+               private bool                            verbose;
+               private int                                     pageBuffers;
+               private int                                     pageSize;
+               private FbRestoreFlags          options;
+               
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/class[@name="FbRestore"]/property[@name="BackupFiles"]/*'/>
+               public ArrayList BackupFiles
+               {
+                       get     { return this.backupFiles; }
+               }
+
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/class[@name="FbRestore"]/property[@name="Verbose"]/*'/>
+               public bool     Verbose
+               {
+                       get     { return this.verbose; }
+                       set     { this.verbose = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/class[@name="FbRestore"]/property[@name="PageBuffers"]/*'/>
+               public int PageBuffers
+               {
+                       get     { return this.pageBuffers; }
+                       set     { this.pageBuffers = value;     }
+               }
+
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/class[@name="FbRestore"]/property[@name="PageSize"]/*'/>
+               public int PageSize
+               {
+                       get     { return this.pageSize; }
+                       set
+                       {
+                               if (this.pageSize != 1024 && this.pageSize != 2048 && 
+                                       this.pageSize != 4096 && this.pageSize != 8192 && 
+                                       this.pageSize != 16384)
+                               {
+                                       throw new InvalidOperationException("Invalid page size.");
+                               }
+                               this.pageSize = value;
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/class[@name="FbRestore"]/property[@name="Options"]/*'/>
+               public FbRestoreFlags Options
+               {
+                       get     { return this.options; }
+                       set     { this.options = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/class[@name="FbRestore"]/constructor[@name="ctor"]/*'/>
+               public FbRestore() : base()
+               {
+                       this.backupFiles        = new ArrayList();
+                       this.pageSize           = 4096;
+                       this.pageBuffers        = 2048;
+               }
+
+               #endregion
+
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/class[@name="FbRestore"]/method[@name="Execute"]/*'/>
+               public void     Execute()
+               {
+                       try
+                       {
+                               // Configure Spb
+                               this.StartSpb = this.CreateParameterBuffer();
+
+                               this.StartSpb.Append(IscCodes.isc_action_svc_restore);                  
+
+                               foreach(FbBackupFile bkpFile in backupFiles)
+                               {
+                                       this.StartSpb.Append(IscCodes.isc_spb_bkp_file, bkpFile.BackupFile);
+                               }
+
+                               this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+
+                               if (this.verbose)
+                               {
+                                       this.StartSpb.Append(IscCodes.isc_spb_verbose);
+                               }
+                               
+                               this.StartSpb.Append(IscCodes.isc_spb_res_buffers, this.pageBuffers);
+                               this.StartSpb.Append(IscCodes.isc_spb_res_page_size, this.pageSize);
+                               this.StartSpb.Append(IscCodes.isc_spb_options, (int)this.options);
+                       
+                               // Start execution
+                               this.StartTask();
+
+                               if (this.verbose)
+                               {
+                                       this.ProcessServiceOutput();
+                               }
+                       }
+                       catch
+                       {
+                               throw;
+                       }
+                       finally
+                       {
+                               this.Close();
+                       }
+               }
+                               
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbRestoreFlags.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbRestoreFlags.cs
new file mode 100644 (file)
index 0000000..25bd67c
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/enum[@name="FbRestoreFlags"]/overview/*'/>
+       [Flags]
+       public enum     FbRestoreFlags
+       {
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/enum[@name="FbRestoreFlags"]/field[@name="DeactivateIndexes"]/*'/>
+               DeactivateIndexes       = 0x0100,
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/enum[@name="FbRestoreFlags"]/field[@name="NoShadow"]/*'/>
+               NoShadow                        = 0x0200,
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/enum[@name="FbRestoreFlags"]/field[@name="NoValidity"]/*'/>
+               NoValidity                      = 0x0400,
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/enum[@name="FbRestoreFlags"]/field[@name="IndividualCommit"]/*'/>
+               IndividualCommit        = 0x0800,
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/enum[@name="FbRestoreFlags"]/field[@name="Replace"]/*'/>
+               Replace                         = 0x1000,
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/enum[@name="FbRestoreFlags"]/field[@name="Create"]/*'/>
+               Create                          = 0x2000,
+               ///     <include file='Doc/en_EN/FbRestore.xml' path='doc/enum[@name="FbRestoreFlags"]/field[@name="UseAllSpace"]/*'/>
+               UseAllSpace                     = 0x4000
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbSecurity.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbSecurity.cs
new file mode 100644 (file)
index 0000000..fd978d0
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/overview/*'/>
+       public sealed class     FbSecurity : FbService
+       {                               
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/property[@name="UsersDbPath"]/*'/>
+               public string UsersDbPath
+               {
+                       get
+                       {
+                               byte[] buffer = this.QueryService(
+                                       new     byte[] {IscCodes.isc_info_svc_user_dbpath});
+                               System.Collections.ArrayList info =     this.ParseQueryInfo(buffer);
+                       
+                               return info.Count != 0 ? (string)info[0] : null;
+                       }                       
+               }
+               
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/constructor[@name="FbSecurity"]/*'/>
+               public FbSecurity()     : base()
+               {
+               }
+               
+               #endregion              
+               
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/method[@name="AddUser(FbUserData)"]/*'/>
+               public void     AddUser(FbUserData user)
+               {
+                       if (user.UserName != null && user.UserName.Length == 0)
+                       {
+                               throw new InvalidOperationException("Invalid user name.");
+                       }
+                       if (user.UserPassword != null && user.UserPassword.Length == 0)
+                       {
+                               throw new InvalidOperationException("Invalid user password.");
+                       }
+
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_add_user);
+                                               
+                       this.StartSpb.Append(IscCodes.isc_spb_sec_username,     user.UserName);
+                       this.StartSpb.Append(IscCodes.isc_spb_sec_password,     user.UserPassword);
+
+                       if (user.FirstName != null && user.FirstName.Length     > 0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sec_firstname, user.FirstName);
+                       }
+
+                       if (user.MiddleName     != null && user.MiddleName.Length >     0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sec_middlename, user.MiddleName);
+                       }
+
+                       if (user.LastName != null && user.LastName.Length >     0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sec_lastname,     user.LastName);
+                       }
+
+                       if (user.UserID != 0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sec_userid, user.UserID);
+                       }
+
+                       if (user.GroupID !=     0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sec_groupid, user.GroupID);
+                       }
+
+                       if (user.GroupName != null && user.GroupName.Length     > 0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sec_groupname, user.GroupName);
+                       }
+
+                       if (user.RoleName != null && user.RoleName.Length >     0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName);
+                       }
+                       
+                       // Start execution
+                       this.StartTask();
+                                               
+                       this.Close();
+               }
+
+               ///     <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/method[@name="DeleteUser(FbUserData)"]/*'/>
+               public void     DeleteUser(FbUserData user)
+               {
+                       if (user.UserName != null && user.UserName.Length == 0)
+                       {
+                               throw new InvalidOperationException("Invalid user name.");
+                       }
+                       
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_delete_user);
+
+                       this.StartSpb.Append(IscCodes.isc_spb_sec_username,     user.UserName);
+                       
+                       if (user.RoleName != null && user.RoleName.Length >     0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName);
+                       }
+                       
+                       // Start execution
+                       this.StartTask();
+                                               
+                       this.Close();                   
+               }
+
+               ///     <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/method[@name="ModifyUser(FbUserData)"]/*'/>
+               public void     ModifyUser(FbUserData user)
+               {
+                       if (user.UserName != null && user.UserName.Length == 0)
+                       {
+                               throw new InvalidOperationException("Invalid user name.");
+                       }
+                       if (user.UserPassword != null && user.UserPassword.Length == 0)
+                       {
+                               throw new InvalidOperationException("Invalid user password.");
+                       }
+
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_modify_user);
+                       this.StartSpb.Append(IscCodes.isc_spb_sec_username,     user.UserName);
+
+                       if (user.UserPassword != null && user.UserPassword.Length >     0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sec_password,     user.UserPassword);
+                       }
+
+                       if (user.FirstName != null && user.FirstName.Length     > 0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sec_firstname, user.FirstName);
+                       }
+
+                       if (user.MiddleName     != null && user.MiddleName.Length >     0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sec_middlename, user.MiddleName);
+                       }
+
+                       if (user.LastName != null && user.LastName.Length >     0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sec_lastname,     user.LastName);
+                       }
+
+                       this.StartSpb.Append(IscCodes.isc_spb_sec_userid, user.UserID);                         
+                       this.StartSpb.Append(IscCodes.isc_spb_sec_groupid, user.GroupID);
+                       
+                       if (user.GroupName != null && user.GroupName.Length     > 0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sec_groupname, user.GroupName);
+                       }
+
+                       if (user.RoleName != null && user.RoleName.Length >     0)
+                       {
+                               this.StartSpb.Append(IscCodes.isc_spb_sql_role_name, user.RoleName);
+                       }
+                       
+                       // Start execution
+                       this.StartTask();
+                                               
+                       this.Close();                   
+               }
+
+               ///     <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/method[@name="DisplayUser(System.String)"]/*'/>
+               public FbUserData DisplayUser(string userName)
+               {
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_display_user);                     
+                       this.StartSpb.Append(IscCodes.isc_spb_sec_username,     userName);
+                                               
+                       // Start execution
+                       this.StartTask();
+
+                       byte[] buffer = this.QueryService(
+                               new     byte[] {IscCodes.isc_info_svc_get_users});
+
+                       System.Collections.ArrayList info =     base.ParseQueryInfo(buffer);
+                       
+                       this.Close();
+                       
+                       if (info.Count == 0)
+                       {
+                               return null;
+                       }
+
+                       FbUserData[] users = (FbUserData[])info[0];
+
+                       return (users != null && users.Length > 0) ? users[0] : null;
+               }
+
+               ///     <include file='Doc/en_EN/FbSecurity.xml' path='doc/class[@name="FbSecurity"]/method[@name="DisplayUsers"]/*'/>
+               public FbUserData[]     DisplayUsers()
+               {
+                       // Configure Spb
+                       this.StartSpb = this.CreateParameterBuffer();
+
+                       this.StartSpb.Append(IscCodes.isc_action_svc_display_user);                     
+                                               
+                       // Start execution
+                       this.StartTask();
+
+                       byte[] buffer = this.QueryService(
+                               new     byte[] {IscCodes.isc_info_svc_get_users});
+                       
+                       System.Collections.ArrayList info =     base.ParseQueryInfo(buffer);
+                       
+                       this.Close();
+               
+                       if (info.Count == 0)
+                       {
+                               return null;
+                       }
+
+                       return (FbUserData[])info[0];
+               }
+               
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServerConfig.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServerConfig.cs
new file mode 100644 (file)
index 0000000..7c884bf
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/overview/*'/>
+       public struct FbServerConfig
+       {
+               #region Fields
+
+               private int     lockMemSize;
+               private int     lockSemCount;
+               private int     lockSignal;
+               private int     eventMemorySize;
+               private int     prioritySwitchDelay;
+               private int     minMemory;
+               private int     maxMemory;
+               private int     lockGrantOrder;
+               private int     anyLockMemory;
+               private int     anyLockSemaphore;
+               private int     anyLockSignal;
+               private int     anyEventMemory;
+               private int     lockHashSlots;
+               private int     deadlockTimeout;
+               private int     lockRequireSpins;
+               private int     connectionTimeout;
+               private int     dummyPacketInterval;
+               private int     ipcMapSize;
+               private int     defaultDbCachePages;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="LockMemSize"]/*'/>
+               public int LockMemSize
+               {
+                       get     { return this.lockMemSize; }
+                       set     { this.lockMemSize = value;     }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="LockSemCount"]/*'/>
+               public int LockSemCount
+               {
+                       get     { return this.lockSemCount;     }
+                       set     { this.lockSemCount     = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="LockSignal"]/*'/>
+               public int LockSignal
+               {
+                       get     { return this.lockSignal; }
+                       set     { this.lockSignal =     value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="EventMemorySize"]/*'/>
+               public int EventMemorySize
+               {
+                       get     { return this.eventMemorySize; }
+                       set     { this.eventMemorySize = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="PrioritySwitchDelay"]/*'/>
+               public int PrioritySwitchDelay
+               {
+                       get     { return this.prioritySwitchDelay; }
+                       set     { this.prioritySwitchDelay = value;     }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="MinMemory"]/*'/>
+               public int MinMemory
+               {
+                       get     { return this.minMemory; }
+                       set     { this.minMemory = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="MaxMemory"]/*'/>
+               public int MaxMemory
+               {
+                       get     { return this.maxMemory; }
+                       set     { this.maxMemory = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="LockGrantOrder"]/*'/>
+               public int LockGrantOrder
+               {
+                       get     { return this.lockGrantOrder; }
+                       set     { this.lockGrantOrder = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="AnyLockMemory"]/*'/>
+               public int AnyLockMemory
+               {
+                       get     { return this.anyLockMemory; }
+                       set     { this.anyLockMemory = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="AnyLockSemaphore"]/*'/>
+               public int AnyLockSemaphore
+               {
+                       get     { return this.anyLockSemaphore; }
+                       set     { this.anyLockSemaphore = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="AnyLockSignal"]/*'/>
+               public int AnyLockSignal
+               {
+                       get     { return this.anyLockSignal; }
+                       set     { this.anyLockSignal = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="AnyEventMemory"]/*'/>
+               public int AnyEventMemory
+               {
+                       get     { return this.anyEventMemory; }
+                       set     { this.anyEventMemory = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="LockHashSlots"]/*'/>
+               public int LockHashSlots
+               {
+                       get     { return this.lockHashSlots; }
+                       set     { this.lockHashSlots = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="DeadlockTimeout"]/*'/>
+               public int DeadlockTimeout
+               {
+                       get     { return this.deadlockTimeout; }
+                       set     { this.deadlockTimeout = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="LockRequireSpins"]/*'/>
+               public int LockRequireSpins
+               {
+                       get     { return this.lockRequireSpins; }
+                       set     { this.lockRequireSpins = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="ConnectionTimeout"]/*'/>
+               public int ConnectionTimeout
+               {
+                       get     { return this.connectionTimeout; }
+                       set     { this.connectionTimeout = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="DummyPacketInterval"]/*'/>
+               public int DummyPacketInterval
+               {
+                       get     { return this.dummyPacketInterval; }
+                       set     { this.dummyPacketInterval = value;     }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="IpcMapSize"]/*'/>
+               public int IpcMapSize
+               {
+                       get     { return this.ipcMapSize; }
+                       set     { this.ipcMapSize =     value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbServerConfig"]/field[@name="DefaultDbCachePages"]/*'/>
+               public int DefaultDbCachePages
+               {
+                       get     { return this.defaultDbCachePages; }
+                       set     { this.defaultDbCachePages = value;     }
+               }
+
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServerProperties.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServerProperties.cs
new file mode 100644 (file)
index 0000000..4403d9b
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/overview/*'/>
+       public sealed class     FbServerProperties : FbService
+       {
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="Version"]/*'/>
+               public int Version
+               {
+                       get     { return this.GetInt32(IscCodes.isc_info_svc_version); }
+               }
+
+               ///     <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="ServerVersion"]/*'/>
+               public string ServerVersion
+               {
+                       get     { return this.GetString(IscCodes.isc_info_svc_server_version); }
+               }
+
+               ///     <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="Implementation"]/*'/>
+               public string Implementation
+               {
+                       get     { return this.GetString(IscCodes.isc_info_svc_implementation); }
+               }
+
+               ///     <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="RootDirectory"]/*'/>
+               public string RootDirectory
+               {                       
+                       get     { return this.GetString(IscCodes.isc_info_svc_get_env); }
+               }
+
+               ///     <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="LockManager"]/*'/>
+               public string LockManager
+               {
+                       get     { return this.GetString(IscCodes.isc_info_svc_get_env_lock); }
+               }
+
+               ///     <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="MessageFile"]/*'/>
+               public string MessageFile
+               {                       
+                       get     { return this.GetString(IscCodes.isc_info_svc_get_env_msg);     }
+               }
+
+               ///     <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="DatabasesInfo"]/*'/>
+               public FbDatabasesInfo DatabasesInfo
+               {
+                       get
+                       {
+                               ArrayList info  = this.GetInfo(IscCodes.isc_info_svc_svr_db_info);
+
+                               return info.Count != 0 ? (FbDatabasesInfo)info[0] :     new     FbDatabasesInfo();
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="ServerConfig"]/*'/>
+               public FbServerConfig ServerConfig
+               {
+                       get
+                       {
+                               ArrayList info = this.GetInfo(IscCodes.isc_info_svc_get_config);
+
+                               return info.Count != 0 ? (FbServerConfig)info[0] : new FbServerConfig();
+                       }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/constructor[@name="FbServerProperties"]/*'/>
+               public FbServerProperties()     : base()
+               {
+               }
+               
+               #endregion
+
+               #region Private Methods
+
+               private string GetString(int item)
+               {
+                       ArrayList info = this.GetInfo(item);
+
+                       return info.Count != 0 ? (string)info[0] : null;
+               }
+
+               private int     GetInt32(int item)
+               {
+                       ArrayList info = this.GetInfo(item);
+
+                       return info.Count != 0 ? (int)info[0] : 0;
+               }
+
+               private ArrayList GetInfo(int item)
+               {
+                       return this.GetInfo(new byte[] { (byte)item     });
+               }
+
+               private ArrayList GetInfo(byte[] items)
+               {
+                       byte[] buffer = this.QueryService(items);
+
+                       return this.ParseQueryInfo(buffer);
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbService.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbService.cs
new file mode 100644 (file)
index 0000000..4f1509f
--- /dev/null
@@ -0,0 +1,563 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using System.Text;
+using System.Net;
+using System.Collections;
+using System.Collections.Specialized;
+
+using FirebirdSql.Data;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/overview/*'/>
+       public abstract class FbService
+       {
+               #region Events
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/event[@name="ServiceOutput"]/*'/>
+               public event ServiceOutputEventHandler ServiceOutput;
+
+               #endregion
+
+               #region Fields
+
+               private IServiceManager                 svc;
+               private FbServiceState                  state;
+               private string                                  connectionString;
+               private string                                  serviceName;
+               private int                                             queryBufferSize;
+               private ServiceParameterBuffer  querySpb;
+               private FbConnectionString              csManager;
+
+               #endregion
+
+               #region Protected Fields
+
+               internal ServiceParameterBuffer StartSpb;
+                               
+               #endregion
+               
+               #region Properties
+               
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/property[@name="State"]/*'/>
+               public FbServiceState State
+               {
+                       get     { return state; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/property[@name="ConnectionString"]/*'/>
+               public string ConnectionString
+               {
+                       get     { return this.connectionString; }                       
+                       set
+                       {
+                               if (this.svc != null && this.state == FbServiceState.Open)
+                               {
+                                       throw new InvalidOperationException("ConnectionString cannot be modified on     active service instances.");
+                               }
+
+                               this.csManager.Load(value);
+
+                               if (value == null)
+                               {
+                                       this.connectionString = String.Empty;
+                               }
+                               else
+                               {
+                                       this.connectionString = value; 
+                               }
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/property[@name="QueryBufferSize"]/*'/>
+               public int QueryBufferSize
+               {
+                       get     { return this.queryBufferSize; }
+                       set     { this.queryBufferSize = value; }
+               }
+               
+               #endregion
+               
+               #region Protected Properties
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/property[@name="Database"]/*'/>
+               protected string Database
+               {
+                       get     { return this.csManager.Database; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/constructor[@name="ctor"]/*'/>
+               protected FbService()
+               {
+                       this.serviceName                = "service_mgr";
+                       this.state                              = FbServiceState.Closed;
+                       this.queryBufferSize    = 1024;
+                       this.connectionString   = String.Empty;
+                       this.csManager                  = new FbConnectionString(true);
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/method[@name="Open"]/*'/>
+               protected void Open()
+               {
+                       if (this.state != FbServiceState.Closed)
+                       {
+                               throw new InvalidOperationException("Service already Open.");
+                       }
+                       
+                       if (this.csManager.UserID == null || this.csManager.UserID.Length == 0)
+                       {
+                               throw new InvalidOperationException("No user name was specified.");
+                       }
+
+                       if (this.csManager.Password     == null || this.csManager.Password.Length == 0)
+                       {
+                               throw new InvalidOperationException("No user password was specified.");
+                       }
+                       
+                       try
+                       {
+                               if (this.svc == null)
+                               {
+                                       // New instance for     Service handler
+                                       this.svc = ClientFactory.CreateServiceManager(this.csManager.ServerType);
+                               }
+
+                               // Set service name
+                               string service = String.Empty;
+                               
+                               switch (this.csManager.ServerType)
+                               {
+                                       case 0:
+                                               service = this.csManager.DataSource     + ":" + serviceName;
+                                               break;
+
+                                       default:
+                                               service = serviceName;
+                                               break;
+                               }
+                                       
+                               // Initialize Services API
+                               this.svc.Attach(this.BuildSpb(), this.csManager.DataSource,     
+                                                               this.csManager.Port, service);
+                               
+                               this.state = FbServiceState.Open;
+                       }
+                       catch (IscException     ex)
+                       {
+                               throw new FbException(ex.Message, ex);
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/method[@name="Close"]/*'/>
+               protected void Close()
+               {
+                       if (this.state != FbServiceState.Open)
+                       {
+                               return;
+                       }
+
+                       try
+                       {
+                               this.svc.Detach();
+                               this.svc = null;
+                               
+                               this.state = FbServiceState.Closed;
+                       }
+                       catch (IscException     ex)
+                       {
+                               throw new FbException(ex.Message, ex);
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/method[@name="startTask"]/*'/>
+               protected void StartTask()
+               {                                       
+                       if (this.state == FbServiceState.Closed)
+                       {
+                               // Attach to Service Manager
+                               this.Open();
+                       }
+                       
+                       try
+                       {                                                                                               
+                               // Start service operation
+                               this.svc.Start(this.StartSpb);
+                       }
+                       catch (IscException     ex)
+                       {
+                               throw new FbException(ex.Message, ex);                          
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/method[@name="queryService"]/*'/>
+               protected byte[] QueryService(byte[] items)
+               {
+                       if (this.state == FbServiceState.Closed)
+                       {
+                               // Attach to Service Manager
+                               this.Open();
+                       }
+
+                       if (this.querySpb == null)
+                       {
+                               this.querySpb = new     ServiceParameterBuffer();
+                       }
+                       
+                       // Response     buffer
+                       byte[] buffer = new     byte[queryBufferSize];
+                                                       
+                       this.svc.Query(this.querySpb, items.Length,     items, buffer.Length, buffer);
+                       
+                       return buffer;
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/method[@name="parseQueryInfo"]/*'/>
+               protected ArrayList     ParseQueryInfo(byte[] buffer)
+               {
+                       int     pos             = 0;
+                       int     length  = 0;
+                       int     type    = 0;
+                       
+                       ArrayList items = new ArrayList();                      
+                       
+                       while ((type = buffer[pos++]) != IscCodes.isc_info_end)
+                       {
+                               length  = IscHelper.VaxInteger(buffer, pos,     2);
+                               pos             += 2;
+                               
+                               if (length != 0)
+                               {
+                                       switch (type)
+                                       {
+                                               case IscCodes.isc_info_svc_version:
+                                               case IscCodes.isc_info_svc_get_license_mask:
+                                               case IscCodes.isc_info_svc_capabilities:
+                                               case IscCodes.isc_info_svc_get_licensed_users:
+                                                       items.Add(IscHelper.VaxInteger(buffer, pos,     4));
+                                                       pos     += length;
+                                                       break;
+                                               
+                                               case IscCodes.isc_info_svc_server_version:
+                                               case IscCodes.isc_info_svc_implementation:
+                                               case IscCodes.isc_info_svc_get_env:
+                                               case IscCodes.isc_info_svc_get_env_lock:
+                                               case IscCodes.isc_info_svc_get_env_msg:
+                                               case IscCodes.isc_info_svc_user_dbpath:
+                                               case IscCodes.isc_info_svc_line:
+                                               case IscCodes.isc_info_svc_to_eof:
+                                                       items.Add(Encoding.Default.GetString(buffer, pos, length));
+                                                       pos     += length;
+                                                       break;
+                                               
+                                               case IscCodes.isc_info_svc_svr_db_info:
+                                                       items.Add(ParseDatabasesInfo(buffer, ref pos));
+                                                       break;
+
+                                               case IscCodes.isc_info_svc_get_users:
+                                                       items.Add(ParseUserData(buffer, ref     pos));
+                                                       break;
+               
+                                               case IscCodes.isc_info_svc_get_config:
+                                                       items.Add(ParseServerConfig(buffer,     ref     pos));
+                                                       break;                                  
+                                       }
+                               }
+                       }
+                       
+                       return items;
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/method[@name="GetNextLine"]/*'/>
+               protected string GetNextLine()
+               {
+                       this.querySpb = new     ServiceParameterBuffer();
+
+                       byte[]  items = new     byte[]{ IscCodes.isc_info_svc_line };
+                       byte[]  buffer = this.QueryService(items);                                                              
+                                       
+                       ArrayList info = this.ParseQueryInfo(buffer);
+                       if (info.Count != 0)
+                       {
+                               return info[0] as string;
+                       }
+                       else
+                       {
+                               return null;    
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbService"]/method[@name="ProcessServiceOutput"]/*'/>
+               protected void ProcessServiceOutput()
+               {
+                       string line     = null;
+
+                       while ((line = this.GetNextLine()) != null)
+                       {
+                               if (this.ServiceOutput != null)
+                               {
+                                       this.ServiceOutput(this, new ServiceOutputEventArgs(line));
+                               }                       
+                       }
+               }
+
+               #endregion
+
+               #region Internal Methods
+
+               internal ServiceParameterBuffer CreateParameterBuffer()
+               {
+                       if (this.svc == null)
+                       {
+                               // New instance for     Service handler
+                               this.svc = ClientFactory.CreateServiceManager(this.csManager.ServerType);
+                       }
+
+                       return this.svc.CreateParameterBuffer();
+               }
+
+               internal ServiceParameterBuffer BuildSpb()
+               {
+                       ServiceParameterBuffer spb = this.CreateParameterBuffer();
+
+                       // SPB configuration                            
+                       spb.Append(IscCodes.isc_spb_version);
+                       spb.Append(IscCodes.isc_spb_current_version);
+                       spb.Append((byte)IscCodes.isc_spb_user_name, this.csManager.UserID);
+                       spb.Append((byte)IscCodes.isc_spb_password,     this.csManager.Password);
+                       spb.Append((byte)IscCodes.isc_spb_dummy_packet_interval, new byte[]     { 120, 10, 0, 0 });
+
+                       if (this.csManager.Role != null && this.csManager.Role.Length > 0)
+                       {
+                               spb.Append((byte)IscCodes.isc_spb_sql_role_name, this.csManager.Role);
+                       }
+
+                       return spb;
+               }
+
+               #endregion
+
+               #region Private Static Methods
+
+               private static FbServerConfig ParseServerConfig(byte[] buffer, ref int pos)
+               {
+                       FbServerConfig config = new     FbServerConfig();
+
+                       pos     = 1;            
+                       while(buffer[pos] != IscCodes.isc_info_flag_end)
+                       {                       
+                               pos++;
+                               
+                               int     key     = buffer[pos - 1];
+                               int     keyValue = IscHelper.VaxInteger(buffer, pos, 4);
+                                               
+                               pos     += 4;   
+                                               
+                               switch (key)
+                               {
+                                       case IscCodes.ISCCFG_LOCKMEM_KEY:
+                                               config.LockMemSize = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_LOCKSEM_KEY:
+                                               config.LockSemCount     = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_LOCKSIG_KEY:
+                                               config.LockSignal =     keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_EVNTMEM_KEY:
+                                               config.EventMemorySize = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_PRIORITY_KEY:
+                                               config.PrioritySwitchDelay = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_MEMMIN_KEY:
+                                               config.MinMemory = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_MEMMAX_KEY:
+                                               config.MaxMemory = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_LOCKORDER_KEY:
+                                               config.LockGrantOrder = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_ANYLOCKMEM_KEY:
+                                               config.AnyLockMemory = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_ANYLOCKSEM_KEY:
+                                               config.AnyLockSemaphore = keyValue;
+                                               break;
+
+                                       case IscCodes.ISCCFG_ANYLOCKSIG_KEY:
+                                               config.AnyLockSignal = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_ANYEVNTMEM_KEY:
+                                               config.AnyEventMemory = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_LOCKHASH_KEY:
+                                               config.LockHashSlots = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_DEADLOCK_KEY:
+                                               config.DeadlockTimeout = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_LOCKSPIN_KEY:
+                                               config.LockRequireSpins = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_CONN_TIMEOUT_KEY:
+                                               config.ConnectionTimeout = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_DUMMY_INTRVL_KEY:
+                                               config.DummyPacketInterval = keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_IPCMAP_KEY:
+                                               config.IpcMapSize =     keyValue;
+                                               break;
+                                       
+                                       case IscCodes.ISCCFG_DBCACHE_KEY:
+                                               config.DefaultDbCachePages = keyValue;
+                                               break;
+                               }
+                       }
+                       
+                       pos++;
+                       
+                       return config;
+               }
+
+               private static FbDatabasesInfo ParseDatabasesInfo(byte[] buffer, ref int pos)
+               {
+                       FbDatabasesInfo dbInfo  = new FbDatabasesInfo();                        
+                       int                             type    = 0;
+                       int                             length  = 0;
+                       
+                       pos     = 1;
+                       while ((type = buffer[pos++]) != IscCodes.isc_info_end)
+                       {                                                       
+                               switch (type)
+                               {
+                                       case IscCodes.isc_spb_num_att:
+                                               dbInfo.ConnectionCount = IscHelper.VaxInteger(buffer, pos, 4);                                                                          
+                                               pos     += 4;
+                                               break;
+
+                                       case IscCodes.isc_spb_num_db:
+                                               pos     += 4;
+                                               break;
+                                       
+                                       case IscCodes.isc_spb_dbname:
+                                               length = IscHelper.VaxInteger(buffer, pos, 2);
+                                               pos     += 2;                                                                           
+                                               dbInfo.Databases.Add(Encoding.Default.GetString(buffer, pos, length));
+                                               pos     += length;
+                                               break;
+                               }
+                       }
+                       pos--;                  
+                       
+                       return dbInfo;
+               }
+
+               private static FbUserData[]     ParseUserData(byte[] buffer, ref int pos)
+               {
+                       ArrayList       users           = new ArrayList();
+                       FbUserData      currentUser     = null;
+                       int                     type            = 0;
+                       int                     length          = 0;
+                                                                                                                               
+                       while ((type = buffer[pos++]) != IscCodes.isc_info_end)
+                       {                                                               
+                               switch (type)
+                               {                                                                                                                                               
+                                       case IscCodes.isc_spb_sec_username:
+                                       {
+                                               currentUser     = new FbUserData();
+
+                                               users.Add(currentUser);
+
+                                               length = IscHelper.VaxInteger(buffer, pos, 2);
+                                               pos     += 2;                                                                           
+                                               currentUser.UserName = Encoding.Default.GetString(buffer, pos, length);
+                                               pos     += length;
+                                       }
+                                       break;
+                                       
+                                       case IscCodes.isc_spb_sec_firstname:
+                                               length = IscHelper.VaxInteger(buffer, pos, 2);
+                                               pos     += 2;                                                                           
+                                               currentUser.FirstName = Encoding.Default.GetString(buffer, pos, length);
+                                               pos     += length;
+                                               break;
+
+                                       case IscCodes.isc_spb_sec_middlename:
+                                               length = IscHelper.VaxInteger(buffer, pos, 2);
+                                               pos     += 2;                                                                           
+                                               currentUser.MiddleName = Encoding.Default.GetString(buffer,     pos, length);
+                                               pos     += length;
+                                               break;
+
+                                       case IscCodes.isc_spb_sec_lastname:
+                                               length = IscHelper.VaxInteger(buffer, pos, 2);
+                                               pos     += 2;                                                                           
+                                               currentUser.LastName = Encoding.Default.GetString(buffer, pos, length);
+                                               pos     += length;
+                                               break;
+
+                                       case IscCodes.isc_spb_sec_userid:
+                                               currentUser.UserID = IscHelper.VaxInteger(buffer, pos, 4);
+                                               pos     += 4;
+                                               break;
+                                       
+                                       case IscCodes.isc_spb_sec_groupid:
+                                               currentUser.GroupID     = IscHelper.VaxInteger(buffer, pos,     4);
+                                               pos     += 4;                                                   
+                                               break;                                  
+                               }
+                       }
+                       pos--;
+                       
+                       return (FbUserData[])users.ToArray(typeof(FbUserData));
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServiceState.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServiceState.cs
new file mode 100644 (file)
index 0000000..41b9e31
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using System.Text;
+using System.Net;
+using System.Collections;
+using System.Collections.Specialized;
+
+using FirebirdSql.Data;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbService.xml' path='doc/enum[@name="FbServiceState"]/overview/*'/>
+       public enum     FbServiceState
+       {
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/enum[@name="FbServiceState"]/field[@name="Closed"]/*'/>
+               Closed = 0,
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/enum[@name="FbServiceState"]/field[@name="Open"]/*'/>
+               Open = 1
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbShutdownMode.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbShutdownMode.cs
new file mode 100644 (file)
index 0000000..d2f66f1
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/enum[@name="FbShutdownMode"]/overview/*'/>
+       public enum     FbShutdownMode
+       {
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/enum[@name="FbShutdownMode"]/field[@name="Forced"]/*'/>
+               Forced,
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/enum[@name="FbShutdownMode"]/field[@name="DenyTransaction"]/*'/>
+               DenyTransaction,
+               ///     <include file='Doc/en_EN/FbConfiguration.xml' path='doc/enum[@name="FbShutdownMode"]/field[@name="DenyConnection"]/*'/>
+               DenyConnection
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbStatistical.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbStatistical.cs
new file mode 100644 (file)
index 0000000..dcb97e0
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbStatistical.xml'     path='doc/class[@name="FbStatistical"]/overview/*'/>
+       public sealed class     FbStatistical : FbService
+       {
+               #region Fields
+               
+               private FbStatisticalFlags      options;
+               
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbStatistical.xml'     path='doc/class[@name="FbStatistical"]/property[@name="Options"]/*'/>
+               public FbStatisticalFlags Options
+               {
+                       get     { return this.options; }
+                       set     { this.options = value; }
+               }
+                               
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbStatistical.xml'     path='doc/class[@name="FbStatistical"]/constructor[@name="FbStatistical"]/*'/>
+               public FbStatistical() : base()
+               {
+               }
+               
+               #endregion
+
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbStatistical.xml'     path='doc/class[@name="FbStatistical"]/constructor[@name="Execute"]/*'/>
+               public void     Execute()
+               {
+                       try
+                       {
+                               this.StartSpb = this.CreateParameterBuffer();
+
+                               // Configure Spb
+                               this.StartSpb.Append(IscCodes.isc_action_svc_db_stats);
+                               this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+                               this.StartSpb.Append(IscCodes.isc_spb_options, (int)this.options);
+                       
+                               // Start execution
+                               this.StartTask();
+
+                               // Process service output
+                               this.ProcessServiceOutput();
+                       }
+                       catch
+                       {
+                               throw;
+                       }
+                       finally
+                       {
+                               this.Close();
+                       }
+               }
+               
+               #endregion              
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbStatisticalFlags.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbStatisticalFlags.cs
new file mode 100644 (file)
index 0000000..26b690b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbStatistical.xml'     path='doc/enum[@name="FbStatisticalFlags"]/overview/*'/>
+       [Flags]
+       public enum     FbStatisticalFlags
+       {
+               ///     <include file='Doc/en_EN/FbStatistical.xml'     path='doc/enum[@name="FbStatisticalFlags"]/field[@name="DataPages"]/*'/>
+               DataPages                               = 0x01,
+               ///     <include file='Doc/en_EN/FbStatistical.xml'     path='doc/enum[@name="FbStatisticalFlags"]/field[@name="DatabaseLog"]/*'/>
+               DatabaseLog                             = 0x02,
+               ///     <include file='Doc/en_EN/FbStatistical.xml'     path='doc/enum[@name="FbStatisticalFlags"]/field[@name="HeaderPages"]/*'/>
+               HeaderPages                             = 0x04,
+               ///     <include file='Doc/en_EN/FbStatistical.xml'     path='doc/enum[@name="FbStatisticalFlags"]/field[@name="IndexPages"]/*'/>
+               IndexPages                              = 0x08,
+               ///     <include file='Doc/en_EN/FbStatistical.xml'     path='doc/enum[@name="FbStatisticalFlags"]/field[@name="SystemTablesRelations"]/*'/>
+               SystemTablesRelations   = 0x10,
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbUserData.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbUserData.cs
new file mode 100644 (file)
index 0000000..d59d4ce
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbUserData"]/overview/*'/>
+       public sealed class     FbUserData
+       {
+               #region Fields
+
+               private string userName;
+               private string firstName;
+               private string lastName;
+               private string middleName;
+               private string userPassword;
+               private string groupName;
+               private string roleName;
+               private int     userID;
+               private int     groupID;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbUserData"]/property[@name="UserName"]/*'/>
+               public string UserName
+               {
+                       get     { return this.userName; }
+                       set
+                       {
+                               if (value == null)
+                               {
+                                       throw new InvalidOperationException("The user name cannot be null.");
+                               }
+                               if (value.Length > 31)
+                               {
+                                       throw new InvalidOperationException("The user name cannot have more     tha     31 characters.");
+                               }
+
+                               this.userName = value;
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbUserData"]/property[@name="UserPassword"]/*'/>
+               public string UserPassword
+               {
+                       get     { return this.userPassword;     }
+                       set
+                       {
+                               if (value == null)
+                               {
+                                       throw new InvalidOperationException("The user password cannot be null.");
+                               }
+                               if (value.Length > 31)
+                               {
+                                       throw new InvalidOperationException("The user password cannot have more tha     31 characters.");
+                               }
+
+                               this.userPassword =     value;
+                       }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbUserData"]/property[@name="FirstName"]/*'/>           
+               public string FirstName
+               {
+                       get     { return this.firstName; }
+                       set     { this.firstName = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbUserData"]/property[@name="LastName"]/*'/>
+               public string LastName
+               {
+                       get     { return this.lastName; }
+                       set     { this.lastName = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbUserData"]/property[@name="MiddleName"]/*'/>
+               public string MiddleName
+               {
+                       get     { return this.middleName; }
+                       set     { this.middleName =     value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbUserData"]/property[@name="UserID"]/*'/>
+               public int UserID
+               {
+                       get     { return this.userID; }
+                       set     { this.userID = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbUserData"]/property[@name="GroupID"]/*'/>
+               public int GroupID
+               {
+                       get     { return this.groupID; }
+                       set     { this.groupID = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbUserData"]/property[@name="GroupName"]/*'/>
+               public string GroupName
+               {
+                       get     { return this.groupName; }
+                       set     { this.groupName = value; }
+               }
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/struct[@name="FbUserData"]/property[@name="RoleName"]/*'/>
+               public string RoleName
+               {
+                       get     { return this.roleName; }
+                       set     { this.roleName = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="FbUserData"]/constructor[@name="FbUserData"]/*'/>
+               public FbUserData()
+               {
+                       this.userName = String.Empty;
+                       this.firstName = String.Empty;
+                       this.lastName = String.Empty;
+                       this.middleName = String.Empty;
+                       this.userPassword =     String.Empty;
+                       this.roleName = String.Empty;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbValidation.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbValidation.cs
new file mode 100644 (file)
index 0000000..614f0e8
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       #region Enumerations
+
+       #endregion
+
+       ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/class[@name="FbValidation"]/overview/*'/>
+       public sealed class     FbValidation : FbService
+       {
+               #region Fields
+               
+               private FbValidationFlags       options;
+               
+               #endregion
+               
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/class[@name="FbValidation"]/property[@name="Options"]/*'/>
+               public FbValidationFlags Options
+               {
+                       get     { return this.options; }
+                       set     { this.options = value; }
+               }               
+               
+               #endregion
+                               
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/class[@name="FbValidation"]/constructor[@name="ctor"]/*'/>
+               public FbValidation() : base()
+               {
+               }
+               
+               #endregion
+               
+               #region Methods
+
+               ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/class[@name="FbValidation"]/method[@name="Execute"]/*'/>
+               public void     Execute()
+               {
+                       try
+                       {
+                               this.StartSpb = this.CreateParameterBuffer();
+
+                               // Configure Spb
+                               this.StartSpb.Append(IscCodes.isc_action_svc_repair);
+                               this.StartSpb.Append(IscCodes.isc_spb_dbname, this.Database);
+                               this.StartSpb.Append(IscCodes.isc_spb_options, (int)this.options);
+                                               
+                               // Start execution
+                               this.StartTask();
+
+                               // Process service output
+                               this.ProcessServiceOutput();
+                       }
+                       catch
+                       {
+                               throw;
+                       }
+                       finally
+                       {
+                               this.Close();
+                       }
+               }
+               
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbValidationFlags.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbValidationFlags.cs
new file mode 100644 (file)
index 0000000..2fb3164
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/struct[@name="FbValidationFlags"]/overview/*'/>
+       [Flags]
+       public enum     FbValidationFlags
+       {
+               ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/struct[@name="FbValidationFlags"]/field[@name="ValidateDatabase"]/*'/>
+               ValidateDatabase        = 0x01,
+               ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/struct[@name="FbValidationFlags"]/field[@name="SweepDatabase"]/*'/>
+               SweepDatabase           = 0x02,
+               ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/struct[@name="FbValidationFlags"]/field[@name="MendDatabase"]/*'/>
+               MendDatabase            = 0x04,
+               ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/struct[@name="FbValidationFlags"]/field[@name="CheckDatabase"]/*'/>
+               CheckDatabase           = 0x10,
+               ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/struct[@name="FbValidationFlags"]/field[@name="IgnoreChecksum"]/*'/>
+               IgnoreChecksum          = 0x20,
+               ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/struct[@name="FbValidationFlags"]/field[@name="KillShadows"]/*'/>
+               KillShadows                     = 0x40,
+               ///     <include file='Doc/en_EN/FbValidation.xml' path='doc/struct[@name="FbValidationFlags"]/field[@name="Full"]/*'/>
+               Full                            = 0x80
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/ServiceOutputEventArgs.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/ServiceOutputEventArgs.cs
new file mode 100644 (file)
index 0000000..2d9dcb2
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Firebird.Services
+{
+       #region Delegates
+
+       ///     <include file='Doc/en_EN/FbService.xml' path='doc/delegate[@name="ServiceOutputEventHandler(System.Object,ServiceOutputEventArgs)"]/*'/>
+       public delegate void ServiceOutputEventHandler(object sender, ServiceOutputEventArgs e);
+
+       #endregion
+
+       ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="ServiceOutputEventArgs"]/overview/*'/>
+       public sealed class     ServiceOutputEventArgs : EventArgs
+       {
+               #region Fields
+
+               private string message;
+
+               #endregion
+
+               #region Properties
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="ServiceOutputEventArgs"]/property[@name="Message"]/*'/>
+               public string Message
+               {
+                       get     { return this.message; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               ///     <include file='Doc/en_EN/FbService.xml' path='doc/class[@name="ServiceOutputEventArgs"]/constructor[@name="ctor(System.String)"]/*'/>
+               public ServiceOutputEventArgs(string message)
+               {
+                       this.message = message;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird_test.dll.sources b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird_test.dll.sources
new file mode 100644 (file)
index 0000000..408e890
--- /dev/null
@@ -0,0 +1,19 @@
+AssemblyInfo.cs
+BaseTest.cs
+FbArrayTest.cs
+FbBlobTest.cs
+FbCommandBuilderTest.cs
+FbCommandTest.cs
+FbConnectionTest.cs
+FbDataAdapterTest.cs
+FbDatabaseInfoTest.cs
+FbDatabaseSchemaTest.cs
+FbDataReaderTest.cs
+FbImplicitTransactionTest.cs
+FbParameterCollectionTest.cs
+FbParameterTest.cs
+FbScriptTest.cs
+FbServicesTests.cs
+FbStoredProcCallsTest.cs
+FbTransactionTest.cs
+GuidTest.cs
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsArray.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsArray.cs
new file mode 100644 (file)
index 0000000..d86260c
--- /dev/null
@@ -0,0 +1,568 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Net;
+using System.Text;
+using System.IO;
+using System.Collections;
+using System.Globalization;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Gds
+{
+       internal sealed class GdsArray : ArrayBase
+       {
+               #region Fields
+
+               private long                    handle;
+               private GdsDatabase             db;
+               private GdsTransaction  transaction;
+
+               #endregion
+
+               #region Properties
+
+               public override long Handle
+               {
+                       get     { return this.handle; }
+                       set     { this.handle = value; }
+               }
+
+               public override IDatabase DB
+               {
+                       get     { return this.db; }
+                       set     { this.db =     (GdsDatabase)value;     }
+               }
+
+               public override ITransaction Transaction
+               {
+                       get     { return this.transaction; }
+                       set     { this.transaction = (GdsTransaction)value;     }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public GdsArray(ArrayDesc descriptor) : base(descriptor)
+               {
+               }
+
+               public GdsArray(
+                       IDatabase               db,
+                       ITransaction    transaction,
+                       string                  tableName,
+                       string                  fieldName) : this(db, transaction, -1, tableName, fieldName)
+               {
+               }
+
+               public GdsArray(
+                       IDatabase               db,
+                       ITransaction    transaction,
+                       long                    handle,
+                       string                  tableName,
+                       string                  fieldName) : base(tableName, fieldName)
+               {
+                       if (!(db is     GdsDatabase))
+                       {
+                               throw new ArgumentException("Specified argument is not of GdsDatabase type.");
+                       }
+
+                       if (!(transaction is GdsTransaction))
+                       {
+                               throw new ArgumentException("Specified argument is not of GdsTransaction type.");
+                       }
+
+                       this.db                         = (GdsDatabase)db;
+                       this.transaction        = (GdsTransaction)transaction;
+                       this.handle                     = handle;
+
+                       this.LookupBounds();
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override byte[] GetSlice(int     sliceLength)
+               {
+                       lock (this.db)
+                       {
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_get_slice);      // Op code
+                                       this.db.Send.Write(this.transaction.Handle);// Transaction
+                                       this.db.Send.Write(this.handle);                        // Array id
+                                       this.db.Send.Write(sliceLength);                        // Slice length
+                                       this.db.Send.WriteBuffer(
+                                               this.GenerateSDL(this.Descriptor));             // Slice descriptor     language
+                                       this.db.Send.Write(String.Empty);                       // Slice parameters                                     
+                                       this.db.Send.Write(0);                                          // Slice proper
+                                       this.db.Send.Flush();
+
+                                       return this.ReceiveSliceResponse(this.Descriptor);
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               public override void PutSlice(System.Array sourceArray, int     sliceLength)
+               {
+                       lock (this.db)
+                       {
+                               try
+                               {
+                                       byte[] sdl = this.GenerateSDL(this.Descriptor);
+                                       byte[] slice = this.EncodeSliceArray(sourceArray);
+
+                                       this.db.Send.Write(IscCodes.op_put_slice);      // Op code
+                                       this.db.Send.Write(this.transaction.Handle);// Transaction
+                                       this.db.Send.Write((long)0);                            // Array Handle
+                                       this.db.Send.Write(sliceLength);                        // Slice length
+                                       this.db.Send.WriteBuffer(sdl);                          // Slice descriptor     language
+                                       this.db.Send.Write(String.Empty);                       // Slice parameters
+                                       this.db.Send.Write(sliceLength);                        // Slice length
+                                       this.db.Send.Write(slice, 0, slice.Length);     // Slice proper
+                                       this.db.Send.Flush();
+
+                                       GdsResponse     r =     this.db.ReadGenericResponse();
+
+                                       this.handle     = r.BlobId;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override System.Array DecodeSlice(byte[] slice)
+               {
+                       DbDataType dbType       = DbDataType.Array;
+                       Array   sliceData       = null;
+                       Array   tempData        = null;
+                       Type    systemType      = this.GetSystemType();
+                       int[]   lengths         = new int[this.Descriptor.Dimensions];
+                       int[]   lowerBounds     = new int[this.Descriptor.Dimensions];
+                       int             type            = 0;
+                       int             index           = 0;
+
+                       // Get upper and lower bounds of each dimension
+                       for     (int i = 0;     i <     this.Descriptor.Dimensions;     i++)
+                       {
+                               lowerBounds[i]  = this.Descriptor.Bounds[i].LowerBound;
+                               lengths[i]              = this.Descriptor.Bounds[i].UpperBound;
+                               if (lowerBounds[i] == 0)
+                               {
+                                       lengths[i]++;
+                               }
+                       }
+
+                       // Create arrays
+#if    (NETCF)
+                       sliceData =     Array.CreateInstance(systemType, lengths);
+#else
+                       sliceData =     Array.CreateInstance(systemType, lengths, lowerBounds);
+#endif
+                       tempData  =     Array.CreateInstance(systemType, sliceData.Length);
+
+                       // Infer Firebird and Db datatypes
+                       type    = TypeHelper.GetFbType(this.Descriptor.DataType);
+                       dbType  = TypeHelper.GetDbDataType(this.Descriptor.DataType, 0, this.Descriptor.Scale);
+
+                       // Decode slice data
+                       XdrStream xdr = new     XdrStream(slice, this.db.Charset);
+
+                       while (xdr.Position     < xdr.Length)
+                       {
+                               switch (dbType)
+                               {
+                                       case DbDataType.Char:
+                                               tempData.SetValue(xdr.ReadString(this.Descriptor.Length), index);
+                                               break;
+
+                                       case DbDataType.VarChar:
+                                               tempData.SetValue(xdr.ReadString(),     index);
+                                               break;
+
+                                       case DbDataType.SmallInt:
+                                               tempData.SetValue(xdr.ReadInt16(), index);
+                                               break;
+
+                                       case DbDataType.Integer:
+                                               tempData.SetValue(xdr.ReadInt32(), index);
+                                               break;
+
+                                       case DbDataType.BigInt:
+                                               tempData.SetValue(xdr.ReadInt64(), index);
+                                               break;
+
+                                       case DbDataType.Numeric:
+                                       case DbDataType.Decimal:
+                                               tempData.SetValue(xdr.ReadDecimal(type, this.Descriptor.Scale), index);
+                                               break;
+
+                                       case DbDataType.Float:
+                                               tempData.SetValue(xdr.ReadSingle(),     index);
+                                               break;
+
+                                       case DbDataType.Double:
+                                               tempData.SetValue(xdr.ReadDouble(),     index);
+                                               break;
+
+                                       case DbDataType.Date:
+                                               tempData.SetValue(xdr.ReadDate(), index);
+                                               break;
+
+                                       case DbDataType.Time:
+                                               tempData.SetValue(xdr.ReadTime(), index);
+                                               break;
+
+                                       case DbDataType.TimeStamp:
+                                               tempData.SetValue(xdr.ReadDateTime(), index);
+                                               break;
+                               }
+
+                               index++;
+                       }
+
+                       if (systemType.IsPrimitive)
+                       {
+                               // For primitive types we can use System.Buffer to copy generated data to destination array
+                               Buffer.BlockCopy(tempData, 0, sliceData, 0,     Buffer.ByteLength(tempData));
+                       }
+                       else
+                       {
+                               sliceData =     tempData;
+                       }
+
+                       // Close XDR stream
+                       xdr.Close();
+
+                       return sliceData;
+               }
+
+               #endregion
+
+               #region Slice response methods
+
+               private byte[] ReceiveSliceResponse(ArrayDesc desc)
+               {
+                       try
+                       {
+                               int     operation =     this.db.ReadOperation();
+                               if (operation == IscCodes.op_slice)
+                               {
+                                       // Read slice length
+                                       bool    isVariying      = false;
+                                       int             elements        = 0;
+                                       int             length          = this.db.Receive.ReadInt32();
+                                       length                          = this.db.Receive.ReadInt32();
+
+                                       switch (desc.DataType)
+                                       {
+                                               case IscCodes.blr_text:
+                                               case IscCodes.blr_text2:
+                                               case IscCodes.blr_cstring:
+                                               case IscCodes.blr_cstring2:
+                                                       elements = length /     desc.Length;
+                                                       length += elements * ((4 - desc.Length) & 3);
+                                                       break;
+
+                                               case IscCodes.blr_varying:
+                                               case IscCodes.blr_varying2:
+                                                       elements = length /     desc.Length;
+                                                       isVariying = true;
+                                                       break;
+
+                                               case IscCodes.blr_short:
+                                                       length = length * desc.Length;
+                                                       break;
+                                       }
+
+                                       if (isVariying)
+                                       {
+                                               XdrStream xdr = new     XdrStream();
+
+                                               for     (int i = 0;     i <     elements; i++)
+                                               {
+                                                       byte[] buffer = this.db.Receive.ReadOpaque(
+                                                               this.db.Receive.ReadInt32());
+
+                                                       xdr.WriteBuffer(buffer, buffer.Length);
+                                               }
+
+                                               return xdr.ToArray();
+                                       }
+                                       else
+                                       {
+                                               return this.db.Receive.ReadOpaque(length);
+                                       }
+                               }
+                               else
+                               {
+                                       this.db.SetOperation(operation);
+                                       this.db.ReadGenericResponse();
+
+                                       return null;
+                               }
+                       }
+                       catch (IOException)
+                       {
+                               throw new IscException(IscCodes.isc_net_read_err);
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private byte[] EncodeSliceArray(Array sourceArray)
+               {
+                       IEnumerator     i               = sourceArray.GetEnumerator();                  
+                       DbDataType      dbType  = DbDataType.Array;
+                       Charset         charset = this.db.Charset;
+                       XdrStream       xdr             = new XdrStream(this.db.Charset);
+                       int                     type    = 0;
+
+                       type    = TypeHelper.GetFbType(this.Descriptor.DataType);
+                       dbType  = TypeHelper.GetDbDataType(this.Descriptor.DataType, 0, this.Descriptor.Scale);
+
+                       while (i.MoveNext())
+                       {
+                               switch (dbType)
+                               {
+                                       case DbDataType.Char:
+                                               byte[] buffer = charset.GetBytes(i.Current.ToString());
+                                               xdr.WriteOpaque(buffer, this.Descriptor.Length);
+                                               break;
+
+                                       case DbDataType.VarChar:
+                                               xdr.Write((string)i.Current);
+                                               break;
+
+                                       case DbDataType.SmallInt:
+                                               xdr.Write((short)i.Current);
+                                               break;
+
+                                       case DbDataType.Integer:
+                                               xdr.Write((int)i.Current);
+                                               break;
+
+                                       case DbDataType.BigInt:
+                                               xdr.Write((long)i.Current);
+                                               break;
+
+                                       case DbDataType.Decimal:
+                                       case DbDataType.Numeric:
+                                               xdr.Write((decimal)i.Current, type,     this.Descriptor.Scale);
+                                               break;
+
+                                       case DbDataType.Float:
+                                               xdr.Write((float)i.Current);
+                                               break;
+
+                                       case DbDataType.Double:
+                                               xdr.Write((double)i.Current);
+                                               break;
+
+                                       case DbDataType.Date:
+                                               xdr.WriteDate(Convert.ToDateTime(i.Current,     CultureInfo.CurrentUICulture.DateTimeFormat));
+                                               break;
+
+                                       case DbDataType.Time:
+                                               xdr.WriteTime(Convert.ToDateTime(i.Current,     CultureInfo.CurrentUICulture.DateTimeFormat));
+                                               break;
+
+                                       case DbDataType.TimeStamp:
+                                               xdr.Write(Convert.ToDateTime(i.Current, CultureInfo.CurrentUICulture.DateTimeFormat));
+                                               break;
+
+                                       default:
+                                               throw new NotSupportedException("Unknown data type");
+                               }
+                       }
+
+                       return xdr.ToArray();
+               }
+
+               private byte[] GenerateSDL(ArrayDesc desc)
+               {
+                       int     n;
+                       int     from;
+                       int     to;
+                       int     increment;
+                       int     dimensions;
+                       ArrayBound tail;
+                       BinaryWriter sdl;
+
+                       dimensions = desc.Dimensions;
+
+                       if (dimensions > 16)
+                       {
+                               throw new IscException(IscCodes.isc_invalid_dimension);
+                       }
+
+                       sdl     = new BinaryWriter(new MemoryStream());
+                       this.Stuff(
+                               sdl,
+                               4,
+                               IscCodes.isc_sdl_version1,
+                               IscCodes.isc_sdl_struct,
+                               1,
+                               desc.DataType);
+
+                       switch (desc.DataType)
+                       {
+                               case IscCodes.blr_short:
+                               case IscCodes.blr_long:
+                               case IscCodes.blr_int64:
+                               case IscCodes.blr_quad:
+                                       this.StuffSdl(sdl, (byte)desc.Scale);
+                                       break;
+
+                               case IscCodes.blr_text:
+                               case IscCodes.blr_cstring:
+                               case IscCodes.blr_varying:
+                                       this.StuffWord(sdl,     desc.Length);
+                                       break;
+
+                               default:
+                                       break;
+                       }
+
+                       this.StuffString(sdl, IscCodes.isc_sdl_relation, desc.RelationName);
+                       this.StuffString(sdl, IscCodes.isc_sdl_field, desc.FieldName);
+
+                       if ((desc.Flags & IscCodes.ARRAY_DESC_COLUMN_MAJOR)     == IscCodes.ARRAY_DESC_COLUMN_MAJOR)
+                       {
+                               from = dimensions -     1;
+                               to = -1;
+                               increment =     -1;
+                       }
+                       else
+                       {
+                               from = 0;
+                               to = dimensions;
+                               increment =     1;
+                       }
+
+                       for     (n = from; n != to;     n += increment)
+                       {
+                               tail = desc.Bounds[n];
+                               if (tail.LowerBound     == 1)
+                               {
+                                       this.Stuff(sdl, 2, IscCodes.isc_sdl_do1, n);
+                               }
+                               else
+                               {
+                                       this.Stuff(sdl, 2, IscCodes.isc_sdl_do2, n);
+
+                                       this.StuffLiteral(sdl, tail.LowerBound);
+                               }
+                               this.StuffLiteral(sdl, tail.UpperBound);
+                       }
+
+                       this.Stuff(
+                               sdl,
+                               5, IscCodes.isc_sdl_element,
+                               1, IscCodes.isc_sdl_scalar,
+                               0, dimensions);
+
+                       for     (n = 0; n <     dimensions;     n++)
+                       {
+                               this.Stuff(sdl, 2, IscCodes.isc_sdl_variable, n);
+                       }
+
+                       this.StuffSdl(sdl, IscCodes.isc_sdl_eoc);
+
+                       return ((MemoryStream)sdl.BaseStream).ToArray();
+               }
+
+               private void Stuff(BinaryWriter sdl, short count, params object[] args)
+               {
+                       for     (int i = 0;     i <     count; i++)
+                       {
+                               sdl.Write(Convert.ToByte(args[i], CultureInfo.InvariantCulture));
+                       }
+               }
+
+               private void Stuff(BinaryWriter sdl, byte[]     args)
+               {
+                       sdl.Write(args);
+               }
+
+               private void StuffSdl(BinaryWriter sdl, byte sdl_byte)
+               {
+                       this.Stuff(sdl, 1, sdl_byte);
+               }
+
+               private void StuffWord(BinaryWriter     sdl, short word)
+               {
+                       this.Stuff(sdl, BitConverter.GetBytes(word));
+               }
+
+               private void StuffLong(BinaryWriter     sdl, int word)
+               {
+                       this.Stuff(sdl, BitConverter.GetBytes(word));
+               }
+
+               private void StuffLiteral(BinaryWriter sdl,     int     literal)
+               {
+                       if (literal     >= -128 && literal <= 127)
+                       {
+                               this.Stuff(sdl, 2, IscCodes.isc_sdl_tiny_integer, literal);
+
+                               return;
+                       }
+
+                       if (literal     >= -32768 && literal <= 32767)
+                       {
+                               this.StuffSdl(sdl, IscCodes.isc_sdl_short_integer);
+                               this.StuffWord(sdl,     (short)literal);
+
+                               return;
+                       }
+
+                       this.StuffSdl(sdl, IscCodes.isc_sdl_long_integer);
+                       this.StuffLong(sdl,     literal);
+               }
+
+               private void StuffString(BinaryWriter sdl, int constant, string value)
+               {
+                       this.StuffSdl(sdl, (byte)constant);
+                       this.StuffSdl(sdl, (byte)value.Length);
+
+                       for     (int i = 0;     i <     value.Length; i++)
+                       {
+                               this.StuffSdl(sdl, (byte)value[i]);
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsBlob.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsBlob.cs
new file mode 100644 (file)
index 0000000..4f1ae30
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Gds
+{
+       internal sealed class GdsBlob : BlobBase
+       {
+               #region Fields
+
+               private GdsDatabase     db;
+
+               #endregion
+
+               #region Properties
+
+               public override IDatabase DB
+               {
+                       get     { return this.db; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public GdsBlob(IDatabase db, ITransaction transaction) 
+                       : this(db, transaction, 0)
+               {
+               }
+
+               public GdsBlob(IDatabase db, ITransaction transaction, long     blobId) : base(db)
+               {
+                       if (!(db is     GdsDatabase))
+                       {
+                               throw new ArgumentException("Specified argument is not of GdsDatabase type.");
+                       }
+                       if (!(transaction is GdsTransaction))
+                       {
+                               throw new ArgumentException("Specified argument is not of GdsTransaction type.");
+                       }
+
+                       this.db                         = (GdsDatabase)db;
+                       this.transaction        = transaction;
+                       this.position           = 0;
+                       this.blobHandle         = 0;
+                       this.blobId                     = blobId;
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void Create()
+               {
+                       try
+                       {
+                               this.CreateOrOpen(IscCodes.op_create_blob, null);
+                               this.RblAddValue(IscCodes.RBL_create);
+                       }
+                       catch (IscException)
+                       {
+                               throw;
+                       }
+               }
+
+               protected override void Open()
+               {
+                       try
+                       {
+                               this.CreateOrOpen(IscCodes.op_open_blob, null);
+                       }
+                       catch (IscException)
+                       {
+                               throw;
+                       }
+               }
+
+               protected override byte[] GetSegment()
+               {
+                       int     requested =     this.SegmentSize;
+
+                       lock (this.db)
+                       {
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_get_segment);
+                                       this.db.Send.Write(this.blobHandle);
+                                       this.db.Send.Write((requested + 2 <     short.MaxValue) ? requested     + 2     : short.MaxValue);
+                                       this.db.Send.Write((int)0);     // Data segment
+                                       this.db.Send.Flush();
+
+                                       GdsResponse     r =     this.db.ReadGenericResponse();
+
+                                       this.RblRemoveValue(IscCodes.RBL_segment);
+                                       if (r.ObjectHandle == 1)
+                                       {
+                                               this.RblAddValue(IscCodes.RBL_segment);
+                                       }
+                                       else if (r.ObjectHandle == 2)
+                                       {
+                                               this.RblAddValue(IscCodes.RBL_eof_pending);
+                                       }
+                                       byte[] buffer = r.Data;
+                                       
+                                       if (buffer.Length == 0)
+                                       {
+                                               // previous     segment was     last, this has no data
+                                               return buffer;
+                                       }
+
+                                       int     len             = 0;
+                                       int     srcpos  = 0;
+                                       int     destpos = 0;
+                                       while (srcpos < buffer.Length)
+                                       {
+                                               len     = IscHelper.VaxInteger(buffer, srcpos, 2);
+                                               srcpos += 2;
+
+                                               Buffer.BlockCopy(buffer, srcpos, buffer, destpos, len);
+                                               srcpos  += len;
+                                               destpos += len;
+                                       }
+
+                                       byte[] result = new     byte[destpos];
+                                       Buffer.BlockCopy(buffer, 0,     result, 0, destpos);
+
+                                       return result;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               protected override void PutSegment(byte[] buffer)
+               {
+                       lock (this.db)
+                       {
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_batch_segments);
+                                       this.db.Send.Write(this.blobHandle);
+                                       this.db.Send.WriteBlobBuffer(buffer);
+                                       this.db.Send.Flush();
+
+                                       this.db.ReadGenericResponse();
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               protected override void Seek(int position)
+               {
+                       lock (this.db)
+                       {
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_seek_blob);
+                                       this.db.Send.Write(this.blobHandle);
+                                       this.db.Send.Write(0);                                  // Seek mode
+                                       this.db.Send.Write(position);                   // Seek offset
+                                       this.db.Send.Flush();
+
+                                       GdsResponse     r =     db.ReadGenericResponse();
+
+                                       this.position = r.ObjectHandle;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_network_error);
+                               }
+                       }
+               }
+
+               protected override void GetBlobInfo()
+               {
+                       throw new NotSupportedException();
+               }
+
+               protected override void Close()
+               {
+                       this.db.ReleaseObject(IscCodes.op_close_blob, this.blobHandle);
+               }
+
+               protected override void Cancel()
+               {
+                       this.db.ReleaseObject(IscCodes.op_cancel_blob, this.blobHandle);
+               }
+
+               #endregion
+
+               #region Private API     Methods
+
+               private void CreateOrOpen(int op, BlobParameterBuffer bpb)
+               {
+                       lock (this.db)
+                       {
+                               try
+                               {
+                                       this.db.Send.Write(op);
+                                       if (bpb != null)
+                                       {
+                                               this.db.Send.WriteTyped(
+                                                       IscCodes.isc_bpb_version1,
+                                                       bpb.ToArray());
+                                       }
+                                       this.db.Send.Write(this.transaction.Handle);
+                                       this.db.Send.Write(this.blobId);
+                                       this.db.Send.Flush();
+
+                                       GdsResponse     r =     this.db.ReadGenericResponse();
+
+                                       this.blobId             = r.BlobId;
+                                       this.blobHandle = r.ObjectHandle;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsConnection.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsConnection.cs
new file mode 100644 (file)
index 0000000..ac7f22d
--- /dev/null
@@ -0,0 +1,292 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Gds
+{
+       internal sealed class GdsConnection
+       {
+               #region Fields
+
+               private Socket                  socket;
+               private NetworkStream   networkStream;
+               private XdrStream               send;
+               private XdrStream               receive;
+               private int                             operation;
+
+               #endregion
+
+               #region Internal Properties
+
+               internal XdrStream Receive
+               {
+                       get     { return this.receive; }
+               }
+
+               internal XdrStream Send
+               {
+                       get     { return this.send;     }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public GdsConnection()
+               {
+                       this.operation = -1;
+
+                       GC.SuppressFinalize(this);
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void     Connect(string dataSource, int port)
+               {
+                       this.Connect(dataSource, port, 8192, Charset.DefaultCharset);
+               }
+
+               public void     Connect(string dataSource, int port, int packetSize, Charset charset)
+               {
+                       try
+                       {
+                               IPAddress hostadd =     Dns.Resolve(dataSource).AddressList[0];
+                               IPEndPoint EPhost =     new     IPEndPoint(hostadd,     port);
+
+                               this.socket     = new Socket(
+                                       AddressFamily.InterNetwork,
+                                       SocketType.Stream,
+                                       ProtocolType.IP);
+
+                               // Set Receive Buffer size.
+                               this.socket.SetSocketOption(
+                                       SocketOptionLevel.Socket,
+                                       SocketOptionName.ReceiveBuffer,
+                                       packetSize);
+
+                               // Set Send     Buffer size.
+                               this.socket.SetSocketOption(
+                                       SocketOptionLevel.Socket,
+                                       SocketOptionName.SendBuffer,
+                                       packetSize);
+
+#if    (!LINUX)
+                               // Disables     the     Nagle algorithm for     send coalescing.
+                               // This seems to be     not     supported in Linux (using mono::)
+                               this.socket.SetSocketOption(
+                                       SocketOptionLevel.Socket,
+                                       SocketOptionName.NoDelay,
+                                       1);
+#endif
+
+                               // Make the     socket to connect to the Server
+                               this.socket.Connect(EPhost);
+                               this.networkStream = new NetworkStream(this.socket,     true);
+
+#if    (NETCF)
+                               this.send        = new XdrStream(this.networkStream, charset);
+                               this.receive = new XdrStream(this.networkStream, charset);
+#else
+                               this.send        = new XdrStream(new BufferedStream(this.networkStream), charset);
+                               this.receive = new XdrStream(new BufferedStream(this.networkStream), charset);
+#endif
+
+                               GC.SuppressFinalize(this.socket);
+                               GC.SuppressFinalize(this.networkStream);
+                               GC.SuppressFinalize(this.send);
+                               GC.SuppressFinalize(this.receive);
+                       }
+                       catch (SocketException)
+                       {
+                               throw new IscException(IscCodes.isc_arg_gds, IscCodes.isc_network_error, dataSource);
+                       }
+               }
+
+               public void     Disconnect()
+               {
+                       try
+                       {
+                               if (this.receive !=     null)
+                               {
+                                       this.receive.Close();
+                               }
+                               if (this.send != null)
+                               {
+                                       this.send.Close();
+                               }
+                               if (this.networkStream != null)
+                               {
+                                       this.networkStream.Close();
+                               }
+                               if (this.socket != null)
+                               {
+                                       this.socket.Close();
+                               }
+
+                               this.receive            = null;
+                               this.send                       = null;
+                               this.socket                     = null;
+                               this.networkStream      = null;
+                       }
+                       catch (IOException)
+                       {
+                               throw;
+                       }
+               }
+
+               #endregion
+
+               #region Internal Methods
+
+               internal int ReadOperation()
+               {
+                       int     op = (this.operation >= 0) ? this.operation     : this.NextOperation();
+                       this.operation = -1;
+
+                       return op;
+               }
+
+               internal int NextOperation()
+               {
+                       do
+                       {
+                               /* loop as long as we are receiving     dummy packets, just
+                                * throwing     them away--note that if we are a server we won't
+                                * be receiving them, but it is better to check for     them at
+                                * this level rather than try to catch them     in all places where
+                                * this routine is called 
+                                */
+                               this.operation = this.receive.ReadInt32();
+                       } while (this.operation == IscCodes.op_dummy);
+
+                       return this.operation;
+               }
+
+               internal GdsResponse ReadGenericResponse()
+               {
+                       try
+                       {
+                               if (this.ReadOperation() ==     IscCodes.op_response)
+                               {
+                                       GdsResponse     r =     new     GdsResponse(
+                                               this.receive.ReadInt32(),
+                                               this.receive.ReadInt64(),
+                                               this.receive.ReadBuffer());
+
+                                       r.Warning =     this.ReadStatusVector();
+
+                                       return r;
+                               }
+                               else
+                               {
+                                       return null;
+                               }
+                       }
+                       catch (IOException)
+                       {
+                               throw new IscException(IscCodes.isc_net_read_err);
+                       }
+               }
+
+               internal IscException ReadStatusVector()
+               {
+                       IscException exception = null;
+                       bool eof = false;
+
+                       try
+                       {
+                               while (!eof)
+                               {
+                                       int     arg     = this.receive.ReadInt32();
+
+                                       switch (arg)
+                                       {
+                                               case IscCodes.isc_arg_gds:
+                                                       int     er = this.receive.ReadInt32();
+                                                       if (er != 0)
+                                                       {
+                                                               if (exception == null)
+                                                               {
+                                                                       exception =     new     IscException();
+                                                               }
+                                                               exception.Errors.Add(arg, er);
+                                                       }
+                                                       break;
+
+                                               case IscCodes.isc_arg_end:
+                                                       if (exception != null && exception.Errors.Count != 0)
+                                                       {
+                                                               exception.BuildExceptionMessage();
+                                                       }
+                                                       eof     = true;
+                                                       break;
+
+                                               case IscCodes.isc_arg_interpreted:
+                                               case IscCodes.isc_arg_string:
+                                                       exception.Errors.Add(arg, this.receive.ReadString());
+                                                       break;
+
+                                               case IscCodes.isc_arg_number:
+                                                       exception.Errors.Add(arg, this.receive.ReadInt32());
+                                                       break;
+
+                                               default:
+                                                       {
+                                                               int     e =     this.receive.ReadInt32();
+                                                               if (e != 0)
+                                                               {
+                                                                       if (exception == null)
+                                                                       {
+                                                                               exception =     new     IscException();
+                                                                       }
+                                                                       exception.Errors.Add(arg, e);
+                                                               }
+                                                       }
+                                                       break;
+                                       }
+                               }
+                       }
+                       catch (IOException)
+                       {
+                               throw new IscException(IscCodes.isc_arg_gds, IscCodes.isc_net_read_err);
+                       }
+
+                       if (exception != null && !exception.IsWarning)
+                       {
+                               throw exception;
+                       }
+
+                       return exception;
+               }
+
+               internal void SetOperation(int operation)
+               {
+                       this.operation = operation;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsDatabase.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsDatabase.cs
new file mode 100644 (file)
index 0000000..15bdca2
--- /dev/null
@@ -0,0 +1,738 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Data;
+using System.Globalization;
+using System.IO;
+using System.Text;
+using System.Net;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Gds
+{
+       internal sealed class GdsDatabase :     IDatabase
+       {
+               #region Callbacks
+
+               public WarningMessageCallback WarningMessage
+               {
+                       get     { return this.warningMessage; }
+                       set     { this.warningMessage = value; }
+               }
+
+               #endregion
+
+               #region Fields
+
+               private WarningMessageCallback warningMessage;
+
+               private GdsConnection   connection;
+               private GdsEventManager eventManager;
+               private Charset                 charset;
+               private int                             handle;
+               private int                             transactionCount;
+               private string                  serverVersion;
+               private short                   packetSize;
+               private short                   dialect;
+               private int                             eventsId;
+               private bool                    disposed;
+
+               #endregion
+
+               #region Properties
+
+               public int Handle
+               {
+                       get     { return this.handle; }
+               }
+
+               public int TransactionCount
+               {
+                       get     { return this.transactionCount; }
+                       set     { this.transactionCount = value; }
+               }
+
+               public string ServerVersion
+               {
+                       get     { return this.serverVersion; }
+               }
+
+               public Charset Charset
+               {
+                       get     { return this.charset; }
+                       set     { this.charset = value; }
+               }
+
+               public short PacketSize
+               {
+                       get     { return this.packetSize; }
+                       set     { this.packetSize =     value; }
+               }
+
+               public short Dialect
+               {
+                       get     { return this.dialect; }
+                       set     { this.dialect = value; }
+               }
+
+               public bool     HasRemoteEventSupport
+               {
+                       get     { return true; }
+               }
+
+               #endregion
+
+               #region Internal properties
+
+               internal XdrStream Send
+               {
+                       get     { return this.connection.Send; }
+               }
+
+               internal XdrStream Receive
+               {
+                       get     { return this.connection.Receive; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public GdsDatabase()
+               {
+                       this.connection = new GdsConnection();
+                       this.charset    = Charset.DefaultCharset;
+                       this.dialect    = 3;
+                       this.packetSize = 8192;
+
+                       GC.SuppressFinalize(this);
+               }
+
+               #endregion
+
+               #region Finalizer
+
+               ~GdsDatabase()
+               {
+                       this.Dispose(false);
+               }
+
+               #endregion
+
+               #region IDisposable     methods
+
+               public void     Dispose()
+               {
+                       this.Dispose(true);
+                       GC.SuppressFinalize(this);
+               }
+
+               private void Dispose(bool disposing)
+               {
+                       lock (this)
+                       {
+                               if (!this.disposed)
+                               {
+                                       try
+                                       {
+                                               // release any unmanaged resources
+                                               this.Detach();
+
+                                               // release any managed resources
+                                               if (disposing)
+                                               {
+                                                       this.connection         = null;
+                                                       this.charset            = null;
+                                                       this.eventManager       = null;
+                                                       this.serverVersion      = null;
+                                                       this.dialect            = 0;
+                                                       this.eventsId           = 0;
+                                                       this.handle                     = 0;
+                                                       this.packetSize         = 0;
+                                                       this.warningMessage     = null;
+                                                       this.transactionCount = 0;
+                                               }
+                                       }
+                                       finally
+                                       {
+                                       }
+
+                                       this.disposed = true;
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Database Methods
+
+               public void     CreateDatabase(DatabaseParameterBuffer dpb,     string dataSource, int port, string     database)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.connection.Connect(dataSource,     port, this.packetSize, this.charset);
+                                       this.Send.Write(IscCodes.op_create);
+                                       this.Send.Write((int)0);
+                                       this.Send.Write(database);
+                                       this.Send.WriteBuffer(dpb.ToArray());
+                                       this.Send.Flush();
+
+                                       try
+                                       {
+                                               this.handle     = this.ReadGenericResponse().ObjectHandle;
+                                               this.Detach();
+                                       }
+                                       catch (IscException)
+                                       {
+                                               try
+                                               {
+                                                       this.connection.Disconnect();
+                                               }
+                                               catch (Exception)
+                                               {
+                                               }
+
+                                               throw;
+                                       }
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_write_err);
+                               }
+                       }
+               }
+
+               public void     DropDatabase()
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.Send.Write(IscCodes.op_drop_database);
+                                       this.Send.Write(this.handle);
+                                       this.Send.Flush();
+
+                                       this.ReadGenericResponse();
+
+                                       this.handle     = 0;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_network_error);
+                               }
+                               finally
+                               {
+                                       try
+                                       {
+                                               this.Detach();
+                                       }
+                                       catch
+                                       {
+                                       }
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Auxiliary connection
+
+               public void     ConnectionRequest(out int auxHandle, out string ipAddress, out int portNumber)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.Send.Write(IscCodes.op_connect_request);
+                                       this.Send.Write(IscCodes.P_REQ_async);  // Connection type
+                                       this.Send.Write(this.handle);                   // Related object
+                                       this.Send.Write(0);                                             // Partner identification
+
+                                       this.Send.Flush();
+
+                                       this.ReadOperation();
+
+                                       auxHandle =     this.Receive.ReadInt32();
+
+                                       // socketaddr_in (non XDR encoded)
+
+                                       // sin_port
+                                       portNumber = BitConverter.ToInt16(this.Receive.ReadBytes(2), 0);
+
+                                       // sin_Family
+                                       this.Receive.ReadBytes(2);
+
+                                       // sin_addr
+                                       byte[] buffer = this.Receive.ReadBytes(4);
+                                       ipAddress =     String.Format(
+                                               CultureInfo.InvariantCulture,
+                                               "{0}.{1}.{2}.{3}", 
+                                               buffer[3], buffer[2], buffer[1], buffer[0]);
+
+                                       // sin_zero     + garbage
+                                       this.Receive.ReadBytes(12);
+
+                                       // Read Status Vector
+                                       this.connection.ReadStatusVector();
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Remote Events Methods
+
+               public void     CloseEventManager()
+               {
+                       lock (this)
+                       {
+                               if (this.eventManager != null)
+                               {
+                                       // Cancel all pending events
+                                       IDictionaryEnumerator e = this.eventManager.EventList.GetEnumerator();
+                                       while (e.MoveNext())
+                                       {
+                                               this.CancelEvents((RemoteEvent)e.Value);
+                                       }
+
+                                       this.eventManager.Close();
+                                       this.eventManager =     null;
+                               }
+                       }
+               }
+
+               public RemoteEvent CreateEvent()
+               {
+                       return new RemoteEvent(this);
+               }
+
+               public void     QueueEvents(RemoteEvent events)
+               {
+                       if (this.eventManager == null)
+                       {
+                               string  ipAddress       = string.Empty;
+                               int             portNumber      = 0;
+                               int             auxHandle       = 0;
+
+                               this.ConnectionRequest(out auxHandle, out ipAddress, out portNumber);
+
+                               this.eventManager =     new     GdsEventManager(auxHandle, ipAddress, portNumber);
+                       }
+
+                       lock (this)
+                       {
+                               try
+                               {
+                                       events.LocalId = ++this.eventsId;
+
+                                       EventParameterBuffer epb = events.ToEpb();
+
+                                       this.Send.Write(IscCodes.op_que_events);// Op codes
+                                       this.Send.Write(this.handle);                   // Database     object id
+                                       this.Send.WriteBuffer(epb.ToArray());   // Event description block
+                                       this.Send.Write(0);                                             // Address of ast routine
+                                       this.Send.Write(0);                                             // Argument     to ast routine                                          
+                                       this.Send.Write(events.LocalId);                // Client side id of remote     event
+
+                                       this.Send.Flush();
+
+                                       // Update event Remote event ID
+                                       events.RemoteId = this.ReadGenericResponse().ObjectHandle;
+
+                                       // Enqueue events in the event manager
+                                       this.eventManager.QueueEvents(events);
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               public void     CancelEvents(RemoteEvent events)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.Send.Write(IscCodes.op_cancel_events);     // Op code
+                                       this.Send.Write(this.handle);                           // Database     object id
+                                       this.Send.Write(events.LocalId);                        // Event ID
+
+                                       this.Send.Flush();
+
+                                       this.ReadGenericResponse();
+
+                                       this.eventManager.CancelEvents(events);
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void     Attach(DatabaseParameterBuffer dpb,     string dataSource, int port, string     database)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.connection.Connect(dataSource,     port, this.packetSize, this.charset);
+
+                                       this.Identify(database);
+
+                                       this.Send.Write(IscCodes.op_attach);
+                                       this.Send.Write((int)0);                                // Database     object ID
+                                       this.Send.Write(database);                              // Database     PATH
+                                       this.Send.WriteBuffer(dpb.ToArray());   // DPB Parameter buffer
+                                       this.Send.Flush();
+
+                                       try
+                                       {
+                                               this.handle     = this.ReadGenericResponse().ObjectHandle;
+                                       }
+                                       catch (IscException)
+                                       {
+                                               try
+                                               {
+                                                       this.connection.Disconnect();
+                                               }
+                                               catch
+                                               {
+                                               }
+                                               throw;
+                                       }
+                               }
+                               catch (IOException)
+                               {
+                                       this.connection.Disconnect();
+
+                                       throw new IscException(IscCodes.isc_net_write_err);
+                               }
+
+                               // Get server version
+                               this.serverVersion = this.GetServerVersion();
+                       }
+               }
+
+               public void     Detach()
+               {
+                       lock (this)
+                       {
+                               if (this.TransactionCount >     0)
+                               {
+                                       throw new IscException(IscCodes.isc_open_trans, this.TransactionCount);
+                               }
+
+                               try
+                               {
+                                       this.Send.Write(IscCodes.op_detach);
+                                       this.Send.Write(this.handle);
+                                       this.Send.Flush();
+
+                                       this.ReadGenericResponse();
+
+                                       // Close the Event Manager
+                                       this.CloseEventManager();
+
+                                       // Close the connection to the server
+                                       this.connection.Disconnect();
+
+                                       this.transactionCount   = 0;
+                                       this.handle                             = 0;
+                                       this.dialect                    = 0;
+                                       this.packetSize                 = 0;
+                                       this.charset                    = null;
+                                       this.connection                 = null;
+                                       this.serverVersion              = null;
+                               }
+                               catch (IOException)
+                               {
+                                       try
+                                       {
+                                               this.connection.Disconnect();
+                                       }
+                                       catch (IOException)
+                                       {
+                                               throw new IscException(IscCodes.isc_network_error);
+                                       }
+
+                                       throw new IscException(IscCodes.isc_network_error);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Transaction     methods
+
+               public ITransaction     BeginTransaction(TransactionParameterBuffer     tpb)
+               {
+                       GdsTransaction transaction = new GdsTransaction(this);
+
+                       transaction.BeginTransaction(tpb);
+
+                       return transaction;
+               }
+
+               #endregion
+
+               #region Statement creation methods
+
+               public StatementBase CreateStatement()
+               {
+                       return new GdsStatement(this);
+               }
+
+               public StatementBase CreateStatement(ITransaction transaction)
+               {
+                       return new GdsStatement(this, transaction as GdsTransaction);
+               }
+
+               #endregion
+
+               #region Parameter Buffer creation methods
+
+               public BlobParameterBuffer CreateBlobParameterBuffer()
+               {
+                       return new BlobParameterBuffer(false);
+               }
+
+               public DatabaseParameterBuffer CreateDatabaseParameterBuffer()
+               {
+                       return new DatabaseParameterBuffer(false);
+               }
+
+               public EventParameterBuffer     CreateEventParameterBuffer()
+               {
+                       return new EventParameterBuffer();
+               }
+
+               public TransactionParameterBuffer CreateTransactionParameterBuffer()
+               {
+                       return new TransactionParameterBuffer(false);
+               }
+
+               #endregion
+
+               #region Database Information methods
+
+               public string GetServerVersion()
+               {
+                       byte[] items = new byte[]
+                       {
+                               IscCodes.isc_info_isc_version,
+                               IscCodes.isc_info_end
+                       };
+
+                       return this.GetDatabaseInfo(items, IscCodes.BUFFER_SIZE_128)[0].ToString();
+               }
+
+               public ArrayList GetDatabaseInfo(byte[] items)
+               {
+                       return this.GetDatabaseInfo(items, IscCodes.MAX_BUFFER_SIZE);
+               }
+
+               public ArrayList GetDatabaseInfo(byte[] items, int bufferLength)
+               {
+                       byte[] buffer = new     byte[bufferLength];
+
+                       this.DatabaseInfo(items, buffer, buffer.Length);
+
+                       return IscHelper.ParseDatabaseInfo(buffer);
+               }
+
+               #endregion
+
+               #region Internal Methods
+
+               internal void ReleaseObject(int op,     int     id)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.Send.Write(op);
+                                       this.Send.Write(id);
+                                       this.Send.Flush();
+
+                                       this.ReadGenericResponse();
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               internal GdsResponse ReadGenericResponse()
+               {
+                       GdsResponse     response = this.connection.ReadGenericResponse();
+
+                       if (response != null && response.Warning !=     null)
+                       {
+                               if (this.warningMessage != null)
+                               {
+                                       this.warningMessage(response.Warning);
+                               }
+                       }
+
+                       return response;
+               }
+
+               internal int ReadOperation()
+               {
+                       return this.connection.ReadOperation();
+               }
+
+               internal int NextOperation()
+               {
+                       return this.connection.NextOperation();
+               }
+
+               internal void SetOperation(int operation)
+               {
+                       this.connection.SetOperation(operation);
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void Identify(string database)
+               {
+                       try
+                       {
+                               // Here we identify     the     user to the     engine.  
+                               // This may     or may not be used as login     info to a database.                             
+#if    (!NETCF)
+                               byte[] user     = Encoding.Default.GetBytes(System.Environment.UserName);
+                               byte[] host     = Encoding.Default.GetBytes(System.Net.Dns.GetHostName());
+#else
+                               byte[] user     = Encoding.Default.GetBytes("fbnetcf");
+                               byte[] host     = Encoding.Default.GetBytes(System.Net.Dns.GetHostName());
+#endif
+
+                               MemoryStream user_id = new MemoryStream();
+
+                               /* User Name */
+                               user_id.WriteByte(1);
+                               user_id.WriteByte((byte)user.Length);
+                               user_id.Write(user,     0, user.Length);
+                               /* Host name */
+                               user_id.WriteByte(4);
+                               user_id.WriteByte((byte)host.Length);
+                               user_id.Write(host,     0, host.Length);
+                               /* Attach/create using this     connection 
+                                * will use     user verification
+                                */
+                               user_id.WriteByte(6);
+                               user_id.WriteByte(0);
+
+                               this.Send.Write(IscCodes.op_connect);
+                               this.Send.Write(IscCodes.op_attach);
+                               this.Send.Write(IscCodes.CONNECT_VERSION2);     // CONNECT_VERSION2
+                               this.Send.Write(1);                                                     // Architecture of client -     Generic
+
+                               this.Send.Write(database);                                      // Database     path
+                               this.Send.Write(1);                                                     // Protocol     versions understood
+                               this.Send.WriteBuffer(user_id.ToArray());       // User identification Stuff
+
+                               this.Send.Write(IscCodes.PROTOCOL_VERSION10);// Protocol version
+                               this.Send.Write(1);                                                     // Architecture of client -     Generic
+                               this.Send.Write(2);                                                     // Minumum type
+                               this.Send.Write(3);                                                     // Maximum type
+                               this.Send.Write(2);                                                     // Preference weight
+
+                               this.Send.Flush();
+
+                               if (this.ReadOperation() ==     IscCodes.op_accept)
+                               {
+                                       this.Receive.ReadInt32();       // Protocol     version
+                                       this.Receive.ReadInt32();       // Architecture for     protocol
+                                       this.Receive.ReadInt32();       // Minimum type
+                               }
+                               else
+                               {
+                                       try
+                                       {
+                                               this.Detach();
+                                       }
+                                       catch (Exception)
+                                       {
+                                       }
+                                       finally
+                                       {
+                                               throw new IscException(IscCodes.isc_connect_reject);
+                                       }
+                               }
+                       }
+                       catch (IOException)
+                       {
+                               // throw new IscException(IscCodes.isc_arg_gds, IscCodes.isc_network_error,     Parameters.DataSource);
+                               throw new IscException(IscCodes.isc_network_error);
+                       }
+               }
+
+               ///     <summary>
+               ///     isc_database_info
+               ///     </summary>
+               private void DatabaseInfo(byte[] items, byte[] buffer, int bufferLength)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       // see src/remote/protocol.h for packet definition (p_info struct)                                      
+                                       this.Send.Write(IscCodes.op_info_database);     //      operation
+                                       this.Send.Write(this.handle);                           //      db_handle
+                                       this.Send.Write(0);                                                     //      incarnation
+                                       this.Send.WriteBuffer(items, items.Length);     //      items
+                                       this.Send.Write(bufferLength);                          //      result buffer length
+
+                                       this.Send.Flush();
+
+                                       GdsResponse     r =     this.ReadGenericResponse();
+
+                                       Buffer.BlockCopy(r.Data, 0,     buffer, 0, bufferLength);
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_network_error);
+                               }
+                       }
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsEventManager.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsEventManager.cs
new file mode 100644 (file)
index 0000000..06ae641
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Threading;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Gds
+{
+       internal class GdsEventManager
+       {
+               #region Fields
+
+               private GdsConnection   connection;
+               private int                             handle;
+               private Thread                  thread;
+               private Hashtable               events;
+
+               #endregion
+
+               #region Properties
+
+               public Hashtable EventList
+               {
+                       get     { return this.events; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public GdsEventManager(int handle, string ipAddress, int portNumber)
+               {
+                       this.events     = new Hashtable();
+                       this.events     = Hashtable.Synchronized(this.events);
+                       this.handle     = handle;
+
+                       // Initialize the connection
+                       if (this.connection     == null)
+                       {
+                               this.connection = new GdsConnection();
+                               this.connection.Connect(ipAddress, portNumber);
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void     QueueEvents(RemoteEvent remoteEvent)
+               {
+                       lock (this)
+                       {
+                               lock (this.events.SyncRoot)
+                               {
+                                       if (!this.events.ContainsKey(remoteEvent.LocalId))
+                                       {
+                                               this.events.Add(remoteEvent.LocalId, remoteEvent);
+                                       }
+                               }
+
+#if    (!NETCF)
+                               if (this.thread == null ||
+                                       (this.thread.ThreadState !=     ThreadState.Running     && this.thread.ThreadState != ThreadState.Background))
+#else
+                               if (this.thread == null)
+#endif
+                               {
+                                       this.thread     = new Thread(new ThreadStart(ThreadHandler));
+                                       this.thread.Start();
+                                       this.thread.IsBackground = true;
+                               }
+                       }
+               }
+
+               public void     CancelEvents(RemoteEvent remoteEvent)
+               {
+                       lock (this.events.SyncRoot)
+                       {
+                               this.events.Remove(remoteEvent.LocalId);
+                       }
+               }
+
+               public void     Close()
+               {
+                       lock (this)
+                       {
+                               if (this.connection     != null)
+                               {
+                                       this.connection.Disconnect();
+                               }
+
+                               if (this.thread != null)
+                               {
+                                       this.thread.Abort();
+                                       this.thread.Join();
+
+                                       this.thread     = null;
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void ThreadHandler()
+               {
+                       int             operation       = -1;
+                       int             dbHandle        = 0;
+                       int             eventId         = 0;
+                       byte[]  buffer          = null;
+                       byte[]  ast                     = null;
+
+                       while (this.events.Count > 0)
+                       {
+                               try
+                               {
+                                       operation =     this.connection.NextOperation();
+
+                                       switch (operation)
+                                       {
+                                               case IscCodes.op_response:
+                                                       this.connection.ReadGenericResponse();
+                                                       break;
+
+                                               case IscCodes.op_exit:
+                                               case IscCodes.op_disconnect:
+                                                       this.connection.Disconnect();
+                                                       return;
+
+                                               case IscCodes.op_event:
+                                                       dbHandle= this.connection.Receive.ReadInt32();
+                                                       buffer  = this.connection.Receive.ReadBuffer();
+                                                       ast             = this.connection.Receive.ReadBytes(8);
+                                                       eventId = this.connection.Receive.ReadInt32();
+
+                                                       if (this.events.ContainsKey(eventId))
+                                                       {
+                                                               RemoteEvent     currentEvent = (RemoteEvent)this.events[eventId];
+
+                                                               lock (this.events.SyncRoot)
+                                                               {
+                                                                       // Remove event from the list
+                                                                       this.events.Remove(eventId);
+
+                                                                       // Notify new event     counts
+                                                                       currentEvent.EventCounts(buffer);
+
+                                                                       if (this.events.Count == 0)
+                                                                       {
+                                                                               return;
+                                                                       }
+                                                               }
+                                                       }
+                                                       break;
+                                       }
+                               }
+                               catch (ThreadAbortException)
+                               {
+                                       return;
+                               }
+                               catch (Exception)
+                               {
+                                       return;
+                               }
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsResponse.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsResponse.cs
new file mode 100644 (file)
index 0000000..2e3eda9
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Gds
+{
+       internal sealed class GdsResponse
+       {
+               #region Fields
+
+               private int                             objectHandle;
+               private long                    blobId;
+               private byte[]                  data;
+               private IscException    warning;
+
+               #endregion
+
+               #region Properties
+
+               public int ObjectHandle
+               {
+                       get     { return objectHandle; }
+               }
+
+               public long     BlobId
+               {
+                       get     { return blobId; }
+               }
+
+               public byte[] Data
+               {
+                       get     { return data; }
+               }
+
+               public IscException     Warning
+               {
+                       get     { return this.warning; }
+                       set     { this.warning = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public GdsResponse(int objectHandle, long blobId, byte[] data)
+               {
+                       this.objectHandle       = objectHandle;
+                       this.blobId                     = blobId;
+                       this.data                       = data;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsServiceManager.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsServiceManager.cs
new file mode 100644 (file)
index 0000000..77d701a
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Gds
+{
+       internal sealed class GdsServiceManager : IServiceManager
+       {
+               #region Fields
+
+               private int                             handle;
+               private GdsConnection   connection;
+
+               #endregion
+
+               #region Properties
+
+               public int Handle
+               {
+                       get     { return this.handle; }
+               }
+
+               public bool     IsLittleEndian
+               {
+                       get     { return false; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public GdsServiceManager()
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void     Attach(ServiceParameterBuffer spb, string dataSource, int port, string service)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       if (this.connection     == null)
+                                       {
+                                               this.connection = new GdsConnection();
+                                       }
+
+                                       this.connection.Connect(dataSource,     port, 8192,     Charset.DefaultCharset);
+
+                                       this.connection.Send.Write(IscCodes.op_service_attach);
+                                       this.connection.Send.Write(0);
+                                       this.connection.Send.Write(service);
+                                       this.connection.Send.WriteBuffer(spb.ToArray());
+                                       this.connection.Send.Flush();
+
+                                       try
+                                       {
+                                               this.handle     = this.connection.ReadGenericResponse().ObjectHandle;
+                                       }
+                                       catch (IscException)
+                                       {
+                                               try
+                                               {
+                                                       this.Detach();
+                                               }
+                                               catch
+                                               {
+                                               }
+
+                                               throw;
+                                       }
+                               }
+                               catch (IOException)
+                               {
+                                       this.connection.Disconnect();
+
+                                       throw new IscException(IscCodes.isc_net_write_err);
+                               }
+                       }
+               }
+
+               public void     Detach()
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.connection.Send.Write(IscCodes.op_service_detach);
+                                       this.connection.Send.Write(this.Handle);
+                                       this.connection.Send.Flush();
+
+                                       this.connection.ReadGenericResponse();
+
+                                       this.handle     = 0;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_network_error);
+                               }
+                               finally
+                               {
+                                       try
+                                       {
+                                               this.connection.Disconnect();
+                                       }
+                                       catch (IOException)
+                                       {
+                                               throw new IscException(IscCodes.isc_network_error);
+                                       }
+                               }
+                       }
+               }
+
+               public void     Start(ServiceParameterBuffer spb)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.connection.Send.Write(IscCodes.op_service_start);
+                                       this.connection.Send.Write(this.Handle);
+                                       this.connection.Send.Write(0);
+                                       this.connection.Send.WriteBuffer(spb.ToArray(), spb.Length);
+                                       this.connection.Send.Flush();
+
+                                       try
+                                       {
+                                               this.connection.ReadGenericResponse();
+                                       }
+                                       catch (IscException)
+                                       {
+                                               throw;
+                                       }
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_write_err);
+                               }
+                       }
+               }
+
+               public void     Query(
+                       ServiceParameterBuffer spb,
+                       int             requestLength,
+                       byte[]  requestBuffer,
+                       int             bufferLength,
+                       byte[]  buffer)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.connection.Send.Write(IscCodes.op_service_info);   //      operation
+                                       this.connection.Send.Write(this.Handle);                                //      db_handle
+                                       this.connection.Send.Write((int)0);                                             //      incarnation                                     
+                                       this.connection.Send.WriteTyped(
+                                               IscCodes.isc_spb_version, spb.ToArray());                       //      Service parameter buffer
+                                       this.connection.Send.WriteBuffer(
+                                               requestBuffer, requestLength);                                          //      request buffer
+                                       this.connection.Send.Write(bufferLength);                               //      result buffer length
+
+                                       this.connection.Send.Flush();
+
+                                       GdsResponse     r =     this.connection.ReadGenericResponse();
+
+                                       Buffer.BlockCopy(r.Data, 0,     buffer, 0, bufferLength);
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_network_error);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Buffer creation methods
+
+               public ServiceParameterBuffer CreateParameterBuffer()
+               {
+                       return new ServiceParameterBuffer();
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsStatement.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsStatement.cs
new file mode 100644 (file)
index 0000000..6db9df5
--- /dev/null
@@ -0,0 +1,792 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.Text;
+using System.IO;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Gds
+{
+       internal class GdsStatement     : StatementBase
+       {
+               #region Fields
+
+               private int                             handle;
+               private GdsDatabase             db;
+               private GdsTransaction  transaction;
+               private Descriptor              parameters;
+               private Descriptor              fields;
+               private StatementState  state;
+               private DbStatementType statementType;
+               private bool                    allRowsFetched;
+               private Queue                   rows;
+               private Queue                   outputParams;
+               private int                             recordsAffected;
+               private int                             fetchSize;
+
+               #endregion
+
+               #region Properties
+
+               public override IDatabase DB
+               {
+                       get     { return this.db; }
+                       set     { this.db =     (GdsDatabase)value;     }
+               }
+
+               public override ITransaction Transaction
+               {
+                       get     { return this.transaction; }
+                       set
+                       {
+                               if (value == null)
+                               {
+                                       this.transaction = null;
+                               }
+                               else
+                               {
+                                       bool addHandler = false;
+                                       if (this.transaction != value)
+                                       {
+                                               if (this.TransactionUpdate != null && this.transaction != null)
+                                               {
+                                                       this.transaction.Update -= this.TransactionUpdate;
+                                                       this.TransactionUpdate = null;
+                                               }
+
+                                               // Add event handler for transaction updates
+                                               this.TransactionUpdate = new TransactionUpdateEventHandler(this.TransactionUpdated);
+
+                                               addHandler = true;
+                                       }
+
+                                       this.transaction = (GdsTransaction)value;
+
+                                       if (addHandler && this.transaction != null)
+                                       {
+                                               this.transaction.Update += this.TransactionUpdate;
+                                       }
+                               }
+                       }
+               }
+
+               public override Descriptor Parameters
+               {
+                       get     { return this.parameters; }
+                       set     { this.parameters =     value; }
+               }
+
+               public override Descriptor Fields
+               {
+                       get     { return this.fields; }
+               }
+
+               public override int     RecordsAffected
+               {
+                       get     { return this.recordsAffected; }
+               }
+
+               public override bool IsPrepared
+               {
+                       get
+                       {
+                               if (this.state == StatementState.Deallocated ||
+                                       this.state == StatementState.Error)
+                               {
+                                       return false;
+                               }
+                               else
+                               {
+                                       return true;
+                               }
+                       }
+               }
+
+               public override DbStatementType StatementType
+               {
+                       get     { return this.statementType; }
+                       set     { this.statementType = value; }
+               }
+
+               public override StatementState State
+               {
+                       get     { return this.state; }
+                       set     { this.state = value; }
+               }
+
+               public override int     FetchSize
+               {
+                       get     { return this.fetchSize; }
+                       set     { this.fetchSize = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public GdsStatement(IDatabase db) :     this(db, null)
+               {
+               }
+
+               public GdsStatement(IDatabase db, ITransaction transaction)
+               {
+                       if (!(db is     GdsDatabase))
+                       {
+                               throw new ArgumentException("Specified argument is not of GdsDatabase type.");
+                       }
+                       if (transaction != null && !(transaction is     GdsTransaction))
+                       {
+                               throw new ArgumentException("Specified argument is not of GdsTransaction type.");
+                       }
+
+                       this.fetchSize                  = 200;
+                       this.recordsAffected    = -1;
+                       this.rows                               = new Queue();
+                       this.outputParams               = new Queue();
+                       
+                       this.db = (GdsDatabase)db;
+                       if (transaction != null)
+                       {
+                               this.Transaction = transaction;
+                       }
+
+                       GC.SuppressFinalize(this);
+               }
+
+               #endregion
+
+               #region IDisposable     Methods
+
+               protected override void Dispose(bool disposing)
+               {
+                       if (!this.IsDisposed)
+                       {
+                               try
+                               {
+                                       // release any unmanaged resources
+                                       this.Release();
+
+                                       // release any managed resources
+                                       if (disposing)
+                                       {
+                                               this.Clear();
+                                               this.rows                       = null;
+                                               this.outputParams       = null;
+                                               this.db                         = null;
+                                               this.fields                     = null;
+                                               this.parameters         = null;
+                                               this.transaction        = null;
+                                               this.allRowsFetched     = false;
+                                               this.state                      = StatementState.Deallocated;
+                                               this.handle                     = 0;
+                                               this.fetchSize          = 0;
+                                               this.recordsAffected = 0;
+                                       }
+                               }
+                               finally
+                               {
+                                       base.Dispose(disposing);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Blob Creation Metods
+
+               public override BlobBase CreateBlob()
+               {
+                       return new GdsBlob(this.db,     this.transaction);
+               }
+
+               public override BlobBase CreateBlob(long blobId)
+               {
+                       return new GdsBlob(this.db,     this.transaction, blobId);
+               }
+
+               #endregion
+
+               #region Array Creation Methods
+
+               public override ArrayBase CreateArray(ArrayDesc descriptor)
+               {
+                       return new GdsArray(descriptor);
+               }
+
+               public override ArrayBase CreateArray(string tableName, string fieldName)
+               {
+                       return new GdsArray(this.db, this.transaction, tableName, fieldName);
+               }
+
+               public override ArrayBase CreateArray(long handle, string tableName, string     fieldName)
+               {
+                       return new GdsArray(this.db, this.transaction, handle, tableName, fieldName);
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Prepare(string     commandText)
+               {
+                       // Clear data
+                       this.Clear();
+                       this.parameters = null;
+                       this.fields             = null;
+
+                       lock (this.db)
+                       {
+                               if (this.state == StatementState.Deallocated)
+                               {
+                                       // Allocate     statement
+                                       this.Allocate();
+                               }
+
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_prepare_statement);
+                                       this.db.Send.Write(this.transaction.Handle);
+                                       this.db.Send.Write(this.handle);
+                                       this.db.Send.Write((int)this.db.Dialect);
+                                       this.db.Send.Write(commandText);
+                                       this.db.Send.WriteBuffer(
+                                               DescribeInfoItems,
+                                               DescribeInfoItems.Length);
+                                       this.db.Send.Write(IscCodes.MAX_BUFFER_SIZE);
+                                       this.db.Send.Flush();
+
+                                       GdsResponse     r =     this.db.ReadGenericResponse();
+                                       this.fields     = this.ParseSqlInfo(r.Data,     DescribeInfoItems);
+
+                                       // Determine the statement type
+                                       this.statementType = this.GetStatementType();
+
+                                       this.state = StatementState.Prepared;
+                               }
+                               catch (IOException)
+                               {
+                                       this.state = StatementState.Error;
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               public override void Execute()
+               {
+                       if (this.state == StatementState.Deallocated)
+                       {
+                               throw new InvalidOperationException("Statment is not correctly created.");
+                       }
+
+                       // Clear data
+                       this.Clear();
+
+                       lock (this.db)
+                       {
+                               try
+                               {
+                                       byte[] descriptor =     null;
+                                       if (this.parameters     != null)
+                                       {
+                                               XdrStream xdr = new     XdrStream(this.db.Charset);
+                                               xdr.Write(this.parameters);
+
+                                               descriptor = xdr.ToArray();
+
+                                               xdr.Close();
+                                       }
+
+                                       if (this.statementType == DbStatementType.StoredProcedure)
+                                       {
+                                               this.db.Send.Write(IscCodes.op_execute2);
+                                       }
+                                       else
+                                       {
+                                               this.db.Send.Write(IscCodes.op_execute);
+                                       }
+
+                                       this.db.Send.Write(this.handle);
+                                       this.db.Send.Write(this.transaction.Handle);
+
+                                       if (this.parameters     != null)
+                                       {
+                                               this.db.Send.WriteBuffer(this.parameters.ToBlrArray());
+                                               this.db.Send.Write(0);  // Message number
+                                               this.db.Send.Write(1);  // Number of messages
+                                               this.db.Send.Write(descriptor, 0, descriptor.Length);
+                                       }
+                                       else
+                                       {
+                                               this.db.Send.WriteBuffer(null);
+                                               this.db.Send.Write(0);
+                                               this.db.Send.Write(0);
+                                       }
+
+                                       if (this.statementType == DbStatementType.StoredProcedure)
+                                       {
+                                               this.db.Send.WriteBuffer(
+                                                       this.fields     == null ? null : this.fields.ToBlrArray());
+                                               this.db.Send.Write(0);  // Output message number
+                                       }
+
+                                       this.db.Send.Flush();
+
+                                       if (this.db.NextOperation()     == IscCodes.op_sql_response)
+                                       {
+                                               // This would be an     Execute procedure
+                                               this.outputParams.Enqueue(this.ReceiveSqlResponse());
+                                       }
+
+                                       this.db.ReadGenericResponse();
+
+                                       // Updated number of records affected by the statement execution                        
+                                       if (this.StatementType == DbStatementType.Insert ||
+                                               this.StatementType == DbStatementType.Delete ||
+                                               this.StatementType == DbStatementType.Update)
+                                       {
+                                               this.recordsAffected = this.GetRecordsAffected();
+                                       }
+                                       else
+                                       {
+                                               this.recordsAffected = -1;
+                                       }
+
+                                       this.state = StatementState.Executed;
+                               }
+                               catch (IOException)
+                               {
+                                       this.state = StatementState.Error;
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               public override DbValue[] Fetch()
+               {
+                       if (this.state == StatementState.Deallocated)
+                       {
+                               throw new InvalidOperationException("Statement is not correctly created.");
+                       }
+                       if (this.statementType != DbStatementType.Select &&
+                               this.statementType != DbStatementType.SelectForUpdate)
+                       {
+                               return null;
+                       }
+
+                       if (!this.allRowsFetched &&     this.rows.Count == 0)
+                       {
+                               // Fetch next batch     of rows
+                               lock (this.db)
+                               {
+                                       try
+                                       {
+                                               this.db.Send.Write(IscCodes.op_fetch);
+                                               this.db.Send.Write(this.handle);
+                                               this.db.Send.WriteBuffer(this.fields.ToBlrArray());
+                                               this.db.Send.Write(0);                  // p_sqldata_message_number                                             
+                                               this.db.Send.Write(fetchSize);  // p_sqldata_messages
+                                               this.db.Send.Flush();
+
+                                               if (this.db.NextOperation()     == IscCodes.op_fetch_response)
+                                               {
+                                                       int     status  = 0;
+                                                       int     count   = 1;
+                                                       int     op              = 0;
+
+                                                       while (count > 0 &&     status == 0)
+                                                       {
+                                                               op              = this.db.ReadOperation();
+                                                               status  = this.db.Receive.ReadInt32();
+                                                               count   = this.db.Receive.ReadInt32();
+
+                                                               if (count >     0 && status     == 0)
+                                                               {
+                                                                       this.rows.Enqueue(this.ReadDataRow());
+                                                               }
+                                                       }
+
+                                                       if (status == 100)
+                                                       {
+                                                               this.allRowsFetched     = true;
+                                                       }
+                                               }
+                                               else
+                                               {
+                                                       this.db.ReadGenericResponse();
+                                               }
+                                       }
+                                       catch (IOException)
+                                       {
+                                               throw new IscException(IscCodes.isc_net_read_err);
+                                       }
+                               }
+                       }
+
+                       if (this.rows != null && this.rows.Count > 0)
+                       {
+                               // return current row
+                               return (DbValue[])this.rows.Dequeue();
+                       }
+                       else
+                       {
+                               // All readed clear     rows and return null
+                               this.rows.Clear();
+
+                               return null;
+                       }
+               }
+
+               public override DbValue[] GetOuputParameters()
+               {
+                       if (this.outputParams.Count     > 0)
+                       {
+                               return (DbValue[])this.outputParams.Dequeue();
+                       }
+
+                       return null;
+               }
+
+               public override void Describe()
+               {
+                       try
+                       {
+                               byte[] buffer   = this.GetSqlInfo(DescribeInfoItems);
+                               this.fields             = this.ParseSqlInfo(buffer,     DescribeInfoItems);
+                       }
+                       catch (IscException)
+                       {
+                               throw;
+                       }
+               }
+
+               public override void DescribeParameters()
+               {
+                       try
+                       {
+                               byte[] buffer   = this.GetSqlInfo(DescribeBindInfoItems);
+                               this.parameters = this.ParseSqlInfo(buffer,     DescribeBindInfoItems);
+                       }
+                       catch (IscException)
+                       {
+                               throw;
+                       }
+               }
+
+               public override byte[] GetSqlInfo(byte[] items, int     bufferLength)
+               {
+                       lock (this.db)
+                       {
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_info_sql);
+                                       this.db.Send.Write(this.handle);
+                                       this.db.Send.Write(0);
+                                       this.db.Send.WriteBuffer(items, items.Length);
+                                       this.db.Send.Write(bufferLength);
+                                       this.db.Send.Flush();
+
+                                       return this.db.ReadGenericResponse().Data;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void Free(int option)
+               {
+                       // Does not     seem to be possible     or necessary to close
+                       // an execute procedure statement.
+                       if (this.StatementType == DbStatementType.StoredProcedure &&
+                               option == IscCodes.DSQL_close)
+                       {
+                               return;
+                       }
+
+                       lock (this.db)
+                       {
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_free_statement);
+                                       this.db.Send.Write(this.handle);
+                                       this.db.Send.Write(option);
+                                       this.db.Send.Flush();
+
+                                       // Reset statement information
+                                       if (option == IscCodes.DSQL_drop)
+                                       {
+                                               this.parameters = null;
+                                               this.fields             = null;
+                                       }
+
+                                       this.Clear();
+                                       this.allRowsFetched     = false;
+
+                                       this.db.ReadGenericResponse();
+                               }
+                               catch (IOException)
+                               {
+                                       this.state = StatementState.Error;
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               protected override void TransactionUpdated(object sender, EventArgs     e)
+               {
+                       lock (this)
+                       {
+                               if (this.Transaction != null && this.TransactionUpdate != null)
+                               {
+                                       this.Transaction.Update -= this.TransactionUpdate;
+                               }
+
+                               this.State                              = StatementState.Closed;
+                               this.TransactionUpdate  = null;
+                               this.allRowsFetched             = false;
+                       }
+               }
+
+               #endregion
+
+               #region Response Methods
+
+               private DbValue[] ReceiveSqlResponse()
+               {
+                       try
+                       {
+                               if (this.db.ReadOperation()     == IscCodes.op_sql_response)
+                               {
+                                       int     messages = this.db.Receive.ReadInt32();
+                                       if (messages > 0)
+                                       {
+                                               return this.ReadDataRow();
+                                       }
+                                       else
+                                       {
+                                               return null;
+                                       }
+                               }
+                               else
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+                       catch (IOException)
+                       {
+                               throw new IscException(IscCodes.isc_net_read_err);
+                       }
+               }
+
+               private DbValue[] ReadDataRow()
+               {
+                       DbValue[]       row             = new DbValue[this.fields.Count];
+                       object          value   = null;
+
+                       lock (this.db)
+                       {
+                               // This only works if not (port->port_flags     & PORT_symmetric)                               
+                               for     (int i = 0;     i <     this.fields.Count; i++)
+                               {
+                                       try
+                                       {
+                                               value   = this.db.Receive.ReadValue(this.fields[i]);
+                                               row[i]  = new DbValue(this,     this.fields[i], value);
+                                       }
+                                       catch (IOException)
+                                       {
+                                               throw new IscException(IscCodes.isc_net_read_err);
+                                       }
+                               }
+                       }
+
+                       return row;
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void Clear()
+               {
+                       if (this.rows != null && this.rows.Count > 0)
+                       {
+                               this.rows.Clear();
+                       }
+                       if (this.outputParams != null && this.outputParams.Count > 0)
+                       {
+                               this.outputParams.Clear();
+                       }
+               }
+
+               private void Allocate()
+               {
+                       lock (this.db)
+                       {
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_allocate_statement);
+                                       this.db.Send.Write(this.db.Handle);
+                                       this.db.Send.Flush();
+
+                                       this.handle                     = this.db.ReadGenericResponse().ObjectHandle;
+                                       this.allRowsFetched     = false;
+                                       this.state                      = StatementState.Allocated;
+                                       this.statementType      = DbStatementType.None;
+                               }
+                               catch (IOException)
+                               {
+                                       this.state = StatementState.Deallocated;
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               private Descriptor ParseSqlInfo(byte[] info, byte[]     items)
+               {
+                       Descriptor rowDesc = null;
+                       int     lastindex =     0;
+
+                       while ((lastindex =     this.ParseTruncSqlInfo(info, ref rowDesc, lastindex)) > 0)
+                       {
+                               lastindex--;                       // Is this OK ?
+
+                               byte[] new_items = new byte[4 + items.Length];
+
+                               new_items[0] = IscCodes.isc_info_sql_sqlda_start;
+                               new_items[1] = 2;
+                               new_items[2] = (byte)(lastindex & 255);
+                               new_items[3] = (byte)(lastindex >> 8);
+
+                               Array.Copy(items, 0, new_items, 4, items.Length);
+                               info = this.GetSqlInfo(new_items, info.Length);
+                       }
+
+                       return rowDesc;
+               }
+
+               private int     ParseTruncSqlInfo(byte[] info, ref Descriptor rowDesc, int lastindex)
+               {
+                       byte item       = 0;
+                       int     index   = 0;
+                       int     i               = 2;
+
+                       int     len     = IscHelper.VaxInteger(info, i, 2);
+                       i += 2;
+                       int     n =     IscHelper.VaxInteger(info, i, len);
+                       i += len;
+
+                       if (rowDesc     == null)
+                       {
+                               rowDesc = new Descriptor((short)n);
+                       }
+
+                       while (info[i] != IscCodes.isc_info_end)
+                       {
+                               while ((item = info[i++]) != IscCodes.isc_info_sql_describe_end)
+                               {
+                                       switch (item)
+                                       {
+                                               case IscCodes.isc_info_sql_sqlda_seq:
+                                                       len     = IscHelper.VaxInteger(info, i, 2);
+                                                       i += 2;
+                                                       index = IscHelper.VaxInteger(info, i, len);
+                                                       i += len;
+                                                       break;
+
+                                               case IscCodes.isc_info_sql_type:
+                                                       len     = IscHelper.VaxInteger(info, i, 2);
+                                                       i += 2;
+                                                       rowDesc[index - 1].DataType     = (short)IscHelper.VaxInteger(info,     i, len);
+                                                       i += len;
+                                                       break;
+
+                                               case IscCodes.isc_info_sql_sub_type:
+                                                       len     = IscHelper.VaxInteger(info, i, 2);
+                                                       i += 2;
+                                                       rowDesc[index - 1].SubType = (short)IscHelper.VaxInteger(info, i, len);
+                                                       i += len;
+                                                       break;
+
+                                               case IscCodes.isc_info_sql_scale:
+                                                       len     = IscHelper.VaxInteger(info, i, 2);
+                                                       i += 2;
+                                                       rowDesc[index - 1].NumericScale = (short)IscHelper.VaxInteger(info,     i, len);
+                                                       i += len;
+                                                       break;
+
+                                               case IscCodes.isc_info_sql_length:
+                                                       len     = IscHelper.VaxInteger(info, i, 2);
+                                                       i += 2;
+                                                       rowDesc[index - 1].Length =     (short)IscHelper.VaxInteger(info, i, len);
+                                                       i += len;
+                                                       break;
+
+                                               case IscCodes.isc_info_sql_field:
+                                                       len     = IscHelper.VaxInteger(info, i, 2);
+                                                       i += 2;
+                                                       rowDesc[index - 1].Name = Encoding.Default.GetString(info, i, len);
+                                                       i += len;
+                                                       break;
+
+                                               case IscCodes.isc_info_sql_relation:
+                                                       len     = IscHelper.VaxInteger(info, i, 2);
+                                                       i += 2;
+                                                       rowDesc[index - 1].Relation     = Encoding.Default.GetString(info, i, len);
+                                                       i += len;
+                                                       break;
+
+                                               case IscCodes.isc_info_sql_owner:
+                                                       len     = IscHelper.VaxInteger(info, i, 2);
+                                                       i += 2;
+                                                       rowDesc[index - 1].Owner = Encoding.Default.GetString(info,     i, len);
+                                                       i += len;
+                                                       break;
+
+                                               case IscCodes.isc_info_sql_alias:
+                                                       len     = IscHelper.VaxInteger(info, i, 2);
+                                                       i += 2;
+                                                       rowDesc[index - 1].Alias = Encoding.Default.GetString(info,     i, len);
+                                                       i += len;
+                                                       break;
+
+                                               case IscCodes.isc_info_truncated:
+                                                       return lastindex;
+
+                                               default:
+                                                       throw new IscException(IscCodes.isc_dsql_sqlda_err);
+                                       }
+                               }
+
+                               lastindex =     index;
+                       }
+
+                       return 0;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsTransaction.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsTransaction.cs
new file mode 100644 (file)
index 0000000..ef95ad6
--- /dev/null
@@ -0,0 +1,369 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.IO;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Gds
+{
+       internal sealed class GdsTransaction : ITransaction, IDisposable
+       {
+               #region Events
+
+               public event TransactionUpdateEventHandler Update;
+
+               #endregion
+
+               #region Fields
+
+               private int                                     handle;
+               private GdsDatabase                     db;
+               private TransactionState        state;
+               private bool                            disposed;
+
+               #endregion
+
+               #region Properties
+
+               public int Handle
+               {
+                       get     { return this.handle; }
+               }
+
+               public TransactionState State
+               {
+                       get     { return this.state; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public GdsTransaction(IDatabase db)
+               {
+                       if (!(db is     GdsDatabase))
+                       {
+                               throw new ArgumentException("Specified argument is not of GdsDatabase type.");
+                       }
+
+                       this.db         = (GdsDatabase)db;
+                       this.state      = TransactionState.NoTransaction;
+
+                       GC.SuppressFinalize(this);
+               }
+
+               #endregion
+
+               #region Finalizer
+
+               ~GdsTransaction()
+               {
+                       this.Dispose(false);
+               }
+
+               #endregion
+
+               #region IDisposable     methods
+
+               public void     Dispose()
+               {
+                       this.Dispose(true);
+                       GC.SuppressFinalize(this);
+               }
+
+               private void Dispose(bool disposing)
+               {
+                       lock (this)
+                       {
+                               if (!this.disposed)
+                               {
+                                       try
+                                       {
+                                               // release any unmanaged resources
+                                               this.Rollback();
+
+                                               // release any managed resources
+                                               if (disposing)
+                                               {
+                                                       this.db         = null;
+                                                       this.handle     = 0;
+                                                       this.state      = TransactionState.NoTransaction;
+                                               }
+                                       }
+                                       finally
+                                       {
+                                               this.disposed = true;
+                                       }
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void     BeginTransaction(TransactionParameterBuffer     tpb)
+               {
+                       lock (this.db)
+                       {
+                               if (this.state != TransactionState.NoTransaction)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds,
+                                               IscCodes.isc_tra_state,
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TrasactionStarting;
+
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_transaction);
+                                       this.db.Send.Write(this.db.Handle);
+                                       this.db.Send.WriteBuffer(tpb.ToArray());
+                                       this.db.Send.Flush();
+
+                                       this.handle     = db.ReadGenericResponse().ObjectHandle;
+                                       this.state      = TransactionState.TransactionStarted;
+
+                                       this.db.TransactionCount++;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               public void     Commit()
+               {
+                       lock (this.db)
+                       {
+                               if (this.state != TransactionState.TransactionStarted &&
+                                       this.state != TransactionState.TransactionPrepared)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds,
+                                               IscCodes.isc_tra_state,
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TransactionCommiting;
+
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_commit);
+                                       this.db.Send.Write(this.handle);
+                                       this.db.Send.Flush();
+
+                                       this.db.ReadGenericResponse();
+
+                                       this.db.TransactionCount--;
+
+                                       if (this.Update != null)
+                                       {
+                                               this.Update(this, new EventArgs());
+                                       }
+
+                                       this.state = TransactionState.NoTransaction;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               public void     Rollback()
+               {
+                       lock (this.db)
+                       {
+                               if (this.state == TransactionState.NoTransaction)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds,
+                                               IscCodes.isc_tra_state,
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TransactionRollbacking;
+
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_rollback);
+                                       this.db.Send.Write(this.handle);
+                                       this.db.Send.Flush();
+
+                                       this.db.ReadGenericResponse();
+
+                                       this.db.TransactionCount--;
+
+                                       if (this.Update != null)
+                                       {
+                                               this.Update(this, new EventArgs());
+                                       }
+
+                                       this.state = TransactionState.NoTransaction;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               public void     CommitRetaining()
+               {
+                       lock (this.db)
+                       {
+                               if (this.state != TransactionState.TransactionStarted &&
+                                       this.state != TransactionState.TransactionPrepared)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds,
+                                               IscCodes.isc_tra_state,
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TransactionCommiting;
+
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_commit_retaining);
+                                       this.db.Send.Write(this.handle);
+                                       this.db.Send.Flush();
+
+                                       this.db.ReadGenericResponse();
+
+                                       this.state = TransactionState.TransactionStarted;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               public void     RollbackRetaining()
+               {
+                       lock (this.db)
+                       {
+                               if (this.state != TransactionState.TransactionStarted &&
+                                       this.state != TransactionState.TransactionPrepared)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds,
+                                               IscCodes.isc_tra_state,
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TransactionRollbacking;
+
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_rollback_retaining);
+                                       this.db.Send.Write(this.handle);
+                                       this.db.Send.Flush();
+
+                                       this.db.ReadGenericResponse();
+
+                                       this.state = TransactionState.TransactionStarted;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               public void     Prepare()
+               {
+                       lock (this.db)
+                       {
+                               if (this.state != TransactionState.TransactionStarted)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds,
+                                               IscCodes.isc_tra_state,
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TransactionPreparing;
+
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_prepare);
+                                       this.db.Send.Write(this.handle);
+                                       this.db.Send.Flush();
+
+                                       this.db.ReadGenericResponse();
+
+                                       this.state = TransactionState.TransactionPrepared;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               public void     Prepare(byte[] buffer)
+               {
+                       lock (this.db)
+                       {
+                               if (this.state != TransactionState.TransactionStarted)
+                               {
+                                       throw new IscException(
+                                               IscCodes.isc_arg_gds,
+                                               IscCodes.isc_tra_state,
+                                               this.handle,
+                                               "no     valid");
+                               }
+
+                               this.state = TransactionState.TransactionPreparing;
+
+                               try
+                               {
+                                       this.db.Send.Write(IscCodes.op_prepare2);
+                                       this.db.Send.Write(this.handle);
+                                       this.db.Send.WriteBuffer(buffer, buffer.Length);
+                                       this.db.Send.Flush();
+
+                                       this.db.ReadGenericResponse();
+
+                                       this.state = TransactionState.TransactionStarted;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_read_err);
+                               }
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/XdrStream.cs b/mcs/class/FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/XdrStream.cs
new file mode 100644 (file)
index 0000000..e855d44
--- /dev/null
@@ -0,0 +1,718 @@
+/*
+ *     Firebird ADO.NET Data provider for .NET and     Mono 
+ * 
+ *        The contents of this file are subject to     the     Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except     in compliance with the 
+ *        License.     You     may     obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software     distributed     under the License is distributed on     
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied.  See     the     License for     the     specific 
+ *        language     governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002,     2004 Carlos     Guzman Alvarez
+ *     All     Rights Reserved.
+ */
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Globalization;
+
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Gds
+{
+       internal class XdrStream : Stream
+       {
+               #region Static Fields
+
+               private static byte[] fill;
+               private static byte[] pad;
+
+               #endregion
+
+               #region Static Properties
+
+               internal static byte[] Fill
+               {
+                       get
+                       {
+                               if (fill ==     null)
+                               {
+                                       fill = new byte[32767];
+                                       for     (int i = 0;     i <     fill.Length; i++)
+                                       {
+                                               fill[i] = 32;
+                                       }
+                               }
+
+                               return fill;
+                       }
+               }
+
+               private static byte[] Pad
+               {
+                       get
+                       {
+                               if (pad == null)
+                               {
+                                       pad     = new byte[] { 0, 0, 0, 0 };
+                               }
+
+                               return pad;
+                       }
+               }
+
+               #endregion
+
+               #region Fields
+
+               private byte[]  buffer;
+               private Charset charset;
+               private Stream  innerStream;
+
+               #endregion
+
+               #region Stream Properties
+
+               public override bool CanWrite
+               {
+                       get     { return this.innerStream.CanWrite;     }
+               }
+
+               public override bool CanRead
+               {
+                       get     { return this.innerStream.CanRead; }
+               }
+
+               public override bool CanSeek
+               {
+                       get     { return this.innerStream.CanSeek; }
+               }
+
+               public override long Position
+               {
+                       get     { return this.innerStream.Position;     }
+                       set     { this.innerStream.Position     = value; }
+               }
+
+               public override long Length
+               {
+                       get     { return this.innerStream.Length; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public XdrStream() : this(new MemoryStream(), Charset.DefaultCharset)
+               {
+               }
+
+               public XdrStream(Charset charset) :     this(new MemoryStream(), charset)
+               {
+               }
+
+               public XdrStream(byte[] buffer, Charset charset) : this(new     MemoryStream(buffer), charset)
+               {
+               }
+
+               public XdrStream(Stream innerStream, Charset charset) : base()
+               {
+                       this.buffer                     = new byte[8] { 0, 0, 0, 0,     0, 0, 0, 0 };
+                       this.innerStream        = innerStream;
+                       this.charset            = charset;
+               }
+
+               #endregion
+
+               #region Stream methods
+
+               public override void Close()
+               {
+                       if (this.innerStream != null)
+                       {
+                               this.innerStream.Close();
+                       }
+                       this.buffer                     = null;
+                       this.charset            = null;
+                       this.innerStream        = null;
+               }
+
+               public override void Flush()
+               {
+                       this.CheckDisposed();
+
+                       this.innerStream.Flush();
+               }
+
+               public override void SetLength(long     length)
+               {
+                       this.CheckDisposed();
+
+                       this.innerStream.SetLength(length);
+               }
+
+               public override long Seek(long offset, System.IO.SeekOrigin     loc)
+               {
+                       this.CheckDisposed();
+
+                       return this.innerStream.Seek(offset, loc);
+               }
+
+               public override int     Read(byte[]     buffer, int     offset, int     count)
+               {
+                       this.CheckDisposed();
+
+                       if (this.CanRead)
+                       {
+                               return this.innerStream.Read(buffer, offset, count);
+                       }
+
+                       throw new InvalidOperationException("Read operations are not allowed by this stream");
+               }
+
+               public override void WriteByte(byte     value)
+               {
+                       this.CheckDisposed();
+
+                       this.innerStream.WriteByte(value);
+               }
+
+               public override void Write(byte[] buffer, int offset, int count)
+               {
+                       this.CheckDisposed();
+
+                       if (this.CanWrite)
+                       {
+                               this.innerStream.Write(buffer, offset, count);
+                       }
+                       else
+                       {
+                               throw new InvalidOperationException("Write operations are not allowed by this stream");
+                       }
+               }
+
+               public byte[] ToArray()
+               {
+                       this.CheckDisposed();
+
+                       if (this.innerStream is MemoryStream)
+                       {
+                               return ((MemoryStream)this.innerStream).ToArray();
+                       }
+
+                       throw new InvalidOperationException();
+               }
+
+               #endregion
+
+               #region Xdr     Read Methods
+
+               public byte[] ReadBytes(int     count)
+               {
+                       byte[] buffer = new     byte[count];
+                       this.Read(buffer, 0, buffer.Length);
+
+                       return buffer;
+               }
+
+               public byte[] ReadOpaque(int length)
+               {
+                       byte[]  buffer = new byte[length];
+                       int             readed = 0;
+
+                       if (length > 0)
+                       {
+                               while (readed < length)
+                               {
+                                       readed += this.Read(buffer,     readed, length - readed);
+                               }
+
+                               int     padLength =     ((4     - length) &     3);
+                               if (padLength > 0)
+                               {
+                                       this.Read(Pad, 0, padLength);
+                               }
+                       }
+
+                       return buffer;
+               }
+
+               public byte[] ReadBuffer()
+               {
+                       return this.ReadOpaque(this.ReadInt32());
+               }
+
+               public string ReadString()
+               {
+                       return this.ReadString(this.charset);
+               }
+
+               public string ReadString(int length)
+               {
+                       return this.ReadString(this.charset, length);
+               }
+
+               public string ReadString(Charset charset)
+               {
+                       return this.ReadString(charset, this.ReadInt32());
+               }
+
+               public string ReadString(Charset charset, int length)
+               {
+                       byte[] buffer = this.ReadOpaque(length);
+
+                       return charset.GetString(buffer, 0,     buffer.Length);
+               }
+
+               public short ReadInt16()
+               {
+                       return Convert.ToInt16(this.ReadInt32());
+               }
+
+               public int ReadInt32()
+               {
+                       this.Read(buffer, 0, 4);
+
+                       return IPAddress.HostToNetworkOrder(BitConverter.ToInt32(buffer, 0));
+               }
+
+               public long     ReadInt64()
+               {
+                       this.Read(buffer, 0, 8);
+
+                       return IPAddress.HostToNetworkOrder(BitConverter.ToInt64(buffer, 0));
+               }
+
+               public Guid     ReadGuid(int length)
+               {
+                       return new Guid(this.ReadOpaque(length));
+               }
+
+               public float ReadSingle()
+               {
+                       return BitConverter.ToSingle(BitConverter.GetBytes(this.ReadInt32()), 0);
+               }
+
+               public double ReadDouble()
+               {
+                       return BitConverter.ToDouble(BitConverter.GetBytes(this.ReadInt64()), 0);
+               }
+
+               public DateTime ReadDateTime()
+               {
+                       DateTime date = this.ReadDate();
+                       DateTime time = this.ReadTime();
+
+                       return new System.DateTime(
+                               date.Year, date.Month, date.Day,
+                               time.Hour, time.Minute, time.Second, time.Millisecond);
+               }
+
+               public DateTime ReadDate()
+               {
+                       return TypeDecoder.DecodeDate(this.ReadInt32());
+               }
+
+               public DateTime ReadTime()
+               {
+                       return TypeDecoder.DecodeTime(this.ReadInt32());
+               }
+
+               public decimal ReadDecimal(int type, int scale)
+               {
+                       decimal value = 0;
+
+                       switch (type)
+                       {
+                               case IscCodes.SQL_SHORT:
+                                       value = TypeDecoder.DecodeDecimal(this.ReadInt16(),     scale, type);
+                                       break;
+
+                               case IscCodes.SQL_LONG:
+                                       value = TypeDecoder.DecodeDecimal(this.ReadInt32(),     scale, type);
+                                       break;
+
+                               case IscCodes.SQL_QUAD:
+                               case IscCodes.SQL_INT64:
+                                       value = TypeDecoder.DecodeDecimal(this.ReadInt64(),     scale, type);
+                                       break;
+
+                               case IscCodes.SQL_DOUBLE:
+                               case IscCodes.SQL_D_FLOAT:
+                                       value = Convert.ToDecimal(this.ReadDouble());
+                                       break;
+                       }
+
+                       return value;
+               }
+
+               public object ReadValue(DbField field)
+               {
+                       object  fieldValue       = null;
+                       Charset innerCharset = (this.charset.Name != "NONE") ? this.charset     : field.Charset;
+
+                       switch (field.DbDataType)
+                       {
+                               case DbDataType.Char:                                   
+                                       {
+                                               string s = this.ReadString(innerCharset, field.Length);
+
+                                               if ((field.Length %     innerCharset.BytesPerCharacter) == 0 &&
+                                                       s.Length > field.CharCount)
+                                               {
+                                                       fieldValue = s.Substring(0,     field.CharCount);
+                                               }
+                                               else
+                                               {
+                                                       fieldValue = s;
+                                               }
+                                       }
+                                       break;
+
+                               case DbDataType.VarChar:
+                                       fieldValue = this.ReadString(innerCharset).TrimEnd();
+                                       break;
+
+                               case DbDataType.SmallInt:
+                                       fieldValue = this.ReadInt16();
+                                       break;
+
+                               case DbDataType.Integer:
+                                       fieldValue = this.ReadInt32();
+                                       break;
+
+                               case DbDataType.Array:
+                               case DbDataType.Binary:
+                               case DbDataType.Text:
+                               case DbDataType.BigInt:
+                                       fieldValue = this.ReadInt64();
+                                       break;
+
+                               case DbDataType.Decimal:
+                               case DbDataType.Numeric:
+                                       fieldValue = this.ReadDecimal(
+                                               field.SqlType,
+                                               field.NumericScale);
+                                       break;
+
+                               case DbDataType.Float:
+                                       fieldValue = this.ReadSingle();
+                                       break;
+
+                               case DbDataType.Guid:
+                                       fieldValue = this.ReadGuid(field.Length);
+                                       break;
+
+                               case DbDataType.Double:
+                                       fieldValue = this.ReadDouble();
+                                       break;
+
+                               case DbDataType.Date:
+                                       fieldValue = this.ReadDate();
+                                       break;
+
+                               case DbDataType.Time:
+                                       fieldValue = this.ReadTime();
+                                       break;
+
+                               case DbDataType.TimeStamp:
+                                       fieldValue = this.ReadDateTime();
+                                       break;
+                       }
+
+                       int     sqlInd = this.ReadInt32();
+
+                       if (sqlInd == 0)
+                       {
+                               return fieldValue;
+                       }
+                       else if (sqlInd == -1)
+                       {
+                               return null;
+                       }
+                       else
+                       {
+                               throw new IscException("invalid sqlind value: " + sqlInd);
+                       }
+               }
+
+               #endregion
+
+               #region Xdr     Write Methods
+
+               public void     WriteOpaque(byte[] buffer)
+               {
+                       this.WriteOpaque(buffer, buffer.Length);
+               }
+
+               public void     WriteOpaque(byte[] buffer, int length)
+               {
+                       if (buffer != null && length > 0)
+                       {
+                               this.Write(buffer, 0, buffer.Length);
+                               this.Write(Fill, 0,     length - buffer.Length);
+                               this.Write(Pad, 0, ((4 - length) & 3));
+                       }
+               }
+
+               public void     WriteBuffer(byte[] buffer)
+               {
+                       this.WriteBuffer(buffer, buffer == null ? 0     : buffer.Length);
+               }
+
+               public void     WriteBuffer(byte[] buffer, int length)
+               {
+                       this.Write(length);
+                       if (buffer != null && length > 0)
+                       {
+                               this.Write(buffer, 0, length);
+                               this.Write(Pad, 0, ((4 - length) & 3));
+                       }
+               }
+
+               public void     WriteBlobBuffer(byte[] buffer)
+               {
+                       int     length = buffer.Length; // 2 for short for buffer length
+
+                       if (length > short.MaxValue)
+                       {
+                               throw (new IOException()); //Need a     value???
+                       }
+                       this.Write(length +     2);
+                       this.Write(length +     2);     //bizarre but true!     three copies of the     length
+                       this.WriteByte((byte)((length >> 0)     & 0xff));
+                       this.WriteByte((byte)((length >> 8)     & 0xff));
+                       this.Write(buffer, 0, length);
+
+                       this.Write(Pad, 0, ((4 - length + 2) & 3));
+               }
+
+               public void     WriteTyped(int type, byte[]     buffer)
+               {
+                       int     length;
+
+                       if (buffer == null)
+                       {
+                               this.Write(1);
+                               this.WriteByte((byte)type);
+                               length = 1;
+                       }
+                       else
+                       {
+                               length = buffer.Length + 1;
+                               this.Write(length);
+                               this.WriteByte((byte)type);
+                               this.Write(buffer, 0, buffer.Length);
+                       }
+                       this.Write(Pad, 0, ((4 - length) & 3));
+               }
+
+               public void     Write(string value)
+               {
+                       byte[] buffer = this.charset.GetBytes(value);
+
+                       this.WriteBuffer(buffer, buffer.Length);
+               }
+
+               public void     Write(short     value)
+               {
+                       this.Write((int)value);
+               }
+
+               public void     Write(int value)
+               {
+                       this.Write(BitConverter.GetBytes(IPAddress.NetworkToHostOrder(value)), 0, 4);
+               }
+
+               public void     Write(long value)
+               {
+                       this.Write(BitConverter.GetBytes(IPAddress.NetworkToHostOrder(value)), 0, 8);
+               }
+
+               public void     Write(float     value)
+               {
+                       byte[] buffer = BitConverter.GetBytes(value);
+
+                       this.Write(BitConverter.ToInt32(buffer, 0));
+               }
+
+               public void     Write(double value)
+               {
+                       byte[] buffer = BitConverter.GetBytes(value);
+
+                       this.Write(BitConverter.ToInt64(buffer, 0));
+               }
+
+               public void     Write(decimal value, int type, int scale)
+               {
+                       object numeric = TypeEncoder.EncodeDecimal(value, scale, type);
+
+                       switch (type)
+                       {
+                               case IscCodes.SQL_SHORT:
+                                       this.Write((short)numeric);
+                                       break;
+
+                               case IscCodes.SQL_LONG:
+                                       this.Write((int)numeric);
+                                       break;
+
+                               case IscCodes.SQL_QUAD:
+                               case IscCodes.SQL_INT64:
+                                       this.Write((long)numeric);
+                                       break;
+
+                               case IscCodes.SQL_DOUBLE:
+                               case IscCodes.SQL_D_FLOAT:
+                                       this.Write((double)value);
+                                       break;
+                       }
+               }
+
+               public void     Write(DateTime value)
+               {
+                       this.WriteDate(value);
+                       this.WriteTime(value);
+               }
+
+               public void     WriteDate(DateTime value)
+               {
+                       this.Write(TypeEncoder.EncodeDate(Convert.ToDateTime(value)));
+               }
+
+               public void     WriteTime(DateTime value)
+               {
+                       this.Write(TypeEncoder.EncodeTime(Convert.ToDateTime(value)));
+               }
+
+               public void     Write(Descriptor descriptor)
+               {
+                       for     (int i = 0;     i <     descriptor.Count; i++)
+                       {
+                               this.Write(descriptor[i]);
+                       }
+               }
+
+               public void     Write(DbField param)
+               {
+                       Charset innerCharset = (this.charset.Name != "NONE") ? this.charset     : param.Charset;
+
+                       param.FixNull();
+
+                       try
+                       {
+                               switch (param.DbDataType)
+                               {
+                                       case DbDataType.Char:
+                                               {
+                                                       string svalue = param.DbValue.GetString();
+
+                                                       if ((param.Length %     innerCharset.BytesPerCharacter) == 0 &&
+                                                               svalue.Length > param.CharCount)
+                                                       {
+                                                               throw new IscException(335544321);
+                                                       }
+
+                                                       this.WriteOpaque(
+                                                               innerCharset.GetBytes(svalue), param.Length);
+                                               }
+                                               break;
+
+                                       case DbDataType.VarChar:
+                                               {
+                                                       string svalue = param.DbValue.GetString().TrimEnd();
+
+                                                       if ((param.Length %     innerCharset.BytesPerCharacter) == 0 &&
+                                                               svalue.Length > param.CharCount)
+                                                       {
+                                                               throw new IscException(335544321);
+                                                       }
+
+                                                       byte[] data     = innerCharset.GetBytes(svalue);
+
+                                                       this.WriteBuffer(data, data.Length);
+                                               }
+                                               break;
+
+                                       case DbDataType.SmallInt:
+                                               this.Write(param.DbValue.GetInt16());
+                                               break;
+
+                                       case DbDataType.Integer:
+                                               this.Write(param.DbValue.GetInt32());
+                                               break;
+
+                                       case DbDataType.BigInt:
+                                       case DbDataType.Array:
+                                       case DbDataType.Binary:
+                                       case DbDataType.Text:
+                                               this.Write(param.DbValue.GetInt64());
+                                               break;
+
+                                       case DbDataType.Decimal:
+                                       case DbDataType.Numeric:
+                                               this.Write(
+                                                       param.DbValue.GetDecimal(),
+                                                       param.SqlType,
+                                                       param.NumericScale);
+                                               break;
+
+                                       case DbDataType.Float:
+                                               this.Write(param.DbValue.GetFloat());
+                                               break;
+
+                                       case DbDataType.Guid:
+                                               this.WriteOpaque(param.DbValue.GetGuid().ToByteArray());
+                                               break;
+
+                                       case DbDataType.Double:
+                                               this.Write(param.DbValue.GetDouble());
+                                               break;
+
+                                       case DbDataType.Date:
+                                               this.Write(param.DbValue.EncodeDate());
+                                               break;
+
+                                       case DbDataType.Time:
+                                               this.Write(param.DbValue.EncodeTime());
+                                               break;
+
+                                       case DbDataType.TimeStamp:
+                                               this.Write(param.DbValue.EncodeDate());
+                                               this.Write(param.DbValue.EncodeTime());
+                                               break;
+
+                                       default:
+                                               throw new IscException("Unknown sql     data type: " + param.DataType);
+                               }
+
+                               this.Write(param.NullFlag);
+                       }
+                       catch (IOException)
+                       {
+                               throw new IscException(IscCodes.isc_net_write_err);
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void CheckDisposed()
+               {
+                       if (this.innerStream == null)
+                       {
+                               throw new ObjectDisposedException("The XdrStream is     closed.");
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Makefile b/mcs/class/FirebirdSql.Data.Firebird/Makefile
new file mode 100644 (file)
index 0000000..9a787e0
--- /dev/null
@@ -0,0 +1,53 @@
+thisdir = class/FirebirdSql.Data.Firebird
+SUBDIRS =
+include ../../build/rules.make
+
+LIBRARY = FirebirdSql.Data.Firebird.dll
+LIBRARY_SNK = FirebirdSql.Data.Firebird.snk
+
+LIB_DEFINE_FLAGS = 
+
+ifeq ($(PLATFORM), linux)
+LIB_DEFINE_FLAGS = /d:LINUX
+endif
+
+LIB_MCS_FLAGS = \
+       $(LIB_DEFINE_FLAGS) \
+       /r:$(corlib) /r:System.dll \
+       /r:System.Xml.dll /r:System.Data.dll \
+       /r:System.Drawing \
+       @FirebirdSql.Data.Firebird.dll.resources
+
+TEST_MCS_FLAGS = /r:$(corlib) /r:System.dll \
+       /r:System.Xml.dll /r:System.Data.dll \
+
+EXTRA_DISTFILES = \
+       license.txt \
+       license.html \
+       readme.txt \
+       changelog.txt \
+       FirebirdSql.Data.Firebird.snk \
+       FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Resources/isc_error_msg.resources \
+       Test/App.config \
+       Test/AssemblyInfo.cs \
+       Test/BaseTest.cs \
+       Test/FbArrayTest.cs \
+       Test/FbBlobTest.cs \
+       Test/FbCommandBuilderTest.cs \
+       Test/FbCommandTest.cs \
+       Test/FbConnectionTest.cs \
+       Test/FbDataAdapterTest.cs \
+       Test/FbDatabaseInfoTest.cs \
+       Test/FbDatabaseSchemaTest.cs \
+       Test/FbDataReaderTest.cs \
+       Test/FbImplicitTransactionTest.cs \
+       Test/FbParameterCollectionTest.cs \
+       Test/FbParameterTest.cs \
+       Test/FbScriptTest.cs \
+       Test/FbServicesTests.cs \
+       Test/FbStoredProcCallsTest.cs \
+       Test/FbTransactionTest.cs \
+       Test/GuidTest.cs \
+
+include ../../build/library.make
+
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/App.config b/mcs/class/FirebirdSql.Data.Firebird/Test/App.config
new file mode 100644 (file)
index 0000000..6013279
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <runtime>
+        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+            <dependentAssembly>
+                <assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" /> 
+                <bindingRedirect oldVersion="2.1.4.0" newVersion="2.2.0.0" /> 
+            </dependentAssembly>
+        </assemblyBinding>
+    </runtime>
+    <appSettings>
+           <add key="DataSource" value="localhost" />
+           <add key="Port" value="3050" />
+           <add key="Database" value="nunit_testdb" />
+           <add key="User" value="SYSDBA" />
+           <add key="Password" value="masterkey" />    
+           <add key="Role" value="" />
+           <add key="Charset" value="UNICODE_FSS" />           
+           <add key="Dialect" value="3" />     
+           <add key="Connection lifetime" value="15" />
+           <add key="Pooling" value="false" />
+           <add key="Packet Size" value="8192" />
+           <add key="PageSize" value="4096" />
+           <add key="ForcedWrite" value="false" />
+           <add key="ServerType" value="0" />
+           <add key="Isql Script" value="" />
+    </appSettings>
+</configuration>
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/AssemblyInfo.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..f85fd1b
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyTitle("NUnit Test - Firebird .NET Data Provider")]
+[assembly: AssemblyDescription("NUnit Test - Firebird .NET Data Provider")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("FirebirdSQL")]
+[assembly: AssemblyProduct("Firebird .NET Data Provider")]
+[assembly: AssemblyCopyright("(c) 2002 - 2003. Carlos Guzman Alvarez")]
+[assembly: AssemblyVersion("1.7.*")]
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyName("")]
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/BaseTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/BaseTest.cs
new file mode 100644 (file)
index 0000000..360c869
--- /dev/null
@@ -0,0 +1,428 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using NUnit.Framework;
+using System;
+using System.Text;
+using System.Configuration;
+using System.Collections;
+using System.Security.Cryptography;
+
+namespace FirebirdSql.Data.Firebird.Tests
+{
+       public class BaseTest
+       {
+               #region Fields
+
+               private FbConnection    connection;
+               private FbTransaction   transaction;
+               private bool                    withTransaction;
+
+               #endregion
+
+               #region Properties
+
+               public FbConnection Connection
+               {
+                       get { return connection; }
+               }
+
+               public FbTransaction Transaction
+               {
+                       get { return transaction; }
+                       set { transaction = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+                               
+               public BaseTest()
+               {
+                       this.withTransaction = false;
+               }
+
+               public BaseTest(bool withTransaction)
+               {
+                       this.withTransaction = withTransaction;
+               }
+
+               #endregion
+
+               #region NUnit Methods
+
+               [SetUp]
+               public virtual void SetUp()
+               {
+                       string cs = this.BuildConnectionString();
+
+                       CreateDatabase(cs);
+                       CreateTables(cs);
+                       InsertTestData(cs);
+                       CreateProcedures(cs);
+                       CreateTriggers(cs);
+
+                       this.connection = new FbConnection(cs);
+                       this.connection.Open();
+
+                       if (this.withTransaction)
+                       {
+                               this.transaction = this.connection.BeginTransaction();
+                       }
+               }
+
+               [TearDown]
+               public virtual void TearDown()
+               {                       
+                       if (this.withTransaction)
+                       {
+                               try
+                               {
+                                       transaction.Commit();
+                               }
+                               catch
+                               {
+                               }
+                       }
+                       connection.Close();
+               }
+
+               #endregion
+
+               #region Database Creation Methods
+
+               private static void CreateDatabase(string connectionString)
+               {
+                       FbConnection.CreateDatabase(
+                               connectionString,
+                               Convert.ToInt32(ConfigurationSettings.AppSettings["PageSize"]),
+                               Boolean.Parse(ConfigurationSettings.AppSettings["ForcedWrite"]),
+                               true);
+               }
+
+               private static void CreateTables(string connectionString)
+               {
+                       FbConnection connection = new FbConnection(connectionString);
+                       connection.Open();
+
+                       StringBuilder commandText = new StringBuilder();
+
+                       // Table for general purpouse tests
+                       commandText.Append("CREATE TABLE TEST (");
+                       commandText.Append("INT_FIELD        INTEGER DEFAULT 0 NOT NULL PRIMARY KEY,");
+                       commandText.Append("CHAR_FIELD       CHAR(30),");
+                       commandText.Append("VARCHAR_FIELD    VARCHAR(100),");
+                       commandText.Append("BIGINT_FIELD     BIGINT,");
+                       commandText.Append("SMALLINT_FIELD   SMALLINT,");
+                       commandText.Append("DOUBLE_FIELD     DOUBLE PRECISION,");
+                       commandText.Append("FLOAT_FIELD          FLOAT,");
+                       commandText.Append("NUMERIC_FIELD    NUMERIC(15,2),");
+                       commandText.Append("DECIMAL_FIELD    DECIMAL(15,2),");
+                       commandText.Append("DATE_FIELD       DATE,");
+                       commandText.Append("TIME_FIELD       TIME,");
+                       commandText.Append("TIMESTAMP_FIELD  TIMESTAMP,");
+                       commandText.Append("CLOB_FIELD       BLOB SUB_TYPE 1 SEGMENT SIZE 80,");
+                       commandText.Append("BLOB_FIELD       BLOB SUB_TYPE 0 SEGMENT SIZE 80,");
+                       commandText.Append("IARRAY_FIELD     INTEGER [0:3],");
+                       commandText.Append("SARRAY_FIELD     SMALLINT [0:4],");
+                       commandText.Append("LARRAY_FIELD     BIGINT [0:5],");
+                       commandText.Append("FARRAY_FIELD     FLOAT [0:3],");
+                       commandText.Append("BARRAY_FIELD     DOUBLE PRECISION [1:4],");
+                       commandText.Append("NARRAY_FIELD     NUMERIC(10,6) [1:4],");
+                       commandText.Append("DARRAY_FIELD     DATE [1:4],");
+                       commandText.Append("TARRAY_FIELD     TIME [1:4],");
+                       commandText.Append("TSARRAY_FIELD    TIMESTAMP [1:4],");
+                       commandText.Append("CARRAY_FIELD     CHAR(21) [1:4],");
+                       commandText.Append("VARRAY_FIELD     VARCHAR(30) [1:4],");
+                       commandText.Append("BIG_ARRAY        INTEGER [1:32767],");
+                       commandText.Append("EXPR_FIELD       COMPUTED BY (smallint_field * 1000),");
+                       commandText.Append("CS_FIELD         CHAR(1) CHARACTER SET UNICODE_FSS,");
+                       commandText.Append("UCCHAR_ARRAY     CHAR(10) [1:10] CHARACTER SET UNICODE_FSS);");
+   
+                       FbCommand command = new FbCommand(commandText.ToString(), connection);
+                       command.ExecuteNonQuery();
+                       command.Dispose();
+                                               
+                       connection.Close();
+               }
+
+               private static void CreateProcedures(string connectionString)
+               {
+                       FbConnection connection = new FbConnection(connectionString);
+                       connection.Open();
+
+                       StringBuilder commandText = new StringBuilder();
+
+                       // SELECT_DATA
+                       commandText = new StringBuilder();
+
+                       commandText.Append("CREATE PROCEDURE SELECT_DATA  \r\n");
+                       commandText.Append("RETURNS ( \r\n");
+                       commandText.Append("INT_FIELD INTEGER, \r\n");
+                       commandText.Append("VARCHAR_FIELD VARCHAR(100), \r\n");
+                       commandText.Append("DECIMAL_FIELD DECIMAL(15,2)) \r\n");
+                       commandText.Append("AS \r\n");
+                       commandText.Append("begin \r\n");
+                       commandText.Append("FOR SELECT INT_FIELD, VARCHAR_FIELD, DECIMAL_FIELD FROM TEST INTO :INT_FIELD, :VARCHAR_FIELD, :DECIMAL_FIELD \r\n");
+                       commandText.Append("DO \r\n");
+                       commandText.Append("SUSPEND; \r\n");
+                       commandText.Append("end;");
+
+                       FbCommand command = new FbCommand(commandText.ToString(), connection);
+                       command.ExecuteNonQuery();
+                       command.Dispose();
+
+                       // GETRECORDCOUNT
+                       commandText = new StringBuilder();
+
+                       commandText.Append("CREATE PROCEDURE GETRECORDCOUNT \r\n");
+                       commandText.Append("RETURNS ( \r\n");
+                       commandText.Append("RECCOUNT SMALLINT) \r\n");
+                       commandText.Append("AS \r\n");
+                       commandText.Append("begin \r\n");
+                       commandText.Append("for select count(*) from test into :reccount \r\n");
+                       commandText.Append("do \r\n");
+                       commandText.Append("suspend; \r\n");
+                       commandText.Append("end\r\n");
+
+                       command = new FbCommand(commandText.ToString(), connection);
+                       command.ExecuteNonQuery();
+                       command.Dispose();
+
+                       // GETVARCHARFIELD
+                       commandText = new StringBuilder();
+
+                       commandText.Append("CREATE PROCEDURE GETVARCHARFIELD (\r\n");
+                       commandText.Append("ID INTEGER)\r\n");
+                       commandText.Append("RETURNS (\r\n");
+                       commandText.Append("VARCHAR_FIELD VARCHAR(100))\r\n");
+                       commandText.Append("AS\r\n");
+                       commandText.Append("begin\r\n");
+                       commandText.Append("for select varchar_field from test where int_field = :id into :varchar_field\r\n");
+                       commandText.Append("do\r\n");
+                       commandText.Append("suspend;\r\n");
+                       commandText.Append("end\r\n");
+
+                       command = new FbCommand(commandText.ToString(), connection);
+                       command.ExecuteNonQuery();
+                       command.Dispose();
+
+                       // GETASCIIBLOB
+                       commandText = new StringBuilder();
+
+                       commandText.Append("CREATE PROCEDURE GETASCIIBLOB (\r\n");
+                       commandText.Append("ID INTEGER)\r\n");
+                       commandText.Append("RETURNS (\r\n");
+                       commandText.Append("ASCII_BLOB BLOB SUB_TYPE 1)\r\n");
+                       commandText.Append("AS\r\n");
+                       commandText.Append("begin\r\n");
+                       commandText.Append("for select clob_field from test where int_field = :id into :ascii_blob\r\n");
+                       commandText.Append("do\r\n");
+                       commandText.Append("suspend;\r\n");
+                       commandText.Append("end\r\n");
+
+                       command = new FbCommand(commandText.ToString(), connection);
+                       command.ExecuteNonQuery();
+                       command.Dispose();
+
+                       // DATAREADERTEST
+                       commandText = new StringBuilder();
+
+                       commandText.Append("CREATE PROCEDURE DATAREADERTEST\r\n");
+                       commandText.Append("RETURNS (\r\n");
+                       commandText.Append("content VARCHAR(128))\r\n");
+                       commandText.Append("AS\r\n");
+                       commandText.Append("begin\r\n");
+                       commandText.Append("content = 'test';\r\n");
+                       commandText.Append("end\r\n");
+
+                       command = new FbCommand(commandText.ToString(), connection);
+                       command.ExecuteNonQuery();
+                       command.Dispose();
+
+                       connection.Close();
+               }
+
+               private static void CreateTriggers(string connectionString)
+               {
+                       FbConnection connection = new FbConnection(connectionString);
+                       connection.Open();
+
+                       StringBuilder commandText = new StringBuilder();
+
+                       // new_row
+                       commandText = new StringBuilder();
+
+                       commandText.Append("CREATE TRIGGER new_row FOR test ACTIVE\r\n");
+                       commandText.Append("AFTER INSERT POSITION 0\r\n");
+                       commandText.Append("AS\r\n");
+                       commandText.Append("BEGIN\r\n");
+                       commandText.Append("POST_EVENT 'new row';\r\n");
+                       commandText.Append("END");
+
+                       FbCommand command = new FbCommand(commandText.ToString(), connection);
+                       command.ExecuteNonQuery();
+                       command.Dispose();
+
+                       // update_row
+
+                       commandText = new StringBuilder();
+
+                       commandText.Append("CREATE TRIGGER update_row FOR test ACTIVE\r\n");
+                       commandText.Append("AFTER UPDATE POSITION 0\r\n");
+                       commandText.Append("AS\r\n");
+                       commandText.Append("BEGIN\r\n");
+                       commandText.Append("POST_EVENT 'updated row';\r\n");
+                       commandText.Append("END");
+
+                       command = new FbCommand(commandText.ToString(), connection);
+                       command.ExecuteNonQuery();
+                       command.Dispose();
+
+                       connection.Close();
+               }
+
+               private static void InsertTestData(string connectionString)
+               {
+                       FbConnection connection = new FbConnection(connectionString);
+                       connection.Open();
+
+                       StringBuilder commandText = new StringBuilder();
+
+                       commandText.Append("insert into test (int_field, char_field, varchar_field, bigint_field, smallint_field, float_field, double_field, numeric_field, date_field, time_field, timestamp_field, clob_field, blob_field)");
+                       commandText.Append(" values(@int_field, @char_field, @varchar_field, @bigint_field, @smallint_field, @float_field, @double_field, @numeric_field, @date_field, @time_field, @timestamp_field, @clob_field, @blob_field)");
+
+                       FbTransaction   transaction = connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(commandText.ToString(), connection, transaction);
+
+                       try
+                       {
+                               // Add command parameters
+                               command.Parameters.Add("@int_field"                     , FbDbType.Integer);
+                               command.Parameters.Add("@char_field"            , FbDbType.Char);
+                               command.Parameters.Add("@varchar_field"         , FbDbType.VarChar);
+                               command.Parameters.Add("@bigint_field"          , FbDbType.BigInt);
+                               command.Parameters.Add("@smallint_field"        , FbDbType.SmallInt);
+                               command.Parameters.Add("@float_field"           , FbDbType.Double);
+                               command.Parameters.Add("@double_field"          , FbDbType.Double);
+                               command.Parameters.Add("@numeric_field"         , FbDbType.Numeric);
+                               command.Parameters.Add("@date_field"            , FbDbType.Date);
+                               command.Parameters.Add("@time_Field"            , FbDbType.Time);
+                               command.Parameters.Add("@timestamp_field"       , FbDbType.TimeStamp);
+                               command.Parameters.Add("@clob_field"            , FbDbType.Text);
+                               command.Parameters.Add("@blob_field"            , FbDbType.Binary);
+
+                               command.Prepare();
+
+                               for (int i = 0; i < 100; i++)
+                               {
+                                       command.Parameters["@int_field"].Value          = i;
+                                       command.Parameters["@char_field"].Value         = "IRow " + i.ToString();
+                                       command.Parameters["@varchar_field"].Value      = "IRow Number " + i.ToString();
+                                       command.Parameters["@bigint_field"].Value       = i;
+                                       command.Parameters["@smallint_field"].Value     = i;
+                                       command.Parameters["@float_field"].Value        = (float)(i + 10)/5;
+                                       command.Parameters["@double_field"].Value       = Math.Log(i, 10);
+                                       command.Parameters["@numeric_field"].Value      = (decimal)(i + 10)/5;
+                                       command.Parameters["@date_field"].Value         = DateTime.Now;
+                                       command.Parameters["@time_field"].Value         = DateTime.Now;
+                                       command.Parameters["@timestamp_field"].Value= DateTime.Now;
+                                       command.Parameters["@clob_field"].Value         = "IRow Number " + i.ToString();
+                                       command.Parameters["@blob_field"].Value         = Encoding.Default.GetBytes("IRow Number " + i.ToString());
+
+                                       command.ExecuteNonQuery();
+                               }
+
+                               // Commit transaction
+                               transaction.Commit();
+                       }
+                       catch (FbException)
+                       {
+                               transaction.Rollback();
+                               throw;
+                       }
+                       finally
+                       {
+                               command.Dispose();
+                               connection.Close();
+                       }
+               }
+
+               #endregion
+
+               #region ConnectionString Building methods
+
+               public string BuildConnectionString()
+               {
+                       return this.BuildConnectionString(false);
+               }
+
+               public string BuildConnectionString(bool pooling)
+               {
+                       FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
+
+                       cs.UserID               = ConfigurationSettings.AppSettings["User"];
+                       cs.Password             = ConfigurationSettings.AppSettings["Password"];
+                       cs.Database             = ConfigurationSettings.AppSettings["Database"];
+                       cs.DataSource   = ConfigurationSettings.AppSettings["DataSource"];
+                       cs.Port                 = Int32.Parse(ConfigurationSettings.AppSettings["Port"]);
+                       cs.Charset              = ConfigurationSettings.AppSettings["Charset"];
+                       cs.Pooling              = pooling;
+                       cs.ServerType   = Int32.Parse(ConfigurationSettings.AppSettings["ServerType"]);
+
+                       return cs.ToString();
+               }
+
+               public string BuildServicesConnectionString()
+               {
+                       return this.BuildServicesConnectionString(true);
+               }
+
+               public string BuildServicesConnectionString(bool includeDatabase)
+               {
+                       FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
+
+                       cs.UserID = ConfigurationSettings.AppSettings["User"];
+                       cs.Password = ConfigurationSettings.AppSettings["Password"];
+                       if (includeDatabase)
+                       {
+                               cs.Database = ConfigurationSettings.AppSettings["Database"];
+                       }
+                       cs.ServerType = Convert.ToInt32(ConfigurationSettings.AppSettings["ServerType"]);
+
+                       return cs.ToString();
+               }
+
+               #endregion
+
+               #region Methods
+
+               public int GetId()
+               {
+                       RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
+
+                       byte[] buffer = new byte[4];
+                       
+                       rng.GetBytes(buffer);
+
+                       return BitConverter.ToInt32(buffer, 0);
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbArrayTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbArrayTest.cs
new file mode 100644 (file)
index 0000000..3413ef8
--- /dev/null
@@ -0,0 +1,1031 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using NUnit.Framework;
+using System;
+using System.Collections;
+using System.Security.Cryptography;
+using FirebirdSql.Data.Firebird;
+
+namespace FirebirdSql.Data.Firebird.Tests
+{
+       [TestFixture]
+       public class FbArrayTest : BaseTest 
+       {
+               public FbArrayTest() : base(true)
+               {               
+               }
+               
+               [Test]
+               public void IntergerArrayTest()
+               {
+                       int id_value = this.GetId();
+
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Integer Array Test");
+
+                       string selectText = "SELECT iarray_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, iarray_field) values(@int_field, @array_field)";
+                       
+                       // Insert new Record
+                       int[] insert_values = new int[4];
+
+                       insert_values[0] = 10;
+                       insert_values[1] = 20;
+                       insert_values[2] = 30;
+                       insert_values[3] = 40;
+
+                       Console.WriteLine("Executing insert command");
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+                                                                                               
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       int[] select_values = new int[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i] != select_values[i])
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+                       reader.Close();
+                       select.Dispose();
+               }
+
+               [Test]
+               public void ShortArrayTest()
+               {
+                       int id_value = this.GetId();
+
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Short Array Test");
+
+                       string selectText = "SELECT sarray_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, sarray_field) values(@int_field, @array_field)";
+                       
+                       // Insert new Record
+                       short[] insert_values = new short[4];
+
+                       insert_values[0] = 50;
+                       insert_values[1] = 60;
+                       insert_values[2] = 70;
+                       insert_values[3] = 80;
+                       
+                       Console.WriteLine("Executing insert command");
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+                                                                                               
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       short[] select_values = new short[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i] != select_values[i])
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+                       reader.Close();
+                       select.Dispose();
+               }
+               
+               [Test]
+               public void BigIntArrayTest()
+               {
+                       int id_value = this.GetId();
+
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("BigInt Array Test");
+
+                       string selectText = "SELECT larray_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, larray_field) values(@int_field, @array_field)";
+                       
+                       // Insert new Record
+                       long[] insert_values = new long[4];
+
+                       insert_values[0] = 50;
+                       insert_values[1] = 60;
+                       insert_values[2] = 70;
+                       insert_values[3] = 80;
+                       
+                       Console.WriteLine("Executing insert command");
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+                                                                                               
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       long[] select_values = new long[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i] != select_values[i])
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+                       reader.Close();
+                       select.Dispose();
+               }
+
+               [Test]
+               public void FloatArrayTest()
+               {
+                       int id_value = this.GetId();
+
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Float Array Test");
+
+                       string selectText = "SELECT farray_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, farray_field) values(@int_field, @array_field)";
+                       
+                       // Insert new Record
+                       float[] insert_values = new float[4];
+
+                       insert_values[0] = 130.10F;
+                       insert_values[1] = 140.20F;
+                       insert_values[2] = 150.30F;
+                       insert_values[3] = 160.40F;
+                       
+                       Console.WriteLine("Executing insert command");
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+                                                                                               
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       float[] select_values = new float[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i] != select_values[i])
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+                       reader.Close();
+                       select.Dispose();
+               }
+
+               [Test]
+               public void DoubleArrayTest()
+               {
+                       int id_value = this.GetId();
+
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Double Array Test");
+
+                       string selectText = "SELECT barray_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, barray_field) values(@int_field, @array_field)";
+                       
+                       // Insert new Record
+                       double[] insert_values = new double[4];
+
+                       insert_values[0] = 170.10;
+                       insert_values[1] = 180.20;
+                       insert_values[2] = 190.30;
+                       insert_values[3] = 200.40;
+                       
+                       Console.WriteLine("Executing insert command");
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+                                                                                               
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       double[] select_values = new double[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i] != select_values[i])
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+                       reader.Close();
+                       select.Dispose();
+               }
+               
+               [Test]
+               public void NumericArrayTest()
+               {
+                       int id_value = this.GetId();
+
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Numeric/Decimal Array Test");
+
+                       string selectText = "SELECT narray_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, narray_field) values(@int_field, @array_field)";
+                       
+                       // Insert new Record
+                       decimal[] insert_values = new decimal[4];
+
+                       insert_values[0] = 210.10M;
+                       insert_values[1] = 220.20M;
+                       insert_values[2] = 230.30M;
+                       insert_values[3] = 240.40M;
+                       
+                       Console.WriteLine("Executing insert command");
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+                                                                                               
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       decimal[] select_values = new decimal[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i] != select_values[i])
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+                       reader.Close();
+                       select.Dispose();
+               }
+
+               [Test]
+               public void DateArrayTest()
+               {
+                       int id_value = this.GetId();
+
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Date Array Test");
+
+                       string selectText = "SELECT darray_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, darray_field) values(@int_field, @array_field)";
+                       
+                       // Insert new Record
+                       DateTime[] insert_values = new DateTime[4];
+
+                       insert_values[0] = DateTime.Now.AddDays(10);
+                       insert_values[1] = DateTime.Now.AddDays(20);
+                       insert_values[2] = DateTime.Now.AddDays(30);
+                       insert_values[3] = DateTime.Now.AddDays(40);
+                       
+                       Console.WriteLine("Executing insert command");
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+                                                                                               
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       DateTime[] select_values = new DateTime[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i].ToString("dd/MM/yyy") != select_values[i].ToString("dd/MM/yyy"))
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+                       reader.Close();
+                       select.Dispose();
+               }
+                       
+               [Test]
+               public void TimeArrayTest()
+               {
+                       int id_value = this.GetId();
+
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Time Array Test");
+
+                       string selectText = "SELECT tarray_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, tarray_field) values(@int_field, @array_field)";
+                       
+                       // Insert new Record
+                       DateTime[] insert_values = new DateTime[4];
+
+                       insert_values[0] = DateTime.Now.AddHours(10);
+                       insert_values[1] = DateTime.Now.AddHours(20);
+                       insert_values[2] = DateTime.Now.AddHours(30);
+                       insert_values[3] = DateTime.Now.AddHours(40);
+                       
+                       Console.WriteLine("Executing insert command");
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+                                                                                               
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       DateTime[] select_values = new DateTime[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i].ToString("HH:mm:ss") != select_values[i].ToString("HH:mm:ss"))
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+                       reader.Close();
+                       select.Dispose();
+               }
+               
+               [Test]
+               public void TimeStampArrayTest()
+               {
+                       int id_value = this.GetId();
+
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("TimeStamp Array Test");
+
+                       string selectText = "SELECT tsarray_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, tsarray_field) values(@int_field, @array_field)";
+                       
+                       // Insert new Record
+                       DateTime[] insert_values = new DateTime[4];
+
+                       insert_values[0] = DateTime.Now.AddSeconds(10);
+                       insert_values[1] = DateTime.Now.AddSeconds(20);
+                       insert_values[2] = DateTime.Now.AddSeconds(30);
+                       insert_values[3] = DateTime.Now.AddSeconds(40);
+                       
+                       Console.WriteLine("Executing insert command");
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+                                                                                               
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       DateTime[] select_values = new DateTime[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i].ToString("dd/MM/yyyy HH:mm:ss") != select_values[i].ToString("dd/MM/yyyy HH:mm:ss"))
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+                       reader.Close();
+                       select.Dispose();
+               }
+                               
+               [Test]
+               public void CharArrayTest()
+               {
+                       int id_value = this.GetId();
+
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Char Array Test");
+
+                       string selectText = "SELECT carray_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, carray_field) values(@int_field, @array_field)";
+                       
+                       // Insert new Record
+                       string[] insert_values = new string[4];
+
+                       insert_values[0] = "abc";
+                       insert_values[1] = "abcdef";
+                       insert_values[2] = "abcdefghi";
+                       insert_values[3] = "abcdefghijkl";
+                       
+                       Console.WriteLine("Executing insert command");
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+                                                                                               
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       string[] select_values = new string[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i].Trim() != select_values[i].Trim())
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+                       reader.Close();
+                       select.Dispose();
+               }
+       
+               [Test]
+               public void VarCharArrayTest()
+               {
+                       int id_value = this.GetId();
+
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("VarChar Array Test");
+
+                       string selectText = "SELECT varray_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, varray_field) values(@int_field, @array_field)";
+                       
+                       // Insert new Record
+                       string[] insert_values = new string[4];
+
+                       insert_values[0] = "abc";
+                       insert_values[1] = "abcdef";
+                       insert_values[2] = "abcdefghi";
+                       insert_values[3] = "abcdefghijkl";
+                       
+                       Console.WriteLine("Executing insert command");
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+                                                                                               
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       string[] select_values = new string[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i].Trim() != select_values[i].Trim())
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+                       reader.Close();
+                       select.Dispose();
+               }
+
+               [Test]
+               public void IntergerArrayPartialUpdateTest()
+               {
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Integer Array Test");
+                       Console.WriteLine("------- ----- ----");
+                                               
+                       string updateText = "update TEST set iarray_field = @array_field " +
+                                                           "WHERE int_field = 1";
+
+                       int[] new_values = new int[2];
+
+                       new_values[0] = 100;
+                       new_values[1] = 200;
+                       
+                       FbCommand update = new FbCommand(updateText, Connection, Transaction);
+                       
+                       update.Parameters.Add("@array_field", FbDbType.Array).Value = new_values;
+                                               
+                       update.ExecuteNonQuery();
+                       update.Dispose();
+                       
+                       PrintArrayValues(new_values, false);
+               }
+
+               [Test]
+               public void ShortArrayPartialUpdateTest()
+               {
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Short Array Test");
+                       Console.WriteLine("----- ----- ----");
+                       
+                       string updateText = "update TEST set sarray_field = @array_field " +
+                                                           "WHERE int_field = 1";
+                       
+                       short[] new_values = new short[3];
+
+                       new_values[0] = 500;
+                       new_values[1] = 600;
+
+                       FbCommand update = new FbCommand(updateText, Connection, Transaction);
+                       
+                       update.Parameters.Add("@array_field", FbDbType.Array).Value = new_values;
+                                               
+                       update.ExecuteNonQuery();
+                       update.Dispose();
+                       
+                       PrintArrayValues(new_values, false);
+               }
+               
+               [Test]
+               public void BigIntArrayPartialUpdateTest()
+               {
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("BigInt Array Test");
+                       Console.WriteLine("------ ----- ----");
+                                               
+                       string updateText = "update TEST set larray_field = @array_field " +
+                                                           "WHERE int_field = 1";
+                                               
+                       long[] new_values = new long[4];
+
+                       new_values[0] = 900;
+                       new_values[1] = 1000;
+                       new_values[2] = 1100;
+                       new_values[3] = 1200;
+
+                       FbCommand update = new FbCommand(updateText, Connection, Transaction);
+                       
+                       update.Parameters.Add("@array_field", FbDbType.Array).Value = new_values;
+                                               
+                       update.ExecuteNonQuery();
+                       update.Dispose();
+                       
+                       PrintArrayValues(new_values, false);
+               }
+
+               [Test]
+               public void FloatArrayPartialUpdateTest()
+               {
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Float Array Test");
+                       Console.WriteLine("----- ----- ----");
+                       
+                       string updateText = "update TEST set farray_field = @array_field " +
+                                                           "WHERE int_field = 1";
+                                               
+                       float[] new_values = new float[4];
+
+                       new_values[0] = 1300.10F;
+                       new_values[1] = 1400.20F;
+                       
+                       FbCommand update = new FbCommand(updateText, Connection, Transaction);
+                       
+                       update.Parameters.Add("@array_field", FbDbType.Array).Value = new_values;
+                                               
+                       update.ExecuteNonQuery();
+                       update.Dispose();
+                       
+                       PrintArrayValues(new_values, false);
+               }
+
+               [Test]
+               public void DoubleArrayPartialUpdateTest()
+               {
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Double Array Test");
+                       Console.WriteLine("------ ----- ----");
+                       
+                       string updateText = "update TEST set barray_field = @array_field " +
+                                                           "WHERE int_field = 1";
+                       
+                       double[] new_values = new double[2];
+
+                       new_values[0] = 1700.10;
+                       new_values[1] = 1800.20;
+                       
+                       FbCommand update = new FbCommand(updateText, Connection, Transaction);
+                       
+                       update.Parameters.Add("@array_field", FbDbType.Array).Value = new_values;
+                                               
+                       update.ExecuteNonQuery();
+                       update.Dispose();
+                       
+                       PrintArrayValues(new_values, false);
+               }
+               
+               [Test]
+               public void NumericArrayPartialUpdateTest()
+               {
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Numeric/Decimal Array Test");
+                       Console.WriteLine("--------------- ----- ----");
+                       
+                       string updateText = "update TEST set narray_field = @array_field " +
+                                                           "WHERE int_field = 1";
+                       
+                       decimal[] new_values = new decimal[2];
+
+                       new_values[0] = 2100.10M;
+                       new_values[1] = 2200.20M;
+                       
+                       FbCommand update = new FbCommand(updateText, Connection, Transaction);
+                       
+                       update.Parameters.Add("@array_field", FbDbType.Array).Value = new_values;
+                                               
+                       update.ExecuteNonQuery();
+                       update.Dispose();
+                       
+                       PrintArrayValues(new_values, false);
+               }
+
+               [Test]
+               public void DateArrayPartialUpdateTest()
+               {
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Date Array Test");
+                       Console.WriteLine("---- ----- ----");
+                       
+                       string updateText = "update TEST set darray_field = @array_field " +
+                                                           "WHERE int_field = 1";
+                       
+                       DateTime[] new_values = new DateTime[4];
+
+                       new_values[0] = DateTime.Now.AddDays(100);
+                       new_values[1] = DateTime.Now.AddDays(200);
+                       
+                       FbCommand update = new FbCommand(updateText, Connection, Transaction);
+                       
+                       update.Parameters.Add("@array_field", FbDbType.Array).Value = new_values;
+                                               
+                       update.ExecuteNonQuery();
+                       update.Dispose();
+                       
+                       PrintArrayValues(new_values, false);
+               }
+                       
+               [Test]
+               public void TimeArrayPartialUpdateTest()
+               {
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Time Array Test");
+                       Console.WriteLine("---- ----- ----");
+                       
+                       string updateText = "update TEST set tarray_field = @array_field " +
+                                                           "WHERE int_field = 1";
+
+                       DateTime[] new_values = new DateTime[2];
+
+                       new_values[0] = DateTime.Now.AddHours(100);
+                       new_values[1] = DateTime.Now.AddHours(200);
+                       
+                       FbCommand update = new FbCommand(updateText, Connection, Transaction);
+                       
+                       update.Parameters.Add("@array_field", FbDbType.Array).Value = new_values;
+                                               
+                       update.ExecuteNonQuery();
+                       update.Dispose();
+                       
+                       PrintArrayValues(new_values, false);
+               }
+               
+               [Test]
+               public void TimeStampArrayPartialUpdateTest()
+               {
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("TimeStamp Array Test");
+                       Console.WriteLine("--------- ----- ----");
+                       
+                       string updateText = "update TEST set tsarray_field = @array_field " +
+                                                           "WHERE int_field = 1";
+               
+                       DateTime[] new_values = new DateTime[2];
+
+                       new_values[0] = DateTime.Now.AddSeconds(100);
+                       new_values[1] = DateTime.Now.AddSeconds(200);
+                       
+                       FbCommand update = new FbCommand(updateText, Connection, Transaction);
+                       
+                       update.Parameters.Add("@array_field", FbDbType.Array).Value = new_values;
+                                               
+                       update.ExecuteNonQuery();
+                       update.Dispose();
+                       
+                       PrintArrayValues(new_values, false);
+               }
+                               
+               [Test]
+               public void CharArrayPartialUpdateTest()
+               {
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("Char Array Test");
+                       Console.WriteLine("---- ----- ----");
+                       
+                       string updateText = "update TEST set carray_field = @array_field " +
+                                                           "WHERE int_field = 1";
+                       
+                       string[] new_values = new string[2];
+
+                       new_values[0] = "abc";
+                       new_values[1] = "abcdef";
+                       
+                       FbCommand update = new FbCommand(updateText, Connection, Transaction);
+                       
+                       update.Parameters.Add("@array_field", FbDbType.Array).Value = new_values;
+                                               
+                       update.ExecuteNonQuery();
+                       update.Dispose();
+                       
+                       PrintArrayValues(new_values, false);
+               }
+       
+               [Test]
+               public void VarCharArrayPartialUpdateTest()
+               {
+                       Console.WriteLine("\r\n");
+                       Console.WriteLine("VarChar Array Test");
+                       Console.WriteLine("------- ----- ----");
+                       
+                       string updateText = "update TEST set varray_field = @array_field " +
+                                                           "WHERE int_field = 1";
+                       
+                       string[] new_values = new string[2];
+
+                       new_values[0] = "abc";
+                       new_values[1] = "abcdef";
+                       
+                       FbCommand update = new FbCommand(updateText, Connection, Transaction);
+                       
+                       update.Parameters.Add("@array_field", FbDbType.Array).Value = new_values;
+                                               
+                       update.ExecuteNonQuery();
+                       update.Dispose();
+                       
+                       PrintArrayValues(new_values, false);
+               }
+
+               [Test]
+               public void BigArrayTest()
+               {
+                       int id_value    = this.GetId();
+                       int elements    = short.MaxValue;
+                       
+                       string selectText = "SELECT big_array FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, big_array) values(@int_field, @array_field)";
+                       
+                       Console.WriteLine("\r\n\r\nBigArrayTest");
+                       Console.WriteLine("Generating an array of temp data");
+                       // Generate an array of temp data
+                       byte[] bytes = new byte[elements*4];
+                       RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
+                       rng.GetBytes(bytes);
+                       
+                       int[] insert_values = new int[elements];
+                       Buffer.BlockCopy(bytes, 0, insert_values, 0, bytes.Length);
+
+                       Console.WriteLine("Executing insert command");
+                       // Execute insert command
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       int[] select_values = new int[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+                                                                               
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i] != select_values[i])
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+
+                       Console.WriteLine("Finishing test");
+                       reader.Close();
+                       select.Dispose();
+
+                       // Start a new Transaction
+                       Transaction = Connection.BeginTransaction();
+               }
+               
+               [Test]
+               public void PartialUpdatesTest()
+               {
+                       int id_value    = this.GetId();
+                       int elements    = 16384;
+                       
+                       string selectText = "SELECT big_array FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, big_array) values(@int_field, @array_field)";
+                       
+                       Console.WriteLine("\r\n\r\nPartialUpdatesTest");
+                       Console.WriteLine("Generating an array of temp data");
+                       // Generate an array of temp data
+                       byte[] bytes = new byte[elements*4];
+                       RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
+                       rng.GetBytes(bytes);
+                       
+                       int[] insert_values = new int[elements];
+                       Buffer.BlockCopy(bytes, 0, insert_values, 0, bytes.Length);
+
+                       Console.WriteLine("Executing insert command");
+                       // Execute insert command
+                       FbCommand insert = new FbCommand(insertText, Connection, Transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@array_field", FbDbType.Array).Value = insert_values;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       Transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       FbDataReader reader = select.ExecuteReader();                   
+                       if (reader.Read())
+                       {
+                               if (!reader.IsDBNull(0))
+                               {
+                                       int[] select_values = new int[insert_values.Length];
+                                       System.Array.Copy((System.Array)reader.GetValue(0), select_values, select_values.Length);
+
+                                       for (int i = 0; i < insert_values.Length; i++)
+                                       {
+                                               if (insert_values[i] != select_values[i])
+                                               {
+                                                       throw new Exception("differences at index " + i.ToString());
+                                               }
+                                       }
+                               }
+                       }
+
+                       Console.WriteLine("Finishing test");
+                       reader.Close();
+                       select.Dispose();
+
+                       // Start a new Transaction
+                       Transaction = Connection.BeginTransaction();
+               }
+
+               private void PrintArrayValues(System.Array array, bool original)
+               {
+                       IEnumerator i = array.GetEnumerator();
+                       
+                       if (original)
+                       {
+                               Console.WriteLine("Original field values:");
+                       }
+                       else
+                       {
+                               Console.WriteLine("New field values:"); 
+                       }
+                       
+                       while(i.MoveNext())
+                       {
+                               Console.WriteLine(i.Current.ToString());
+                       }
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbBlobTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbBlobTest.cs
new file mode 100644 (file)
index 0000000..0b9f363
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using NUnit.Framework;
+using System;
+using System.Collections;
+using System.Security.Cryptography;
+using FirebirdSql.Data.Firebird;
+
+namespace FirebirdSql.Data.Firebird.Tests
+{
+       [TestFixture]
+       public class FbBlobTest : BaseTest 
+       {
+               public FbBlobTest() : base(false)
+               {               
+               }
+               
+               [Test]
+               public void BinaryBlobTest()
+               {
+                       int id_value = this.GetId();
+                       
+                       string selectText = "SELECT blob_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, blob_field) values(@int_field, @blob_field)";
+                       
+                       Console.WriteLine("\r\n\r\nBinary Blob Test");
+                       
+                       Console.WriteLine("Generating an array of temp data");
+                       // Generate an array of temp data
+                       byte[] insert_values = new byte[100000*4];
+                       RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
+                       rng.GetBytes(insert_values);
+                       
+                       Console.WriteLine("Executing insert command");
+
+                       // Execute insert command
+                       FbTransaction transaction = Connection.BeginTransaction();
+
+                       FbCommand insert = new FbCommand(insertText, Connection, transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@blob_field", FbDbType.Binary).Value = insert_values;
+                       insert.ExecuteNonQuery();
+
+                       transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+                       byte[] select_values = (byte[])select.ExecuteScalar();                  
+
+                       for (int i = 0; i < insert_values.Length; i++)
+                       {
+                               if (insert_values[i] != select_values[i])
+                               {
+                                       throw new Exception("differences at index " + i.ToString());
+                               }
+                       }
+
+                       Console.WriteLine("Finishing test");
+               }
+
+               [Test]
+               public void ReaderGetBytes()
+               {
+                       int id_value = this.GetId();
+                       
+                       string selectText = "SELECT blob_field FROM TEST WHERE int_field = " + id_value.ToString();
+                       string insertText = "INSERT INTO TEST (int_field, blob_field) values(@int_field, @blob_field)";
+                       
+                       Console.WriteLine("\r\n\r\nFbDataReader.GetBytes with Binary Blob Test");
+                       
+                       Console.WriteLine("Generating an array of temp data");
+                       // Generate an array of temp data
+                       byte[] insert_values = new byte[100000*4];
+                       RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
+                       rng.GetBytes(insert_values);
+                       
+                       Console.WriteLine("Executing insert command");
+
+                       // Execute insert command
+                       FbTransaction transaction = Connection.BeginTransaction();
+
+                       FbCommand insert = new FbCommand(insertText, Connection, transaction);
+                       insert.Parameters.Add("@int_field", FbDbType.Integer).Value = id_value;
+                       insert.Parameters.Add("@blob_field", FbDbType.Binary).Value = insert_values;
+                       insert.ExecuteNonQuery();
+
+                       transaction.Commit();
+
+                       Console.WriteLine("Checking inserted values");
+
+                       // Check that inserted values are correct
+                       FbCommand select = new FbCommand(selectText, Connection);
+
+                       FbDataReader reader = select.ExecuteReader();
+
+                       int             index           = 0;
+                       int             segmentSize     = 1000;
+                       byte[]  select_values = new byte[100000*4];
+                       while (reader.Read())
+                       {
+                               while (index < 400000)
+                               {
+                                       reader.GetBytes(0, index, select_values, index, segmentSize);
+
+                                       index += segmentSize;
+                               }
+                       }
+
+                       for (int i = 0; i < insert_values.Length; i++)
+                       {
+                               if (insert_values[i] != select_values[i])
+                               {
+                                       throw new Exception("differences at index " + i.ToString());
+                               }
+                       }
+               }
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbCommandBuilderTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbCommandBuilderTest.cs
new file mode 100644 (file)
index 0000000..f7406c9
--- /dev/null
@@ -0,0 +1,185 @@
+/*\r
+ *  Firebird ADO.NET Data provider for .NET and Mono \r
+ * \r
+ *     The contents of this file are subject to the Initial \r
+ *     Developer's Public License Version 1.0 (the "License"); \r
+ *     you may not use this file except in compliance with the \r
+ *     License. You may obtain a copy of the License at \r
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl\r
+ *\r
+ *     Software distributed under the License is distributed on \r
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either \r
+ *     express or implied.  See the License for the specific \r
+ *     language governing rights and limitations under the License.\r
+ * \r
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez\r
+ *  All Rights Reserved.\r
+ */\r
+\r
+using NUnit.Framework;\r
+using System;\r
+using System.Data;\r
+using FirebirdSql.Data.Firebird;\r
+\r
+namespace FirebirdSql.Data.Firebird.Tests\r
+{\r
+       [TestFixture]\r
+       public class FbCommandBuilderTest : BaseTest\r
+       {\r
+               FbDataAdapter   adapter;\r
+               \r
+               public FbCommandBuilderTest() : base(false)\r
+               {\r
+               }\r
+               \r
+               [SetUp]\r
+               public override void SetUp()\r
+               {\r
+                       base.SetUp();\r
+                       adapter = new FbDataAdapter(new FbCommand("select * from TEST where VARCHAR_FIELD = ?", Connection));\r
+               }\r
+               \r
+               [TearDown]\r
+               public override void TearDown()\r
+               {\r
+                       adapter.Dispose();\r
+                       base.TearDown();\r
+               }\r
+               \r
+               [Test]\r
+               public void GetInsertCommandTest()\r
+               {\r
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);\r
+\r
+                       Console.WriteLine();\r
+                       Console.WriteLine("CommandBuilder - GetInsertCommand Method Test");\r
+                       \r
+                       Console.WriteLine( builder.GetInsertCommand().CommandText );\r
+\r
+                       builder.Dispose();\r
+               }\r
+               \r
+               [Test]\r
+               public void GetUpdateCommandTest()\r
+               {\r
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);\r
+\r
+                       Console.WriteLine();\r
+                       Console.WriteLine("CommandBuilder - GetUpdateCommand Method Test");\r
+                       \r
+                       Console.WriteLine( builder.GetUpdateCommand().CommandText );\r
+\r
+                       builder.Dispose();\r
+               }\r
+               \r
+               [Test]\r
+               public void GetDeleteCommandTest()\r
+               {\r
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);\r
+\r
+                       Console.WriteLine();\r
+                       Console.WriteLine("CommandBuilder - GetDeleteCommand Method Test");\r
+                       \r
+                       Console.WriteLine( builder.GetDeleteCommand().CommandText );\r
+\r
+                       builder.Dispose();\r
+               }\r
+               \r
+               [Test]\r
+               public void RefreshSchemaTest()\r
+               {\r
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);\r
+                       \r
+                       Console.WriteLine();\r
+                       Console.WriteLine("CommandBuilder - RefreshSchema Method Test - Commands for original SQL statement: ");\r
+\r
+                       Console.WriteLine( builder.GetInsertCommand().CommandText );\r
+                       Console.WriteLine( builder.GetUpdateCommand().CommandText );\r
+                       Console.WriteLine( builder.GetDeleteCommand().CommandText );\r
+                       \r
+                       adapter.SelectCommand.CommandText = "select * from TEST where BIGINT_FIELD = ?";\r
+                       \r
+                       builder.RefreshSchema();\r
+                       \r
+                       Console.WriteLine();\r
+                       Console.WriteLine("CommandBuilder - RefreshSchema Method Test - Commands for new SQL statement: ");\r
+                                               \r
+                       Console.WriteLine( builder.GetInsertCommand().CommandText );\r
+                       Console.WriteLine( builder.GetUpdateCommand().CommandText );\r
+                       Console.WriteLine( builder.GetDeleteCommand().CommandText );\r
+\r
+                       builder.Dispose();\r
+               }\r
+               \r
+               [Test]\r
+               public void CommandBuilderWithExpressionFieldTest()\r
+               {\r
+                       adapter.SelectCommand.CommandText = "select TEST.*, 0 AS VALOR from TEST";\r
+\r
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);\r
+\r
+                       Console.WriteLine();\r
+                       Console.WriteLine("CommandBuilder - GetUpdateCommand Method Test");\r
+                       \r
+                       Console.WriteLine( builder.GetUpdateCommand().CommandText );\r
+\r
+                       builder.Dispose();\r
+               }\r
+\r
+               [Test]\r
+               public void DeriveParameters()\r
+               {       \r
+                       FbCommand command = new FbCommand("GETVARCHARFIELD", Connection);\r
+                       \r
+                       command.CommandType = CommandType.StoredProcedure;\r
+                                               \r
+                       FbCommandBuilder.DeriveParameters(command);\r
+\r
+            Assert.AreEqual(2, command.Parameters.Count);\r
+        }\r
+\r
+               [Test]\r
+               public void DeriveParameters2()\r
+               {\r
+                       FbTransaction transaction = Connection.BeginTransaction();\r
+\r
+                       FbCommand command = new FbCommand("GETVARCHARFIELD", Connection, transaction);\r
+                       \r
+                       command.CommandType = CommandType.StoredProcedure;\r
+                                               \r
+                       FbCommandBuilder.DeriveParameters(command);\r
+\r
+            Assert.AreEqual(2, command.Parameters.Count);\r
+\r
+                       transaction.Commit();\r
+               }\r
+\r
+               [Test]\r
+               public void TestWithClosedConnection()\r
+               {\r
+                       Connection.Close();\r
+\r
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);\r
+                       \r
+                       Console.WriteLine();\r
+                       Console.WriteLine("CommandBuilder - RefreshSchema Method Test - Commands for original SQL statement: ");\r
+\r
+                       Console.WriteLine( builder.GetInsertCommand().CommandText );\r
+                       Console.WriteLine( builder.GetUpdateCommand().CommandText );\r
+                       Console.WriteLine( builder.GetDeleteCommand().CommandText );\r
+                       \r
+                       adapter.SelectCommand.CommandText = "select * from TEST where BIGINT_FIELD = ?";\r
+                       \r
+                       builder.RefreshSchema();\r
+                       \r
+                       Console.WriteLine();\r
+                       Console.WriteLine("CommandBuilder - RefreshSchema Method Test - Commands for new SQL statement: ");\r
+                                               \r
+                       Console.WriteLine( builder.GetInsertCommand().CommandText );\r
+                       Console.WriteLine( builder.GetUpdateCommand().CommandText );\r
+                       Console.WriteLine( builder.GetDeleteCommand().CommandText );\r
+\r
+                       builder.Dispose();\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbCommandTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbCommandTest.cs
new file mode 100644 (file)
index 0000000..13c4e8e
--- /dev/null
@@ -0,0 +1,485 @@
+/*\r
+ *  Firebird ADO.NET Data provider for .NET and Mono \r
+ * \r
+ *     The contents of this file are subject to the Initial \r
+ *     Developer's Public License Version 1.0 (the "License"); \r
+ *     you may not use this file except in compliance with the \r
+ *     License. You may obtain a copy of the License at \r
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl\r
+ *\r
+ *     Software distributed under the License is distributed on \r
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either \r
+ *     express or implied.  See the License for the specific \r
+ *     language governing rights and limitations under the License.\r
+ * \r
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez\r
+ *  All Rights Reserved.\r
+ */\r
+\r
+using NUnit.Framework;\r
+using System;\r
+using System.Collections;\r
+using System.Data;\r
+using FirebirdSql.Data.Firebird;\r
+\r
+namespace FirebirdSql.Data.Firebird.Tests\r
+{\r
+       [TestFixture]\r
+       public class FbCommandTest : BaseTest \r
+       {       \r
+               public FbCommandTest() : base(false)\r
+               {               \r
+               }\r
+\r
+               [Test]\r
+               public void ExecuteNonQueryTest()\r
+               {                                                       \r
+                       Transaction = Connection.BeginTransaction();\r
+\r
+                       FbCommand command = Connection.CreateCommand();\r
+                       \r
+                       command.Transaction = Transaction;\r
+                       command.CommandText = "insert into TEST (INT_FIELD) values (?) ";\r
+                                                                       \r
+                       command.Parameters.Add("@INT_FIELD", 100);\r
+                                                                       \r
+                       int affectedRows = command.ExecuteNonQuery();\r
+                                                                       \r
+                       Assert.AreEqual(affectedRows, 1);\r
+                                                               \r
+                       Transaction.Rollback();\r
+\r
+                       command.Dispose();\r
+               }\r
+               \r
+               [Test]\r
+               public void ExecuteReaderTest()\r
+               {                                                       \r
+                       FbCommand command = Connection.CreateCommand();\r
+                       \r
+                       command.CommandText = "select * from TEST";\r
+                       \r
+                       FbDataReader reader = command.ExecuteReader();\r
+                       reader.Close();\r
+\r
+                       command.Dispose();\r
+               }\r
+\r
+        [Test]\r
+        public void ExecuteMultipleReaderTest()\r
+        {\r
+            FbCommand command1 = Connection.CreateCommand();\r
+            FbCommand command2 = Connection.CreateCommand();\r
+\r
+            command1.CommandText = "select * from test where int_field = 1";\r
+            command2.CommandText = "select * from test where int_field = 2";\r
+\r
+            FbDataReader r1 = command1.ExecuteReader();\r
+            FbDataReader r2 = command2.ExecuteReader();\r
+\r
+            r2.Close();\r
+\r
+            try\r
+            {\r
+                // Try to call ExecuteReader in command1\r
+                // it should throw an exception\r
+                r2 = command1.ExecuteReader();\r
+\r
+                throw new InvalidProgramException();\r
+            }\r
+            catch\r
+            {\r
+                r1.Close();\r
+            }\r
+        }\r
+\r
+        [Test]\r
+               public void ExecuteReaderWithBehaviorTest()\r
+               {                                                       \r
+                       FbCommand command = new FbCommand("select * from TEST", Connection);\r
+                       \r
+                       FbDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);                                                           \r
+                       reader.Close();\r
+\r
+                       command.Dispose();\r
+               }\r
+               \r
+               [Test]\r
+               public void ExecuteScalarTest()\r
+               {                                                       \r
+                       FbCommand command = Connection.CreateCommand();\r
+                       \r
+                       command.CommandText = "select CHAR_FIELD from TEST where INT_FIELD = ?";                                                                        \r
+                       command.Parameters.Add("@INT_FIELD", 2);\r
+                                               \r
+                       string charFieldValue = command.ExecuteScalar().ToString();\r
+                       \r
+                       Console.WriteLine("Scalar value: {0}", charFieldValue);\r
+\r
+                       command.Dispose();\r
+               }\r
+               \r
+               [Test]\r
+               public void PrepareTest()\r
+               {                                       \r
+                       // Create a new test table\r
+                       FbCommand create = new FbCommand("create table PrepareTest(test_field varchar(20));", Connection);\r
+                       create.ExecuteNonQuery();\r
+                       create.Dispose();\r
+               \r
+                       // Insert data using a prepared statement\r
+                       FbCommand command = new FbCommand(\r
+                               "insert into PrepareTest(test_field) values(@test_field);",\r
+                               Connection);\r
+                       \r
+                       command.Parameters.Add("@test_field", FbDbType.VarChar).Value = DBNull.Value;\r
+                       command.Prepare();\r
+\r
+                       for (int i = 0; i < 5; i++) \r
+                       {\r
+                               if (i < 1)\r
+                               {\r
+                                       command.Parameters[0].Value = DBNull.Value;\r
+                               }\r
+                               else\r
+                               {\r
+                                       command.Parameters[0].Value = i.ToString();\r
+                               }\r
+                               command.ExecuteNonQuery();\r
+                       }\r
+\r
+                       command.Dispose();\r
+\r
+                       try\r
+                       {\r
+                               // Check that data is correct\r
+                               FbCommand select = new FbCommand("select * from PrepareTest", Connection);\r
+                               FbDataReader reader = select.ExecuteReader();\r
+                               int count = 0;\r
+                               while (reader.Read())\r
+                               {\r
+                                       if (count == 0)\r
+                                       {\r
+                                               Assert.AreEqual(DBNull.Value, reader[0], "Invalid value.");\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               Assert.AreEqual(count, reader.GetInt32(0), "Invalid value.");\r
+                                       }\r
+\r
+                                       count++;\r
+                               }\r
+                               reader.Close();\r
+                               select.Dispose();\r
+                       }\r
+                       catch (Exception)\r
+                       {\r
+                               throw;\r
+                       }\r
+                       finally\r
+                       {\r
+                               // Drop table\r
+                               FbCommand drop = new FbCommand("drop table PrepareTest", Connection);\r
+                               drop.ExecuteNonQuery();\r
+                               drop.Dispose();\r
+                       }                       \r
+               }\r
+\r
+               [Test]\r
+               public void NamedParametersTest()\r
+               {\r
+                       FbCommand command = Connection.CreateCommand();\r
+                       \r
+                       command.CommandText = "select CHAR_FIELD from TEST where INT_FIELD = @int_field or CHAR_FIELD = @char_field";\r
+                                                                       \r
+                       command.Parameters.Add("@int_field", 2);\r
+                       command.Parameters.Add("@char_field", "TWO");\r
+                                               \r
+                       FbDataReader reader = command.ExecuteReader();\r
+                       \r
+                       int count = 0;\r
+\r
+                       while (reader.Read())\r
+                       {\r
+                               count++;\r
+                       }\r
+\r
+                       Assert.AreEqual(1, count, "Invalid number of records fetched.");\r
+\r
+                       reader.Close();\r
+                       command.Dispose();\r
+               }\r
+\r
+               [Test]\r
+               public void NamedParametersAndLiterals()\r
+               {\r
+                       string sql = "update test set char_field = 'carlos@firebird.org', bigint_field = @bigint, varchar_field = 'carlos@ado.net' where int_field = @integer";\r
+\r
+                       FbCommand command = new FbCommand(sql, this.Connection);\r
+                       command.Parameters.Add("@bigint", FbDbType.BigInt).Value = 200;\r
+                       command.Parameters.Add("@integer", FbDbType.Integer).Value = 1;\r
+\r
+                       int recordsAffected = command.ExecuteNonQuery();\r
+\r
+                       command.Dispose();\r
+\r
+                       Assert.AreEqual(recordsAffected, 1, "Invalid number of records affected.");\r
+               }\r
+\r
+               [Test]\r
+               public void NamedParametersReuseTest()\r
+               {\r
+                       string sql = "select * from test where int_field >= @lang and int_field <= @lang";\r
+\r
+                       FbCommand command = new FbCommand(sql, this.Connection);\r
+                       command.Parameters.Add("@lang", FbDbType.Integer).Value = 10;\r
+                                               \r
+                       FbDataReader reader = command.ExecuteReader();\r
+                       \r
+                       int count               = 0;\r
+                       int intValue    = 0;\r
+\r
+                       while (reader.Read())\r
+                       {\r
+                               if (count == 0)\r
+                               {\r
+                                       intValue = reader.GetInt32(0);\r
+                               }\r
+                               count++;\r
+                       }\r
+\r
+                       Assert.AreEqual(1, count, "Invalid number of records fetched.");\r
+                       Assert.AreEqual(10, intValue, "Invalid record fetched.");\r
+\r
+                       reader.Close();\r
+                       command.Dispose();\r
+               }\r
+\r
+               [Test]\r
+               public void ExecuteStoredProcTest()\r
+               {                       \r
+                       FbCommand command = new FbCommand("EXECUTE PROCEDURE GETVARCHARFIELD(?)", Connection);\r
+                               \r
+                       command.CommandType = CommandType.StoredProcedure;\r
+\r
+                       command.Parameters.Add("@ID", FbDbType.VarChar).Direction = ParameterDirection.Input;\r
+                       command.Parameters.Add("@VARCHAR_FIELD", FbDbType.VarChar).Direction = ParameterDirection.Output;\r
+\r
+                       command.Parameters[0].Value = 1;\r
+\r
+                       // This will fill output parameters values\r
+                       command.ExecuteNonQuery();\r
+\r
+                       Console.WriteLine("Output Parameters");\r
+                       Console.WriteLine(command.Parameters[1].Value);\r
+               }\r
+\r
+               [Test]\r
+               public void RecordsAffectedTest()\r
+               {\r
+                       FbCommand selectCommand = new FbCommand("SELECT * FROM TEST WHERE INT_FIELD = -1", Connection);\r
+                       int recordsAffected = selectCommand.ExecuteNonQuery();\r
+                       Console.WriteLine("\r\nRecords Affected: {0}", recordsAffected);\r
+                       Assert.IsTrue(recordsAffected == -1);\r
+                       selectCommand.Dispose();\r
+\r
+                       FbCommand deleteCommand = new FbCommand("DELETE FROM TEST WHERE INT_FIELD = -1", Connection);   \r
+                       recordsAffected = deleteCommand.ExecuteNonQuery();\r
+                       Console.WriteLine("\r\nRecords Affected: {0}", recordsAffected);\r
+                       Assert.IsTrue(recordsAffected == 0);\r
+                       deleteCommand.Dispose();\r
+               }\r
+\r
+               [Test]\r
+               public void ExecuteNonQueryWithOutputParameters()\r
+               {\r
+                       FbCommand command = new FbCommand("EXECUTE PROCEDURE GETASCIIBLOB(?)", Connection);\r
+                               \r
+                       command.CommandType = CommandType.StoredProcedure;\r
+\r
+                       command.Parameters.Add("@ID", FbDbType.VarChar).Direction = ParameterDirection.Input;\r
+                       command.Parameters.Add("@CLOB_FIELD", FbDbType.Text).Direction = ParameterDirection.Output;\r
+\r
+                       command.Parameters[0].Value = 1;\r
+\r
+                       // This will fill output parameters values\r
+                       command.ExecuteNonQuery();\r
+\r
+                       // Check that the output parameter has a correct value\r
+                       Assert.AreEqual("IRow Number 1", command.Parameters[1].Value, "Output parameter value is not valid");\r
+\r
+                       // Dispose command - this will do a transaction commit\r
+                       command.Dispose();\r
+               }\r
+\r
+               [Test]\r
+               public void InvalidParameterFormat()\r
+               {\r
+                       string sql = "update test set timestamp_field = @timestamp where int_field = @integer";\r
+\r
+                       FbTransaction transaction = this.Connection.BeginTransaction();\r
+                       try\r
+                       {\r
+                               FbCommand command = new FbCommand(sql, this.Connection, transaction);\r
+                               command.Parameters.Add("@timestamp", FbDbType.TimeStamp).Value = 1;\r
+                               command.Parameters.Add("@integer", FbDbType.Integer).Value = 1;\r
+\r
+                               command.ExecuteNonQuery();\r
+\r
+                               command.Dispose();\r
+\r
+                               transaction.Commit();\r
+                       }\r
+                       catch\r
+                       {\r
+                               transaction.Rollback();\r
+                       }\r
+               }\r
+\r
+        [Test]\r
+        public void UnicodeTest()\r
+        {\r
+            string createTable = "CREATE TABLE VARCHARTEST (VARCHAR_FIELD  VARCHAR(10));";\r
+\r
+            FbCommand ct = new FbCommand(createTable, this.Connection);\r
+            ct.ExecuteNonQuery();\r
+            ct.Dispose();\r
+\r
+            ArrayList l = new ArrayList();\r
+\r
+            l.Add("INSERT INTO VARCHARTEST (VARCHAR_FIELD) VALUES ('1');");\r
+            l.Add("INSERT INTO VARCHARTEST (VARCHAR_FIELD) VALUES ('11');");\r
+            l.Add("INSERT INTO VARCHARTEST (VARCHAR_FIELD) VALUES ('111');");\r
+            l.Add("INSERT INTO VARCHARTEST (VARCHAR_FIELD) VALUES ('1111');");\r
+\r
+            foreach (string statement in l)\r
+            {\r
+                FbCommand insert = new FbCommand(statement, this.Connection);\r
+                insert.ExecuteNonQuery();\r
+                insert.Dispose();\r
+            }\r
+\r
+            string sql = "select * from varchartest";\r
+\r
+            FbCommand cmd = new FbCommand(sql, this.Connection);\r
+            FbDataReader r = cmd.ExecuteReader();\r
+\r
+            while (r.Read())\r
+            {\r
+                Console.WriteLine("{0} :: {1}", r[0], r[0].ToString().Length);\r
+            }\r
+\r
+            r.Close();\r
+        }\r
+\r
+        [Test]\r
+        public void SimplifiedChineseTest()\r
+        {\r
+            string createTable = "CREATE TABLE TABLE1 (FIELD1 varchar(20))";\r
+            FbCommand create = new FbCommand(createTable, this.Connection);\r
+            create.ExecuteNonQuery();\r
+            create.Dispose();\r
+\r
+            // insert using parametrized SQL\r
+            string sql = "INSERT INTO Table1 VALUES (@value)";\r
+            FbCommand command = new FbCommand(sql, this.Connection);\r
+            command.Parameters.Add("@value", FbDbType.VarChar).Value = "中文";\r
+            command.ExecuteNonQuery();\r
+            command.Dispose();\r
+\r
+            sql = "SELECT * FROM TABLE1";\r
+            FbCommand select = new FbCommand(sql, this.Connection);\r
+            string result = select.ExecuteScalar().ToString();\r
+            select.Dispose();\r
+\r
+            Assert.AreEqual("中文", result, "Incorrect results in parametrized insert");\r
+\r
+            sql = "DELETE FROM TABLE1";\r
+            FbCommand delete = new FbCommand(sql, this.Connection);\r
+            delete.ExecuteNonQuery();\r
+            delete.Dispose();\r
+\r
+            // insert using plain SQL\r
+            sql = "INSERT INTO Table1 VALUES ('中文')";\r
+            FbCommand plainCommand = new FbCommand(sql, this.Connection);\r
+            plainCommand.ExecuteNonQuery();\r
+            plainCommand.Dispose();\r
+\r
+            sql = "SELECT * FROM TABLE1";\r
+            select = new FbCommand(sql, this.Connection);\r
+            result = select.ExecuteScalar().ToString();\r
+            select.Dispose();\r
+\r
+            Assert.AreEqual("中文", result, "Incorrect results in plain insert");\r
+        }\r
+\r
+               [Test]\r
+               public void InsertDateTest()\r
+               {\r
+                       string sql = "insert into TEST (int_field, date_field) values (1002, @date)";\r
+\r
+                       FbCommand command = new FbCommand(sql, this.Connection);\r
+\r
+                       command.Parameters.Add("@date", FbDbType.Date).Value = DateTime.Now.ToString();\r
+\r
+                       int ra = command.ExecuteNonQuery();\r
+\r
+                       Assert.AreEqual(ra, 1);\r
+               }\r
+\r
+               [Test]\r
+               public void InsertNullTest()\r
+               {\r
+                       string sql = "insert into TEST (int_field) values (@value)";\r
+\r
+                       FbCommand command = new FbCommand(sql, this.Connection);\r
+                       command.Parameters.Add("@value", FbDbType.Integer).Value = null;\r
+\r
+                       try\r
+                       {\r
+                               command.ExecuteNonQuery();\r
+\r
+                               throw new Exception("The command was executed without throw an exception");\r
+                       }\r
+                       catch\r
+                       {\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void ParameterDescribeTest()\r
+               {\r
+                       string sql = "insert into TEST (int_field) values (@value)";\r
+\r
+                       FbCommand command = new FbCommand(sql, this.Connection);\r
+                       command.Prepare();\r
+                       command.Parameters.Add("@value", FbDbType.Integer).Value = 100000;\r
+\r
+                       command.ExecuteNonQuery();\r
+\r
+                       command.Dispose();\r
+               }\r
+\r
+               [Test]\r
+               public void ReadOnlyTransactionTest()\r
+               {\r
+                       using (IDbCommand command = this.Connection.CreateCommand())\r
+                       {\r
+                               using (IDbTransaction transaction = this.Connection.BeginTransaction(FbTransactionOptions.Read))\r
+                               {\r
+                                       try\r
+                                       {\r
+                                               command.Transaction = transaction;\r
+                                               command.CommandType = System.Data.CommandType.Text;\r
+                                               command.CommandText = "CREATE TABLE X_TABLE_1(FIELD VARCHAR(50));";\r
+                                               command.ExecuteNonQuery();\r
+                                               transaction.Commit();\r
+                                       }\r
+                                       catch (FbException)\r
+                                       {\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbConnectionTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbConnectionTest.cs
new file mode 100644 (file)
index 0000000..ca3a618
--- /dev/null
@@ -0,0 +1,162 @@
+/*\r
+ *  Firebird ADO.NET Data provider for .NET and Mono \r
+ * \r
+ *     The contents of this file are subject to the Initial \r
+ *     Developer's Public License Version 1.0 (the "License"); \r
+ *     you may not use this file except in compliance with the \r
+ *     License. You may obtain a copy of the License at \r
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl\r
+ *\r
+ *     Software distributed under the License is distributed on \r
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either \r
+ *     express or implied.  See the License for the specific \r
+ *     language governing rights and limitations under the License.\r
+ * \r
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez\r
+ *  All Rights Reserved.\r
+ */\r
+\r
+using NUnit.Framework;\r
+using System;\r
+using System.Configuration;\r
+using System.Data;\r
+using System.Reflection;\r
+using FirebirdSql.Data.Firebird;\r
+\r
+namespace FirebirdSql.Data.Firebird.Tests\r
+{\r
+       [TestFixture]\r
+       public class FbConnectionTest : BaseTest \r
+       {\r
+               public FbConnectionTest() : base(false)\r
+               {\r
+               }\r
+                               \r
+               [Test]\r
+               public void BeginTrasactionTest()\r
+               {\r
+                       string connectionString = this.BuildConnectionString();\r
+\r
+                       FbConnection conn01 = new FbConnection(connectionString);\r
+                       conn01.Open();\r
+                       FbTransaction txn01 = conn01.BeginTransaction(IsolationLevel.Unspecified);\r
+            txn01.Rollback();\r
+                       conn01.Close();\r
+            \r
+                       FbConnection conn02 = new FbConnection(connectionString);\r
+                       conn02.Open();\r
+                       FbTransaction txn02 = conn02.BeginTransaction(IsolationLevel.ReadCommitted);\r
+            txn02.Rollback();\r
+                       conn02.Close();\r
+            \r
+                       FbConnection conn03 = new FbConnection(connectionString);\r
+                       conn03.Open();\r
+                       FbTransaction txn03 = conn03.BeginTransaction(IsolationLevel.ReadUncommitted);\r
+            txn03.Rollback();\r
+            conn03.Close();\r
+\r
+                       FbConnection conn04 = new FbConnection(connectionString);\r
+                       conn04.Open();\r
+                       FbTransaction txn04 = conn04.BeginTransaction(IsolationLevel.RepeatableRead);\r
+            txn04.Rollback();\r
+                       conn04.Close();\r
+\r
+                       FbConnection conn05 = new FbConnection(connectionString);\r
+                       conn05.Open();\r
+                       FbTransaction txn05 = conn05.BeginTransaction(IsolationLevel.Serializable);\r
+            txn05.Rollback();\r
+                       conn05.Close();                 \r
+               }\r
+               \r
+               [Test]\r
+               public void CreateCommandTest()\r
+               {\r
+                       FbCommand command = Connection.CreateCommand();\r
+\r
+                       Assert.AreEqual(command.Connection, Connection);\r
+               }\r
+\r
+               [Test]\r
+               public void ConnectionPoolingTest()\r
+               {\r
+                       string cs = this.BuildConnectionString(true);\r
+\r
+                       FbConnection myConnection1 = new FbConnection(cs);\r
+                       FbConnection myConnection2 = new FbConnection(cs);\r
+                       FbConnection myConnection3 = new FbConnection(cs);\r
+\r
+                       // Open two connections.\r
+                       Console.WriteLine ("Open two connections.");\r
+                       myConnection1.Open();\r
+                       myConnection2.Open();\r
+\r
+                       // Now there are two connections in the pool that matches the connection string.\r
+                       // Return the both connections to the pool. \r
+                       Console.WriteLine ("Return both of the connections to the pool.");\r
+                       myConnection1.Close();\r
+                       myConnection2.Close();\r
+\r
+                       // Get a connection out of the pool.\r
+                       Console.WriteLine ("Open a connection from the pool.");\r
+                       myConnection1.Open();\r
+\r
+                       // Get a second connection out of the pool.\r
+                       Console.WriteLine ("Open a second connection from the pool.");\r
+                       myConnection2.Open();\r
+\r
+                       // Open a third connection.\r
+                       Console.WriteLine ("Open a third connection.");\r
+                       myConnection3.Open();\r
+\r
+                       // Return the all connections to the pool.  \r
+                       Console.WriteLine ("Return all three connections to the pool.");\r
+                       myConnection1.Close();\r
+                       myConnection2.Close();\r
+                       myConnection3.Close();\r
+\r
+                       // Clear pools\r
+                       FbConnection.ClearAllPools();\r
+               }\r
+\r
+        [Test]\r
+        public void FbConnectionStringBuilderTest()\r
+        {\r
+            FbConnectionStringBuilder cs = new FbConnectionStringBuilder();\r
+\r
+            cs.DataSource = ConfigurationSettings.AppSettings["DataSource"];\r
+            cs.Database = ConfigurationSettings.AppSettings["Database"];\r
+            cs.Port = Convert.ToInt32(ConfigurationSettings.AppSettings["Port"]);\r
+            cs.UserID = ConfigurationSettings.AppSettings["User"];\r
+            cs.Password = ConfigurationSettings.AppSettings["Password"];\r
+            cs.ServerType = Convert.ToInt32(ConfigurationSettings.AppSettings["ServerType"]);\r
+            cs.Charset = ConfigurationSettings.AppSettings["Charset"];\r
+            cs.Pooling = Convert.ToBoolean(ConfigurationSettings.AppSettings["Pooling"]);\r
+\r
+            using (FbConnection c = new FbConnection(cs.ToString()))\r
+            {\r
+                c.Open();\r
+            }\r
+\r
+        }\r
+\r
+        public void OnStateChange(object sender, StateChangeEventArgs e)\r
+               {               \r
+                       Console.WriteLine("OnStateChange");\r
+                       Console.WriteLine("  event args: ("+\r
+                                  "originalState=" + e.OriginalState +\r
+                                  " currentState=" + e.CurrentState +")");\r
+               }\r
+                                               \r
+               public FbTransaction BeginTransaction(IsolationLevel level)\r
+               {       \r
+                       switch(level)\r
+                       {\r
+                               case IsolationLevel.Unspecified:\r
+                                       return Connection.BeginTransaction();\r
+                               \r
+                               default:\r
+                                       return Connection.BeginTransaction(level);\r
+                       }\r
+               }               \r
+       }\r
+}\r
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbDataAdapterTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbDataAdapterTest.cs
new file mode 100644 (file)
index 0000000..26981b6
--- /dev/null
@@ -0,0 +1,683 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using NUnit.Framework;
+using System;
+using System.Data;
+using FirebirdSql.Data.Firebird;
+
+namespace FirebirdSql.Data.Firebird.Tests
+{
+       [TestFixture]
+       public class FbDataAdapterTest : BaseTest 
+       {
+               public FbDataAdapterTest() : base(false)
+               {               
+               }
+       
+               [Test]
+               public void FillTest()
+               {
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command = new FbCommand("select * from TEST", Connection, transaction);
+                       FbDataAdapter   adapter = new FbDataAdapter(command);
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+                       
+                       Assert.AreEqual(100, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       Console.WriteLine();
+                       Console.WriteLine("DataAdapter - Fill Method - Test");
+
+                       foreach (DataTable table in ds.Tables)
+                       {
+                               foreach (DataColumn col in table.Columns)
+                               {
+                                       Console.Write(col.ColumnName + "\t\t");
+                               }
+                               
+                               Console.WriteLine();
+                               
+                               foreach (DataRow row in table.Rows)
+                               {
+                                       for (int i = 0; i < table.Columns.Count; i++)
+                                       {
+                                               Console.Write(row[i] + "\t\t");
+                                       }
+
+                                       Console.WriteLine("");
+                               }
+                       }
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+                       transaction.Commit();
+               }
+
+               [Test]
+               public void FillMultipleTest()
+               {
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command = new FbCommand("select * from TEST", Connection, transaction);
+                       FbDataAdapter   adapter = new FbDataAdapter(command);
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds1 = new DataSet();
+                       DataSet ds2 = new DataSet();
+                       
+                       adapter.Fill(ds1, "TEST");
+                       adapter.Fill(ds2, "TEST");
+
+                       Assert.AreEqual(100, ds1.Tables["TEST"].Rows.Count, "Incorrect row count (ds1)");
+                       Assert.AreEqual(100, ds2.Tables["TEST"].Rows.Count, "Incorrect row count (ds2)");
+                       
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+                       transaction.Commit();
+               }
+
+               [Test]
+        public void FillMultipleWithImplicitTransactionTest()
+               {
+                       FbCommand               command = new FbCommand("select * from TEST", Connection);
+                       FbDataAdapter   adapter = new FbDataAdapter(command);
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds1 = new DataSet();
+                       DataSet ds2 = new DataSet();
+                       
+                       adapter.Fill(ds1, "TEST");
+                       adapter.Fill(ds2, "TEST");
+                       
+                       Assert.AreEqual(100, ds1.Tables["TEST"].Rows.Count, "Incorrect row count (ds1)");
+                       Assert.AreEqual(100, ds2.Tables["TEST"].Rows.Count, "Incorrect row count (ds2)");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+               }
+
+               [Test]
+               public void InsertTest()
+               {
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand("select * from TEST", Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(100, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       DataRow newRow = ds.Tables["TEST"].NewRow();
+
+                       newRow["int_field"]                     = 101;
+                       newRow["CHAR_FIELD"]            = "ONE THOUSAND";
+                       newRow["VARCHAR_FIELD"]         = ":;,.{}`+^*[]\\!|@#$%&/()?_-<>";
+                       newRow["BIGint_field"]          = 100000;
+                       newRow["SMALLint_field"]        = 100;
+                       newRow["DOUBLE_FIELD"]          = 100.01;
+                       newRow["NUMERIC_FIELD"]         = 100.01;
+                       newRow["DECIMAL_FIELD"]         = 100.01;
+                       newRow["DATE_FIELD"]            = new DateTime(100, 10, 10);
+                       newRow["TIME_FIELD"]            = new DateTime(100, 10, 10, 10, 10, 10, 10);
+                       newRow["TIMESTAMP_FIELD"]       = new DateTime(100, 10, 10, 10, 10, 10, 10);
+                       newRow["CLOB_FIELD"]            = "ONE THOUSAND";
+
+                       ds.Tables["TEST"].Rows.Add(newRow);
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+                       transaction.Commit();
+               }
+
+               [Test]
+               public void UpdateCharTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       ds.Tables["TEST"].Rows[0]["CHAR_FIELD"] = "ONE THOUSAND";
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+
+                       transaction.Commit();
+
+                       transaction = Connection.BeginTransaction();
+
+                       sql             = "SELECT char_field FROM TEST WHERE int_field = @int_field";
+                       command = new FbCommand(sql, Connection, transaction);                  
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+
+                       string val = (string)command.ExecuteScalar();
+
+                       transaction.Commit();
+
+                       Assert.AreEqual("ONE THOUSAND", val.Trim(), "char_field has not correct value");
+               }
+
+               [Test]
+               public void UpdateVarCharTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       ds.Tables["TEST"].Rows[0]["VARCHAR_FIELD"]      = "ONE VAR THOUSAND";
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+
+                       transaction.Commit();
+
+                       transaction = Connection.BeginTransaction();
+
+                       sql             = "SELECT varchar_field FROM TEST WHERE int_field = @int_field";
+                       command = new FbCommand(sql, Connection, transaction);                  
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+
+                       string val = (string)command.ExecuteScalar();
+
+                       transaction.Commit();
+
+                       Assert.AreEqual("ONE VAR THOUSAND", val.Trim(), "varchar_field has not correct value");
+               }
+
+               [Test]
+               public void UpdateSmallIntTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       ds.Tables["TEST"].Rows[0]["SMALLint_field"] = System.Int16.MaxValue;
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+
+                       transaction.Commit();
+
+                       transaction = Connection.BeginTransaction();
+
+                       sql             = "SELECT smallint_field FROM TEST WHERE int_field = @int_field";
+                       command = new FbCommand(sql, Connection, transaction);                  
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+
+                       short val = (short)command.ExecuteScalar();
+
+                       transaction.Commit();
+
+                       Assert.AreEqual(System.Int16.MaxValue, val, "smallint_field has not correct value");
+               }
+
+               [Test]
+               public void UpdateBigIntTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       ds.Tables["TEST"].Rows[0]["BIGINT_FIELD"] = System.Int32.MaxValue;
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+
+                       transaction.Commit();
+
+                       transaction = Connection.BeginTransaction();
+
+                       sql             = "SELECT bigint_field FROM TEST WHERE int_field = @int_field";
+                       command = new FbCommand(sql, Connection, transaction);                  
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+
+                       long val = (long)command.ExecuteScalar();
+
+                       transaction.Commit();
+
+                       Assert.AreEqual(System.Int32.MaxValue, val, "bigint_field has not correct value");
+               }
+
+               [Test]
+               public void UpdateDoubleTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       ds.Tables["TEST"].Rows[0]["DOUBLE_FIELD"]       = System.Int32.MaxValue;
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+
+                       transaction.Commit();
+
+                       transaction = Connection.BeginTransaction();
+
+                       sql             = "SELECT double_field FROM TEST WHERE int_field = @int_field";
+                       command = new FbCommand(sql, Connection, transaction);
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+
+                       double val = (double)command.ExecuteScalar();
+
+                       transaction.Commit();
+
+                       Assert.AreEqual(System.Int32.MaxValue, val, "double_field has not correct value");
+               }
+
+               [Test]
+               public void UpdateNumericTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       ds.Tables["TEST"].Rows[0]["NUMERIC_FIELD"]      = System.Int32.MaxValue;
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+
+                       transaction.Commit();
+
+                       transaction = Connection.BeginTransaction();
+
+                       sql             = "SELECT numeric_field FROM TEST WHERE int_field = @int_field";
+                       command = new FbCommand(sql, Connection, transaction);
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+
+                       decimal val = (decimal)command.ExecuteScalar();
+
+                       transaction.Commit();
+
+                       Assert.AreEqual(System.Int32.MaxValue, val, "numeric_field has not correct value");
+               }
+
+               [Test]
+               public void UpdateDecimalTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       ds.Tables["TEST"].Rows[0]["DECIMAL_FIELD"]      = System.Int32.MaxValue;
+                       
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+
+                       transaction.Commit();
+
+                       transaction = Connection.BeginTransaction();
+
+                       sql             = "SELECT decimal_field FROM TEST WHERE int_field = @int_field";
+                       command = new FbCommand(sql, Connection, transaction);
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+
+                       decimal val = (decimal)command.ExecuteScalar();
+
+                       transaction.Commit();
+
+                       Assert.AreEqual(System.Int32.MaxValue, val, "decimal_field has not correct value");
+               }
+
+               [Test]
+               public void UpdateDateTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       DateTime dtValue = DateTime.Now;
+
+                       ds.Tables["TEST"].Rows[0]["DATE_FIELD"] = dtValue;
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+
+                       transaction.Commit();
+
+                       transaction = Connection.BeginTransaction();
+
+                       sql             = "SELECT date_field FROM TEST WHERE int_field = @int_field";
+                       command = new FbCommand(sql, Connection, transaction);
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+
+                       DateTime val = (DateTime)command.ExecuteScalar();
+
+                       transaction.Commit();
+
+                       Assert.AreEqual(dtValue.Day, val.Day, "date_field has not correct day");
+                       Assert.AreEqual(dtValue.Month, val.Month, "date_field has not correct month");
+                       Assert.AreEqual(dtValue.Year, val.Year, "date_field has not correct year");
+               }
+
+               [Test]
+               public void UpdateTimeTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       DateTime dtValue = DateTime.Now;
+
+                       ds.Tables["TEST"].Rows[0]["TIME_FIELD"] = dtValue;
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+
+                       transaction.Commit();
+
+                       transaction = Connection.BeginTransaction();
+
+                       sql             = "SELECT time_field FROM TEST WHERE int_field = @int_field";
+                       command = new FbCommand(sql, Connection, transaction);
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+
+                       DateTime val = (DateTime)command.ExecuteScalar();
+
+                       transaction.Commit();
+
+                       Assert.AreEqual(dtValue.Hour, val.Hour, "time_field has not correct hour");
+                       Assert.AreEqual(dtValue.Minute, val.Minute, "time_field has not correct minute");
+                       Assert.AreEqual(dtValue.Second, val.Second, "time_field has not correct second");
+               }
+
+               [Test]
+               public void UpdateTimeStampTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       DateTime dtValue = DateTime.Now;
+
+                       ds.Tables["TEST"].Rows[0]["TIMESTAMP_FIELD"] = dtValue;
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+
+                       transaction.Commit();
+
+                       transaction = Connection.BeginTransaction();
+
+                       sql             = "SELECT timestamp_field FROM TEST WHERE int_field = @int_field";
+                       command = new FbCommand(sql, Connection, transaction);
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+
+                       DateTime val = (DateTime)command.ExecuteScalar();
+
+                       transaction.Commit();
+
+                       Assert.AreEqual(dtValue.Day, val.Day, "timestamp_field has not correct day");
+                       Assert.AreEqual(dtValue.Month, val.Month, "timestamp_field has not correct month");
+                       Assert.AreEqual(dtValue.Year, val.Year, "timestamp_field has not correct year");
+                       Assert.AreEqual(dtValue.Hour, val.Hour, "timestamp_field has not correct hour");
+                       Assert.AreEqual(dtValue.Minute, val.Minute, "timestamp_field has not correct minute");
+                       Assert.AreEqual(dtValue.Second, val.Second, "timestamp_field has not correct second");
+               }
+
+               [Test]
+               public void UpdateClobTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       ds.Tables["TEST"].Rows[0]["CLOB_FIELD"] = "ONE THOUSAND";
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+                       transaction.Commit();
+               }
+       
+               [Test]
+               public void DeleteTest()
+               {
+                       string                  sql             = "select * from TEST where int_field = @int_field";
+                       FbTransaction   transaction = this.Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(sql, Connection, transaction);
+                       FbDataAdapter   adapter         = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@int_field", FbDbType.Integer).Value = 10;
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+
+                       Assert.AreEqual(1, ds.Tables["TEST"].Rows.Count, "Incorrect row count");
+
+                       ds.Tables["TEST"].Rows[0].Delete();
+
+                       adapter.Update(ds, "TEST");
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+                       transaction.Commit();
+               }
+
+               [Test]
+               public void SubsequentDeletes()
+               {
+                       string selectSql = "SELECT * FROM test";
+                       string deleteSql = "DELETE FROM test WHERE int_field = @id";
+
+                       // Set up conenction and select/delete commands
+                       FbConnection connection = new FbConnection(this.Connection.ConnectionString);
+                       FbCommand select = new FbCommand(selectSql, connection);
+                       FbCommand delete = new FbCommand(deleteSql, connection);
+                       delete.Parameters.Add("@id", FbDbType.Integer);
+                       delete.Parameters[0].SourceColumn = "INT_FIELD";
+                       
+                       // Set up the FbDataAdapter
+                       FbDataAdapter adapter = new FbDataAdapter(select);
+                       adapter.DeleteCommand = delete;
+
+                       // Set up dataset
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds);
+
+                       // Delete one row
+                       ds.Tables[0].Rows[0].Delete();
+                       adapter.Update(ds);
+
+                       // Delete another row
+                       ds.Tables[0].Rows[0].Delete();
+                       adapter.Update(ds);
+
+                       // Delete another row
+                       ds.Tables[0].Rows[0].Delete();
+                       adapter.Update(ds);
+               }
+
+               [Test]
+        [Ignore("Not supported")]
+        public void MultipleResultsetTest()
+               {
+                       FbCommand command = new FbCommand("", this.Connection);
+
+                       command.CommandText = "select * from test;";
+                       command.CommandText += "select int_field from test;";
+                       command.CommandText += "select int_field, char_field from test;";
+
+                       FbDataAdapter adapter = new FbDataAdapter(command);
+
+                       DataSet ds = new DataSet();
+
+                       adapter.Fill(ds);
+
+            Assert.AreEqual(3, ds.Tables.Count, "Incorrect tables count");
+        }
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbDataReaderTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbDataReaderTest.cs
new file mode 100644 (file)
index 0000000..a2db12c
--- /dev/null
@@ -0,0 +1,382 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using NUnit.Framework;
+
+using System;
+using System.Data;
+using FirebirdSql.Data.Firebird;
+
+namespace FirebirdSql.Data.Firebird.Tests
+{
+       [TestFixture]
+       public class FbDataReaderTest : BaseTest 
+       {       
+               public FbDataReaderTest() : base(false)
+               {               
+               }
+
+               [Test]
+               public void ReadTest()
+               {
+                       FbTransaction transaction = Connection.BeginTransaction();
+                                               
+                       FbCommand command = new FbCommand("select * from TEST", Connection, transaction);
+                       
+                       Console.WriteLine();
+                       Console.WriteLine("DataReader - Read Method - Test");
+                       
+                       IDataReader reader = command.ExecuteReader();
+                       while (reader.Read())
+                       {
+                               for(int i = 0; i < reader.FieldCount; i++)
+                               {
+                                       Console.Write(reader.GetValue(i) + "\t");
+                               }
+                       
+                               Console.WriteLine();
+                       }
+
+                       reader.Close();
+                       command.Dispose();
+                       transaction.Rollback();
+               }
+
+               [Test]
+               public void BigIntGetStringTest()
+               {
+                       FbTransaction transaction = Connection.BeginTransaction();
+
+                       FbCommand command = new FbCommand("select * from TEST", Connection, transaction);
+
+                       Console.WriteLine();
+                       Console.WriteLine("DataReader - Read Method - Test");
+
+                       IDataReader reader = command.ExecuteReader();
+                       while (reader.Read())
+                       {
+                               Console.Write(reader.GetString(reader.GetOrdinal("bigint_field")) + "\t");
+
+                               Console.WriteLine();
+                       }
+
+                       reader.Close();
+                       command.Dispose();
+                       transaction.Rollback();
+               }
+
+               [Test]
+               public void GetValuesTest()
+               {
+                       FbTransaction transaction = Connection.BeginTransaction();
+                                               
+                       FbCommand command = new FbCommand("select * from TEST", Connection, transaction);
+                       
+                       Console.WriteLine();
+                       Console.WriteLine("DataReader - Read Method - Test");
+                       
+                       IDataReader reader = command.ExecuteReader();
+                       while (reader.Read())
+                       {
+                               object[] values = new object[reader.FieldCount];
+                               reader.GetValues(values);
+
+                               for (int i = 0; i < values.Length; i++)
+                               {
+                                       Console.Write(values[i] + "\t");                                        
+                               }
+                       
+                               Console.WriteLine();
+                       }
+
+                       reader.Close();
+                       transaction.Rollback(); 
+                       command.Dispose();
+               }
+
+               [Test]
+               public void IndexerByIndexTest()
+               {
+                       FbTransaction transaction = Connection.BeginTransaction();
+                                               
+                       FbCommand command = new FbCommand("select * from TEST", Connection, transaction);
+                       
+                       Console.WriteLine();
+                       Console.WriteLine("DataReader - Read Method - Test");
+                       
+                       IDataReader reader = command.ExecuteReader();
+                       while (reader.Read())
+                       {
+                               for(int i = 0; i < reader.FieldCount; i++)
+                               {
+                                       Console.Write(reader[i] + "\t");                                        
+                               }
+                       
+                               Console.WriteLine();
+                       }
+
+                       reader.Close();
+                       transaction.Rollback();                         
+                       command.Dispose();
+               }
+
+               [Test]
+               public void IndexerByNameTest()
+               {
+                       FbTransaction transaction = Connection.BeginTransaction();
+                                               
+                       FbCommand command = new FbCommand("select * from TEST", Connection, transaction);
+                       
+                       Console.WriteLine();
+                       Console.WriteLine("DataReader - Read Method - Test");
+                       
+                       IDataReader reader = command.ExecuteReader();
+                       while (reader.Read())
+                       {
+                               for(int i = 0; i < reader.FieldCount; i++)
+                               {
+                                       Console.Write(reader[reader.GetName(i)] + "\t");                                        
+                               }
+                       
+                               Console.WriteLine();
+                       }
+
+                       reader.Close();
+                       transaction.Rollback();                         
+                       command.Dispose();
+               }
+
+               [Test]
+               public void GetSchemaTableTest()
+               {
+                       FbTransaction transaction       = Connection.BeginTransaction();
+                       FbCommand         command               = new FbCommand("select * from TEST", Connection, transaction);
+       
+                       FbDataReader reader = command.ExecuteReader(CommandBehavior.SchemaOnly);                
+               
+                       DataTable schema = reader.GetSchemaTable();
+                       
+                       Console.WriteLine();
+                       Console.WriteLine("DataReader - GetSchemaTable Method- Test");
+
+                       DataRow[] currRows = schema.Select(null, null, DataViewRowState.CurrentRows);
+
+                       foreach (DataColumn myCol in schema.Columns)
+                       {
+                               Console.Write("{0}\t\t", myCol.ColumnName);
+                       }
+
+                       Console.WriteLine();
+                       
+                       foreach (DataRow myRow in currRows)
+                       {
+                               foreach (DataColumn myCol in schema.Columns)
+                               {
+                                       Console.Write("{0}\t\t", myRow[myCol]);
+                               }
+                               
+                               Console.WriteLine();
+                       }
+                       
+                       reader.Close();
+                       transaction.Rollback();
+                       command.Dispose();
+               }
+               
+               [Test]
+               public void GetSchemaTableWithExpressionFieldTest()
+               {
+                       FbTransaction transaction       = Connection.BeginTransaction();
+                       FbCommand         command               = new FbCommand("select TEST.*, 0 AS VALOR from TEST", Connection, transaction);
+       
+                       FbDataReader reader = command.ExecuteReader(CommandBehavior.SchemaOnly);                
+               
+                       DataTable schema = reader.GetSchemaTable();
+                       
+                       Console.WriteLine();
+                       Console.WriteLine("DataReader - GetSchemaTable Method- Test");
+
+                       DataRow[] currRows = schema.Select(null, null, DataViewRowState.CurrentRows);
+
+                       foreach (DataColumn myCol in schema.Columns)
+                       {
+                               Console.Write("{0}\t\t", myCol.ColumnName);
+                       }
+
+                       Console.WriteLine();
+                       
+                       foreach (DataRow myRow in currRows)
+                       {
+                               foreach (DataColumn myCol in schema.Columns)
+                               {
+                                       Console.Write("{0}\t\t", myRow[myCol]);
+                               }
+                               
+                               Console.WriteLine();
+                       }
+                       
+                       reader.Close();
+                       transaction.Rollback();
+                       command.Dispose();
+               }
+
+               [Test]
+        [Ignore("Not supported")]
+        public void NextResultTest()
+               {
+                       string querys = "select * from TEST order by INT_FIELD asc;" +
+                                                       "select * from TEST order by INT_FIELD desc;";
+
+                       FbTransaction   transaction = Connection.BeginTransaction();
+                       FbCommand               command         = new FbCommand(querys, Connection, transaction);
+       
+                       FbDataReader reader = command.ExecuteReader();          
+
+                       Console.WriteLine();
+                       Console.WriteLine("DataReader - NextResult Method - Test ( First Result )");
+
+                       while (reader.Read())
+                       {
+                               for(int i = 0; i < reader.FieldCount; i++)
+                               {
+                                       Console.Write(reader.GetValue(i) + "\t");                                       
+                               }
+                       
+                               Console.WriteLine();
+                       }
+
+                       if(reader.NextResult())
+                       {
+                               Console.WriteLine("DataReader - NextResult Method - Test ( Second Result )");
+               
+                               while (reader.Read())
+                               {
+                                       for(int i = 0; i < reader.FieldCount; i++)
+                                       {
+                                               Console.Write(reader.GetValue(i) + "\t");                                       
+                                       }
+                               
+                                       Console.WriteLine();
+                               }
+                       }
+
+                       reader.Close();
+                       transaction.Rollback();
+                       command.Dispose();
+               }
+
+               [Test]
+               public void RecordAffectedTest()
+               {
+                       string sql = "insert into test (int_field) values (100000)";
+
+                       FbCommand command = new FbCommand(sql, this.Connection);
+
+                       FbDataReader reader = command.ExecuteReader();
+
+                       bool nextResult = true;
+
+                       while (nextResult)
+                       {
+                               while (reader.Read())
+                               {
+                               }
+
+                               nextResult = reader.NextResult();
+                       }
+
+                       reader.Close();
+
+                       Assert.AreEqual(1, reader.RecordsAffected, "RecordsAffected value is incorrect");
+               }
+
+               [Test]
+               public void GetBytesLengthTest()
+               {
+                       string sql = "select blob_field from TEST where int_field = @int_field";
+
+                       FbCommand command = new FbCommand(sql, this.Connection);
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 2;
+
+                       FbDataReader reader = command.ExecuteReader();
+
+                       reader.Read();
+
+                       long length = reader.GetBytes(0, 0, null, 0, 0);
+
+                       reader.Close();
+
+                       Assert.AreEqual(13, length, "Incorrect blob length");
+               }
+
+               [Test]
+               public void GetCharsLengthTest()
+               {
+                       string sql = "select clob_field from TEST where int_field = @int_field";
+
+                       FbCommand command = new FbCommand(sql, this.Connection);
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 50;
+
+                       FbDataReader reader = command.ExecuteReader();
+
+                       reader.Read();
+
+                       long length = reader.GetChars(0, 0, null, 0, 0);
+
+                       reader.Close();
+
+                       Assert.AreEqual(14, length, "Incorrect clob length");
+               }
+
+        [Test]
+        public void ValidateDecimalSchema()
+        {
+            string sql = "select decimal_field from test";
+
+            FbCommand test = new FbCommand(sql, this.Connection);
+            FbDataReader r = test.ExecuteReader(CommandBehavior.SchemaOnly);
+
+            DataTable schema = r.GetSchemaTable();
+
+            r.Close();
+
+            // Check schema values
+            Assert.AreEqual(schema.Rows[0]["ColumnSize"], 8, "Invalid length");
+            Assert.AreEqual(schema.Rows[0]["NumericPrecision"], 15, "Invalid precision");
+            Assert.AreEqual(schema.Rows[0]["NumericScale"], 2, "Invalid scale");
+        }
+
+               [Test]
+               public void DisposeTest()
+               {
+                       using (FbCommand command = new FbCommand("DATAREADERTEST", Connection))
+                       {
+                               command.CommandType = CommandType.StoredProcedure;
+
+                               FbCommandBuilder.DeriveParameters(command);
+
+                               using (IDataReader reader = command.ExecuteReader())
+                               {
+                                       while (reader.Read())
+                                       {
+                                       }
+                               }
+                       }
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbDatabaseInfoTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbDatabaseInfoTest.cs
new file mode 100644 (file)
index 0000000..9fb600c
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using NUnit.Framework;
+using System;
+using System.Data;
+using FirebirdSql.Data.Firebird;
+
+namespace FirebirdSql.Data.Firebird.Tests
+{
+       [TestFixture]
+       public class FbDatabaseInfoTest : BaseTest 
+       {
+               public FbDatabaseInfoTest() : base(false)
+               {               
+               }
+
+               [Test]
+               public void DatabaseInfoTest()
+               {
+                       FbDatabaseInfo dbInfo = new FbDatabaseInfo(Connection);
+                       
+                       Console.WriteLine("Server Version: {0}", dbInfo.ServerVersion);
+                       Console.WriteLine("ISC Version : {0}", dbInfo.IscVersion);
+                       Console.WriteLine("Server Class : {0}", dbInfo.ServerClass);
+                       Console.WriteLine("Max memory : {0}", dbInfo.MaxMemory);
+                       Console.WriteLine("Current memory : {0}", dbInfo.CurrentMemory);
+                       Console.WriteLine("Page size : {0}", dbInfo.PageSize);
+                       Console.WriteLine("ODS Mayor version : {0}", dbInfo.OdsVersion);
+                       Console.WriteLine("ODS Minor version : {0}", dbInfo.OdsMinorVersion);
+                       Console.WriteLine("Allocation pages: {0}", dbInfo.AllocationPages);
+                       Console.WriteLine("Base level: {0}", dbInfo.BaseLevel);
+                       Console.WriteLine("Database id: {0}", dbInfo.DbId);
+                       Console.WriteLine("Database implementation: {0}", dbInfo.Implementation);
+                       Console.WriteLine("No reserve: {0}", dbInfo.NoReserve);
+                       Console.WriteLine("Forced writes: {0}", dbInfo.ForcedWrites);
+                       Console.WriteLine("Sweep interval: {0}", dbInfo.SweepInterval);
+                       Console.WriteLine("Number of page fetches: {0}", dbInfo.Fetches);
+                       Console.WriteLine("Number of page marks: {0}", dbInfo.Marks);
+                       Console.WriteLine("Number of page reads: {0}", dbInfo.Reads);
+                       Console.WriteLine("Number of page writes: {0}", dbInfo.Writes);
+                       Console.WriteLine("Removals of a version of a record: {0}", dbInfo.BackoutCount);
+                       Console.WriteLine("Number of database deletes: {0}", dbInfo.DeleteCount);
+                       Console.WriteLine("Number of removals of a record and all of its ancestors: {0}", dbInfo.ExpungeCount);
+                       Console.WriteLine("Number of inserts: {0}", dbInfo.InsertCount);
+                       Console.WriteLine("Number of removals of old versions of fully mature records: {0}", dbInfo.PurgeCount);
+                       Console.WriteLine("Number of reads done via an index: {0}", dbInfo.ReadIdxCount);
+                       Console.WriteLine("Number of sequential sequential table scans: {0}", dbInfo.ReadSeqCount);
+                       Console.WriteLine("Number of database updates: {0}", dbInfo.UpdateCount);
+                       Console.WriteLine("Database size in pages: {0}", dbInfo.DatabaseSizeInPages);
+                       Console.WriteLine("Number of the oldest transaction: {0}", dbInfo.OldestTransaction);
+                       Console.WriteLine("Number of the oldest active transaction: {0}", dbInfo.OldestActiveTransaction);
+                       Console.WriteLine("Number of the oldest active snapshot: {0}", dbInfo.OldestActiveSnapshot);
+                       Console.WriteLine("Number of the next transaction: {0}", dbInfo.NextTransaction);
+                       Console.WriteLine("Number of active transactions: {0}", dbInfo.ActiveTransactions);
+               }               
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbDatabaseSchemaTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbDatabaseSchemaTest.cs
new file mode 100644 (file)
index 0000000..2f7f922
--- /dev/null
@@ -0,0 +1,221 @@
+/*\r
+ *  Firebird ADO.NET Data provider for .NET and Mono \r
+ * \r
+ *     The contents of this file are subject to the Initial \r
+ *     Developer's Public License Version 1.0 (the "License"); \r
+ *     you may not use this file except in compliance with the \r
+ *     License. You may obtain a copy of the License at \r
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl\r
+ *\r
+ *     Software distributed under the License is distributed on \r
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either \r
+ *     express or implied.  See the License for the specific \r
+ *     language governing rights and limitations under the License.\r
+ * \r
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez\r
+ *  All Rights Reserved.\r
+ */\r
+\r
+using System;\r
+using System.Data;\r
+using System.Collections;\r
+using FirebirdSql.Data.Firebird;\r
+using FirebirdSql.Data.Firebird.Isql;\r
+using NUnit.Framework;\r
+\r
+namespace FirebirdSql.Data.Firebird.Tests\r
+{\r
+    [TestFixture]\r
+    public class FbDatabaseSchemaTest : BaseTest\r
+    {\r
+        public FbDatabaseSchemaTest() : base(false)\r
+        {\r
+        }\r
+\r
+        [Test]\r
+        public void CharacterSets()\r
+        {\r
+            Connection.GetSchema("CharacterSets");\r
+        }\r
+\r
+        [Test]\r
+        public void CheckConstraints()\r
+        {\r
+            Connection.GetSchema("CheckConstraints");\r
+        }\r
+\r
+        [Test]\r
+        public void CheckConstraintsByTable()\r
+        {\r
+            Connection.GetSchema("CheckConstraintsByTable");\r
+        }\r
+\r
+        [Test]\r
+        public void Collations()\r
+        {\r
+            Connection.GetSchema("Collations");\r
+        }\r
+\r
+        [Test]\r
+        public void Columns()\r
+        {\r
+            DataTable columns = Connection.GetSchema("Columns");\r
+\r
+            columns = Connection.GetSchema(\r
+                            "Columns",\r
+                            new string[] { null, null, "TEST", "INT_FIELD" });\r
+\r
+            Assert.AreEqual(1, columns.Rows.Count);\r
+        }\r
+\r
+        [Test]\r
+        public void ColumnPrivileges()\r
+        {\r
+            Connection.GetSchema("ColumnPrivileges");\r
+        }\r
+\r
+        [Test]\r
+        public void Domains()\r
+        {\r
+            Connection.GetSchema("Domains");\r
+        }\r
+\r
+        [Test]\r
+        public void ForeignKeys()\r
+        {\r
+            Connection.GetSchema("ForeignKeys");\r
+        }\r
+\r
+        [Test]\r
+        public void Functions()\r
+        {\r
+            Connection.GetSchema("Functions");\r
+        }\r
+\r
+        [Test]\r
+        public void Generators()\r
+        {\r
+            Connection.GetSchema("Generators");\r
+        }\r
+\r
+        [Test]\r
+        public void Indexes()\r
+        {\r
+            Connection.GetSchema("Indexes");\r
+        }\r
+\r
+        [Test]\r
+        public void PrimaryKeys()\r
+        {\r
+            DataTable primaryKeys = Connection.GetSchema("PrimaryKeys");\r
+\r
+            primaryKeys = Connection.GetSchema(\r
+                "PrimaryKeys",\r
+                new string[] { null, null, "TEST" });\r
+\r
+            Assert.AreEqual(1, primaryKeys.Rows.Count);\r
+        }\r
+\r
+        [Test]\r
+        public void ProcedureParameters()\r
+        {\r
+            Connection.GetSchema("ProcedureParameters");\r
+\r
+            DataTable procedureParameters = Connection.GetSchema(\r
+                "ProcedureParameters",\r
+                new string[] { null, null, "SELECT_DATA" });\r
+\r
+            Assert.AreEqual(3, procedureParameters.Rows.Count);\r
+        }\r
+\r
+        [Test]\r
+        public void ProcedurePrivileges()\r
+        {\r
+            Connection.GetSchema("ProcedurePrivileges");\r
+        }\r
+\r
+        [Test]\r
+        public void Procedures()\r
+        {\r
+            DataTable procedures = Connection.GetSchema("Procedures");\r
+\r
+            procedures = Connection.GetSchema(\r
+                "Procedures",\r
+                new string[] { null, null, "SELECT_DATA" });\r
+\r
+            Assert.AreEqual(1, procedures.Rows.Count);\r
+        }\r
+\r
+        [Test]\r
+        public void DataTypes()\r
+        {\r
+            Connection.GetSchema("DataTypes");\r
+        }\r
+\r
+        [Test]\r
+        public void Roles()\r
+        {\r
+            Connection.GetSchema("Roles");\r
+        }\r
+\r
+        [Test]\r
+        public void Tables()\r
+        {\r
+            DataTable tables = Connection.GetSchema("Tables");\r
+\r
+            tables = Connection.GetSchema(\r
+                "Tables",\r
+                new string[] { null, null, "TEST" });\r
+\r
+            Assert.AreEqual(tables.Rows.Count, 1);\r
+\r
+            tables = Connection.GetSchema(\r
+                "Tables",\r
+                new string[] { null, null, null, "TABLE" });\r
+\r
+            Assert.AreEqual(tables.Rows.Count, 1);\r
+        }\r
+\r
+        [Test]\r
+        public void TableConstraints()\r
+        {\r
+            Connection.GetSchema("TableConstraints");\r
+        }\r
+\r
+        [Test]\r
+        public void TablePrivileges()\r
+        {\r
+            Connection.GetSchema("TablePrivileges");\r
+        }\r
+\r
+        [Test]\r
+        public void Triggers()\r
+        {\r
+            Connection.GetSchema("Triggers");\r
+        }\r
+\r
+        [Test]\r
+        public void UniqueKeys()\r
+        {\r
+            Connection.GetSchema("UniqueKeys");\r
+        }\r
+\r
+        [Test]\r
+        public void ViewColumnUsage()\r
+        {\r
+            Connection.GetSchema("ViewColumnUsage");\r
+        }\r
+\r
+        [Test]\r
+        public void Views()\r
+        {\r
+            Connection.GetSchema("Views");\r
+        }\r
+\r
+        [Test]\r
+        public void ViewPrivileges()\r
+        {\r
+            Connection.GetSchema("ViewPrivileges");\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbImplicitTransactionTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbImplicitTransactionTest.cs
new file mode 100644 (file)
index 0000000..257fab7
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Text;
+
+using FirebirdSql.Data.Firebird;
+using NUnit.Framework;
+
+namespace FirebirdSql.Data.Firebird.Tests
+{
+       [TestFixture]
+       public class FbImplicitTransactionTest : BaseTest
+       {
+               public FbImplicitTransactionTest() : base(false)
+               {               
+               }
+               
+               [Test]
+               public void DataAdapterFillTest()
+               {
+                       FbCommand               command = new FbCommand("select * from TEST where DATE_FIELD = ?", Connection);
+                       FbDataAdapter   adapter = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@DATE_FIELD", FbDbType.Date, 4, "DATE_FIELD").Value = new DateTime(2003, 1, 5);
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+                       
+                       Console.WriteLine();
+                       Console.WriteLine("Implicit transactions - DataAdapter Fill Method - Test");
+
+                       foreach (DataTable table in ds.Tables)
+                       {
+                               foreach (DataColumn col in table.Columns)
+                               {
+                                       Console.Write(col.ColumnName + "\t\t");
+                               }
+                               
+                               Console.WriteLine();
+                               
+                               foreach (DataRow row in table.Rows)
+                               {
+                                       for (int i = 0; i < table.Columns.Count; i++)
+                                       {
+                                               Console.Write(row[i] + "\t\t");
+                                       }
+
+                                       Console.WriteLine("");
+                               }
+                       }
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+               }
+       
+               [Test]
+               public void MultipleDataAdapterFillTest()
+               {
+                       FbCommand               command = new FbCommand("select * from TEST where DATE_FIELD = ?", Connection);
+                       FbDataAdapter   adapter = new FbDataAdapter(command);
+
+                       adapter.SelectCommand.Parameters.Add("@DATE_FIELD", FbDbType.Date, 4, "DATE_FIELD").Value = new DateTime(2003, 1, 5);
+                       
+                       FbCommandBuilder builder = new FbCommandBuilder(adapter);
+
+                       DataSet ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+                       
+                       Console.WriteLine();
+                       Console.WriteLine("Implicit transactions - DataAdapter Fill Method - Test");
+
+                       foreach (DataTable table in ds.Tables)
+                       {
+                               foreach (DataColumn col in table.Columns)
+                               {
+                                       Console.Write(col.ColumnName + "\t\t");
+                               }
+                               
+                               Console.WriteLine();
+                               
+                               foreach (DataRow row in table.Rows)
+                               {
+                                       for (int i = 0; i < table.Columns.Count; i++)
+                                       {
+                                               Console.Write(row[i] + "\t\t");
+                                       }
+
+                                       Console.WriteLine("");
+                               }
+                       }
+
+                       adapter.SelectCommand.Parameters[0].Value = new DateTime(2003, 1, 6);
+
+                       ds = new DataSet();
+                       adapter.Fill(ds, "TEST");
+                       
+                       Console.WriteLine();
+                       Console.WriteLine("Implicit transactions - DataAdapter Fill Method - Test");
+
+                       foreach (DataTable table in ds.Tables)
+                       {
+                               foreach (DataColumn col in table.Columns)
+                               {
+                                       Console.Write(col.ColumnName + "\t\t");
+                               }
+                               
+                               Console.WriteLine();
+                               
+                               foreach (DataRow row in table.Rows)
+                               {
+                                       for (int i = 0; i < table.Columns.Count; i++)
+                                       {
+                                               Console.Write(row[i] + "\t\t");
+                                       }
+
+                                       Console.WriteLine("");
+                               }
+                       }
+
+
+                       adapter.Dispose();
+                       builder.Dispose();
+                       command.Dispose();
+               }
+
+               [Test]
+               public void ExecuteScalarTest()
+               {
+                       FbCommand command = new FbCommand("select sum(int_field) from TEST", Connection);
+
+                       Console.WriteLine("\r\nExecuteScalar with implicit transaction: {0}", command.ExecuteScalar());
+
+                       command.Dispose();
+               }
+
+               [Test]
+               public void UpdatedClobFieldTest()
+               {
+                       Console.WriteLine("\r\nUpdate CLOB field with implicit transaction.");
+
+                       FbCommand command = new FbCommand("update TEST set clob_field = @clob_field where int_field = @int_field", Connection);
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       command.Parameters.Add("@clob_field", FbDbType.Text).Value = "Clob field update with implicit transaction";
+
+                       int i = command.ExecuteNonQuery();
+
+                       Assert.AreEqual(i, 1, "Clob field update with implicit transaction failed");
+
+                       // Force the implicit transaction to be committed
+                       command.Dispose();
+               }
+
+               [Test]
+               public void UpdatedBlobFieldTest()
+               {
+                       Console.WriteLine("\r\nUpdate BLOB field with implicit transaction.");
+
+                       FbCommand command = new FbCommand("update TEST set blob_field = @blob_field where int_field = @int_field", Connection);
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       command.Parameters.Add("@blob_field", FbDbType.Binary).Value = 
+                               Encoding.Default.GetBytes("Blob field update with implicit transaction");
+
+                       int i = command.ExecuteNonQuery();
+
+                       Assert.AreEqual(i, 1, "Blob field update with implicit transaction failed");
+
+                       // Force the implicit transaction to be committed
+                       command.Dispose();
+               }
+
+               [Test]
+               public void UpdatedArrayFieldTest()
+               {
+                       Console.WriteLine("\r\nUpdate CLOB field with implicit transaction.");
+
+                       int[] values = new int[4];
+
+                       values[0] = 10;
+                       values[1] = 20;
+                       values[2] = 30;
+                       values[3] = 40;
+                       
+                       FbCommand command = new FbCommand("update TEST set iarray_field = @iarray_field where int_field = @int_field", Connection);
+                       command.Parameters.Add("@int_field", FbDbType.Integer).Value = 1;
+                       command.Parameters.Add("@iarray_field", FbDbType.Array).Value = values;
+
+                       int i = command.ExecuteNonQuery();
+
+                       Assert.AreEqual(i, 1, "Array field update with implicit transaction failed");
+
+                       // Force the implicit transaction to be committed
+                       command.Dispose();
+               }
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbParameterCollectionTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbParameterCollectionTest.cs
new file mode 100644 (file)
index 0000000..eb9d118
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using NUnit.Framework;
+using System;
+using FirebirdSql.Data.Firebird;
+
+namespace FirebirdSql.Data.Firebird.Tests
+{
+       [TestFixture]
+       public class FbParameterCollectionTest : BaseTest 
+       {
+               public FbParameterCollectionTest() : base()
+               {               
+               }
+               
+               [Test]
+               public void AddTest()
+               {
+                       FbCommand command = new FbCommand();
+                                               
+                       command.Parameters.Add(new FbParameter("@p292", 10000));                        
+                       command.Parameters.Add("@p01", FbDbType.Integer);                       
+                       command.Parameters.Add("@p02", 289273);
+                       command.Parameters.Add("#p3", FbDbType.SmallInt, 2, "sourceColumn");
+               }
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbParameterTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbParameterTest.cs
new file mode 100644 (file)
index 0000000..b97d5a4
--- /dev/null
@@ -0,0 +1,86 @@
+/*\r
+ *  Firebird ADO.NET Data provider for .NET and Mono \r
+ * \r
+ *     The contents of this file are subject to the Initial \r
+ *     Developer's Public License Version 1.0 (the "License"); \r
+ *     you may not use this file except in compliance with the \r
+ *     License. You may obtain a copy of the License at \r
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl\r
+ *\r
+ *     Software distributed under the License is distributed on \r
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either \r
+ *     express or implied.  See the License for the specific \r
+ *     language governing rights and limitations under the License.\r
+ * \r
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez\r
+ *  All Rights Reserved.\r
+ */\r
+\r
+using System;\r
+using System.Data;\r
+using System.Data.Common;\r
+\r
+using NUnit.Framework;\r
+using FirebirdSql.Data.Firebird;\r
+\r
+namespace FirebirdSql.Data.Firebird.Tests\r
+{\r
+       [TestFixture]\r
+       public class FbParameterTest : BaseTest \r
+       {\r
+               public FbParameterTest() : base()\r
+               {               \r
+               }\r
+               \r
+               [Test]\r
+               public void ConstructorsTest()\r
+               {\r
+                       FbParameter ctor01 = new FbParameter();\r
+                       FbParameter ctor02 = new FbParameter("ctor2", 10);\r
+                       FbParameter ctor03 = new FbParameter("ctor3", FbDbType.Char);\r
+                       FbParameter ctor04 = new FbParameter("ctor4", FbDbType.Integer, 4);\r
+                       FbParameter ctor05 = new FbParameter("ctor5", FbDbType.Integer, 4, "int_field");\r
+                       FbParameter ctor06 = new FbParameter(\r
+                               "ctor6", \r
+                               FbDbType.Integer, \r
+                               4, \r
+                               ParameterDirection.Input, \r
+                               false, \r
+                               0, \r
+                               0, \r
+                               "int_field", \r
+                               DataRowVersion.Original, \r
+                               100);\r
+\r
+            ctor01 = null;\r
+            ctor02 = null;\r
+            ctor03 = null;\r
+            ctor04 = null;\r
+            ctor05 = null;\r
+            ctor06 = null;\r
+               }\r
+\r
+        [Test]\r
+        public void CloneTest()\r
+        {\r
+            FbParameter p = new FbParameter("@p1", FbDbType.Integer);\r
+            p.Value = 1;\r
+            p.Charset = FbCharset.Dos850;\r
+\r
+            FbParameter p1 = ((ICloneable)p).Clone() as FbParameter;\r
+\r
+            Assert.AreEqual(p1.ParameterName, p.ParameterName);\r
+            Assert.AreEqual(p1.FbDbType     , p.FbDbType);\r
+            Assert.AreEqual(p1.DbType       , p.DbType);\r
+            Assert.AreEqual(p1.Direction    , p.Direction);\r
+            Assert.AreEqual(p1.SourceColumn , p.SourceColumn);\r
+            Assert.AreEqual(p1.SourceVersion, p.SourceVersion);\r
+            Assert.AreEqual(p1.Charset      , p.Charset);\r
+            Assert.AreEqual(p1.IsNullable   , p.IsNullable);\r
+            Assert.AreEqual(p1.Size         , p.Size);\r
+            Assert.AreEqual(p1.Scale        , p.Scale);\r
+            Assert.AreEqual(p1.Precision    , p.Precision);\r
+            Assert.AreEqual(p1.Value        , p.Value);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbScriptTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbScriptTest.cs
new file mode 100644 (file)
index 0000000..5236cae
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ *  Firebird ADO.NET Data provider for .NET and Mono \r
+ * \r
+ *     The contents of this file are subject to the Initial \r
+ *     Developer's Public License Version 1.0 (the "License"); \r
+ *     you may not use this file except in compliance with the \r
+ *     License. You may obtain a copy of the License at \r
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl\r
+ *\r
+ *     Software distributed under the License is distributed on \r
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either \r
+ *     express or implied.  See the License for the specific \r
+ *     language governing rights and limitations under the License.\r
+ * \r
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez\r
+ *  All Rights Reserved.\r
+ */\r
+\r
+using System;\r
+using System.Data;\r
+using System.Configuration;\r
+using System.Collections.Specialized;\r
+\r
+using FirebirdSql.Data.Firebird;\r
+using FirebirdSql.Data.Firebird.Isql;\r
+using NUnit.Framework;\r
+\r
+namespace FirebirdSql.Data.Firebird.Tests\r
+{\r
+       [TestFixture]\r
+       public class FbScriptTest : BaseTest \r
+       {\r
+               public FbScriptTest()\r
+               {\r
+               }\r
+\r
+               [Test]\r
+               public void IsqlScriptTest()\r
+               {\r
+                       string fileName = ConfigurationSettings.AppSettings["IsqlScript"];\r
+                       if (System.IO.File.Exists(fileName))\r
+                       {\r
+                               FbScript isql = new FbScript(fileName);\r
+                               foreach (string command in isql.Results)\r
+                               {\r
+                                       Console.WriteLine(command);\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbServicesTests.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbServicesTests.cs
new file mode 100644 (file)
index 0000000..32e3bae
--- /dev/null
@@ -0,0 +1,228 @@
+/*\r
+ *  Firebird ADO.NET Data provider for .NET and Mono \r
+ * \r
+ *     The contents of this file are subject to the Initial \r
+ *     Developer's Public License Version 1.0 (the "License"); \r
+ *     you may not use this file except in compliance with the \r
+ *     License. You may obtain a copy of the License at \r
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl\r
+ *\r
+ *     Software distributed under the License is distributed on \r
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either \r
+ *     express or implied.  See the License for the specific \r
+ *     language governing rights and limitations under the License.\r
+ * \r
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez\r
+ *  All Rights Reserved.\r
+ */\r
+\r
+using System;\r
+using System.Configuration;\r
+using System.IO;\r
+using System.Data;\r
+using System.Text;\r
+\r
+using FirebirdSql.Data.Firebird;\r
+using FirebirdSql.Data.Firebird.Services;\r
+\r
+using NUnit.Framework;\r
+\r
+namespace FirebirdSql.Data.Firebird.Tests\r
+{\r
+       [TestFixture]\r
+       public class FbServicesTest : BaseTest \r
+       {       \r
+               public FbServicesTest() : base(false)\r
+               {\r
+               }\r
+\r
+               [SetUp]\r
+               public override void SetUp()\r
+               {\r
+                       base.SetUp();\r
+\r
+                       if (this.Connection != null && this.Connection.State == ConnectionState.Open)\r
+                       {\r
+                               this.Connection.Close();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void BackupTest()\r
+               {\r
+                       FbBackup backupSvc = new FbBackup();\r
+                                               \r
+                       backupSvc.ConnectionString = this.BuildServicesConnectionString();\r
+                       backupSvc.BackupFiles.Add(new FbBackupFile(@"c:\testdb.gbk", 2048));\r
+                       backupSvc.Verbose = true;\r
+                       \r
+                       backupSvc.Options = FbBackupFlags.IgnoreLimbo;\r
+\r
+                       backupSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);\r
+                       \r
+                       backupSvc.Execute();\r
+               }\r
+               \r
+               [Test]\r
+               public void RestoreTest()\r
+               {\r
+                       FbRestore restoreSvc = new FbRestore();\r
+\r
+                       restoreSvc.ConnectionString = this.BuildServicesConnectionString();\r
+                       restoreSvc.BackupFiles.Add(new FbBackupFile(@"c:\testdb.gbk", 2048));\r
+                       restoreSvc.Verbose      = true;\r
+                       restoreSvc.PageSize = 4096;\r
+                       restoreSvc.Options      = FbRestoreFlags.Create | FbRestoreFlags.Replace; \r
+\r
+                       restoreSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);\r
+\r
+                       restoreSvc.Execute();\r
+               }\r
+\r
+               [Test]\r
+               public void ValidationTest()\r
+               {\r
+                       FbValidation validationSvc = new FbValidation();\r
+\r
+                       validationSvc.ConnectionString = this.BuildServicesConnectionString();\r
+                       validationSvc.Options = FbValidationFlags.ValidateDatabase; \r
+\r
+                       validationSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);\r
+\r
+                       validationSvc.Execute();\r
+               }\r
+\r
+               [Test]\r
+               public void SweepTest()\r
+               {\r
+                       FbValidation validationSvc = new FbValidation();\r
+\r
+                       validationSvc.ConnectionString = this.BuildServicesConnectionString();\r
+                       validationSvc.Options = FbValidationFlags.SweepDatabase;\r
+\r
+                       validationSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);\r
+\r
+                       validationSvc.Execute();\r
+               }\r
+\r
+               [Test]\r
+               public void SetPropertiesTest()\r
+               {\r
+                       FbConfiguration configurationSvc = new FbConfiguration();\r
+\r
+                       configurationSvc.ConnectionString = this.BuildServicesConnectionString();\r
+\r
+                       configurationSvc.SetSweepInterval(1000);\r
+                       configurationSvc.SetReserveSpace(true);\r
+                       configurationSvc.SetForcedWrites(true);\r
+                       configurationSvc.DatabaseShutdown(FbShutdownMode.Forced, 10);\r
+                       configurationSvc.DatabaseOnline();\r
+               }\r
+\r
+               [Test]\r
+               public void StatisticsTest()\r
+               {\r
+                       FbStatistical statisticalSvc = new FbStatistical();\r
+\r
+                       statisticalSvc.ConnectionString = this.BuildServicesConnectionString();\r
+                       statisticalSvc.Options                  = FbStatisticalFlags.SystemTablesRelations;\r
+                                               \r
+                       statisticalSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);\r
+\r
+                       statisticalSvc.Execute();\r
+               }\r
+               \r
+               [Test]\r
+               public void FbLogTest()\r
+               {\r
+                       FbLog logSvc = new FbLog();\r
+\r
+                       logSvc.ConnectionString = this.BuildServicesConnectionString(false);\r
+\r
+                       logSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);\r
+                                               \r
+                       logSvc.Execute();\r
+               }\r
+\r
+               [Test]\r
+               public void AddUserTest()\r
+               {\r
+                       FbSecurity securitySvc = new FbSecurity();\r
+\r
+                       securitySvc.ConnectionString = this.BuildServicesConnectionString(false);\r
+\r
+                       FbUserData user = new FbUserData();\r
+                       \r
+                       user.UserName           = "new_user";\r
+                       user.UserPassword       = "1";\r
+                       \r
+                       securitySvc.AddUser(user);\r
+               }\r
+               \r
+               [Test]\r
+               public void DeleteUser()\r
+               {\r
+                       FbSecurity securitySvc = new FbSecurity();\r
+\r
+                       securitySvc.ConnectionString = this.BuildServicesConnectionString(false);\r
+\r
+                       FbUserData user = new FbUserData();\r
+                       \r
+                       user.UserName = "new_user";\r
+                                               \r
+                       securitySvc.DeleteUser(user);\r
+               }\r
+\r
+               [Test]\r
+               public void DisplayUser()\r
+               {\r
+                       FbSecurity securitySvc = new FbSecurity();\r
+\r
+                       securitySvc.ConnectionString = this.BuildServicesConnectionString(false);\r
+\r
+                       FbUserData user = securitySvc.DisplayUser("SYSDBA");\r
+\r
+                       Console.WriteLine("User name {0}", user.UserName);\r
+               }\r
+\r
+               [Test]\r
+               public void DisplayUsers()\r
+               {\r
+                       FbSecurity securitySvc = new FbSecurity();\r
+\r
+                       securitySvc.ConnectionString = this.BuildServicesConnectionString(false);\r
+\r
+                       FbUserData[] users = securitySvc.DisplayUsers();\r
+\r
+                       Console.WriteLine("User List");\r
+\r
+                       for (int i = 0; i < users.Length; i++)\r
+                       {\r
+                               Console.WriteLine("User {0} name {1}", i, users[i].UserName);\r
+                       }\r
+               }\r
+               \r
+               [Test]\r
+               public void ServerPropertiesTest()\r
+               {\r
+                       FbServerProperties serverProp = new FbServerProperties();\r
+\r
+                       serverProp.ConnectionString = this.BuildServicesConnectionString(false);\r
+\r
+                       FbServerConfig  serverConfig    = serverProp.ServerConfig;\r
+                       FbDatabasesInfo databasesInfo   = serverProp.DatabasesInfo;\r
+                       \r
+                       Console.WriteLine(serverProp.MessageFile);\r
+                       Console.WriteLine(serverProp.LockManager);\r
+                       Console.WriteLine(serverProp.RootDirectory);\r
+                       Console.WriteLine(serverProp.Implementation);\r
+                       Console.WriteLine(serverProp.ServerVersion);\r
+                       Console.WriteLine(serverProp.Version);\r
+               }\r
+\r
+               void ServiceOutput(object sender, ServiceOutputEventArgs e)\r
+               {\r
+                       Console.WriteLine(e.Message);\r
+               }\r
+       }\r
+}
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbStoredProcCallsTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbStoredProcCallsTest.cs
new file mode 100644 (file)
index 0000000..a2552bf
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using FirebirdSql.Data.Firebird;
+using NUnit.Framework;
+
+namespace FirebirdSql.Data.Firebird.Tests
+{
+       /// <summary>
+       /// All the test in this TestFixture are using implicit transaction support.
+       /// </summary>
+       [TestFixture]
+       public class FbStoredProcCallsTest : BaseTest 
+       {
+               public FbStoredProcCallsTest() : base(false)
+               {               
+               }
+
+               [Test]
+               public void FirebirdLikeTest00()
+               {
+                       FbCommand command = new FbCommand("EXECUTE PROCEDURE GETVARCHARFIELD(?)", Connection);
+                               
+                       command.CommandType = CommandType.StoredProcedure;
+
+                       command.Parameters.Add("@ID", FbDbType.VarChar).Direction = ParameterDirection.Input;
+                       command.Parameters.Add("@VARCHAR_FIELD", FbDbType.VarChar).Direction = ParameterDirection.Output;
+
+                       command.Parameters[0].Value = 1;
+
+                       // This will fill output parameters values
+                       command.ExecuteNonQuery();
+
+            // Check the value
+            Assert.AreEqual("IRow Number 1", command.Parameters[1].Value);
+
+            // Dispose command - this will do a transaction commit
+                       command.Dispose();
+               }
+
+               [Test]
+               public void FirebirdLikeTest01()
+               {
+                       FbCommand command = new FbCommand("SELECT * FROM GETVARCHARFIELD(?)", Connection);                              
+                       command.CommandType = CommandType.StoredProcedure;
+
+                       command.Parameters.Add("@ID", FbDbType.VarChar).Direction = ParameterDirection.Input;
+                       command.Parameters[0].Value = 1;
+
+                       // This will fill output parameters values
+                       FbDataReader reader = command.ExecuteReader();
+                       reader.Read();
+
+                       // Print output value
+                       Console.WriteLine("Output Parameters - Result of SELECT command");
+                       Console.WriteLine(reader[0]);
+
+                       reader.Close();
+
+                       // Dispose command - this will do a transaction commit
+                       command.Dispose();
+               }
+
+               [Test]
+               public void SqlServerLikeTest00()
+               {
+                       FbCommand command = new FbCommand("GETVARCHARFIELD", Connection);
+                               
+                       command.CommandType = CommandType.StoredProcedure;
+
+                       command.Parameters.Add("@ID", FbDbType.VarChar).Direction = ParameterDirection.Input;
+                       command.Parameters.Add("@VARCHAR_FIELD", FbDbType.VarChar).Direction = ParameterDirection.Output;
+
+                       command.Parameters[0].Value = 1;
+
+                       // This will fill output parameters values
+                       command.ExecuteNonQuery();
+
+                       // Print output value
+                       Console.WriteLine("Output Parameters");
+                       Console.WriteLine(command.Parameters[1].Value);
+
+                       // Dispose command - this will do a transaction commit
+                       command.Dispose();
+               }
+
+               [Test]
+               public void SqlServerLikeTest01()
+               {
+                       FbCommand command = new FbCommand("GETRECORDCOUNT", Connection);                        
+                       command.CommandType = CommandType.StoredProcedure;
+
+                       command.Parameters.Add("@RECORDCOUNT", FbDbType.Integer).Direction = ParameterDirection.Output;
+
+                       // This will fill output parameters values
+                       command.ExecuteNonQuery();
+
+                       // Print output value
+                       Console.WriteLine("Output Parameters - Record Count");
+                       Console.WriteLine(command.Parameters[0].Value);
+
+                       // Dispose command - this will do a transaction commit
+                       command.Dispose();
+               }
+
+               [Test]
+               public void SqlServerLikeTest02()
+               {
+                       FbCommand command = new FbCommand("GETVARCHARFIELD", Connection);
+
+                       command.CommandType = CommandType.StoredProcedure;
+
+                       command.Parameters.Add("@ID", FbDbType.VarChar).Value = 1;
+
+                       // This will fill output parameters values
+                       FbDataReader r = command.ExecuteReader();
+
+                       int count = 0;
+
+                       while (r.Read())
+                       {
+                               count++;
+                       }
+
+                       r.Close();
+
+                       // Dispose command - this will do a transaction commit
+                       command.Dispose();
+
+                       Assert.AreEqual(1, count);
+               }
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/FbTransactionTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/FbTransactionTest.cs
new file mode 100644 (file)
index 0000000..c783e60
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using NUnit.Framework;
+using System;
+using System.Data;
+using System.Text;
+using FirebirdSql.Data.Firebird;
+
+namespace FirebirdSql.Data.Firebird.Tests
+{
+       [TestFixture]
+       public class FbTransactionTest : BaseTest 
+       {
+               public FbTransactionTest() : base(false)
+               {               
+               }
+
+        [Test]
+        public void DisposeTest()
+        {
+            bool result = true;
+            try
+            {
+                FbCommand cmd = new FbCommand("select * from test", this.Connection);
+                cmd.Transaction = this.Connection.BeginTransaction(IsolationLevel.RepeatableRead);
+
+                FbDataReader r = cmd.ExecuteReader();
+                while (r.Read())
+                {
+                }
+                r.Close();
+
+                cmd.Transaction.Rollback();
+                cmd.Transaction.Dispose();
+
+                result = false;
+            }
+            catch
+            {
+            }
+            finally
+            {
+                if (!result)
+                {
+                    throw new Exception("Incorrect Dispose behavior");
+                }
+            }
+        }
+
+        [Test]
+               public void CommitTest()
+               {                       
+                       Transaction = Connection.BeginTransaction();
+                       Transaction.Commit();
+               }
+               
+               [Test]
+               public void RollbackTest()
+               {
+                       Transaction = Connection.BeginTransaction();
+                       Transaction.Rollback();
+               }
+
+        [Test]
+               public void SavePointTest()
+               {
+                       FbCommand command = new FbCommand();
+
+                       Console.WriteLine("Iniciada nueva transaccion");
+                       
+                       Transaction = Connection.BeginTransaction("InitialSavePoint");
+                       
+                       command.Connection      = Connection;
+                       command.Transaction     = Transaction;
+
+                       command.CommandText = "insert into TEST (INT_FIELD) values (200) ";
+                       command.ExecuteNonQuery();                      
+
+                       Transaction.Save("FirstSavePoint");
+
+                       command.CommandText = "insert into TEST (INT_FIELD) values (201) ";
+                       command.ExecuteNonQuery();                      
+                       Transaction.Save("SecondSavePoint");
+
+                       command.CommandText = "insert into TEST (INT_FIELD) values (202) ";
+                       command.ExecuteNonQuery();                      
+                       Transaction.Rollback("InitialSavePoint");
+
+                       Transaction.Commit();
+                       command.Dispose();
+               }
+
+               [Test]
+               public void AbortTransaction()
+               {
+                       StringBuilder b1 = new StringBuilder();
+                       b1.AppendFormat("ALTER TABLE \"{0}\" drop \"INT_FIELD\"", "TEST");
+
+                       FbTransaction   transaction = null;
+                       FbCommand               command         = null;
+
+                       try
+                       {
+                               transaction = this.Connection.BeginTransaction();
+
+                               command = new FbCommand(b1.ToString(), this.Connection, transaction);
+                               command.ExecuteNonQuery();
+
+                               transaction.Commit();
+                               transaction = null;
+                       }
+                       catch (Exception)
+                       {
+                               transaction.Rollback();
+                               transaction = null;
+                       }
+                       finally
+                       {
+                               if (command != null)
+                               {
+                                       command.Dispose();
+                               }
+                       }
+               }
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/Test/GuidTest.cs b/mcs/class/FirebirdSql.Data.Firebird/Test/GuidTest.cs
new file mode 100644 (file)
index 0000000..9d2274b
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ *  Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *     The contents of this file are subject to the Initial 
+ *     Developer's Public License Version 1.0 (the "License"); 
+ *     you may not use this file except in compliance with the 
+ *     License. You may obtain a copy of the License at 
+ *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *     Software distributed under the License is distributed on 
+ *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *     express or implied.  See the License for the specific 
+ *     language governing rights and limitations under the License.
+ * 
+ *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  All Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using FirebirdSql.Data.Firebird;
+using NUnit.Framework;
+
+namespace FirebirdSql.Data.Firebird.Tests
+{
+       /// <summary>
+       /// All the test in this TestFixture are using implicit transaction support.
+       /// </summary>
+       [TestFixture]
+       public class GuidTest : BaseTest
+       {
+               public GuidTest() : base()
+               {
+               }
+
+               [Test]
+               public void InsertGuidTest()
+               {
+                       FbCommand createTable = new FbCommand("CREATE TABLE GUID_TEST (GUID_FIELD CHAR(16) CHARACTER SET OCTETS)", Connection);
+                       createTable.ExecuteNonQuery();
+                       createTable.Dispose();
+
+                       Guid newGuid = Guid.Empty;
+                       Guid guidValue = Guid.NewGuid();
+
+                       // Insert the Guid
+                       FbCommand insert = new FbCommand("INSERT INTO GUID_TEST (GUID_FIELD) VALUES (@GuidValue)", Connection);
+                       insert.Parameters.Add("@GuidValue", FbDbType.Guid).Value = guidValue;
+                       insert.ExecuteNonQuery();
+                       insert.Dispose();
+
+                       // Select the value
+                       FbCommand select = new FbCommand("SELECT * FROM GUID_TEST", Connection);
+                       FbDataReader r = select.ExecuteReader();
+                       if (r.Read())
+                       {
+                               newGuid = r.GetGuid(0);
+                       }
+
+                       Assert.AreEqual(guidValue, newGuid);
+                }
+       }
+}
diff --git a/mcs/class/FirebirdSql.Data.Firebird/changelog.txt b/mcs/class/FirebirdSql.Data.Firebird/changelog.txt
new file mode 100644 (file)
index 0000000..8a9b587
--- /dev/null
@@ -0,0 +1,1884 @@
+Firebird ADO.NET Data provider for .NET and Mono 
+================================================
+
+
+2005-01-14 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Embedded/FesArray.cs:
+       * FirebirdSql.Data.Embedded/FesBlob.cs:
+       * FirebirdSql.Data.Embedded/FesConnection.cs:
+       * FirebirdSql.Data.Embedded/FesDatabase.cs:
+       * FirebirdSql.Data.Embedded/FesServiceManager.cs:
+       * FirebirdSql.Data.Embedded/FesStatement.cs:
+       * FirebirdSql.Data.Embedded/FesTransaction.cs:
+       * FirebirdSql.Data.Gds/GdsArray.cs:
+       * FirebirdSql.Data.Gds/GdsBlob.cs:
+       * FirebirdSql.Data.Gds/GdsDatabase.cs:
+       * FirebirdSql.Data.Gds/GdsEventManager.cs:
+       * FirebirdSql.Data.Gds/GdsServiceManager.cs:
+       * FirebirdSql.Data.Gds/GdsStatement.cs:
+       * FirebirdSql.Data.Gds/GdsTransaction.cs:
+
+               - Cleanup.
+
+------------------ Release Candaidate 1 ----------------------
+
+2005-01-02 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.WizardFramework/WizardStep.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep1.cs
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep2.cs
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep3.cs
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep4.cs
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep5.cs
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep6.cs
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep7.cs
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterDataSetGenerator.cs
+
+               - Changes for try to get the Wizard working on VS 2003.
+
+       * FirebirdSql.Data.Common/BinaryEncoding.cs
+
+               - Integrate the Encoding implementation for the OCTETS character set
+               Contributed by Jim Beveridge. (It's under the Public Domain)
+
+       * FirebirdSql.Data.Common/Charset.cs:
+
+               - Integrate the BinaryEncoding implementation.
+
+       * FirebirdSql.Data.Embedded/XsqldaMarshaler.cs:
+
+               - Added support for Guid parameters.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterDesigner.cs
+
+               - Show a MessageBox with the exception deatils.
+
+
+
+
+-------------------------- Beta 3 ----------------------------
+
+2005-01-01 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               -Fixed problem with the Guid parameters support.
+
+       * FirebirdSql.Data.Firebird/Isql/FbbatchExecution.cs:
+
+               - Added initial autocommit mode support (needs testing).
+
+2004-12-24 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/Charset.cs:
+       * FirebirdSql.Data.Common/DbDataType.cs:
+       * FirebirdSql.Data.Common/DbField.cs:
+       * FirebirdSql.Data.Common/DbValue.cs:
+       * FirebirdSql.Data.Common/TypeHelper.cs:
+       * FirebirdSql.Data.Gds/XdrStream.cs:
+       * FirebirdSql.Data.Firebird/FbCharset.cs:
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+       * FirebirdSql.Data.Firebird/FbDbType.cs:
+       * FirebirdSql.Data.Firebird/FbParameter.cs:
+
+               - Added initial suport for the GUID datatype.
+               Guids will be mapped to CHAR(16) CHARACTER SET OCTETS fields in firebird.
+               In the FbParameter class Guid values should be passed as Guid instances or 
+               byte arrays.
+               The changes are not finished yet.
+               A new Test suite for the Guid support is included.
+
+               Thanks to Jim Beveridge for his help and feedback.
+
+2004-12-21 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/DbValue.cs:
+
+               - Fixed bug on long values conversion to string (Thanks to Sven Kammradt for his feedback).
+               Test case added to the test suite.
+
+2004-12-16 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommandbBuilder.cs:
+
+               - Removed check of the DataColumn.Autoincrement property in the IsUpdateable method.
+
+       * FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+
+               - Fixed globalization issues.
+
+2004-12-13 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Design/FbDataAdapter/Designer/FbDataAdapterWizardSettings.cs
+       * FirebirdSql.Data.Firebird/Design/FbDataAdapter/Designer/FbDataAdapterWizard.cs
+       * FirebirdSql.Data.Firebird/Design/FbDataAdapter/Designer/FbDataAdapterDesigner.cs
+
+               - Changes for see if we can get the wizard to work with VS 2003
+
+2004-12-10 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+
+               - Fixed validation of connection strings without a data source when the
+               ServerType parameter is 1 (Thanks to Peter Turcan for his feedback).
+
+       * FirebirdSql.Data.Common/Charset.cs:
+       * FirebirdSql.Data.Common/CharsetCollection.cs:
+
+               - Load encodings at runtime in order to improve memory usage. (Thnaks to Jim Beveridge for his feedback)
+
+2004-12-08 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep2.cs
+
+               - Fixed FillConnections method.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterDataSetGenerator.cs
+
+               - Prevent to generate Typed DataSets if the provider was
+               not build with the VISUAL_STUDIO define
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/VSExtensibility.cs:
+
+               - Fixed DTE creation when there are more than one Visual Studio instance.
+               Reference:
+                       http://devresource.hp.com/technical_white_papers/CodeModel1.pdf
+
+       * FirebirdSql.Data.Common/StatementBase.cs:
+
+               - Better checks on Release method (Thanks to Pierre Arnaud)
+
+-------------------------- Beta 2 ----------------------------
+
+2004-12-03 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterWizardSettings.cs:
+
+               - Fixed conversion doing a cast.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterWizardStep2.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterWizardStep4.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterWizardStep6.cs:
+
+               - Changes for allow a better initialization of the step data when 
+               the DataAdapter was already configured before.
+
+       * Fixed FxCop issues.
+
+       * FirebirdSql.Data.Gds/XdrStream.cs:
+
+               - Fix Stream and IDisposable implementation.
+
+2004-12-02 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Changes on the Firebird Events implementation.
+
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+       * FirebirdSql.Data.Common/DbValue.cs:
+               
+               - Try to get the FbDataReader.GetBoolean method working.
+
+2004-12-01 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbTransaction.cs:
+
+               - Added a new Commit(string) method (Thanks to for Andrzej Kaczmarczyk his feedback)
+
+2004-11-29 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Reorganization of the Services sources.
+
+2004-11-28 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/IscException.cs:
+
+               - Fix for the latest changes of the exception message formatting
+
+2004-11-26 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/IscException.cs:
+
+               - If the resource cannot be found raise the 
+               exception with the default message.
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Changes on Transaction and resources management.
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+
+               - Fixed problem with the CreateDatabase problem, when it's requested to not
+               overwrite the an existing database database, and there are no real database 
+               to connect to.
+
+2004-11-25 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSQl.Data.Gds/GdsTransaction.cs:
+       * FirebirdSQl.Data.Embedded/FesTransaction.cs:
+
+               - Fixed bug in the Dispose method (Thanks to Pierre Arnaud for his feedback)
+                 Test case added for this bug.
+
+2004-11-22 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/DataSetGenerator.cs:
+
+               - Set the dataset namespace.
+
+2004-11-22 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/DataSetGenerator.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/VSExtensibility.cs:
+
+               - Changes for better support of Visual Studio project files,
+               when adding Typed Datasets (not finished.)
+
+2004-11-21 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbErrorCollection.cs:
+       * FirebirdSql.Data.Firebird/FbParameterCollection.cs:
+               
+                       - Better fit to ADO.NET
+       
+       * FirebirdSql.Data.Common/IscErrorCollection.cs:
+       * FirebirdSql.WizardFramework/WizardStepCollection.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+       * FirebirdSql.Data.Firebird/FbRemoteEventEventArgs.cs:
+       * FirebirdSql.Data.Firebird/Isql/FbbatchExecution.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/DataSetGenerator.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep6.cs:
+       
+                       - Fixed FxCop issues.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/VSExtensibility.cs:
+       
+                       - Minor reorganization.
+                       
+2004-11-20 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Gds/XdrStream.cs:
+
+               - Changes to try to handle correctly the character sets (Thanks to Kazuhiro Kato for his feedback)
+
+       * FirebirdSql.Data.Common/Charset.cs:
+       * FirebirdSql.Data.Common/BlobBase.cs:
+       * FirebirdSql.Data.Common/DbField.cs:
+       * FirebirdSql.Data.Common/RemoteEvent.cs:
+       * FirebirdSql.Data.Common/StatementBase.cs:
+       * FirebirdSql.Data.Embedded/FesArray.cs:
+       * FirebirdSql.Data.Embedded/FesStatement.cs:
+       * FirebirdSql.Data.Embedded/XsldaMarshaler.cs:
+       * FirebirdSql.Data.Gds/GdsArray.cs:
+       * FirebirdSql.Data.Gds/XdrStream.cs:
+
+               - Make the charset class to be a full wrapper for the .NET encoding class.
+
+2004-11-19 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.WizardFramework/WizardStep.cs:
+       * FirebirdSql.Data.WizardFramework/WizardForm.cs:
+
+               - Added changes to allow condition navigation to previous steps.
+
+               - Simplify finish navigation.
+
+       * FirebirdSql.Data.WizardFramework/WizardForm.cs:
+
+               - Moved Validation handler configuration to the ShowStep method.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/FbDataAdadapterWizardStep7.cs:
+
+               - New wizard step to show the results.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/FbDataAdadapterWizardForm.cs:
+
+               - Removed DataAdapter configuration code.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/DataSetGenerator.cs:
+
+               - Let Visual Studio to generate the source code for the Typed DataSet.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/VSExtensibility.cs:
+
+               - Changes to add a file as an embedded resource.
+
+2004-11-16 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnectionInternal.cs:
+
+               - Fixed bug in DropDatabase implementation. (Thanks to Daniel Letecky for his feedback.)
+
+       * FirebirdSql.Data.Common/CharsetCollection.cs:
+       * FirebirdSql.Data.Common/IscErrorCollection.cs:
+
+               - Changes to inherit from CollectionBase
+
+2004-11-13 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterDesigner.cs:
+
+               - Override OnSetComponentDefaults and launch the wizard for initialization.
+
+               - Do not use localization support in the wizard for now.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/DataSetGenerator.cs:
+
+               - Use FillSchema to generate the tables in the DataSet.
+
+               - Make one of the DataSet generation methods to be more
+               general (it takes a connection string instead of a DataAdapter
+               as parameter).
+
+2004-11-12 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+       * FirebirdSql.Data.Firebird/FbTransaction.cs:
+
+               - Try to fix a problem with the transactions and data readers handling.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/VSextensibility.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/DataSetGenerator.cs:
+
+               - Added class for handle Visual Studio Extensibility support
+               (No terminado)
+
+2004-11-11 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/DataSetGenerator.cs:
+
+               - New DataSet generation class for the Design Time support.
+
+2004-11-10 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbRemoteEventEventArgs.cs:
+
+               - New file.
+
+       * FirebirdSql.Data.Firebird/FbEvent.cs:
+
+               - Try to improve the remothe event handling, the
+               new event should provide cancelation capabilities.              
+
+2004-11-09 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep4.cs:
+
+               - Save settings and control wheter the textbox is empty
+
+       * FirebirdSql.WizardFramework/WizardForm.cs:
+
+               - Save settings before raise the BeforeFinish event.
+
+       * FirebirdSql.WizardFramework/WizardStep.cs:
+
+               - Changed the SaveSettings method to public.
+
+2004-11-07 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterWizardSettings.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterWizardForm.cs:
+
+                -Added initial DataAdapter configuration code in the BeforeFinsh event.
+
+       * Fixed FxCop rules.
+
+2004-11-06 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionInternal.cs:
+       * FirebirdSql.Data.Firebird/FbEvent.cs:
+       * FirebirdSql.Data.Common/IDatabase.cs:
+       * FirebirdSql.Data.Embedded/FesDatabase.cs:
+       * FirebirdSql.Data.Gds/GdsDatabase.cs:
+       * FirebirdSql.Data.Gds/GdsEventManager.cs:
+
+               - Improved Firebird Events Implementation.
+
+       * Fixed FxCop rules.
+
+       * Added FxCop project file to the builds directory.
+
+2004-11-05 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep3.cs:
+
+               - Fixed problem with the Setting update.
+
+       * FirebirdSql.Data.Firebird/Embedded/FesStatement.cs:
+       * FirebirdSql.Data.Firebird/Embedded/XSQLDA.cs:
+       * FirebirdSql.Data.Firebird/Embedded/XsqlMarshaler.cs:
+
+               - Better handling of the XSQLVAR strings, now
+               instead of being marshaled directly as strings
+               they are being marshaed as byte arrays, what
+               would make possible to handle strings with a
+               multibyte encoding.
+               The encoding/decoding of the strings are being 
+               done using the connection character set.
+
+
+-------------------------- Beta 1 ----------------------------
+
+
+2004-11-04 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Updated Wizard Framework sources.
+
+2004-11-01 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbDataTypes.cs:
+
+               - Update schema information (Thanks to Viatcheslav V. Vassiliev for his feedback)
+
+       * Updated documentation of the WizardFramework classes.
+
+       * Removed WizardState class (the validation will be done
+       using the DialogResult as the wizard will be called always
+       using the ShowDialog method).
+
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+
+               - Fixed bug on initialization of the user id
+
+       * FirebirdSql.WizardFramework/WizardStep.cs:    
+
+               - Added support for custom navigations (for next button)
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationWizard.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep3.cs:
+
+               - Implemented custom navigation.
+
+2004-10-31 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Design/Connection/Editor/FbConnectionStringEditor.cs:
+
+               - Minor change for allow the editor to be used with the default constructor.
+
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterDataSetGenerator.cs:
+
+               - New class for the DataSet Genetator (without implementation)
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep3.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep4.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep5.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep6.cs:
+
+               - New steps (without implementation)
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep2.cs:
+
+               - Implement funcionaly of the new connection button.
+               It will call the FbConnectionStringEditor.
+
+               - Changed settings handling.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterWizardSettings.cs:
+
+               - New inner class for handle wizard settings.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationWizard.cs:
+
+               - Change step loading and settings handling.
+
+2004-10-30 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/StatementBase.cs:
+
+               - Format the statement plan using the character set
+               of the connection.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterDesigner.cs:
+               
+               - Run the wizard automatically when the componenet is created (.NET 2.0 only).
+
+               - Initialize the SelectCommand, InsertCommand, UpdateCommand and DeleteCommand
+               when the component is created (the first time only) (.NET 2.0 only).
+
+2004-10-29 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.WizardFramework/WizardSettings.cs:
+       * FirebirdSql.WizardFramework/WizardSettingsManager.cs:
+
+               - New classes.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep2.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationWizard.cs:
+
+               - Added some settings handling code.
+
+       * FirebirdSql.WizardFramework/WizardForm.cs:
+       * FirebirdSql.WizardFramework/WizardStep.cs:    
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep2.cs;
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationWizard.cs:
+
+               - Added better validations.
+
+2004-10-28 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Modified the build file to include the Wizard Framework.
+
+       * FirebirdSql.WizardFramework/WizardForm.cs:
+
+               - Minor change.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep1.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationStep2.cs:
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterConfigurationWizard.cs:
+
+               - New files for the FbDataAdapter Configuration wizard (not finished)
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterDesigner.cs:
+
+               - Changes for load the Wizard. (not finished)
+
+2004-10-25 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+
+               - Changes for try to get the Role to be working again (Thanbks to Oleg Deribas for his feedback)
+
+2004-10-24 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.WizardFramework/ActionStep.cs:
+       * FirebirdSql.WizardFramework/WelcomeStep.cs:   
+
+               - New clases.
+
+       * FirebirdSql.WizardFramework
+
+               - New Directory
+
+       * FirebirdSql.WizardFramework/WizardForm.cs:
+       * FirebirdSql.WizardFramework/WizardStep.cs:    
+       * FirebirdSql.WizardFramework/WizardState.cs:
+
+               - Added an initial implementation of a simple wizard Framework
+               to simplify the creation of the provider Design Time Wizards.
+
+               * It's under heavy development so it's not finished and it's untested *
+
+               * For now it will be not included in the build process *
+
+2004-10-23 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Isql/FbBatchExecution.cs:
+
+               - Minor fix (Thanks to Viatcheslav V. Vassiliev for his
+               feedback)
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Fixed Input parameter describe when the Prepare method
+               is called before the FbCommand instance has parameters assigned.
+               ( test case included ) Thanks to Viatcheslav V. Vassiliev for his
+               feedback
+
+       * FirebirdSql.Data.Firebird/Design/Command/Designer/FbCommandDesigner.cs:
+               
+               - Override PreFilterAttributes and add teh DesignTimeVisibleAttribute using
+               the FbCommand.DesignTimeVisible property value.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdpater/Designer/FbDataAdapterDesigner.cs:
+
+               - Minor changes (contains test code).
+
+2004-10-22 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/RemoteEvent.cs:
+       * FirebirdSql.Data.Common/EventParameterBuffer.cs:
+
+               - Fixed TPB generation (Olaf Lüder)
+
+2004-10-19 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Fixed command text initialization.
+
+2004-10-17 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Design/Connection/Designer/FbCommandDesigner.cs
+
+               - New class.
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs
+
+               - Added Designer Attribute.
+
+       * FirebirdSql.Data.Firebird/Design/DataAdapter/Designer/FbDataAdapterDesigner.cs
+
+               - New class.
+
+       * FirebirdSql.Data.Firebird/FbDataAdapter.cs
+
+               - Added Designer Attribute.
+
+2004-10-17 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Reorganization of the Design Time support classes.
+
+2004-10-09 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/StringCollection.cs:
+
+               - Added CopyTo method.
+
+2004-10-05 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbSecurity.cs
+
+               - Added better checks for user data.
+
+2004-10-04 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommandbuilder.cs:
+
+               - Fixed quoted identifier generation when
+               the quote prefix or the quote suffix are null.
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+
+               - Fixed exception handling on Open method.
+
+       * FirebirdSql.Data.Common/ArrayBase.cs:
+       * FirebirdSql.Data.Embedded/FesArray.cs:
+       * FirebirdSql.Data.Gds/GdsArray.cs:
+
+               - Changes for try to allow work with arrays
+               defined with lowerbound 0.
+
+2004-10-01 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbEvent.cs:
+       * FirebirdSql.Data.Common/RemoteEvent.cs:
+
+               - Modified handling of actual event counts.
+
+2004-09-30 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Gds/GdsDatabase.cs:
+       * FirebirdSql.Data.Embedded/FesDatabase.cs:
+       * FirebirdSql.Data.Common/EventParameterBuffer.cs:
+
+               - Fixed EventParameter buffer handling.
+
+
+2004-09-29 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cs:
+
+               - Cleanup.
+
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs:
+
+               - Removed IsolationLevel.Snapshot that is supported only 
+               in .NET 2.0
+
+2004-09-28 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       - Updated IDPL license URL to point to the FirebirdSQL project web site.
+
+       - Fixed FbDataAdapter documentation example (Thanks to Roland Turcan)
+
+2004-09-27 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs:
+
+               - Added new "Isolation Level" parameter for the connection string,
+               that allows to set the default IsolationLevel for implicit transactions.
+
+       * FirebirdSql.Data.Embedded/XSQLDA.cs:
+       * FirebirdSql.Data.Embedded/XsqldaMarshaler.cs:
+
+               - Changes on pointer address calculation.
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Improve handling of parameters when they have null values.
+               Affects mainly the embedded server support (Thanks to Pierre 
+               Arnaud for his feedback)        
+
+2004-09-25 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbField.cs:
+
+               - Fix for SetValue method on character values trimming when 
+               working with system tables. Affects only the embedded server 
+               support (Thanks to Sander Bosman for his feedback)
+
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+
+               - Added new synonym for the 'Server Type' parameter.
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Fixed implicit transaction handling.
+
+       * FirebirdSql.Data.Firebird/FbCommandBuilder.cs:
+
+               - Set IsNullable property for parameters of generated 
+               commands.
+
+       * FirebirdSql.Data.Embedded/XsqdaMarshaler.cs:
+
+               - Minor changes on sqlind handling.
+
+2004-09-23 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Added support for the .NET Compact Framework 2.0 Beta 1
+
+2004-09-21 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Gds/XdrStream.cs:
+       * FirebirdSql.Data.Gds/GdsArray.cs:     
+       * FirebirdSql.Data.Gds/FesArray.cs:
+
+               - Changes on DateTime conversions by using CurrentUICulture
+               instead of the InvariantCulture.
+
+       * FirebirdSql.Data.Gds/XdrStream.cs:
+
+               - Minor formatting changes.
+
+2004-09-20 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbParameter.cs:
+       * FirebirdSql.Data.Firebird/FbParameterCollection.cs:
+
+               - Format changes
+
+       * FirebirdSql.Data.Firebird/FbException.cs:
+
+               - Minor reorganization.
+
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cs:
+
+               - Added new code for handle the Max Connection Pool behavior (needs testing)
+
+       * FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs:
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+
+               - Globalization changes.
+
+       * FirebirdSql.Data.Common/ArrayBase.cs:
+       * FirebirdSql.Data.Common/IscException.cs:
+       
+               - Globalization changes.
+
+       * FirebirdSql.Data.Common/IscCodes.cs:
+
+               - Minor reorganization.
+
+               - Added new constants for standard buffer sizes.
+
+       * FirebirdSql.Data.Common/StatementBase.cs:
+       * FirebirdSql.Data.Gds/GdsDatabase.cs:
+
+               - Use constants instead of hard-coded values for buffer sizes
+
+       * FirebirdSql.Data.Gds/GdsConnection.cs:
+
+               - Added GC.SupressFinalize calls.
+
+
+-------------------------- Alpha 3 ----------------------------
+
+
+2004-09-18 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cs:
+
+               - Added changes to the connection cleanup.
+
+               - Fixed connection checkout from the pol.
+
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+
+               - Fixed packet size synonym
+
+2004-09-17 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Added new nunit test case for the database sweep (Validation service)
+
+       * FirebirdSql.Data.Gds/GdsServiceManager.cs:
+               
+               - Minor fix.
+
+2004-09-16 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionInternal.cs:
+
+               - Added new GetSchema methods to FbConnectionInternall class.
+
+       * FirebirdSql.Data.Gds/GdsDatabase.cs:
+
+               - Fixed buffer size for the Server Version
+               50 bytes seems to be not enough when working 
+               against Firbeird 1.0.3 (it's weird because it returns 
+               a string of length less than 50)
+
+
+2004-09-15 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbDbConnection.cs:
+
+               - Renamed to FbConnectionInternal.
+
+       * FirebirdSql.Data.Firebird/FbConnectionInternal.cs:
+
+               - New file (ADO.NET 2.0 has an DbConnectionInternal that should be implemented
+               in ado.net provider implementations this class should be used in the future
+               as base for that class implementation)
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+       * FirebirdSql.Data.Firebird/FbTransaction.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cs:
+       * FirebirdSql.Data.Firebird/FbDataAdapter.cs:
+       * FirebirdSql.Data.Firebird/FbDatabaseInfo.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbDbSchema.cs:
+       * FirebirdSql.Data.Firebird/FbEvent.cs:
+       * FirebirdSql.Data.Firebird/FbException.cs:
+
+               - Formatting changes.
+
+               - Moved some of the FbConnection and FbTransaction classes
+               funcionality to FbConnectionInternal.
+
+               With the new changes the connection handling matches better the
+               .net 2.0 compliant version i have in my local tree and will allow
+               an easy transaction in the future to ADO.NET 2.0.
+
+2004-09-13 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+
+               - Added changes on connection pool handling.
+
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cS:
+
+               - Minor improvements on pool handling.
+
+               - Fixed bug on GetConnection method when
+               timestamps are equal including the milliseconds
+               (Thanks to Alessandro Petrelli for his help ontesting the problem)
+
+2004-09-12 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cs:
+
+               - Added better lock handling in the FbPoolManager class.
+               
+2004-09-11 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+
+               - Return back to use regular expressions for
+               connection string parsing as they ar emore precise
+               for this purpouse (Thanks to Sven Kammradt for his feedback)
+
+2004-09-10 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+
+               - CheckState shouldn't check for eof.
+
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cs:
+
+               - Added changes for the initial implementation
+               iof a Wendell Wilkie suggestion for improve 
+               connection checkouts adn pools load.
+
+2004-09-09 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cs:
+
+               - Added new ConnectionPoolsCount and 
+               GetPooledConnectionCount members to the
+               FbConnection class.
+
+               - Minor change in FbConnectionPool class.
+
+
+2004-09-08 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Updated documentation.
+
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+
+               - Minor fix for better detection of the datareader position.
+
+
+2004-09-03 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cs:
+
+               - Fixed pool cleaning when the for pools with
+               connection lifetime of 0.
+
+       * Formatting changes.
+
+       * Added new parameter buffer classes and reworked existent 
+       parameter buffer classes.
+
+       New classes:
+
+               - TransactionParameterBuffer.cs
+
+               - BlobParameterBuffer.cs
+
+       * Renamed parameter buffer classes:
+
+               - BufferBase -> ParameterBuffer
+               - DpbBuffer -> DatabaseParameterBuffer
+               - SpbBuffer -> ServiceParameterBuffer
+               - EpbBuffer -> EventParameterBuffer
+
+       * FirebirdSql.Data.Common/IDatabase.cs:
+       * FirebirdSql.Data.Common/IServiceManager.cs:
+       * FirebirdSql.Data.Common/RemoteEvent.cs:
+       * FirebirdSql.Data.Embedded/FesDatabase.cs:
+       * FirebirdSql.Data.Embedded/FesServerManager.cs:
+       * FirebirdSql.Data.Embedded/FesTransaction.cs:
+       * FirebirdSql.Data.Gds/GdsDatabase.cs:
+       * FirebirdSql.Data.Gds/GdsBlob.cs:
+       * FirebirdSql.Data.Gds/GdsTransaction.cs:
+       * FirebirdSql.Data.Gds/GdsServerManager.cs:
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+       * FirebirdSql.Data.Firebird/FbDbConnection.cs:
+       * FirebirdSql.Data.Firebird/FbTransaction.cs:
+       * FirebirdSql.Data.Firebird/Services/FbService.cs:
+       * FirebirdSql.Data.Firebird/Services/FbBackup.cs:
+       * FirebirdSql.Data.Firebird/Services/FbRestore.cs:
+       * FirebirdSql.Data.Firebird/Services/FbConfiguration.cs:
+       * FirebirdSql.Data.Firebird/Services/FbLog.cs:
+       * FirebirdSql.Data.Firebird/Services/FbSecurity.cs:
+       * FirebirdSql.Data.Firebird/Services/FbStatistical.cs:
+       * FirebirdSql.Data.Firebird/Services/FbServerProperties.cs:
+       * FirebirdSql.Data.Firebird/Services/FbValidation.cs:
+               
+               - Improved parameter buffer handling
+
+2004-09-02 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/IscCodes.cs:
+
+               - Added Firebird facilities codes.
+
+               - Added ISC_MASK code for isc error code generation.
+
+       * FirebirdSql.Data.Common/IscException.cs:
+
+               - Changes on the error collection handling
+
+               - Added new statioc method for generation of isc error codes.
+
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cs:
+
+               - Added changes for try to get the connection pooling working correctly.
+               (Thanks to Alessandro Petrelli.  for his feedback)
+
+2004-08-31 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+       
+       * FirebirdSql.Data.Firebird/Embedded/FbClient.dll:
+
+               - Allow the embedded GDS to be built for work against Vulcan.
+
+2004-08-30 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+
+               - Added changes to the GetSchemaTable method to 
+               avoid schema command execution when the field
+               doesn't belong to a firebird table.
+               (Thanks to Gregory P. for his feedback)
+
+2004-08-26 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+
+               - Fixed bug #1017108
+
+2004-08-25 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/IscException.cs:
+
+               - Improved building of the exception message.
+
+       * FirebirdSql.Data.Embedded/FesServiceManager.cs:
+
+               - Monor fix.
+
+       * FirebirdSql.Data.Firebird/Services/FbService.cs:
+
+               - Do not throw an exception if the service is closed and
+               a new call to close is done.
+
+       * FirebirdSql.Data.Common/IDatabase.cs:
+       * FirebirdSql.Data.Common/FesDatabase.cs:
+       * FirebirdSql.Data.Common/GdsDatabase.cs:
+       * FirebirdSql.Data.Firebird/FbDbConnection.cs:
+
+               - Changes on GetDatabaseInfo overloads.
+
+               - Make the GetServerVersion method to request only 50 bytes.
+
+       * FirebirdSql.Data.Common/StatementBase.cs:
+               
+               - Try to get the statement plan only 4 times,
+               if the plan cannot be retrieved returns null (Thanks to Claudio Valderrama)
+
+       * FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+
+               - Minor changes and improvements over the latest commit.
+
+2004-08-24 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumns.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbDomains.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbProcedureParameters.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbViewColumnsUsage.cs:
+
+               - Set the CHARACTER_OCTET_LENGTH to 0 if the comlumns is not a char/varchar column.
+
+       * FirebirdSql.Data.Common/StatementBase.cs:
+
+               - Fixed bug #1015453.
+
+       * FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+       
+               - Changed FbConnectionString class to be internal.
+
+               - NEw class to build connection strings.
+
+       * FirebirdSql.Data.Firebird/Design/*.cs:
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Include the classes only if we are doing the build using MS.NET
+       
+       * FirebirdSql.Data.Common/DbField.cs:
+
+               - Trim trainling spaces for char fields when using the
+               embedded server and character sets with 2/3 characters per byte.
+
+
+2004-08-23 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Embedded/FbClient.cs:
+
+               - Cleanup.
+
+               - Change isc_dsql_prepare to get a byte array as parameter instead of a string.
+
+       * FirebirdSql.Data.Embedded/FesStatement.cs:
+
+               - Send a byte array in the isc_dsql_prepare call instead of a string.
+
+
+-------------------------- Alpha 2 ----------------------------
+
+
+2004-08-22 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumns.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbDomains.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbProcedureParameters.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbViewColumnsUsage.cs:
+
+               - Added new CHARACTER_OCTET_LENGTH column
+
+               - Fixed size for char/varchar columns
+
+2004-08-21 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * The nunit test suite will run now using UNICODE_FSS 
+       by default.
+
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumns.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbDomains.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbProcedureParameters.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbViewColumnsUsage.cs:
+
+               - Fixed NUMERIC_PRECISION value.
+       
+       * FirebirdSql.Data.Firebird/FbCommandBuilder.cs:
+
+               - Do not set the numeric precision and scale if the parameter
+               is not a decimal or numeric type.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbMetaDataCollections.cs:
+
+               - Added Restrictions definition.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbMetaDataCollections.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbDataTypes.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbRestrictions.cs:
+
+               - Added name to the DataTable.
+
+2004-08-20 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+
+               - Fixed bug #1013031
+
+2004-08-19 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumns.cs:
+
+               - Added domain information.
+
+2004-08-18 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Updated nant build system.
+
+               - Put in different directories the nant build files
+               of the ADO.NET Provider and the Borland Data Provider.
+
+       * The build will done always in a single assembly.
+
+       * Fixed Globalization problems reported by FxCop.
+
+2004-08-16 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/StatementBase.cs:
+
+               - [TESTING CHANGE] Do not request the owner when
+               describing statements as we are not using it for 
+               never at this moment.
+
+       * FirebirdSql.Data.Gds/GdsConnection.cs:
+
+               - Added a call to GC.SuprresFinalize in the constructor.
+
+
+2004-08-15 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbDataAdapter.cs:
+
+               - Throw a InvalidOperationException instead of a
+               DataAdapterException that it's .NET 2.0 specific.
+
+               - Minor change on update count, seems that it needs to return
+               the number of *DataRows* updated.
+
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+
+               - Cleanup.
+
+2004-08-14 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Minor change on Null value check.
+
+               - Removed Attributes form the CommandTimeout,
+               they prevents the sources to be built using .net 1.0
+               (Thanks to Mara)
+
+       * FirebirdSql.Data.Firebird/FbDataAdapter.cs:
+
+               - Override the DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
+               method to make calls to FbCommand.ExecuteNonQuery method always on
+               inserts, updates and deletes.
+
+               It's  on *testing* for now and it's not clear if it will be finally used.
+
+2004-08-13 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+
+               - Set conenction string default value to an empty string.
+
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+
+               - Changes on constructor implementation.
+
+
+2004-08-12 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/TypeHelper.cs:
+
+               - Fixed Float to mapping (Thanks to HDV).
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbForeignKeys.cs:
+
+               - Added IS_DEFERRANLE and INITIALLY_DEFERRED columns
+
+
+2004-08-11 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Do not use GetMaxByteCount to calc the number of bytes for the input parameters.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumns.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbDomains.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbProcedureParameters.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbViewColumnUsage.cs:
+
+               - Improved numeric precision handling.
+
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cs:
+
+               - Fixed bug #1007104
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumns.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbDomains.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbProcedureParameters.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbViewColumnUsage.cs:
+
+               - Improved numeric precision handling.
+
+               - Minor fix to schema queries to let them to run
+               using the embedded server.
+
+2004-08-10 Carlos Guzman Alvarez  <carlosga@telefonica.net>    
+
+       * FirebirdSql.Data.Common/StatementBase.cs:
+       * FirebirdSql.Data.Embedded/FesStatement.cs:
+       * FirebirdSql.Data.Gds/GdsStatement.cs:
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+               
+               - Cleanup.
+
+               - Reworked handling of stored procedure output 
+               parameter values.
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Improved input parameter descriptor generation.
+
+       * Last changes for the database schmeas support:
+
+
+               * All source files has been renamed to remove
+               the Schema suffix (FbTablesSchema.cs -> FbTables.cs)
+               The same for the class names.
+
+               * There are a new 'Restrictions' schema that will
+               return the restriction columns for each schema.
+
+               * There are new columns in some schemas:
+
+                          XXXX_CATALOG
+                          XXXX_SCHEMA
+
+               That will make the returned schemas more
+               general and compatible with other databases
+               (what will be nice for .net 2.0 as the schema
+               support is in the System.Data.Common.DbConnection
+               class)
+
+               These new columns are restriction columns as
+               well (the value will be null always)            
+
+
+2004-08-07 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Removed test comments.
+
+               - Throw an exception when trying to set the FetchSzie with an
+               active DataReader open.
+
+               - Set fetch size on execute instead of fetch.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbTablesSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbMetaDataCollections.cs:
+
+               - Now it's no possible to filter by the IS_SYSTEM_TABLE column,
+               doing that using the table type restriction.
+
+       * FirebirdSql.Data.Common/StatementBase.cs:
+       * FirebirdSql.Data.Embedded/FesStatement.cs:
+
+               - Removed Rows property.
+
+       * FirebirdSql.Data.Gds/GdsStatement.cs:
+
+               - Removed Rows property.
+
+               - Use a Queue instead of a object[] to store the rows.
+               Performance looks similar (seems to be better with greater
+               fetch sizes) and the code is more readable.
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Changes on the way that output parameters
+               for Stored procedures query are retrieved.
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+
+               - Minor changes in method calls.
+
+2004-08-06 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Fixed invalid references in the documentation reported by 
+       .NET 2.0
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+
+               - Cleanup.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbTablesSchema.cs:
+
+               - The system tables will now be filtered using the table type parameter.
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+               
+               - Check connection state in GetSchema methods.  
+
+2004-08-05 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/StatementBase.cs:
+       * FirebirdSql.Data.Embedded/FesStatement.cs:
+       * FirebirdSql.Data.GDS/GdsStatement.cs:
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Fetch Size implementation that allows to define the 
+               fetch size (number of rows fetches in the call selectable queries)
+               in the connection string and command objects.
+
+       * FirebirdSql.Data.Firebird/FbConnectionString.cs:
+
+               - Fixed bug #1004055 
+
+               - Added new nunit test.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbDbSchema.cs:
+
+               - Added a little hack for the Tables schema restrictions.
+       
+
+2004-08-04 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumnsSchema.cs:
+
+               - Removed PRIMARY_KEY and UNIQUE_KEY columns
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbPrimaryKeysSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbUniqueKeysSchema.cs:
+
+               - Allow filter by the column name
+
+
+2004-08-03 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumnsSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbViewColumnUsage.cs:
+
+               - Added new IS_ARRAY column.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbForeignKeySchema.cs:
+
+               - Fixed error in latest commit.
+
+2004-08-02 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbForeignKeySchema.cs:
+
+               - Updated sql statement.
+
+       * FirebirdSql.Data.Common/StatementBase.cs:
+       * FirebirdSql.Data.Gds/GdsStatement.cs:
+       * FirebirdSql.Data.Embbeded/FesStatement.cs:
+
+               - Some cleanup and refactoring.
+
+2004-08-01 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbDbSchemaType.cs:
+
+               - Removed not implemented elements.
+
+               - Added new MEtaDataCollections element.
+       
+       * FirebirdSql.Data.Firebird/FbMetaDataCollections.cs:
+
+               - Added restriction counts values.
+
+               - Modided the constructos of the schame classes
+               to remove the restriction count value.
+
+       * FirebirdSql.Data.Firebird/FbDbSchema.cs:
+
+               - Use the new MetaDataCollections schema to check the
+               restriction count.
+
+2004-07-31 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+       * FirebirdSql.Data.Firebird/FbTransaction.cs:
+
+               - Removed the code of the partial batch command
+               execution (that was available only using FbDataReader.NextResult)
+
+
+       * FirebirdSql.Data.Gds/GdsStatement.cs:
+
+               - Added testing change on statement execution.
+               Now on execute we will request the number of rows 
+               affected in the same message.
+
+       * FirebirdSql.Data.Firebird/DbSchema/*.cs:
+
+               - Updated Database schema support.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbMetaDataCollections.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbDataTypes.cs:
+
+               - Added new files.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbProviderTypesSchema.cs:
+
+               - Removed file.
+
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+
+               - Added new CreateDatabase overload
+
+       * FirebirdSql.Data.Firebird/FbCommandBuilder.cs:
+
+               - Updated DeriveParameters method to work with the new
+               Database schema stuff.
+
+
+2004-07-30 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+
+               - Added new GetSchema method
+
+               - Set GetDbSchemaTable method as Obsolete.
+
+       * FirebirdSql.Data.Firebird/FbDbSchemaType.cs:
+
+               - Removed _ from the element names.
+
+               - Set as obsolete.
+
+       * Improvements on Database schema support.
+
+       * FirebirdSql.Data.Firebird/FbService.cs:
+
+               - Fixed parsing database infor buffer (Thanks to Christian for his feedback).
+
+
+2004-07-29 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbDbSchema.cs:
+
+               - Fixed bug #1000160
+
+2004-07-28 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+       * FirebirdSql.Data.Common/FbCharsetCollection.cs:
+       * FirebirdSql.Data.Common/FbIscErrorCollection.cs:
+       * FirebirdSql.Data.Common/DbValue.cs:
+       * FirebirdSql.Data.Common/BlobBase.cs:
+       * FirebirdSql.Data.Common/TypeEncoder.cs:
+       * FirebirdSql.Data.Common/StatementBase.cs:
+
+               - Fixed FxCop rules.
+
+2004-07-27 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+       * FirebirdSql.Data.Firebird/FbTransaction.cs:
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+
+               - Removed limitation of one active 
+               data reader per connection, now it
+               will be one active data reader per
+               command.
+
+               NUNit tests will be commited later 
+               today.
+
+
+2004-07-26 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbParameter.cs:
+
+               - Fixed bug #998002
+
+
+-------------------------- Alpha 1 ----------------------------
+
+2004-07-21 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbParameter.cs:
+
+               - Fixed bug #995178
+
+2004-07-20 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Updated documentation.
+
+       * Updated assembly version.
+
+       * Updated installation script.
+       With th enew changes the assembly will be registered
+       in the HKLM\Software\Microsoft\.NETFramework\AssemblyFolders
+       registry element, this will allow the assembly to be shown by the
+       Visual Studio Add Reference dialog.
+
+
+2004-07-18 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       - Private methods naming changes in all classes, using PascalCase,
+       to match MS Guidelines.
+
+2004-07-17 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Changed CommandTimeout property accesible only using
+               explicit interfaces.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbDomainsSchema.cs:
+
+               - Fixed IS_NULLABLE column value.
+
+
+2004-07-16 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumnsSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbDomainsSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbProcedureParametersSchema.cs:
+
+               - Fixed mistake in latest commit.
+
+       * FirebirdSql.Data.Firebird/FbCommandBuilder.cs:
+
+               - Make use of the new PARAMETER_DIRECTION column.
+
+               - Remove COLUMN_SIZE reference.
+
+2004-07-15 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumnsSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbDomainsSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbProcedureParametersSchema.cs:
+
+               - Report correct size for blob columns.
+
+2004-07-12 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbFunctionsSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbIndexeschema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbGeneratorsSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbTablesSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbTriggersSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbUniqueKeysSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbViewColumnsUsageSchema.cs:
+
+
+               - Columns that indicates wheter an object is a system
+               object are now called IS_SYSTEM_XXXX.
+
+               - Columns that indicates wheter an object is inactive
+               are now called IS_INACTIVE. 
+               
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumnsSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbForeignKeysSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbIndexesSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbPremaryKeysSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbProcedureParametersSchema.cs:
+
+               - Set ORDINAL_POSITION as name for all ordinal columns.
+
+2004-07-11 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCharset.cs:
+
+               - Added Serializable attribute.
+
+2004-07-10 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbDomainsSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbProcedureParametersSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbProceduresSchema.cs:
+
+               - Added AcceptChanges call.
+
+       * FirebirdSql.Data.Firebird/FbDataReader.cs:
+
+               - Cleanup.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbProceduresSchema.cs:
+
+               - Return intputs and outputs columns null values
+               as 0.
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbProcedureParametersSchema.cs:
+
+               - Renamed PARAMETER_TYPE column as PARAMETER_DIRECTION
+               and set the value as ParameterDirection.Input or
+               ParameterDirection.Output.
+
+2004-07-02 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+
+               - Set actual CreateDatabase and DropDatabase as Obsolete
+
+               - Added new CreateDatabase and DropDatabase methods
+               that uses connection strings.
+
+
+2004-07-01 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/DbField.cs:
+
+               - Added new IsDecimal method.
+
+       * FirebirdSql.Data.Common/FbDataReader.cs:
+
+               - Set numeric precision and scale only for decimal/numeric datatypes.
+
+
+2004-06-30 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbDbSchemaType.cs:
+
+               - Added Serializable attribute.
+
+       * FirebirdSql.Data.Firebird/FbTransaction.cs:
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Simplify constructor implementation.
+
+       * FirebirdSql.Data.Firebird/FbParameter.cs:
+
+               - Added private keyyworkd to class fields.
+
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+
+               - Simplified BeginTransaction overloads.
+
+2004-06-25 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Gds/GdsDatabase.cs:
+
+               - Fixed bug on Detach method.   
+
+       * FirebirdSql.Data.common/IDatabase.cs
+       * FirebirdSql.Data.common/ITransaction.cs
+       * FirebirdSql.Data.common/StatementBase.cs
+       * FirebirdSql.Data.Embedded/FesDatabase.cs:
+       * FirebirdSql.Data.Embedded/FesTransaction.cs:
+       * FirebirdSql.Data.Embedded/FesStatement.cs:
+       * FirebirdSql.Data.Gds/GdsDatabase.cs:
+       * FirebirdSql.Data.Gds/GdsTransaction.cs:
+       * FirebirdSql.Data.Gds/GdsStatement.cs:
+       * FirebirdSql.Data.Firebird/FbConnection.cs:
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+       * FirebirdSql.Data.Firebird/FbTransaction.cs:
+       * FirebirdSql.Data.Firebird/FbDbConnection.cs:  
+
+               - Implement IDisposable interface in 
+               Database, Transaction and statement implementations
+               of GDs's.
+
+               Prior sources are tagged as NP_1_7_Alpha1.
+
+               * This change needs carefully review/testing. *
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbProcedureParametersSchema.cs:
+       * FirebirdSql.Data.Firebird/DbSchema/FbColumnsSchema.cs:
+
+               - Fixed NUMERIC_SCALE column value (Thanks to Jack for his feedback).
+
+2004-06-24 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Services/FbService.cs:
+
+               - Modify the delegate and event used for
+               handling service output by adding a new
+               ServiceOutputEventArgs class (Thanks to Mike Scott for his feedback).
+
+2004-06-23 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/Services/*.cs:
+       
+               - Changes on output processing, now it's going to be done
+               using an event instead of the GetNextLine method.
+               
+               Start methods has been renamed to Execute in every class.
+               
+               (Thanks to Pierre Y. for his suggestion)
+
+2004-06-16 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Gds/GdsArray.cs:
+
+               - Fix Array implementation. All NUnit tests suite are running fine.
+
+       * Added setup projects.
+
+       * FirebirdSql.Data.Firebird.UnitTest/FbDataAdapter.cs:
+
+               - Added new nunit test for check dataset fill using
+               an execute procedure statement.
+
+2004-06-14 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbConenctionString.cs:
+
+               - Added Validate method.
+
+       * Updated/added documentation of classes:
+
+               - FbConnection
+               - FbEvent
+               - FbService
+
+       * Added BDP NUnit test suite.
+
+
+2004-06-13 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Bdp/Fbconnection.cs:
+
+               - Finish connection code for work with new
+               GDS implementation structure.
+
+
+2004-06-12 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Gds/GdsStatement.cs:
+
+               - Fixed bug in Fetch method when working
+               with statements using EXECUTE PROCEDURE syntax.
+
+
+2004-06-08 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Finished first stage of the events reimplementation.
+
+
+2004-06-02 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Firebird/FbCommand.cs:
+
+               - Simplify handling of input parameters with null values (Thanks to Jojakim Stahl).
+
+       * FirebirdSql.Data.Firebird/DbSchema/FbForeignKeysSchema.cs:
+
+               - Fix order by clausule.
+
+       * FirebirdSql.Data.Firebird/FbConnectionPool.cs:
+
+               - Run cleanup over pooled connections
+               only when there are a number of pooled connections
+               greater than the min pool size (needs testing).
+
+2004-06-01 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * FirebirdSql.Data.Common/FbCommandBuilder.cs:
+       
+               - Improved DeriveParameters implementation.
+
+       * FirebirdSql.Data.Common/Descriptor.cs:
+
+               - Changed ToBlr method for use a MemoryStream.
+
+       * FirebirdSql.Data.Common/IscError.cs:
+       * FirebirdSql.Data.Common/IscCodes.cs:
+       * FirebirdSql.Data.Common/IscException.cs:
+
+               - Clean up on fatal errors exceptions.
+
+       * FirebirdSql.Data.Common/IscException.cs:
+
+               - Rewrite the way the exeption emessage is built.
+               
+       * FirebirdSql.Data.Common/IscExceptionHelper.cs:
+
+               - Removed.
+
+       * FirebirdSql.Data.Common:
+
+               - RowDescriptor.cs renamed as Descriptor.cs
+
+
+2004-05-28 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+    * FirebirdSql.Data.Common:
+
+    Removed classes:
+
+        - AttachmentParams
+        - Factorybase
+        - IAttachment
+
+    Renamed classes:
+
+        - IDbAttachment    -> IDatabase
+        - ISvcAttachment   -> IServiceManager
+
+    * FirebirdSql.Data.Embedded:
+
+    Removed classes:
+
+        - FesFactory
+        - FesAttachment
+
+    Renamed classes
+
+        - FesDbAttachment     -> FesDatabase
+        - FesSvcAttachment    -> FesServiceManager
+        * FirebirdSql.Data.Gds: 
+    Removed classes:
+
+        - GdsFactory
+
+    Renamed classes
+
+        - GdsAttachment       -> GdsConnection
+        - GdsDbAttachment     -> GdsDatabase
+        - GdsSvcAttachment    -> GdsServiceManager
+
+    * FirebirdSql.Data.Firebird:
+
+    New classes:
+
+        - FbConnectionString
+
+    * FirebirdSql.Data.Firebird.Service:
+
+    Removed classes:
+
+        - FbServiceParameters.
+
+    (The services implementation now works with a connection strings. 
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/license.html b/mcs/class/FirebirdSql.Data.Firebird/license.html
new file mode 100644 (file)
index 0000000..b663c07
--- /dev/null
@@ -0,0 +1,549 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+       <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
+       <TITLE>Initial Developer's PUBLIC LICENSE Version 1.0</TITLE>
+       <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.1  (Win32)">
+       <META NAME="CREATED" CONTENT="20040603;16204312">
+       <META NAME="CHANGED" CONTENT="20040603;16215490">
+       <STYLE>
+       <!--
+               TD P { color: #000000; font-family: "verdana", "arial", "geneva", sans-serif; font-size: 9pt }
+               P { color: #000000; font-family: "verdana", "arial", "geneva", sans-serif; font-size: 9pt }
+               H2 { color: #008080; font-family: "verdana", "arial", "geneva", sans-serif; font-size: 13pt }
+               A:visited { font-family: "verdana", "arial", "geneva", sans-serif; font-size: 9pt; text-decoration: none }
+               A:link { color: #0000ff; font-family: "verdana", "arial", "geneva", sans-serif; font-size: 9pt; text-decoration: none }
+       -->
+       </STYLE>
+</HEAD>
+<BODY LANG="es-ES" TEXT="#000000" LINK="#0000ff" BGCOLOR="#ffffff" DIR="LTR">
+<TABLE WIDTH=65% CELLPADDING=2 CELLSPACING=2>
+       <TR>
+               <TD>
+                       <H2>Initial Developer's PUBLIC LICENSE Version 1.0</H2>
+               </TD>
+       </TR>
+       <TR>
+               <TD>
+                       <P>1. Definitions 
+                       </P>
+                       <P>1.0 &quot;<B>Commercial Use</B>&quot; means distribution or
+                       otherwise making the Covered Code available to a third party. 
+                       </P>
+                       <P>1.1 ''<B>Contributor</B>'' means each entity that creates or
+                       contributes to the creation of Modifications. 
+                       </P>
+                       <P>1.2 ''<B>Contributor Version</B>'' means the combination of the
+                       Original Code, prior Modifications used by a Contributor, and the
+                       Modifications made by that particular Contributor. 
+                       </P>
+                       <P>1.3. ''<B>Covered Code</B>'' means the Original Code or
+                       Modifications or the combination of the Original Code and
+                       Modifications, in each case including portions thereof. 
+                       </P>
+                       <P>1.4. ''<B>Electronic Distribution Mechanism</B>'' means a
+                       mechanism generally accepted in the software development community
+                       for the electronic transfer of data. 
+                       </P>
+                       <P>1.5. ''<B>Executable</B>'' means Covered Code in any form other
+                       than Source Code. 
+                       </P>
+                       <P>1.6. ''<B>Initial Developer</B>'' means the individual or
+                       entity identified as the Initial Developer in the Source Code
+                       notice required by Exhibit A. 
+                       </P>
+                       <P>1.7. ''<B>Larger Work</B>'' means a work which combines Covered
+                       Code or portions thereof with code not governed by the terms of
+                       this License. 
+                       </P>
+                       <P>1.8. ''<B>License</B>'' means this document. 
+                       </P>
+                       <P>1.8.1. &quot;<B>Licensable</B>&quot; means having the right to
+                       grant, to the maximum extent possible, whether at the time of the
+                       initial grant or subsequently acquired, any and all of the rights
+                       conveyed herein. 
+                       </P>
+                       <P>1.9. ''<B>Modifications</B>'' means any addition to or deletion
+                       from the substance or structure of either the Original Code or any
+                       previous Modifications. When Covered Code is released as a series
+                       of files, a Modification is: 
+                       </P>
+                       <P>Any addition to or deletion from the contents of a file
+                       containing Original Code or previous Modifications. 
+                       </P>
+                       <P>Any new file that contains any part of the Original Code or
+                       previous Modifications. 
+                       </P>
+                       <P>1.10. ''<B>Original Code</B>'' means Source Code of computer
+                       software code which is described in the Source Code notice
+                       required by Exhibit A as Original Code, and which, at the time of
+                       its release under this License is not already Covered Code
+                       governed by this License. 
+                       </P>
+                       <P>1.10.1. &quot;<B>Patent Claims</B>&quot; means any patent
+                       claim(s), now owned or hereafter acquired, including without
+                       limitation, method, process, and apparatus claims, in any patent
+                       Licensable by grantor. 
+                       </P>
+                       <P>1.11. ''<B>Source Code</B>'' means the preferred form of the
+                       Covered Code for making modifications to it, including all modules
+                       it contains, plus any associated interface definition files,
+                       scripts used to control compilation and installation of an
+                       Executable, or source code differential comparisons against either
+                       the Original Code or another well known, available Covered Code of
+                       the Contributor's choice. The Source Code can be in a compressed
+                       or archival form, provided the appropriate decompression or
+                       de-archiving software is widely available for no charge. 
+                       </P>
+                       <P>1.12. &quot;<B>You</B>'' (or &quot;<B>Your</B>&quot;) means an
+                       individual or a legal entity exercising rights under, and
+                       complying with all of the terms of, this License or a future
+                       version of this License issued under Section 6.1. For legal
+                       entities, &quot;You'' includes any entity w hich controls, is
+                       controlled by, or is under common control with You. For purposes
+                       of this definition, &quot;control'' means (a) the power, direct or
+                       indirect, to cause the direction or management of such entity,
+                       whether by contract or otherwise, or (b) ownership of more than
+                       fifty percent (50%) of the outstanding shares or beneficial
+                       ownership of such entity.</P>
+                       <P>2. Source Code License. 
+                       </P>
+                       <P><B>2.1. The Initial Developer Grant.</B> The Initial Developer
+                       hereby grants You a world-wide, royalty-free, non-exclusive
+                       license, subject to third party intellectual property claims: 
+                       </P>
+                       <P>(a) under intellectual property rights (other than patent or
+                       trademark) Licensable by Initial Developer to use, reproduce,
+                       modify, display, perform, sublicense and distribute the Original
+                       Code (or portions thereof) with or without Modifications, and/or
+                       as part of a Larger Work; and 
+                       </P>
+                       <P>(b) under Patents Claims infringed by the making, using or
+                       selling of Original Code, to make, have made, use, practice, sell,
+                       and offer for sale, and/or otherwise dispose of the Original Code
+                       (or portions thereof). 
+                       </P>
+                       <P>(c) the licenses granted in this Section 2.1(a) and (b) are
+                       effective on the date Initial Developer first distributes Original
+                       Code under the terms of this License. 
+                       </P>
+                       <P>d) Notwithstanding Section 2.1(b) above, no patent license is
+                       granted:</P>
+                       <P>1) for code that You delete from the Original Code; 
+                       </P>
+                       <P>2) separate from the Original Code; or 
+                       </P>
+                       <P>3) for infringements caused by: 
+                       </P>
+                       <P>i) the modification of the Original Code or 
+                       </P>
+                       <P>ii) the combination of the Original Code with other software or
+                       devices. 
+                       </P>
+                       <P><B>2.2. Contributor Grant.</B> Subject to third party
+                       intellectual property claims, each Contributor hereby grants You a
+                       world-wide, royalty-free, non-exclusive license 
+                       </P>
+                       <P>(a) under intellectual property rights (other than patent or
+                       trademark) Licensable by Contributor, to use, reproduce, modify,
+                       display, perform, sublicense and distribute the Modifications
+                       created by such Contributor (or portions thereof) either on an
+                       unmodified basis, with other Modifications, as Covered Code and/or
+                       as part of a Larger Work; and 
+                       </P>
+                       <P>(b) under Patent Claims infringed by the making, using, or
+                       selling of Modifications made by that Contributor either alone
+                       and/or in combination with its Contributor Version (or portions of
+                       such combination), to make, use, sell, offer for sale, have made,
+                       and/or otherwise dispose of: 1) Modifications made by that
+                       Contributor (or portions thereof); and 2) the combination of
+                       Modifications made by that Contributor with its Contributor
+                       Version (or portions of such combination). 
+                       </P>
+                       <P>(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+                       effective on the date Contributor first makes Commercial Use of
+                       the Covered Code. 
+                       </P>
+                       <P>(d) Notwithstanding Section 2.2(b) above, no patent license is
+                       granted: 
+                       </P>
+                       <P>1) for any code that Contributor has deleted from the
+                       Contributor Version; 
+                       </P>
+                       <P>2) separate from the Contributor Version; 
+                       </P>
+                       <P>3) for infringements caused by: i) third party modifications of
+                       Contributor Version or 
+                       </P>
+                       <P>ii) the combination of Modifications made by that Contributor
+                       with other software (except as part of the Contributor Version) or
+                       other devices; or 
+                       </P>
+                       <P>4) under Patent Claims infringed by Covered Code in the absence
+                       of Modifications made by that Contributor. 
+                       </P>
+                       <P>3. Distribution Obligations. 
+                       </P>
+                       <P><B>3.1. Application of License.</B> The Modifications which You
+                       create or to which You contribute are governed by the terms of
+                       this License, including without limitation Section 2.2. The Source
+                       Code version of Covered Code may be distributed only under the
+                       terms of this License or a future version of this License released
+                       under Section 6.1, and You must include a copy of this License
+                       with every copy of the Source Code You distribute. You may not
+                       offer or impose any terms on any Source Code version that alters
+                       or restricts the applicable version of this License or the
+                       recipients' rights hereunder. However, You may include an
+                       additional document offering the additional rights described in
+                       Section 3.5.</P>
+                       <P><B>3.2. Availability of Source Code</B>. Any Modification which
+                       You create or to which You contribute must be made available in
+                       Source Code form under the terms of this License either on the
+                       same media as an Executable version or via an accepted Electronic
+                       Distribution Mechanism to anyone to whom you made an Executable
+                       version available; and if made available via Electronic
+                       Distribution Mechanism, must remain available for at least twelve
+                       (12) months after the date it initially became available, or at
+                       least six (6) months after a subsequent version of that particular
+                       Modification has been made available to such recipients. You are
+                       responsible for ensuring that the Source Code version remains
+                       available even if the Electronic Distribution Mechanism is
+                       maintained by a third party. 
+                       </P>
+                       <P><B>3.3. Description of Modifications.</B> You must cause all
+                       Covered Code to which You contribute to contain a file documenting
+                       the changes You made to create that Covered Code and the date of
+                       any change. You must include a prominent statement that the
+                       Modification is derived, directly or indirectly, from Original
+                       Code provided by the Initial Developer and including the name of
+                       the Initial Developer in 
+                       </P>
+                       <P>(a) the Source Code, and 
+                       </P>
+                       <P>(b) in any notice in an Executable version or related
+                       documentation in which You describe the origin or ownership of the
+                       Covered Code.</P>
+                       <P><B>3.4. Intellectual Property Matters </B>
+                       </P>
+                       <P>a) Third Party Claims. If Contributor has knowledge that a
+                       license under a third party's intellectual property rights is
+                       required to exercise the rights granted by such Contributor under
+                       Sections 2.1 or 2.2, Contributor must include a text file with the
+                       Source Code distribution titled &quot;LEGAL'' which describes the
+                       claim and the party making the claim in sufficient detail that a
+                       recipient will know whom to contact. If Contributor obtains such
+                       knowledge after the Modification is made available as described in
+                       Section 3.2, Contributor shall promptly modify the LEGAL file in
+                       all copies Contributor makes available thereafter and shall take
+                       other steps (such as notifying appropriate mailing lists or
+                       newsgroups) reasonably calculated to inform those who received the
+                       Covered Code that new knowledge has been obtained. 
+                       </P>
+                       <P>(b) Contributor APIs. If Contributor's Modifications include an
+                       application programming interface and Contributor has knowledge of
+                       patent licenses which are reasonably necessary to implement that
+                       API, Contributor must also include this information in the LEGAL
+                       file. 
+                       </P>
+                       <P>(c) Representations. Contributor represents that, except as
+                       disclosed pursuant to Section 3.4(a) above, Contributor believes
+                       that Contributor's Modifications are Contributor's original
+                       creation(s) and/or Contributor has sufficient rights to grant the
+                       rights conveyed by this License. 
+                       </P>
+                       <P><B>3.5. Required Notices.</B> You must duplicate the notice in
+                       Exhibit A in each file of the Source Code. If it is not possible
+                       to put such notice in a particular Source Code file due to its
+                       structure, then You must include such notice in a location (such
+                       as a relevant directory) where a user would be likely to look for
+                       such a notice. If You created one or more Modification(s) You may
+                       add your name as a Contributor to the notice described in Exhibit
+                       A. You must also duplicate this License in any documentation for
+                       the Source Code where You describe recipients' rights or ownership
+                       rights relating to Covered Code. You may choose to offer, and to
+                       charge a fee for, warranty, support, indemnity or liability
+                       obligations to one or more recipients of Covered Code. However,
+                       You may do so only on Your own behalf, and not on behalf of the
+                       Initial Developer or any Contributor. You must make it absolutely
+                       clear than any such warranty, support, indemnity or liability
+                       obligation is offered by You alone, and You hereby agree to
+                       indemnify the Initial Developer and every Contributor for any
+                       liability incurred by the Initial Developer or such Contributor as
+                       a result of warranty, support, indemnity or liability terms You
+                       offer. 
+                       </P>
+                       <P><B>3.6. Distribution of Executable Versions.</B> You may
+                       distribute Covered Code in Executable form only if the
+                       requirements of Section 3.1-3.5 have been met for that Covered
+                       Code, and if You include a notice stating that the Source Code
+                       version of the Covered Code is available under the terms of this
+                       License, including a description of how and where You have
+                       fulfilled the obligations of Section 3.2. The notice must be
+                       conspicuously included in any notice in an Executable version,
+                       related documentation or collateral in which You describe
+                       recipients' rights relating to the Covered Code. You may
+                       distribute the Executable version of Covered Code or ownership
+                       rights under a license of Your choice, which may contain terms
+                       different from this License, provided that You are in compliance
+                       with the terms of this License and hat the license for the
+                       Executable version does not attempt to limit or alter the
+                       recipient's rights in the Source Code version from the rights set
+                       forth in this License. If You distribute the Executable version
+                       under a different license You must make it absolutely clear that
+                       any terms which differ from this License are offered by You alone,
+                       not by the Initial Developer or any Contributor. You hereby agree
+                       to indemnify the Initial Developer and every Contributor for any
+                       liability incurred by the Initial Developer or such Contributor as
+                       a result of any such terms You offer. 
+                       </P>
+                       <P><B>3.7. Larger Works.</B> You may create a Larger Work by
+                       combining Covered Code with other code not governed by the terms
+                       of this License and distribute the Larger Work as a single
+                       product. In such a case, You must make sure the requirements of
+                       this License are fulfilled for the Covered Code. 
+                       </P>
+                       <P>4. Inability to Comply Due to Statute or Regulation. 
+                       </P>
+                       <P>If it is impossible for You to comply with any of the terms of
+                       this License with respect to some or all of the Covered Code due
+                       to statute, judicial order, or regulation then You must: 
+                       </P>
+                       <P>(a) comply with the terms of this License to the maximum extent
+                       possible; and 
+                       </P>
+                       <P>(b) describe the limitations and the code they affect. Such
+                       description must be included in the LEGAL file described in
+                       Section 3.4 and must be included with all distributions of the
+                       Source Code. Except to the extent prohibited by statute or
+                       regulation, such description must be sufficiently detailed for a
+                       recipient of ordinary skill to be able to understand it. 
+                       </P>
+                       <P>5. Application of this License.</P>
+                       <P>This License applies to code to which the Initial Developer has
+                       attached the notice in Exhibit A and to related Covered Code. 
+                       </P>
+                       <P>6. Versions of the License. 
+                       </P>
+                       <P><B>6.1. New Versions.</B> The Initial Developer of this code
+                       may publish revised and/or new versions of the License from time
+                       to time. Each version will be given a distinguishing version
+                       number. 
+                       </P>
+                       <P><B>6.2. Effect of New Versions.</B> Once Covered Code has been
+                       published under a particular version of the License, You may
+                       always continue to use it under the terms of that version. You may
+                       also choose to use such Covered Code under the terms of any
+                       subsequent version of the License published by the Initial
+                       Developer. No one other than the Initial Developer has the right
+                       to modify the terms applicable to Covered Code created under this
+                       License. 
+                       </P>
+                       <P><B>6.3. Derivative Works.</B> If You create or use a modified
+                       version of this License (which you may only do in order to apply
+                       it to code which is not already Covered Code governed by this
+                       License), You must 
+                       </P>
+                       <P>(a) rename Your license so that the phrases ''Mozilla'',
+                       ''MOZILLAPL'', ''MOZPL'', ''Netscape'', &quot;MPL&quot;, ''NPL&quot;,
+                       or any confusingly similar phrases do not appear in your license
+                       (except to note that your license differs from this License) and 
+                       </P>
+                       <P>(b) otherwise make it clear that Your version of the license
+                       contains terms which differ from the Mozilla Public License and
+                       Netscape Public License. (Filling in the name of the Initial
+                       Developer, Original Code or Contributor in the notice described in
+                       Exhibit A shall not of themselves be deemed to be modifications of
+                       this License.) 
+                       </P>
+                       <P><B>6.4 Origin of the Initial Developer's Public License.</B>
+                       The Initial Developer's Public License is based on the Mozilla
+                       Public License V 1.1 with the following changes: 
+                       </P>
+                       <P>1) The license is published by the Initial Developer of this
+                       code. Only the Initial Developer can modify the terms applicable
+                       to Covered Code. 
+                       </P>
+                       <P>2) The license can be modified and used for code which is not
+                       already governed by this license. Modified versions of the license
+                       must be renamed to avoid confusion with Netscape's license Initial
+                       Developer's's license and must include a description of changes
+                       from the Initial Developer's Public License. 
+                       </P>
+                       <P>3) The name of the license in Exhibit A is the &quot;Initial
+                       Developer's Public License&quot;. 
+                       </P>
+                       <P>4) The reference to an alternative license in Exhibit A has
+                       been removed . 
+                       </P>
+                       <P>5) Amendments I, II, III, V, and VI have been deleted. 
+                       </P>
+                       <P>6) Exhibit A, Netscape Public License has been deleted 
+                       </P>
+                       <P>7. DISCLAIMER OF WARRANTY. 
+                       </P>
+                       <P>COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN &quot;AS IS''
+                       BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+                       INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS
+                       FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR
+                       NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
+                       OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE
+                       DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY
+                       OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING,
+                       REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN
+                       ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS
+                       AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.</P>
+                       <P>8. TERMINATION. 
+                       </P>
+                       <P>8.1. This License and the rights granted hereunder will
+                       terminate automatically if You fail to comply with terms herein
+                       and fail to cure such breach within 30 days of becoming aware of
+                       the breach. All sublicenses to the Covered Code which are properly
+                       granted shall survive any termination of this License. Provisions
+                       which, by their nature, must remain in effect beyond the
+                       termination of this License shall survive. 
+                       </P>
+                       <P>8.2. If You initiate litigation by asserting a patent
+                       infringement claim (excluding declatory judgment actions) against
+                       Initial Developer or a Contributor (the Initial Developer or
+                       Contributor against whom You file such action is referred to as
+                       &quot;Participant&quot;) alleging that: 
+                       </P>
+                       <P>(a) such Participant's Contributor Version directly or
+                       indirectly infringes any patent, then any and all rights granted
+                       by such Participant to You under Sections 2.1 and/or 2.2 of this
+                       License shall, upon 60 days notice from Participant terminate
+                       prospectively, unless if within 60 days after receipt of notice
+                       You either: 
+                       </P>
+                       <P>(i) agree in writing to pay Participant a mutually agreeable
+                       reasonable royalty for Your past and future use of Modifications
+                       made by such Participant, or</P>
+                       <P>(ii) withdraw Your litigation claim with respect to the
+                       Contributor Version against such Participant. 
+                       </P>
+                       <P>If within 60 days of notice, a reasonable royalty and payment
+                       arrangement are not mutually agreed upon in writing by the parties
+                       or the litigation claim is not withdrawn, the rights granted by
+                       Participant to You under Sections 2.1 and/or 2.2 automatically
+                       terminate at the expiration of the 60 day notice period specified
+                       above.</P>
+                       <P>(b) any software, hardware, or device, other than such
+                       Participant's Contributor Version, directly or indirectly
+                       infringes any patent, then any rights granted to You by such
+                       Participant under Sections 2.1(b) and 2.2(b) are revoked effective
+                       as of the date You first made, used, sold, distributed, or had
+                       made, Modifications made by that Participant. 
+                       </P>
+                       <P>8.3. If You assert a patent infringement claim against
+                       Participant alleging that such Participant's Contributor Version
+                       directly or indirectly infringes any patent where such claim is
+                       resolved (such as by license or settlement) prior to the
+                       initiation of patent infringement litigation, then the reasonable
+                       value of the licenses granted by such Participant under Sections
+                       2.1 or 2.2 shall be taken into account in determining the amount
+                       or value of any payment or license. 
+                       </P>
+                       <P>8.4. In the event of termination under Sections 8.1 or 8.2
+                       above, all end user license agreements (excluding distributors and
+                       resellers) which have been validly granted by You or any
+                       distributor hereunder prior to termination shall survive
+                       termination. 
+                       </P>
+                       <P>9. LIMITATION OF LIABILITY.</P>
+                       <P>UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+                       (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
+                       INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
+                       COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO
+                       ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+                       DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES
+                       FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR
+                       MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES,
+                       EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
+                       SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO
+                       LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S
+                       NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION.
+                       SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF
+                       INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND
+                       LIMITATION MAY NOT APPLY TO YOU. 
+                       </P>
+                       <P>10. U.S. GOVERNMENT END USERS. 
+                       </P>
+                       <P>The Covered Code is a ''commercial item,'' as that term is
+                       defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of ''commercial
+                       computer software'' and ''commercial computer software
+                       documentation,'' as such terms are used in 48 C.F.R. 12.212 (Sept.
+                       1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+                       through 227.7202-4 (June 1995), all U.S. Government End Users
+                       acquire Covered Code with only those rights set forth herein. 
+                       </P>
+                       <P>11. MISCELLANEOUS. 
+                       </P>
+                       <P>This License represents the complete agreement concerning
+                       subject matter hereof. If any provision of this License is held to
+                       be unenforceable, such provision shall be reformed only to the
+                       extent necessary to make it enforceable. This License shall be
+                       governed by California law provisions (except to the extent
+                       applicable law, if any, provides otherwise), excluding its
+                       conflict-of-law provisions. With respect to disputes in which at
+                       least one party is a citizen of, or an entity chartered or
+                       registered to do business in the United States of America, any
+                       litigation relating to this License shall be subject to the
+                       jurisdiction of the Federal Courts of the Northern District of
+                       California, with venue lying in Santa Clara County, California,
+                       with the losing party responsible for costs, including without
+                       limitation, court costs and reasonable attorneys' fees and
+                       expenses. The application of the United Nations Convention on
+                       Contracts for the International Sale of Goods is expressly
+                       excluded. Any law or regulation which provides that the language
+                       of a contract shall be construed against the drafter shall not
+                       apply to this License. 
+                       </P>
+                       <P>12. RESPONSIBILITY FOR CLAIMS. 
+                       </P>
+                       <P>As between Initial Developer and the Contributors, each party
+                       is responsible for claims and damages arising, directly or
+                       indirectly, out of its utilization of rights under this License
+                       and You agree to work with Initial Developer and Contributors to
+                       distribute such responsibility on an equitable basis. Nothing
+                       herein is intended or shall be deemed to constitute any admission
+                       of liability. 
+                       </P>
+                       <P>13. MULTIPLE-LICENSED CODE. 
+                       </P>
+                       <P>Initial Developer may designate portions of the Covered Code as
+                       &quot;Multiple-Licensed&quot;. &quot;Multiple-Licensed&quot; means
+                       that the Initial Devpoeloper permits you to utilize portions of
+                       the Covered Code under Your choice of the IDPL or the alternative
+                       licenses, if any, specified by the Initial Developer in the file
+                       described in Exhibit A. 
+                       </P>
+                       <P><B>EXHIBIT A</B> -Initial Developer's Public License. 
+                       </P>
+                       <P>The contents of this file are subject to the Initial
+                       Developer's Public License Version 1.0 (the &quot;License&quot;);
+                       you may not use this file except in compliance with the License.
+                       You may obtain a copy of the License <A HREF="http://www.ibphoenix.com/main.nfs?a=ibphoenix&amp;page=ibp_idpl">here.</A></P>
+                       <P>Software distributed under the License is distributed on an &quot;AS
+                       IS&quot; basis, WITHOUT WARRANTY OF ANY KIND, either express or
+                       implied. See the License for the specific language governing
+                       rights and limitations under the License. 
+                       </P>
+                       <P>The Original Code is ______________________________________. 
+                       </P>
+                       <P>The Initial Developer of the Original Code is
+                       ________________________. 
+                       </P>
+                       <P>Portions created by ______________________ <BR>are Copyright
+                       (C) ______ _______________________. 
+                       </P>
+                       <P>All Rights Reserved. 
+                       </P>
+                       <P>Contributor(s): ______________________________________. 
+                       </P>
+               </TD>
+       </TR>
+</TABLE>
+<P><BR><BR>
+</P>
+</BODY>
+</HTML>
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/license.txt b/mcs/class/FirebirdSql.Data.Firebird/license.txt
new file mode 100644 (file)
index 0000000..0330568
--- /dev/null
@@ -0,0 +1,204 @@
+Initial Developer's PUBLIC LICENSE Version 1.0
+
+1. Definitions
+
+1.0 "Commercial Use" means distribution or otherwise making the Covered Code available to a third party.
+
+1.1 ''Contributor'' means each entity that creates or contributes to the creation of Modifications.
+
+1.2 ''Contributor Version'' means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor.
+
+1.3. ''Covered Code'' means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof.
+
+1.4. ''Electronic Distribution Mechanism'' means a mechanism generally accepted in the software development community for the electronic transfer of data.
+
+1.5. ''Executable'' means Covered Code in any form other than Source Code.
+
+1.6. ''Initial Developer'' means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A.
+
+1.7. ''Larger Work'' means a work which combines Covered Code or portions thereof with code not governed by the terms of this License.
+
+1.8. ''License'' means this document.
+
+1.8.1. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
+
+1.9. ''Modifications'' means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is:
+
+Any addition to or deletion from the contents of a file containing Original Code or previous Modifications.
+
+Any new file that contains any part of the Original Code or previous Modifications.
+
+1.10. ''Original Code'' means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License.
+
+1.10.1. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
+
+1.11. ''Source Code'' means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge.
+
+1.12. "You'' (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You'' includes any entity w hich controls, is controlled by, or is under common control with You. For purposes of this definition, "control'' means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
+
+2. Source Code License.
+
+2.1. The Initial Developer Grant. The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims:
+
+(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and
+
+(b) under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof).
+
+(c) the licenses granted in this Section 2.1(a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License.
+
+d) Notwithstanding Section 2.1(b) above, no patent license is granted:
+
+1) for code that You delete from the Original Code;
+
+2) separate from the Original Code; or
+
+3) for infringements caused by:
+
+i) the modification of the Original Code or
+
+ii) the combination of the Original Code with other software or devices.
+
+2.2. Contributor Grant. Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license
+
+(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and
+
+(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
+
+(c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first makes Commercial Use of the Covered Code.
+
+(d) Notwithstanding Section 2.2(b) above, no patent license is granted:
+
+1) for any code that Contributor has deleted from the Contributor Version;
+
+2) separate from the Contributor Version;
+
+3) for infringements caused by: i) third party modifications of Contributor Version or
+
+ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or
+
+4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor.
+
+3. Distribution Obligations.
+
+3.1. Application of License. The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5.
+
+3.2. Availability of Source Code. Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party.
+
+3.3. Description of Modifications. You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in
+
+(a) the Source Code, and
+
+(b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code.
+
+3.4. Intellectual Property Matters
+
+a) Third Party Claims. If Contributor has knowledge that a license under a third party's intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled "LEGAL'' which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained.
+
+(b) Contributor APIs. If Contributor's Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file.
+
+(c) Representations. Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor's Modifications are Contributor's original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License.
+
+3.5. Required Notices. You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients' rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
+
+3.6. Distribution of Executable Versions. You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and hat the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
+
+3.7. Larger Works. You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must:
+
+(a) comply with the terms of this License to the maximum extent possible; and
+
+(b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
+
+5. Application of this License.
+
+This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+6.1. New Versions. The Initial Developer of this code may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number.
+
+6.2. Effect of New Versions. Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by the Initial Developer. No one other than the Initial Developer has the right to modify the terms applicable to Covered Code created under this License.
+
+6.3. Derivative Works. If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must
+
+(a) rename Your license so that the phrases ''Mozilla'', ''MOZILLAPL'', ''MOZPL'', ''Netscape'', "MPL", ''NPL", or any confusingly similar phrases do not appear in your license (except to note that your license differs from this License) and
+
+(b) otherwise make it clear that Your version of the license contains terms which differ from the Mozilla Public License and Netscape Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.)
+
+6.4 Origin of the Initial Developer's Public License. The Initial Developer's Public License is based on the Mozilla Public License V 1.1 with the following changes:
+
+1) The license is published by the Initial Developer of this code. Only the Initial Developer can modify the terms applicable to Covered Code.
+
+2) The license can be modified and used for code which is not already governed by this license. Modified versions of the license must be renamed to avoid confusion with Netscape's license Initial Developer's's license and must include a description of changes from the Initial Developer's Public License.
+
+3) The name of the license in Exhibit A is the "Initial Developer's Public License".
+
+4) The reference to an alternative license in Exhibit A has been removed .
+
+5) Amendments I, II, III, V, and VI have been deleted.
+
+6) Exhibit A, Netscape Public License has been deleted
+
+7. DISCLAIMER OF WARRANTY.
+
+COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS'' BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+8. TERMINATION.
+
+8.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
+
+8.2. If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You file such action is referred to as "Participant") alleging that:
+
+(a) such Participant's Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either:
+
+(i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or
+
+(ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant.
+
+If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above.
+
+(b) any software, hardware, or device, other than such Participant's Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant.
+
+8.3. If You assert a patent infringement claim against Participant alleging that such Participant's Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license.
+
+8.4. In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+The Covered Code is a ''commercial item,'' as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of ''commercial computer software'' and ''commercial computer software documentation,'' as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein.
+
+11. MISCELLANEOUS.
+
+This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+Initial Developer may designate portions of the Covered Code as "Multiple-Licensed". "Multiple-Licensed" means that the Initial Devpoeloper permits you to utilize portions of the Covered Code under Your choice of the IDPL or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A.
+
+EXHIBIT A -Initial Developer's Public License.
+
+The contents of this file are subject to the Initial Developer's Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License here.
+
+Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
+
+The Original Code is ______________________________________.
+
+The Initial Developer of the Original Code is ________________________.
+
+Portions created by ______________________
+are Copyright (C) ______ _______________________.
+
+All Rights Reserved.
+
+Contributor(s): ______________________________________. 
\ No newline at end of file
diff --git a/mcs/class/FirebirdSql.Data.Firebird/readme.txt b/mcs/class/FirebirdSql.Data.Firebird/readme.txt
new file mode 100644 (file)
index 0000000..9eaa408
--- /dev/null
@@ -0,0 +1,81 @@
+Firebird ADO.NET Data provider for .NET and Mono 
+================================================
+
+This project is supported by:
+---- ------- -- --------- ---
+
+       Sean Leyne ( Broadview Software )
+
+
+Developement list
+-----------------
+
+You can subscribe to the developement list at:
+
+       http://lists.sourceforge.net/lists/listinfo/firebird-net-provider
+
+
+You can access to the lastest developement sources through CVS, see:
+
+       http://sourceforge.net/cvs/?group_id=9028
+
+
+Reporting Bugs
+--------------
+
+Yo can report bugs using two ways:
+
+1. Sending it to the developement list.
+2. If you have a Sourceforge ID you can send it using the Bugs section of the Firebird Project web page 
+(category .Net Provider):
+
+
+       http://sourceforge.net/tracker/?group_id=9028&atid=109028
+
+
+Requirements for build the sources on Windows
+---------------------------------------------
+
+- The Microsoft .NET Framework or Mono:: platform.
+
+
+Build with Microsoft .NET Framework:
+
+       - You need the Microsoft .NET Platform.
+
+       - The provider sources have a build file for NAnt ( http://nant.sourceforge.net/ ), 
+       FirebirdNetProvider.build.
+
+       For build it you only need to exececute nant (0.85) on the same directory as the build file.
+
+       - The Nant build file generates (inside framework version directory net-1.0, net-1.1, ...):
+
+                       1.- FirebirdSql.Data.Firebird.dll ( binary of the ADO .NET data provider )
+                       2.- FirebirdSql.Data.Firebird.UnitTest.dll ( binary of the NUnit tests. )
+                       3.- MSDN style documentation.
+
+
+Build with mono:: platform ( www.go-mono.com ):
+
+       - The mono platform with ICU support.
+
+       - The provider sources have a build file, makefile, for build the sources ( this script file needs Cygwin ).
+
+       - The makefile build file generates:
+
+               1.- FirebirdSql.Data.Firebird.dll ( binary of the ado .net provider )
+
+       Note : You can build it using NAnt too, for this you need to modify the NAnt script changing the build 
+       file for allow it.
+
+
+
+Requirements for build the sources on Linux
+-------------------------------------------
+
+Build with mono:: platform ( www.go-mono.com ):
+
+       - The mono platform with ICU support.
+
+       - The provider sources have a build file, makefile, for build the sources, you only need to execute make on the same
+       directory as the script.